]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blame - test/grsecurity-3.1-4.1.3-201508011613.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-3.1-4.1.3-201508011613.patch
CommitLineData
4b5ba0cf
PK
1diff --git a/Documentation/dontdiff b/Documentation/dontdiff
2index 9de9813..1462492 100644
3--- a/Documentation/dontdiff
4+++ b/Documentation/dontdiff
5@@ -3,9 +3,11 @@
6 *.bc
7 *.bin
8 *.bz2
9+*.c.[012]*.*
10 *.cis
11 *.cpio
12 *.csp
13+*.dbg
14 *.dsp
15 *.dvi
16 *.elf
17@@ -15,6 +17,7 @@
18 *.gcov
19 *.gen.S
20 *.gif
21+*.gmo
22 *.grep
23 *.grp
24 *.gz
25@@ -51,14 +54,17 @@
26 *.tab.h
27 *.tex
28 *.ver
29+*.vim
30 *.xml
31 *.xz
32 *_MODULES
33+*_reg_safe.h
34 *_vga16.c
35 *~
36 \#*#
37 *.9
38-.*
39+.[^g]*
40+.gen*
41 .*.d
42 .mm
43 53c700_d.h
44@@ -72,9 +78,11 @@ Image
45 Module.markers
46 Module.symvers
47 PENDING
48+PERF*
49 SCCS
50 System.map*
51 TAGS
52+TRACEEVENT-CFLAGS
53 aconf
54 af_names.h
55 aic7*reg.h*
56@@ -83,6 +91,7 @@ aic7*seq.h*
57 aicasm
58 aicdb.h*
59 altivec*.c
60+ashldi3.S
61 asm-offsets.h
62 asm_offsets.h
63 autoconf.h*
64@@ -95,32 +104,40 @@ bounds.h
65 bsetup
66 btfixupprep
67 build
68+builtin-policy.h
69 bvmlinux
70 bzImage*
71 capability_names.h
72 capflags.c
73 classlist.h*
74+clut_vga16.c
75+common-cmds.h
76 comp*.log
77 compile.h*
78 conf
79 config
80 config-*
81 config_data.h*
82+config.c
83 config.mak
84 config.mak.autogen
85+config.tmp
86 conmakehash
87 consolemap_deftbl.c*
88 cpustr.h
89 crc32table.h*
90 cscope.*
91 defkeymap.c
92+devicetable-offsets.h
93 devlist.h*
94 dnotify_test
95 docproc
96 dslm
97+dtc-lexer.lex.c
98 elf2ecoff
99 elfconfig.h*
100 evergreen_reg_safe.h
101+exception_policy.conf
102 fixdep
103 flask.h
104 fore200e_mkfirm
105@@ -128,12 +145,15 @@ fore200e_pca_fw.c*
106 gconf
107 gconf.glade.h
108 gen-devlist
109+gen-kdb_cmds.c
110 gen_crc32table
111 gen_init_cpio
112 generated
113 genheaders
114 genksyms
115 *_gray256.c
116+hash
117+hid-example
118 hpet_example
119 hugepage-mmap
120 hugepage-shm
121@@ -148,14 +168,14 @@ int32.c
122 int4.c
123 int8.c
124 kallsyms
125-kconfig
126+kern_constants.h
127 keywords.c
128 ksym.c*
129 ksym.h*
130 kxgettext
131 lex.c
132 lex.*.c
133-linux
134+lib1funcs.S
135 logo_*.c
136 logo_*_clut224.c
137 logo_*_mono.c
138@@ -165,14 +185,15 @@ mach-types.h
139 machtypes.h
140 map
141 map_hugetlb
142-media
143 mconf
144+mdp
145 miboot*
146 mk_elfconfig
147 mkboot
148 mkbugboot
149 mkcpustr
150 mkdep
151+mkpiggy
152 mkprep
153 mkregtable
154 mktables
155@@ -188,6 +209,8 @@ oui.c*
156 page-types
157 parse.c
158 parse.h
159+parse-events*
160+pasyms.h
161 patches*
162 pca200e.bin
163 pca200e_ecd.bin2
164@@ -197,6 +220,7 @@ perf-archive
165 piggyback
166 piggy.gzip
167 piggy.S
168+pmu-*
169 pnmtologo
170 ppc_defs.h*
171 pss_boot.h
172@@ -206,7 +230,12 @@ r200_reg_safe.h
173 r300_reg_safe.h
174 r420_reg_safe.h
175 r600_reg_safe.h
176+randomize_layout_hash.h
177+randomize_layout_seed.h
178+realmode.lds
179+realmode.relocs
180 recordmcount
181+regdb.c
182 relocs
183 rlim_names.h
184 rn50_reg_safe.h
185@@ -216,8 +245,12 @@ series
186 setup
187 setup.bin
188 setup.elf
189+signing_key*
190+size_overflow_hash.h
191 sImage
192+slabinfo
193 sm_tbl*
194+sortextable
195 split-include
196 syscalltab.h
197 tables.c
198@@ -227,6 +260,7 @@ tftpboot.img
199 timeconst.h
200 times.h*
201 trix_boot.h
202+user_constants.h
203 utsrelease.h*
204 vdso-syms.lds
205 vdso.lds
206@@ -238,13 +272,17 @@ vdso32.lds
207 vdso32.so.dbg
208 vdso64.lds
209 vdso64.so.dbg
210+vdsox32.lds
211+vdsox32-syms.lds
212 version.h*
213 vmImage
214 vmlinux
215 vmlinux-*
216 vmlinux.aout
217 vmlinux.bin.all
218+vmlinux.bin.bz2
219 vmlinux.lds
220+vmlinux.relocs
221 vmlinuz
222 voffset.h
223 vsyscall.lds
224@@ -252,9 +290,12 @@ vsyscall_32.lds
225 wanxlfw.inc
226 uImage
227 unifdef
228+utsrelease.h
229 wakeup.bin
230 wakeup.elf
231 wakeup.lds
232+x509*
233 zImage*
234 zconf.hash.c
235+zconf.lex.c
236 zoffset.h
237diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
238index 74b6c6d..eac0e77 100644
239--- a/Documentation/kbuild/makefiles.txt
240+++ b/Documentation/kbuild/makefiles.txt
241@@ -23,10 +23,11 @@ This document describes the Linux kernel Makefiles.
242 === 4 Host Program support
243 --- 4.1 Simple Host Program
244 --- 4.2 Composite Host Programs
245- --- 4.3 Using C++ for host programs
246- --- 4.4 Controlling compiler options for host programs
247- --- 4.5 When host programs are actually built
248- --- 4.6 Using hostprogs-$(CONFIG_FOO)
249+ --- 4.3 Defining shared libraries
250+ --- 4.4 Using C++ for host programs
251+ --- 4.5 Controlling compiler options for host programs
252+ --- 4.6 When host programs are actually built
253+ --- 4.7 Using hostprogs-$(CONFIG_FOO)
254
255 === 5 Kbuild clean infrastructure
256
257@@ -643,7 +644,29 @@ Both possibilities are described in the following.
258 Finally, the two .o files are linked to the executable, lxdialog.
259 Note: The syntax <executable>-y is not permitted for host-programs.
260
261---- 4.3 Using C++ for host programs
262+--- 4.3 Defining shared libraries
263+
264+ Objects with extension .so are considered shared libraries, and
265+ will be compiled as position independent objects.
266+ Kbuild provides support for shared libraries, but the usage
267+ shall be restricted.
268+ In the following example the libkconfig.so shared library is used
269+ to link the executable conf.
270+
271+ Example:
272+ #scripts/kconfig/Makefile
273+ hostprogs-y := conf
274+ conf-objs := conf.o libkconfig.so
275+ libkconfig-objs := expr.o type.o
276+
277+ Shared libraries always require a corresponding -objs line, and
278+ in the example above the shared library libkconfig is composed by
279+ the two objects expr.o and type.o.
280+ expr.o and type.o will be built as position independent code and
281+ linked as a shared library libkconfig.so. C++ is not supported for
282+ shared libraries.
283+
284+--- 4.4 Using C++ for host programs
285
286 kbuild offers support for host programs written in C++. This was
287 introduced solely to support kconfig, and is not recommended
288@@ -666,7 +689,7 @@ Both possibilities are described in the following.
289 qconf-cxxobjs := qconf.o
290 qconf-objs := check.o
291
292---- 4.4 Controlling compiler options for host programs
293+--- 4.5 Controlling compiler options for host programs
294
295 When compiling host programs, it is possible to set specific flags.
296 The programs will always be compiled utilising $(HOSTCC) passed
297@@ -694,7 +717,7 @@ Both possibilities are described in the following.
298 When linking qconf, it will be passed the extra option
299 "-L$(QTDIR)/lib".
300
301---- 4.5 When host programs are actually built
302+--- 4.6 When host programs are actually built
303
304 Kbuild will only build host-programs when they are referenced
305 as a prerequisite.
306@@ -725,7 +748,7 @@ Both possibilities are described in the following.
307 This will tell kbuild to build lxdialog even if not referenced in
308 any rule.
309
310---- 4.6 Using hostprogs-$(CONFIG_FOO)
311+--- 4.7 Using hostprogs-$(CONFIG_FOO)
312
313 A typical pattern in a Kbuild file looks like this:
314
315diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
316index 6726139..c825c0a 100644
317--- a/Documentation/kernel-parameters.txt
318+++ b/Documentation/kernel-parameters.txt
319@@ -1223,6 +1223,13 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
320 Format: <unsigned int> such that (rxsize & ~0x1fffc0) == 0.
321 Default: 1024
322
323+ grsec_proc_gid= [GRKERNSEC_PROC_USERGROUP] Chooses GID to
324+ ignore grsecurity's /proc restrictions
325+
326+ grsec_sysfs_restrict= Format: 0 | 1
327+ Default: 1
328+ Disables GRKERNSEC_SYSFS_RESTRICT if enabled in config
329+
330 hashdist= [KNL,NUMA] Large hashes allocated during boot
331 are distributed across NUMA nodes. Defaults on
332 for 64-bit NUMA, off otherwise.
333@@ -2333,6 +2340,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
334 noexec=on: enable non-executable mappings (default)
335 noexec=off: disable non-executable mappings
336
337+ nopcid [X86-64]
338+ Disable PCID (Process-Context IDentifier) even if it
339+ is supported by the processor.
340+
341 nosmap [X86]
342 Disable SMAP (Supervisor Mode Access Prevention)
343 even if it is supported by processor.
344@@ -2631,6 +2642,30 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
345 the specified number of seconds. This is to be used if
346 your oopses keep scrolling off the screen.
347
348+ pax_nouderef [X86] disables UDEREF. Most likely needed under certain
349+ virtualization environments that don't cope well with the
350+ expand down segment used by UDEREF on X86-32 or the frequent
351+ page table updates on X86-64.
352+
353+ pax_sanitize_slab=
354+ Format: { 0 | 1 | off | fast | full }
355+ Options '0' and '1' are only provided for backward
356+ compatibility, 'off' or 'fast' should be used instead.
357+ 0|off : disable slab object sanitization
358+ 1|fast: enable slab object sanitization excluding
359+ whitelisted slabs (default)
360+ full : sanitize all slabs, even the whitelisted ones
361+
362+ pax_softmode= 0/1 to disable/enable PaX softmode on boot already.
363+
364+ pax_extra_latent_entropy
365+ Enable a very simple form of latent entropy extraction
366+ from the first 4GB of memory as the bootmem allocator
367+ passes the memory pages to the buddy allocator.
368+
369+ pax_weakuderef [X86-64] enables the weaker but faster form of UDEREF
370+ when the processor supports PCID.
371+
372 pcbit= [HW,ISDN]
373
374 pcd. [PARIDE]
375diff --git a/Documentation/sysctl/kernel.txt b/Documentation/sysctl/kernel.txt
376index c831001..1bfbbf6 100644
377--- a/Documentation/sysctl/kernel.txt
378+++ b/Documentation/sysctl/kernel.txt
379@@ -41,6 +41,7 @@ show up in /proc/sys/kernel:
380 - kptr_restrict
381 - kstack_depth_to_print [ X86 only ]
382 - l2cr [ PPC only ]
383+- modify_ldt [ X86 only ]
384 - modprobe ==> Documentation/debugging-modules.txt
385 - modules_disabled
386 - msg_next_id [ sysv ipc ]
387@@ -391,6 +392,20 @@ This flag controls the L2 cache of G3 processor boards. If
388
389 ==============================================================
390
391+modify_ldt: (X86 only)
392+
393+Enables (1) or disables (0) the modify_ldt syscall. Modifying the LDT
394+(Local Descriptor Table) may be needed to run a 16-bit or segmented code
395+such as Dosemu or Wine. This is done via a system call which is not needed
396+to run portable applications, and which can sometimes be abused to exploit
397+some weaknesses of the architecture, opening new vulnerabilities.
398+
399+This sysctl allows one to increase the system's security by disabling the
400+system call, or to restore compatibility with specific applications when it
401+was already disabled.
402+
403+==============================================================
404+
405 modules_disabled:
406
407 A toggle value indicating if modules are allowed to be loaded
408diff --git a/Makefile b/Makefile
409index e3cdec4..56ae73d 100644
410--- a/Makefile
411+++ b/Makefile
412@@ -299,7 +299,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
413 HOSTCC = gcc
414 HOSTCXX = g++
415 HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89
416-HOSTCXXFLAGS = -O2
417+HOSTCFLAGS = -W -Wno-unused-parameter -Wno-missing-field-initializers -fno-delete-null-pointer-checks
418+HOSTCFLAGS += $(call cc-option, -Wno-empty-body)
419+HOSTCXXFLAGS = -O2 -Wall -W -Wno-array-bounds
420
421 ifeq ($(shell $(HOSTCC) -v 2>&1 | grep -c "clang version"), 1)
422 HOSTCFLAGS += -Wno-unused-value -Wno-unused-parameter \
423@@ -444,8 +446,8 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
424 # Rules shared between *config targets and build targets
425
426 # Basic helpers built in scripts/
427-PHONY += scripts_basic
428-scripts_basic:
429+PHONY += scripts_basic gcc-plugins
430+scripts_basic: gcc-plugins
431 $(Q)$(MAKE) $(build)=scripts/basic
432 $(Q)rm -f .tmp_quiet_recordmcount
433
434@@ -620,6 +622,74 @@ endif
435 # Tell gcc to never replace conditional load with a non-conditional one
436 KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0)
437
438+ifndef DISABLE_PAX_PLUGINS
439+ifeq ($(call cc-ifversion, -ge, 0408, y), y)
440+PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCXX)" "$(HOSTCXX)" "$(CC)")
441+else
442+PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCC)" "$(HOSTCXX)" "$(CC)")
443+endif
444+ifneq ($(PLUGINCC),)
445+ifdef CONFIG_PAX_CONSTIFY_PLUGIN
446+CONSTIFY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/constify_plugin.so -DCONSTIFY_PLUGIN
447+endif
448+ifdef CONFIG_PAX_MEMORY_STACKLEAK
449+STACKLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/stackleak_plugin.so -DSTACKLEAK_PLUGIN
450+STACKLEAK_PLUGIN_CFLAGS += -fplugin-arg-stackleak_plugin-track-lowest-sp=100
451+endif
452+ifdef CONFIG_KALLOCSTAT_PLUGIN
453+KALLOCSTAT_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kallocstat_plugin.so
454+endif
455+ifdef CONFIG_PAX_KERNEXEC_PLUGIN
456+KERNEXEC_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kernexec_plugin.so
457+KERNEXEC_PLUGIN_CFLAGS += -fplugin-arg-kernexec_plugin-method=$(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD) -DKERNEXEC_PLUGIN
458+KERNEXEC_PLUGIN_AFLAGS := -DKERNEXEC_PLUGIN
459+endif
460+ifdef CONFIG_GRKERNSEC_RANDSTRUCT
461+RANDSTRUCT_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/randomize_layout_plugin.so -DRANDSTRUCT_PLUGIN
462+ifdef CONFIG_GRKERNSEC_RANDSTRUCT_PERFORMANCE
463+RANDSTRUCT_PLUGIN_CFLAGS += -fplugin-arg-randomize_layout_plugin-performance-mode
464+endif
465+endif
466+ifdef CONFIG_CHECKER_PLUGIN
467+ifeq ($(call cc-ifversion, -ge, 0406, y), y)
468+CHECKER_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/checker_plugin.so -DCHECKER_PLUGIN
469+endif
470+endif
471+COLORIZE_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/colorize_plugin.so
472+ifdef CONFIG_PAX_SIZE_OVERFLOW
473+SIZE_OVERFLOW_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/size_overflow_plugin/size_overflow_plugin.so -DSIZE_OVERFLOW_PLUGIN
474+endif
475+ifdef CONFIG_PAX_LATENT_ENTROPY
476+LATENT_ENTROPY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/latent_entropy_plugin.so -DLATENT_ENTROPY_PLUGIN
477+endif
478+ifdef CONFIG_PAX_MEMORY_STRUCTLEAK
479+STRUCTLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/structleak_plugin.so -DSTRUCTLEAK_PLUGIN
480+endif
481+INITIFY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/initify_plugin.so -DINITIFY_PLUGIN
482+GCC_PLUGINS_CFLAGS := $(CONSTIFY_PLUGIN_CFLAGS) $(STACKLEAK_PLUGIN_CFLAGS) $(KALLOCSTAT_PLUGIN_CFLAGS)
483+GCC_PLUGINS_CFLAGS += $(KERNEXEC_PLUGIN_CFLAGS) $(CHECKER_PLUGIN_CFLAGS) $(COLORIZE_PLUGIN_CFLAGS)
484+GCC_PLUGINS_CFLAGS += $(SIZE_OVERFLOW_PLUGIN_CFLAGS) $(LATENT_ENTROPY_PLUGIN_CFLAGS) $(STRUCTLEAK_PLUGIN_CFLAGS)
485+GCC_PLUGINS_CFLAGS += $(INITIFY_PLUGIN_CFLAGS)
486+GCC_PLUGINS_CFLAGS += $(RANDSTRUCT_PLUGIN_CFLAGS)
487+GCC_PLUGINS_AFLAGS := $(KERNEXEC_PLUGIN_AFLAGS)
488+export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGINS_AFLAGS CONSTIFY_PLUGIN LATENT_ENTROPY_PLUGIN_CFLAGS
489+ifeq ($(KBUILD_EXTMOD),)
490+gcc-plugins:
491+ $(Q)$(MAKE) $(build)=tools/gcc
492+else
493+gcc-plugins: ;
494+endif
495+else
496+gcc-plugins:
497+ifeq ($(call cc-ifversion, -ge, 0405, y), y)
498+ $(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.))
499+else
500+ $(Q)echo "warning, your gcc version does not support plugins, you should upgrade it to gcc 4.5 at least"
501+endif
502+ $(Q)echo "PAX_MEMORY_STACKLEAK, constification, PAX_LATENT_ENTROPY and other features will be less secure. PAX_SIZE_OVERFLOW will not be active."
503+endif
504+endif
505+
506 ifdef CONFIG_READABLE_ASM
507 # Disable optimizations that make assembler listings hard to read.
508 # reorder blocks reorders the control in the function
509@@ -712,7 +782,7 @@ KBUILD_CFLAGS += $(call cc-option, -gsplit-dwarf, -g)
510 else
511 KBUILD_CFLAGS += -g
512 endif
513-KBUILD_AFLAGS += -Wa,-gdwarf-2
514+KBUILD_AFLAGS += -Wa,--gdwarf-2
515 endif
516 ifdef CONFIG_DEBUG_INFO_DWARF4
517 KBUILD_CFLAGS += $(call cc-option, -gdwarf-4,)
518@@ -883,7 +953,7 @@ export mod_sign_cmd
519
520
521 ifeq ($(KBUILD_EXTMOD),)
522-core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
523+core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ grsecurity/
524
525 vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
526 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
527@@ -933,6 +1003,8 @@ endif
528
529 # The actual objects are generated when descending,
530 # make sure no implicit rule kicks in
531+$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
532+$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
533 $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
534
535 # Handle descending into subdirectories listed in $(vmlinux-dirs)
536@@ -942,7 +1014,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
537 # Error messages still appears in the original language
538
539 PHONY += $(vmlinux-dirs)
540-$(vmlinux-dirs): prepare scripts
541+$(vmlinux-dirs): gcc-plugins prepare scripts
542 $(Q)$(MAKE) $(build)=$@
543
544 define filechk_kernel.release
545@@ -985,10 +1057,13 @@ prepare1: prepare2 $(version_h) include/generated/utsrelease.h \
546
547 archprepare: archheaders archscripts prepare1 scripts_basic
548
549+prepare0: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
550+prepare0: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
551 prepare0: archprepare FORCE
552 $(Q)$(MAKE) $(build)=.
553
554 # All the preparing..
555+prepare: KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
556 prepare: prepare0
557
558 # Generate some files
559@@ -1096,6 +1171,8 @@ all: modules
560 # using awk while concatenating to the final file.
561
562 PHONY += modules
563+modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
564+modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
565 modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
566 $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
567 @$(kecho) ' Building modules, stage 2.';
568@@ -1111,7 +1188,7 @@ modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
569
570 # Target to prepare building external modules
571 PHONY += modules_prepare
572-modules_prepare: prepare scripts
573+modules_prepare: gcc-plugins prepare scripts
574
575 # Target to install modules
576 PHONY += modules_install
577@@ -1177,7 +1254,10 @@ MRPROPER_FILES += .config .config.old .version .old_version \
578 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
579 signing_key.priv signing_key.x509 x509.genkey \
580 extra_certificates signing_key.x509.keyid \
581- signing_key.x509.signer vmlinux-gdb.py
582+ signing_key.x509.signer vmlinux-gdb.py \
583+ tools/gcc/size_overflow_plugin/size_overflow_hash_aux.h \
584+ tools/gcc/size_overflow_plugin/size_overflow_hash.h \
585+ tools/gcc/randomize_layout_seed.h
586
587 # clean - Delete most, but leave enough to build external modules
588 #
589@@ -1216,7 +1296,7 @@ distclean: mrproper
590 @find $(srctree) $(RCS_FIND_IGNORE) \
591 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
592 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
593- -o -name '.*.rej' -o -name '*%' -o -name 'core' \) \
594+ -o -name '.*.rej' -o -name '*.so' -o -name '*%' -o -name 'core' \) \
595 -type f -print | xargs rm -f
596
597
598@@ -1382,6 +1462,8 @@ PHONY += $(module-dirs) modules
599 $(module-dirs): crmodverdir $(objtree)/Module.symvers
600 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
601
602+modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
603+modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
604 modules: $(module-dirs)
605 @$(kecho) ' Building modules, stage 2.';
606 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
607@@ -1522,17 +1604,21 @@ else
608 target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
609 endif
610
611-%.s: %.c prepare scripts FORCE
612+%.s: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
613+%.s: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
614+%.s: %.c gcc-plugins prepare scripts FORCE
615 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
616 %.i: %.c prepare scripts FORCE
617 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
618-%.o: %.c prepare scripts FORCE
619+%.o: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
620+%.o: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
621+%.o: %.c gcc-plugins prepare scripts FORCE
622 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
623 %.lst: %.c prepare scripts FORCE
624 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
625-%.s: %.S prepare scripts FORCE
626+%.s: %.S gcc-plugins prepare scripts FORCE
627 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
628-%.o: %.S prepare scripts FORCE
629+%.o: %.S gcc-plugins prepare scripts FORCE
630 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
631 %.symtypes: %.c prepare scripts FORCE
632 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
633@@ -1544,11 +1630,15 @@ endif
634 $(build)=$(build-dir)
635 # Make sure the latest headers are built for Documentation
636 Documentation/: headers_install
637-%/: prepare scripts FORCE
638+%/: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
639+%/: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
640+%/: gcc-plugins prepare scripts FORCE
641 $(cmd_crmodverdir)
642 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
643 $(build)=$(build-dir)
644-%.ko: prepare scripts FORCE
645+%.ko: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
646+%.ko: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
647+%.ko: gcc-plugins prepare scripts FORCE
648 $(cmd_crmodverdir)
649 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
650 $(build)=$(build-dir) $(@:.ko=.o)
651diff --git a/arch/alpha/include/asm/atomic.h b/arch/alpha/include/asm/atomic.h
652index 8f8eafb..3405f46 100644
653--- a/arch/alpha/include/asm/atomic.h
654+++ b/arch/alpha/include/asm/atomic.h
655@@ -239,4 +239,14 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
656 #define atomic_dec(v) atomic_sub(1,(v))
657 #define atomic64_dec(v) atomic64_sub(1,(v))
658
659+#define atomic64_read_unchecked(v) atomic64_read(v)
660+#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
661+#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
662+#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
663+#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
664+#define atomic64_inc_unchecked(v) atomic64_inc(v)
665+#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
666+#define atomic64_dec_unchecked(v) atomic64_dec(v)
667+#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
668+
669 #endif /* _ALPHA_ATOMIC_H */
670diff --git a/arch/alpha/include/asm/cache.h b/arch/alpha/include/asm/cache.h
671index ad368a9..fbe0f25 100644
672--- a/arch/alpha/include/asm/cache.h
673+++ b/arch/alpha/include/asm/cache.h
674@@ -4,19 +4,19 @@
675 #ifndef __ARCH_ALPHA_CACHE_H
676 #define __ARCH_ALPHA_CACHE_H
677
678+#include <linux/const.h>
679
680 /* Bytes per L1 (data) cache line. */
681 #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EV6)
682-# define L1_CACHE_BYTES 64
683 # define L1_CACHE_SHIFT 6
684 #else
685 /* Both EV4 and EV5 are write-through, read-allocate,
686 direct-mapped, physical.
687 */
688-# define L1_CACHE_BYTES 32
689 # define L1_CACHE_SHIFT 5
690 #endif
691
692+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
693 #define SMP_CACHE_BYTES L1_CACHE_BYTES
694
695 #endif
696diff --git a/arch/alpha/include/asm/elf.h b/arch/alpha/include/asm/elf.h
697index 968d999..d36b2df 100644
698--- a/arch/alpha/include/asm/elf.h
699+++ b/arch/alpha/include/asm/elf.h
700@@ -91,6 +91,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
701
702 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x1000000)
703
704+#ifdef CONFIG_PAX_ASLR
705+#define PAX_ELF_ET_DYN_BASE (current->personality & ADDR_LIMIT_32BIT ? 0x10000 : 0x120000000UL)
706+
707+#define PAX_DELTA_MMAP_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 28)
708+#define PAX_DELTA_STACK_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 19)
709+#endif
710+
711 /* $0 is set by ld.so to a pointer to a function which might be
712 registered using atexit. This provides a mean for the dynamic
713 linker to call DT_FINI functions for shared libraries that have
714diff --git a/arch/alpha/include/asm/pgalloc.h b/arch/alpha/include/asm/pgalloc.h
715index aab14a0..b4fa3e7 100644
716--- a/arch/alpha/include/asm/pgalloc.h
717+++ b/arch/alpha/include/asm/pgalloc.h
718@@ -29,6 +29,12 @@ pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
719 pgd_set(pgd, pmd);
720 }
721
722+static inline void
723+pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
724+{
725+ pgd_populate(mm, pgd, pmd);
726+}
727+
728 extern pgd_t *pgd_alloc(struct mm_struct *mm);
729
730 static inline void
731diff --git a/arch/alpha/include/asm/pgtable.h b/arch/alpha/include/asm/pgtable.h
732index a9a1195..e9b8417 100644
733--- a/arch/alpha/include/asm/pgtable.h
734+++ b/arch/alpha/include/asm/pgtable.h
735@@ -101,6 +101,17 @@ struct vm_area_struct;
736 #define PAGE_SHARED __pgprot(_PAGE_VALID | __ACCESS_BITS)
737 #define PAGE_COPY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
738 #define PAGE_READONLY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
739+
740+#ifdef CONFIG_PAX_PAGEEXEC
741+# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOE)
742+# define PAGE_COPY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
743+# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
744+#else
745+# define PAGE_SHARED_NOEXEC PAGE_SHARED
746+# define PAGE_COPY_NOEXEC PAGE_COPY
747+# define PAGE_READONLY_NOEXEC PAGE_READONLY
748+#endif
749+
750 #define PAGE_KERNEL __pgprot(_PAGE_VALID | _PAGE_ASM | _PAGE_KRE | _PAGE_KWE)
751
752 #define _PAGE_NORMAL(x) __pgprot(_PAGE_VALID | __ACCESS_BITS | (x))
753diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c
754index 2fd00b7..cfd5069 100644
755--- a/arch/alpha/kernel/module.c
756+++ b/arch/alpha/kernel/module.c
757@@ -160,7 +160,7 @@ apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab,
758
759 /* The small sections were sorted to the end of the segment.
760 The following should definitely cover them. */
761- gp = (u64)me->module_core + me->core_size - 0x8000;
762+ gp = (u64)me->module_core_rw + me->core_size_rw - 0x8000;
763 got = sechdrs[me->arch.gotsecindex].sh_addr;
764
765 for (i = 0; i < n; i++) {
766diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
767index 36dc91a..6769cb0 100644
768--- a/arch/alpha/kernel/osf_sys.c
769+++ b/arch/alpha/kernel/osf_sys.c
770@@ -1295,10 +1295,11 @@ SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
771 generic version except that we know how to honor ADDR_LIMIT_32BIT. */
772
773 static unsigned long
774-arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
775- unsigned long limit)
776+arch_get_unmapped_area_1(struct file *filp, unsigned long addr, unsigned long len,
777+ unsigned long limit, unsigned long flags)
778 {
779 struct vm_unmapped_area_info info;
780+ unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
781
782 info.flags = 0;
783 info.length = len;
784@@ -1306,6 +1307,7 @@ arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
785 info.high_limit = limit;
786 info.align_mask = 0;
787 info.align_offset = 0;
788+ info.threadstack_offset = offset;
789 return vm_unmapped_area(&info);
790 }
791
792@@ -1338,20 +1340,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
793 merely specific addresses, but regions of memory -- perhaps
794 this feature should be incorporated into all ports? */
795
796+#ifdef CONFIG_PAX_RANDMMAP
797+ if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
798+#endif
799+
800 if (addr) {
801- addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit);
802+ addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(addr), len, limit, flags);
803 if (addr != (unsigned long) -ENOMEM)
804 return addr;
805 }
806
807 /* Next, try allocating at TASK_UNMAPPED_BASE. */
808- addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),
809- len, limit);
810+ addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(current->mm->mmap_base), len, limit, flags);
811+
812 if (addr != (unsigned long) -ENOMEM)
813 return addr;
814
815 /* Finally, try allocating in low memory. */
816- addr = arch_get_unmapped_area_1 (PAGE_SIZE, len, limit);
817+ addr = arch_get_unmapped_area_1 (filp, PAGE_SIZE, len, limit, flags);
818
819 return addr;
820 }
821diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
822index 9d0ac09..479a962 100644
823--- a/arch/alpha/mm/fault.c
824+++ b/arch/alpha/mm/fault.c
825@@ -53,6 +53,124 @@ __load_new_mm_context(struct mm_struct *next_mm)
826 __reload_thread(pcb);
827 }
828
829+#ifdef CONFIG_PAX_PAGEEXEC
830+/*
831+ * PaX: decide what to do with offenders (regs->pc = fault address)
832+ *
833+ * returns 1 when task should be killed
834+ * 2 when patched PLT trampoline was detected
835+ * 3 when unpatched PLT trampoline was detected
836+ */
837+static int pax_handle_fetch_fault(struct pt_regs *regs)
838+{
839+
840+#ifdef CONFIG_PAX_EMUPLT
841+ int err;
842+
843+ do { /* PaX: patched PLT emulation #1 */
844+ unsigned int ldah, ldq, jmp;
845+
846+ err = get_user(ldah, (unsigned int *)regs->pc);
847+ err |= get_user(ldq, (unsigned int *)(regs->pc+4));
848+ err |= get_user(jmp, (unsigned int *)(regs->pc+8));
849+
850+ if (err)
851+ break;
852+
853+ if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
854+ (ldq & 0xFFFF0000U) == 0xA77B0000U &&
855+ jmp == 0x6BFB0000U)
856+ {
857+ unsigned long r27, addr;
858+ unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
859+ unsigned long addrl = ldq | 0xFFFFFFFFFFFF0000UL;
860+
861+ addr = regs->r27 + ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
862+ err = get_user(r27, (unsigned long *)addr);
863+ if (err)
864+ break;
865+
866+ regs->r27 = r27;
867+ regs->pc = r27;
868+ return 2;
869+ }
870+ } while (0);
871+
872+ do { /* PaX: patched PLT emulation #2 */
873+ unsigned int ldah, lda, br;
874+
875+ err = get_user(ldah, (unsigned int *)regs->pc);
876+ err |= get_user(lda, (unsigned int *)(regs->pc+4));
877+ err |= get_user(br, (unsigned int *)(regs->pc+8));
878+
879+ if (err)
880+ break;
881+
882+ if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
883+ (lda & 0xFFFF0000U) == 0xA77B0000U &&
884+ (br & 0xFFE00000U) == 0xC3E00000U)
885+ {
886+ unsigned long addr = br | 0xFFFFFFFFFFE00000UL;
887+ unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
888+ unsigned long addrl = lda | 0xFFFFFFFFFFFF0000UL;
889+
890+ regs->r27 += ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
891+ regs->pc += 12 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
892+ return 2;
893+ }
894+ } while (0);
895+
896+ do { /* PaX: unpatched PLT emulation */
897+ unsigned int br;
898+
899+ err = get_user(br, (unsigned int *)regs->pc);
900+
901+ if (!err && (br & 0xFFE00000U) == 0xC3800000U) {
902+ unsigned int br2, ldq, nop, jmp;
903+ unsigned long addr = br | 0xFFFFFFFFFFE00000UL, resolver;
904+
905+ addr = regs->pc + 4 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
906+ err = get_user(br2, (unsigned int *)addr);
907+ err |= get_user(ldq, (unsigned int *)(addr+4));
908+ err |= get_user(nop, (unsigned int *)(addr+8));
909+ err |= get_user(jmp, (unsigned int *)(addr+12));
910+ err |= get_user(resolver, (unsigned long *)(addr+16));
911+
912+ if (err)
913+ break;
914+
915+ if (br2 == 0xC3600000U &&
916+ ldq == 0xA77B000CU &&
917+ nop == 0x47FF041FU &&
918+ jmp == 0x6B7B0000U)
919+ {
920+ regs->r28 = regs->pc+4;
921+ regs->r27 = addr+16;
922+ regs->pc = resolver;
923+ return 3;
924+ }
925+ }
926+ } while (0);
927+#endif
928+
929+ return 1;
930+}
931+
932+void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
933+{
934+ unsigned long i;
935+
936+ printk(KERN_ERR "PAX: bytes at PC: ");
937+ for (i = 0; i < 5; i++) {
938+ unsigned int c;
939+ if (get_user(c, (unsigned int *)pc+i))
940+ printk(KERN_CONT "???????? ");
941+ else
942+ printk(KERN_CONT "%08x ", c);
943+ }
944+ printk("\n");
945+}
946+#endif
947
948 /*
949 * This routine handles page faults. It determines the address,
950@@ -133,8 +251,29 @@ retry:
951 good_area:
952 si_code = SEGV_ACCERR;
953 if (cause < 0) {
954- if (!(vma->vm_flags & VM_EXEC))
955+ if (!(vma->vm_flags & VM_EXEC)) {
956+
957+#ifdef CONFIG_PAX_PAGEEXEC
958+ if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->pc)
959+ goto bad_area;
960+
961+ up_read(&mm->mmap_sem);
962+ switch (pax_handle_fetch_fault(regs)) {
963+
964+#ifdef CONFIG_PAX_EMUPLT
965+ case 2:
966+ case 3:
967+ return;
968+#endif
969+
970+ }
971+ pax_report_fault(regs, (void *)regs->pc, (void *)rdusp());
972+ do_group_exit(SIGKILL);
973+#else
974 goto bad_area;
975+#endif
976+
977+ }
978 } else if (!cause) {
979 /* Allow reads even for write-only mappings */
980 if (!(vma->vm_flags & (VM_READ | VM_WRITE)))
981diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
982index 45df48b..952017a 100644
983--- a/arch/arm/Kconfig
984+++ b/arch/arm/Kconfig
985@@ -1716,7 +1716,7 @@ config ALIGNMENT_TRAP
986
987 config UACCESS_WITH_MEMCPY
988 bool "Use kernel mem{cpy,set}() for {copy_to,clear}_user()"
989- depends on MMU
990+ depends on MMU && !PAX_MEMORY_UDEREF
991 default y if CPU_FEROCEON
992 help
993 Implement faster copy_to_user and clear_user methods for CPU
994@@ -1951,6 +1951,7 @@ config XIP_PHYS_ADDR
995 config KEXEC
996 bool "Kexec system call (EXPERIMENTAL)"
997 depends on (!SMP || PM_SLEEP_SMP)
998+ depends on !GRKERNSEC_KMEM
999 help
1000 kexec is a system call that implements the ability to shutdown your
1001 current kernel, and to start another kernel. It is like a reboot
1002diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
1003index e22c119..abe7041 100644
1004--- a/arch/arm/include/asm/atomic.h
1005+++ b/arch/arm/include/asm/atomic.h
1006@@ -18,17 +18,41 @@
1007 #include <asm/barrier.h>
1008 #include <asm/cmpxchg.h>
1009
1010+#ifdef CONFIG_GENERIC_ATOMIC64
1011+#include <asm-generic/atomic64.h>
1012+#endif
1013+
1014 #define ATOMIC_INIT(i) { (i) }
1015
1016 #ifdef __KERNEL__
1017
1018+#ifdef CONFIG_THUMB2_KERNEL
1019+#define REFCOUNT_TRAP_INSN "bkpt 0xf1"
1020+#else
1021+#define REFCOUNT_TRAP_INSN "bkpt 0xf103"
1022+#endif
1023+
1024+#define _ASM_EXTABLE(from, to) \
1025+" .pushsection __ex_table,\"a\"\n"\
1026+" .align 3\n" \
1027+" .long " #from ", " #to"\n" \
1028+" .popsection"
1029+
1030 /*
1031 * On ARM, ordinary assignment (str instruction) doesn't clear the local
1032 * strex/ldrex monitor on some implementations. The reason we can use it for
1033 * atomic_set() is the clrex or dummy strex done on every exception return.
1034 */
1035 #define atomic_read(v) ACCESS_ONCE((v)->counter)
1036+static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
1037+{
1038+ return ACCESS_ONCE(v->counter);
1039+}
1040 #define atomic_set(v,i) (((v)->counter) = (i))
1041+static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
1042+{
1043+ v->counter = i;
1044+}
1045
1046 #if __LINUX_ARM_ARCH__ >= 6
1047
1048@@ -38,26 +62,50 @@
1049 * to ensure that the update happens.
1050 */
1051
1052-#define ATOMIC_OP(op, c_op, asm_op) \
1053-static inline void atomic_##op(int i, atomic_t *v) \
1054+#ifdef CONFIG_PAX_REFCOUNT
1055+#define __OVERFLOW_POST \
1056+ " bvc 3f\n" \
1057+ "2: " REFCOUNT_TRAP_INSN "\n"\
1058+ "3:\n"
1059+#define __OVERFLOW_POST_RETURN \
1060+ " bvc 3f\n" \
1061+" mov %0, %1\n" \
1062+ "2: " REFCOUNT_TRAP_INSN "\n"\
1063+ "3:\n"
1064+#define __OVERFLOW_EXTABLE \
1065+ "4:\n" \
1066+ _ASM_EXTABLE(2b, 4b)
1067+#else
1068+#define __OVERFLOW_POST
1069+#define __OVERFLOW_POST_RETURN
1070+#define __OVERFLOW_EXTABLE
1071+#endif
1072+
1073+#define __ATOMIC_OP(op, suffix, c_op, asm_op, post_op, extable) \
1074+static inline void atomic_##op##suffix(int i, atomic##suffix##_t *v) \
1075 { \
1076 unsigned long tmp; \
1077 int result; \
1078 \
1079 prefetchw(&v->counter); \
1080- __asm__ __volatile__("@ atomic_" #op "\n" \
1081+ __asm__ __volatile__("@ atomic_" #op #suffix "\n" \
1082 "1: ldrex %0, [%3]\n" \
1083 " " #asm_op " %0, %0, %4\n" \
1084+ post_op \
1085 " strex %1, %0, [%3]\n" \
1086 " teq %1, #0\n" \
1087-" bne 1b" \
1088+" bne 1b\n" \
1089+ extable \
1090 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter) \
1091 : "r" (&v->counter), "Ir" (i) \
1092 : "cc"); \
1093 } \
1094
1095-#define ATOMIC_OP_RETURN(op, c_op, asm_op) \
1096-static inline int atomic_##op##_return(int i, atomic_t *v) \
1097+#define ATOMIC_OP(op, c_op, asm_op) __ATOMIC_OP(op, _unchecked, c_op, asm_op, , )\
1098+ __ATOMIC_OP(op, , c_op, asm_op##s, __OVERFLOW_POST, __OVERFLOW_EXTABLE)
1099+
1100+#define __ATOMIC_OP_RETURN(op, suffix, c_op, asm_op, post_op, extable) \
1101+static inline int atomic_##op##_return##suffix(int i, atomic##suffix##_t *v)\
1102 { \
1103 unsigned long tmp; \
1104 int result; \
1105@@ -65,12 +113,14 @@ static inline int atomic_##op##_return(int i, atomic_t *v) \
1106 smp_mb(); \
1107 prefetchw(&v->counter); \
1108 \
1109- __asm__ __volatile__("@ atomic_" #op "_return\n" \
1110+ __asm__ __volatile__("@ atomic_" #op "_return" #suffix "\n" \
1111 "1: ldrex %0, [%3]\n" \
1112 " " #asm_op " %0, %0, %4\n" \
1113+ post_op \
1114 " strex %1, %0, [%3]\n" \
1115 " teq %1, #0\n" \
1116-" bne 1b" \
1117+" bne 1b\n" \
1118+ extable \
1119 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter) \
1120 : "r" (&v->counter), "Ir" (i) \
1121 : "cc"); \
1122@@ -80,6 +130,9 @@ static inline int atomic_##op##_return(int i, atomic_t *v) \
1123 return result; \
1124 }
1125
1126+#define ATOMIC_OP_RETURN(op, c_op, asm_op) __ATOMIC_OP_RETURN(op, _unchecked, c_op, asm_op, , )\
1127+ __ATOMIC_OP_RETURN(op, , c_op, asm_op##s, __OVERFLOW_POST_RETURN, __OVERFLOW_EXTABLE)
1128+
1129 static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
1130 {
1131 int oldval;
1132@@ -115,12 +168,24 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1133 __asm__ __volatile__ ("@ atomic_add_unless\n"
1134 "1: ldrex %0, [%4]\n"
1135 " teq %0, %5\n"
1136-" beq 2f\n"
1137-" add %1, %0, %6\n"
1138+" beq 4f\n"
1139+" adds %1, %0, %6\n"
1140+
1141+#ifdef CONFIG_PAX_REFCOUNT
1142+" bvc 3f\n"
1143+"2: " REFCOUNT_TRAP_INSN "\n"
1144+"3:\n"
1145+#endif
1146+
1147 " strex %2, %1, [%4]\n"
1148 " teq %2, #0\n"
1149 " bne 1b\n"
1150-"2:"
1151+"4:"
1152+
1153+#ifdef CONFIG_PAX_REFCOUNT
1154+ _ASM_EXTABLE(2b, 4b)
1155+#endif
1156+
1157 : "=&r" (oldval), "=&r" (newval), "=&r" (tmp), "+Qo" (v->counter)
1158 : "r" (&v->counter), "r" (u), "r" (a)
1159 : "cc");
1160@@ -131,14 +196,36 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1161 return oldval;
1162 }
1163
1164+static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *ptr, int old, int new)
1165+{
1166+ unsigned long oldval, res;
1167+
1168+ smp_mb();
1169+
1170+ do {
1171+ __asm__ __volatile__("@ atomic_cmpxchg_unchecked\n"
1172+ "ldrex %1, [%3]\n"
1173+ "mov %0, #0\n"
1174+ "teq %1, %4\n"
1175+ "strexeq %0, %5, [%3]\n"
1176+ : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1177+ : "r" (&ptr->counter), "Ir" (old), "r" (new)
1178+ : "cc");
1179+ } while (res);
1180+
1181+ smp_mb();
1182+
1183+ return oldval;
1184+}
1185+
1186 #else /* ARM_ARCH_6 */
1187
1188 #ifdef CONFIG_SMP
1189 #error SMP not supported on pre-ARMv6 CPUs
1190 #endif
1191
1192-#define ATOMIC_OP(op, c_op, asm_op) \
1193-static inline void atomic_##op(int i, atomic_t *v) \
1194+#define __ATOMIC_OP(op, suffix, c_op, asm_op) \
1195+static inline void atomic_##op##suffix(int i, atomic##suffix##_t *v) \
1196 { \
1197 unsigned long flags; \
1198 \
1199@@ -147,8 +234,11 @@ static inline void atomic_##op(int i, atomic_t *v) \
1200 raw_local_irq_restore(flags); \
1201 } \
1202
1203-#define ATOMIC_OP_RETURN(op, c_op, asm_op) \
1204-static inline int atomic_##op##_return(int i, atomic_t *v) \
1205+#define ATOMIC_OP(op, c_op, asm_op) __ATOMIC_OP(op, , c_op, asm_op) \
1206+ __ATOMIC_OP(op, _unchecked, c_op, asm_op)
1207+
1208+#define __ATOMIC_OP_RETURN(op, suffix, c_op, asm_op) \
1209+static inline int atomic_##op##_return##suffix(int i, atomic##suffix##_t *v)\
1210 { \
1211 unsigned long flags; \
1212 int val; \
1213@@ -161,6 +251,9 @@ static inline int atomic_##op##_return(int i, atomic_t *v) \
1214 return val; \
1215 }
1216
1217+#define ATOMIC_OP_RETURN(op, c_op, asm_op) __ATOMIC_OP_RETURN(op, , c_op, asm_op)\
1218+ __ATOMIC_OP_RETURN(op, _unchecked, c_op, asm_op)
1219+
1220 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1221 {
1222 int ret;
1223@@ -175,6 +268,11 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1224 return ret;
1225 }
1226
1227+static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
1228+{
1229+ return atomic_cmpxchg((atomic_t *)v, old, new);
1230+}
1231+
1232 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1233 {
1234 int c, old;
1235@@ -196,16 +294,38 @@ ATOMIC_OPS(sub, -=, sub)
1236
1237 #undef ATOMIC_OPS
1238 #undef ATOMIC_OP_RETURN
1239+#undef __ATOMIC_OP_RETURN
1240 #undef ATOMIC_OP
1241+#undef __ATOMIC_OP
1242
1243 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
1244+static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
1245+{
1246+ return xchg(&v->counter, new);
1247+}
1248
1249 #define atomic_inc(v) atomic_add(1, v)
1250+static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
1251+{
1252+ atomic_add_unchecked(1, v);
1253+}
1254 #define atomic_dec(v) atomic_sub(1, v)
1255+static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
1256+{
1257+ atomic_sub_unchecked(1, v);
1258+}
1259
1260 #define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0)
1261+static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
1262+{
1263+ return atomic_add_return_unchecked(1, v) == 0;
1264+}
1265 #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0)
1266 #define atomic_inc_return(v) (atomic_add_return(1, v))
1267+static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
1268+{
1269+ return atomic_add_return_unchecked(1, v);
1270+}
1271 #define atomic_dec_return(v) (atomic_sub_return(1, v))
1272 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
1273
1274@@ -216,6 +336,14 @@ typedef struct {
1275 long long counter;
1276 } atomic64_t;
1277
1278+#ifdef CONFIG_PAX_REFCOUNT
1279+typedef struct {
1280+ long long counter;
1281+} atomic64_unchecked_t;
1282+#else
1283+typedef atomic64_t atomic64_unchecked_t;
1284+#endif
1285+
1286 #define ATOMIC64_INIT(i) { (i) }
1287
1288 #ifdef CONFIG_ARM_LPAE
1289@@ -232,6 +360,19 @@ static inline long long atomic64_read(const atomic64_t *v)
1290 return result;
1291 }
1292
1293+static inline long long atomic64_read_unchecked(const atomic64_unchecked_t *v)
1294+{
1295+ long long result;
1296+
1297+ __asm__ __volatile__("@ atomic64_read_unchecked\n"
1298+" ldrd %0, %H0, [%1]"
1299+ : "=&r" (result)
1300+ : "r" (&v->counter), "Qo" (v->counter)
1301+ );
1302+
1303+ return result;
1304+}
1305+
1306 static inline void atomic64_set(atomic64_t *v, long long i)
1307 {
1308 __asm__ __volatile__("@ atomic64_set\n"
1309@@ -240,6 +381,15 @@ static inline void atomic64_set(atomic64_t *v, long long i)
1310 : "r" (&v->counter), "r" (i)
1311 );
1312 }
1313+
1314+static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
1315+{
1316+ __asm__ __volatile__("@ atomic64_set_unchecked\n"
1317+" strd %2, %H2, [%1]"
1318+ : "=Qo" (v->counter)
1319+ : "r" (&v->counter), "r" (i)
1320+ );
1321+}
1322 #else
1323 static inline long long atomic64_read(const atomic64_t *v)
1324 {
1325@@ -254,6 +404,19 @@ static inline long long atomic64_read(const atomic64_t *v)
1326 return result;
1327 }
1328
1329+static inline long long atomic64_read_unchecked(const atomic64_unchecked_t *v)
1330+{
1331+ long long result;
1332+
1333+ __asm__ __volatile__("@ atomic64_read_unchecked\n"
1334+" ldrexd %0, %H0, [%1]"
1335+ : "=&r" (result)
1336+ : "r" (&v->counter), "Qo" (v->counter)
1337+ );
1338+
1339+ return result;
1340+}
1341+
1342 static inline void atomic64_set(atomic64_t *v, long long i)
1343 {
1344 long long tmp;
1345@@ -268,29 +431,57 @@ static inline void atomic64_set(atomic64_t *v, long long i)
1346 : "r" (&v->counter), "r" (i)
1347 : "cc");
1348 }
1349+
1350+static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
1351+{
1352+ long long tmp;
1353+
1354+ prefetchw(&v->counter);
1355+ __asm__ __volatile__("@ atomic64_set_unchecked\n"
1356+"1: ldrexd %0, %H0, [%2]\n"
1357+" strexd %0, %3, %H3, [%2]\n"
1358+" teq %0, #0\n"
1359+" bne 1b"
1360+ : "=&r" (tmp), "=Qo" (v->counter)
1361+ : "r" (&v->counter), "r" (i)
1362+ : "cc");
1363+}
1364 #endif
1365
1366-#define ATOMIC64_OP(op, op1, op2) \
1367-static inline void atomic64_##op(long long i, atomic64_t *v) \
1368+#undef __OVERFLOW_POST_RETURN
1369+#define __OVERFLOW_POST_RETURN \
1370+ " bvc 3f\n" \
1371+" mov %0, %1\n" \
1372+" mov %H0, %H1\n" \
1373+ "2: " REFCOUNT_TRAP_INSN "\n"\
1374+ "3:\n"
1375+
1376+#define __ATOMIC64_OP(op, suffix, op1, op2, post_op, extable) \
1377+static inline void atomic64_##op##suffix(long long i, atomic64##suffix##_t *v)\
1378 { \
1379 long long result; \
1380 unsigned long tmp; \
1381 \
1382 prefetchw(&v->counter); \
1383- __asm__ __volatile__("@ atomic64_" #op "\n" \
1384+ __asm__ __volatile__("@ atomic64_" #op #suffix "\n" \
1385 "1: ldrexd %0, %H0, [%3]\n" \
1386 " " #op1 " %Q0, %Q0, %Q4\n" \
1387 " " #op2 " %R0, %R0, %R4\n" \
1388+ post_op \
1389 " strexd %1, %0, %H0, [%3]\n" \
1390 " teq %1, #0\n" \
1391-" bne 1b" \
1392+" bne 1b\n" \
1393+ extable \
1394 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter) \
1395 : "r" (&v->counter), "r" (i) \
1396 : "cc"); \
1397 } \
1398
1399-#define ATOMIC64_OP_RETURN(op, op1, op2) \
1400-static inline long long atomic64_##op##_return(long long i, atomic64_t *v) \
1401+#define ATOMIC64_OP(op, op1, op2) __ATOMIC64_OP(op, _unchecked, op1, op2, , ) \
1402+ __ATOMIC64_OP(op, , op1, op2##s, __OVERFLOW_POST, __OVERFLOW_EXTABLE)
1403+
1404+#define __ATOMIC64_OP_RETURN(op, suffix, op1, op2, post_op, extable) \
1405+static inline long long atomic64_##op##_return##suffix(long long i, atomic64##suffix##_t *v) \
1406 { \
1407 long long result; \
1408 unsigned long tmp; \
1409@@ -298,13 +489,15 @@ static inline long long atomic64_##op##_return(long long i, atomic64_t *v) \
1410 smp_mb(); \
1411 prefetchw(&v->counter); \
1412 \
1413- __asm__ __volatile__("@ atomic64_" #op "_return\n" \
1414+ __asm__ __volatile__("@ atomic64_" #op "_return" #suffix "\n" \
1415 "1: ldrexd %0, %H0, [%3]\n" \
1416 " " #op1 " %Q0, %Q0, %Q4\n" \
1417 " " #op2 " %R0, %R0, %R4\n" \
1418+ post_op \
1419 " strexd %1, %0, %H0, [%3]\n" \
1420 " teq %1, #0\n" \
1421-" bne 1b" \
1422+" bne 1b\n" \
1423+ extable \
1424 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter) \
1425 : "r" (&v->counter), "r" (i) \
1426 : "cc"); \
1427@@ -314,6 +507,9 @@ static inline long long atomic64_##op##_return(long long i, atomic64_t *v) \
1428 return result; \
1429 }
1430
1431+#define ATOMIC64_OP_RETURN(op, op1, op2) __ATOMIC64_OP_RETURN(op, _unchecked, op1, op2, , ) \
1432+ __ATOMIC64_OP_RETURN(op, , op1, op2##s, __OVERFLOW_POST_RETURN, __OVERFLOW_EXTABLE)
1433+
1434 #define ATOMIC64_OPS(op, op1, op2) \
1435 ATOMIC64_OP(op, op1, op2) \
1436 ATOMIC64_OP_RETURN(op, op1, op2)
1437@@ -323,7 +519,12 @@ ATOMIC64_OPS(sub, subs, sbc)
1438
1439 #undef ATOMIC64_OPS
1440 #undef ATOMIC64_OP_RETURN
1441+#undef __ATOMIC64_OP_RETURN
1442 #undef ATOMIC64_OP
1443+#undef __ATOMIC64_OP
1444+#undef __OVERFLOW_EXTABLE
1445+#undef __OVERFLOW_POST_RETURN
1446+#undef __OVERFLOW_POST
1447
1448 static inline long long atomic64_cmpxchg(atomic64_t *ptr, long long old,
1449 long long new)
1450@@ -351,6 +552,31 @@ static inline long long atomic64_cmpxchg(atomic64_t *ptr, long long old,
1451 return oldval;
1452 }
1453
1454+static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *ptr, long long old,
1455+ long long new)
1456+{
1457+ long long oldval;
1458+ unsigned long res;
1459+
1460+ smp_mb();
1461+
1462+ do {
1463+ __asm__ __volatile__("@ atomic64_cmpxchg_unchecked\n"
1464+ "ldrexd %1, %H1, [%3]\n"
1465+ "mov %0, #0\n"
1466+ "teq %1, %4\n"
1467+ "teqeq %H1, %H4\n"
1468+ "strexdeq %0, %5, %H5, [%3]"
1469+ : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1470+ : "r" (&ptr->counter), "r" (old), "r" (new)
1471+ : "cc");
1472+ } while (res);
1473+
1474+ smp_mb();
1475+
1476+ return oldval;
1477+}
1478+
1479 static inline long long atomic64_xchg(atomic64_t *ptr, long long new)
1480 {
1481 long long result;
1482@@ -376,21 +602,35 @@ static inline long long atomic64_xchg(atomic64_t *ptr, long long new)
1483 static inline long long atomic64_dec_if_positive(atomic64_t *v)
1484 {
1485 long long result;
1486- unsigned long tmp;
1487+ u64 tmp;
1488
1489 smp_mb();
1490 prefetchw(&v->counter);
1491
1492 __asm__ __volatile__("@ atomic64_dec_if_positive\n"
1493-"1: ldrexd %0, %H0, [%3]\n"
1494-" subs %Q0, %Q0, #1\n"
1495-" sbc %R0, %R0, #0\n"
1496+"1: ldrexd %1, %H1, [%3]\n"
1497+" subs %Q0, %Q1, #1\n"
1498+" sbcs %R0, %R1, #0\n"
1499+
1500+#ifdef CONFIG_PAX_REFCOUNT
1501+" bvc 3f\n"
1502+" mov %Q0, %Q1\n"
1503+" mov %R0, %R1\n"
1504+"2: " REFCOUNT_TRAP_INSN "\n"
1505+"3:\n"
1506+#endif
1507+
1508 " teq %R0, #0\n"
1509-" bmi 2f\n"
1510+" bmi 4f\n"
1511 " strexd %1, %0, %H0, [%3]\n"
1512 " teq %1, #0\n"
1513 " bne 1b\n"
1514-"2:"
1515+"4:\n"
1516+
1517+#ifdef CONFIG_PAX_REFCOUNT
1518+ _ASM_EXTABLE(2b, 4b)
1519+#endif
1520+
1521 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1522 : "r" (&v->counter)
1523 : "cc");
1524@@ -414,13 +654,25 @@ static inline int atomic64_add_unless(atomic64_t *v, long long a, long long u)
1525 " teq %0, %5\n"
1526 " teqeq %H0, %H5\n"
1527 " moveq %1, #0\n"
1528-" beq 2f\n"
1529+" beq 4f\n"
1530 " adds %Q0, %Q0, %Q6\n"
1531-" adc %R0, %R0, %R6\n"
1532+" adcs %R0, %R0, %R6\n"
1533+
1534+#ifdef CONFIG_PAX_REFCOUNT
1535+" bvc 3f\n"
1536+"2: " REFCOUNT_TRAP_INSN "\n"
1537+"3:\n"
1538+#endif
1539+
1540 " strexd %2, %0, %H0, [%4]\n"
1541 " teq %2, #0\n"
1542 " bne 1b\n"
1543-"2:"
1544+"4:\n"
1545+
1546+#ifdef CONFIG_PAX_REFCOUNT
1547+ _ASM_EXTABLE(2b, 4b)
1548+#endif
1549+
1550 : "=&r" (val), "+r" (ret), "=&r" (tmp), "+Qo" (v->counter)
1551 : "r" (&v->counter), "r" (u), "r" (a)
1552 : "cc");
1553@@ -433,10 +685,13 @@ static inline int atomic64_add_unless(atomic64_t *v, long long a, long long u)
1554
1555 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
1556 #define atomic64_inc(v) atomic64_add(1LL, (v))
1557+#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1LL, (v))
1558 #define atomic64_inc_return(v) atomic64_add_return(1LL, (v))
1559+#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1LL, (v))
1560 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
1561 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
1562 #define atomic64_dec(v) atomic64_sub(1LL, (v))
1563+#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1LL, (v))
1564 #define atomic64_dec_return(v) atomic64_sub_return(1LL, (v))
1565 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
1566 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
1567diff --git a/arch/arm/include/asm/barrier.h b/arch/arm/include/asm/barrier.h
1568index d2f81e6..3c4dba5 100644
1569--- a/arch/arm/include/asm/barrier.h
1570+++ b/arch/arm/include/asm/barrier.h
1571@@ -67,7 +67,7 @@
1572 do { \
1573 compiletime_assert_atomic_type(*p); \
1574 smp_mb(); \
1575- ACCESS_ONCE(*p) = (v); \
1576+ ACCESS_ONCE_RW(*p) = (v); \
1577 } while (0)
1578
1579 #define smp_load_acquire(p) \
1580diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
1581index 75fe66b..ba3dee4 100644
1582--- a/arch/arm/include/asm/cache.h
1583+++ b/arch/arm/include/asm/cache.h
1584@@ -4,8 +4,10 @@
1585 #ifndef __ASMARM_CACHE_H
1586 #define __ASMARM_CACHE_H
1587
1588+#include <linux/const.h>
1589+
1590 #define L1_CACHE_SHIFT CONFIG_ARM_L1_CACHE_SHIFT
1591-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
1592+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
1593
1594 /*
1595 * Memory returned by kmalloc() may be used for DMA, so we must make
1596@@ -24,5 +26,6 @@
1597 #endif
1598
1599 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
1600+#define __read_only __attribute__ ((__section__(".data..read_only")))
1601
1602 #endif
1603diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
1604index 2d46862..a35415b 100644
1605--- a/arch/arm/include/asm/cacheflush.h
1606+++ b/arch/arm/include/asm/cacheflush.h
1607@@ -116,7 +116,7 @@ struct cpu_cache_fns {
1608 void (*dma_unmap_area)(const void *, size_t, int);
1609
1610 void (*dma_flush_range)(const void *, const void *);
1611-};
1612+} __no_const;
1613
1614 /*
1615 * Select the calling method
1616diff --git a/arch/arm/include/asm/checksum.h b/arch/arm/include/asm/checksum.h
1617index 5233151..87a71fa 100644
1618--- a/arch/arm/include/asm/checksum.h
1619+++ b/arch/arm/include/asm/checksum.h
1620@@ -37,7 +37,19 @@ __wsum
1621 csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
1622
1623 __wsum
1624-csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1625+__csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1626+
1627+static inline __wsum
1628+csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr)
1629+{
1630+ __wsum ret;
1631+ pax_open_userland();
1632+ ret = __csum_partial_copy_from_user(src, dst, len, sum, err_ptr);
1633+ pax_close_userland();
1634+ return ret;
1635+}
1636+
1637+
1638
1639 /*
1640 * Fold a partial checksum without adding pseudo headers
1641diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
1642index abb2c37..96db950 100644
1643--- a/arch/arm/include/asm/cmpxchg.h
1644+++ b/arch/arm/include/asm/cmpxchg.h
1645@@ -104,6 +104,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
1646
1647 #define xchg(ptr,x) \
1648 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1649+#define xchg_unchecked(ptr,x) \
1650+ ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1651
1652 #include <asm-generic/cmpxchg-local.h>
1653
1654diff --git a/arch/arm/include/asm/cpuidle.h b/arch/arm/include/asm/cpuidle.h
1655index 0f84249..8e83c55 100644
1656--- a/arch/arm/include/asm/cpuidle.h
1657+++ b/arch/arm/include/asm/cpuidle.h
1658@@ -32,7 +32,7 @@ struct device_node;
1659 struct cpuidle_ops {
1660 int (*suspend)(int cpu, unsigned long arg);
1661 int (*init)(struct device_node *, int cpu);
1662-};
1663+} __no_const;
1664
1665 struct of_cpuidle_method {
1666 const char *method;
1667diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h
1668index 6ddbe44..b5e38b1a 100644
1669--- a/arch/arm/include/asm/domain.h
1670+++ b/arch/arm/include/asm/domain.h
1671@@ -48,18 +48,37 @@
1672 * Domain types
1673 */
1674 #define DOMAIN_NOACCESS 0
1675-#define DOMAIN_CLIENT 1
1676 #ifdef CONFIG_CPU_USE_DOMAINS
1677+#define DOMAIN_USERCLIENT 1
1678+#define DOMAIN_KERNELCLIENT 1
1679 #define DOMAIN_MANAGER 3
1680+#define DOMAIN_VECTORS DOMAIN_USER
1681 #else
1682+
1683+#ifdef CONFIG_PAX_KERNEXEC
1684 #define DOMAIN_MANAGER 1
1685+#define DOMAIN_KERNEXEC 3
1686+#else
1687+#define DOMAIN_MANAGER 1
1688+#endif
1689+
1690+#ifdef CONFIG_PAX_MEMORY_UDEREF
1691+#define DOMAIN_USERCLIENT 0
1692+#define DOMAIN_UDEREF 1
1693+#define DOMAIN_VECTORS DOMAIN_KERNEL
1694+#else
1695+#define DOMAIN_USERCLIENT 1
1696+#define DOMAIN_VECTORS DOMAIN_USER
1697+#endif
1698+#define DOMAIN_KERNELCLIENT 1
1699+
1700 #endif
1701
1702 #define domain_val(dom,type) ((type) << (2*(dom)))
1703
1704 #ifndef __ASSEMBLY__
1705
1706-#ifdef CONFIG_CPU_USE_DOMAINS
1707+#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1708 static inline void set_domain(unsigned val)
1709 {
1710 asm volatile(
1711@@ -68,15 +87,7 @@ static inline void set_domain(unsigned val)
1712 isb();
1713 }
1714
1715-#define modify_domain(dom,type) \
1716- do { \
1717- struct thread_info *thread = current_thread_info(); \
1718- unsigned int domain = thread->cpu_domain; \
1719- domain &= ~domain_val(dom, DOMAIN_MANAGER); \
1720- thread->cpu_domain = domain | domain_val(dom, type); \
1721- set_domain(thread->cpu_domain); \
1722- } while (0)
1723-
1724+extern void modify_domain(unsigned int dom, unsigned int type);
1725 #else
1726 static inline void set_domain(unsigned val) { }
1727 static inline void modify_domain(unsigned dom, unsigned type) { }
1728diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
1729index d2315ff..f60b47b 100644
1730--- a/arch/arm/include/asm/elf.h
1731+++ b/arch/arm/include/asm/elf.h
1732@@ -117,7 +117,14 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1733 the loader. We need to make sure that it is out of the way of the program
1734 that it will "exec", and that there is sufficient room for the brk. */
1735
1736-#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1737+#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1738+
1739+#ifdef CONFIG_PAX_ASLR
1740+#define PAX_ELF_ET_DYN_BASE 0x00008000UL
1741+
1742+#define PAX_DELTA_MMAP_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1743+#define PAX_DELTA_STACK_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1744+#endif
1745
1746 /* When the program starts, a1 contains a pointer to a function to be
1747 registered with atexit, as per the SVR4 ABI. A value of 0 means we
1748diff --git a/arch/arm/include/asm/fncpy.h b/arch/arm/include/asm/fncpy.h
1749index de53547..52b9a28 100644
1750--- a/arch/arm/include/asm/fncpy.h
1751+++ b/arch/arm/include/asm/fncpy.h
1752@@ -81,7 +81,9 @@
1753 BUG_ON((uintptr_t)(dest_buf) & (FNCPY_ALIGN - 1) || \
1754 (__funcp_address & ~(uintptr_t)1 & (FNCPY_ALIGN - 1))); \
1755 \
1756+ pax_open_kernel(); \
1757 memcpy(dest_buf, (void const *)(__funcp_address & ~1), size); \
1758+ pax_close_kernel(); \
1759 flush_icache_range((unsigned long)(dest_buf), \
1760 (unsigned long)(dest_buf) + (size)); \
1761 \
1762diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
1763index 4e78065..f265b48 100644
1764--- a/arch/arm/include/asm/futex.h
1765+++ b/arch/arm/include/asm/futex.h
1766@@ -46,6 +46,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1767 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1768 return -EFAULT;
1769
1770+ pax_open_userland();
1771+
1772 smp_mb();
1773 /* Prefetching cannot fault */
1774 prefetchw(uaddr);
1775@@ -63,6 +65,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1776 : "cc", "memory");
1777 smp_mb();
1778
1779+ pax_close_userland();
1780+
1781 *uval = val;
1782 return ret;
1783 }
1784@@ -93,6 +97,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1785 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1786 return -EFAULT;
1787
1788+ pax_open_userland();
1789+
1790 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1791 "1: " TUSER(ldr) " %1, [%4]\n"
1792 " teq %1, %2\n"
1793@@ -103,6 +109,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1794 : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
1795 : "cc", "memory");
1796
1797+ pax_close_userland();
1798+
1799 *uval = val;
1800 return ret;
1801 }
1802@@ -125,6 +133,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1803 return -EFAULT;
1804
1805 pagefault_disable(); /* implies preempt_disable() */
1806+ pax_open_userland();
1807
1808 switch (op) {
1809 case FUTEX_OP_SET:
1810@@ -146,6 +155,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1811 ret = -ENOSYS;
1812 }
1813
1814+ pax_close_userland();
1815 pagefault_enable(); /* subsumes preempt_enable() */
1816
1817 if (!ret) {
1818diff --git a/arch/arm/include/asm/kmap_types.h b/arch/arm/include/asm/kmap_types.h
1819index 83eb2f7..ed77159 100644
1820--- a/arch/arm/include/asm/kmap_types.h
1821+++ b/arch/arm/include/asm/kmap_types.h
1822@@ -4,6 +4,6 @@
1823 /*
1824 * This is the "bare minimum". AIO seems to require this.
1825 */
1826-#define KM_TYPE_NR 16
1827+#define KM_TYPE_NR 17
1828
1829 #endif
1830diff --git a/arch/arm/include/asm/mach/dma.h b/arch/arm/include/asm/mach/dma.h
1831index 9e614a1..3302cca 100644
1832--- a/arch/arm/include/asm/mach/dma.h
1833+++ b/arch/arm/include/asm/mach/dma.h
1834@@ -22,7 +22,7 @@ struct dma_ops {
1835 int (*residue)(unsigned int, dma_t *); /* optional */
1836 int (*setspeed)(unsigned int, dma_t *, int); /* optional */
1837 const char *type;
1838-};
1839+} __do_const;
1840
1841 struct dma_struct {
1842 void *addr; /* single DMA address */
1843diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
1844index f98c7f3..e5c626d 100644
1845--- a/arch/arm/include/asm/mach/map.h
1846+++ b/arch/arm/include/asm/mach/map.h
1847@@ -23,17 +23,19 @@ struct map_desc {
1848
1849 /* types 0-3 are defined in asm/io.h */
1850 enum {
1851- MT_UNCACHED = 4,
1852- MT_CACHECLEAN,
1853- MT_MINICLEAN,
1854+ MT_UNCACHED_RW = 4,
1855+ MT_CACHECLEAN_RO,
1856+ MT_MINICLEAN_RO,
1857 MT_LOW_VECTORS,
1858 MT_HIGH_VECTORS,
1859- MT_MEMORY_RWX,
1860+ __MT_MEMORY_RWX,
1861 MT_MEMORY_RW,
1862- MT_ROM,
1863- MT_MEMORY_RWX_NONCACHED,
1864+ MT_MEMORY_RX,
1865+ MT_ROM_RX,
1866+ MT_MEMORY_RW_NONCACHED,
1867+ MT_MEMORY_RX_NONCACHED,
1868 MT_MEMORY_RW_DTCM,
1869- MT_MEMORY_RWX_ITCM,
1870+ MT_MEMORY_RX_ITCM,
1871 MT_MEMORY_RW_SO,
1872 MT_MEMORY_DMA_READY,
1873 };
1874diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
1875index 563b92f..689d58e 100644
1876--- a/arch/arm/include/asm/outercache.h
1877+++ b/arch/arm/include/asm/outercache.h
1878@@ -39,7 +39,7 @@ struct outer_cache_fns {
1879 /* This is an ARM L2C thing */
1880 void (*write_sec)(unsigned long, unsigned);
1881 void (*configure)(const struct l2x0_regs *);
1882-};
1883+} __no_const;
1884
1885 extern struct outer_cache_fns outer_cache;
1886
1887diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
1888index 4355f0e..cd9168e 100644
1889--- a/arch/arm/include/asm/page.h
1890+++ b/arch/arm/include/asm/page.h
1891@@ -23,6 +23,7 @@
1892
1893 #else
1894
1895+#include <linux/compiler.h>
1896 #include <asm/glue.h>
1897
1898 /*
1899@@ -114,7 +115,7 @@ struct cpu_user_fns {
1900 void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
1901 void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
1902 unsigned long vaddr, struct vm_area_struct *vma);
1903-};
1904+} __no_const;
1905
1906 #ifdef MULTI_USER
1907 extern struct cpu_user_fns cpu_user;
1908diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
1909index 19cfab5..3f5c7e9 100644
1910--- a/arch/arm/include/asm/pgalloc.h
1911+++ b/arch/arm/include/asm/pgalloc.h
1912@@ -17,6 +17,7 @@
1913 #include <asm/processor.h>
1914 #include <asm/cacheflush.h>
1915 #include <asm/tlbflush.h>
1916+#include <asm/system_info.h>
1917
1918 #define check_pgt_cache() do { } while (0)
1919
1920@@ -43,6 +44,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1921 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
1922 }
1923
1924+static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1925+{
1926+ pud_populate(mm, pud, pmd);
1927+}
1928+
1929 #else /* !CONFIG_ARM_LPAE */
1930
1931 /*
1932@@ -51,6 +57,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1933 #define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
1934 #define pmd_free(mm, pmd) do { } while (0)
1935 #define pud_populate(mm,pmd,pte) BUG()
1936+#define pud_populate_kernel(mm,pmd,pte) BUG()
1937
1938 #endif /* CONFIG_ARM_LPAE */
1939
1940@@ -128,6 +135,19 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
1941 __free_page(pte);
1942 }
1943
1944+static inline void __section_update(pmd_t *pmdp, unsigned long addr, pmdval_t prot)
1945+{
1946+#ifdef CONFIG_ARM_LPAE
1947+ pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1948+#else
1949+ if (addr & SECTION_SIZE)
1950+ pmdp[1] = __pmd(pmd_val(pmdp[1]) | prot);
1951+ else
1952+ pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1953+#endif
1954+ flush_pmd_entry(pmdp);
1955+}
1956+
1957 static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,
1958 pmdval_t prot)
1959 {
1960diff --git a/arch/arm/include/asm/pgtable-2level-hwdef.h b/arch/arm/include/asm/pgtable-2level-hwdef.h
1961index 5e68278..1869bae 100644
1962--- a/arch/arm/include/asm/pgtable-2level-hwdef.h
1963+++ b/arch/arm/include/asm/pgtable-2level-hwdef.h
1964@@ -27,7 +27,7 @@
1965 /*
1966 * - section
1967 */
1968-#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 0) /* v7 */
1969+#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 0) /* v7 */
1970 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1971 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1972 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 4) /* v6 */
1973@@ -39,6 +39,7 @@
1974 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17) /* v6 */
1975 #define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18) /* v6 */
1976 #define PMD_SECT_AF (_AT(pmdval_t, 0))
1977+#define PMD_SECT_RDONLY (_AT(pmdval_t, 0))
1978
1979 #define PMD_SECT_UNCACHED (_AT(pmdval_t, 0))
1980 #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE)
1981@@ -68,6 +69,7 @@
1982 * - extended small page/tiny page
1983 */
1984 #define PTE_EXT_XN (_AT(pteval_t, 1) << 0) /* v6 */
1985+#define PTE_EXT_PXN (_AT(pteval_t, 1) << 2) /* v7 */
1986 #define PTE_EXT_AP_MASK (_AT(pteval_t, 3) << 4)
1987 #define PTE_EXT_AP0 (_AT(pteval_t, 1) << 4)
1988 #define PTE_EXT_AP1 (_AT(pteval_t, 2) << 4)
1989diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
1990index bfd662e..f6cbb02 100644
1991--- a/arch/arm/include/asm/pgtable-2level.h
1992+++ b/arch/arm/include/asm/pgtable-2level.h
1993@@ -127,6 +127,9 @@
1994 #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */
1995 #define L_PTE_NONE (_AT(pteval_t, 1) << 11)
1996
1997+/* Two-level page tables only have PXN in the PGD, not in the PTE. */
1998+#define L_PTE_PXN (_AT(pteval_t, 0))
1999+
2000 /*
2001 * These are the memory types, defined to be compatible with
2002 * pre-ARMv6 CPUs cacheable and bufferable bits: XXCB
2003diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
2004index a745a2a..481350a 100644
2005--- a/arch/arm/include/asm/pgtable-3level.h
2006+++ b/arch/arm/include/asm/pgtable-3level.h
2007@@ -80,6 +80,7 @@
2008 #define L_PTE_USER (_AT(pteval_t, 1) << 6) /* AP[1] */
2009 #define L_PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
2010 #define L_PTE_YOUNG (_AT(pteval_t, 1) << 10) /* AF */
2011+#define L_PTE_PXN (_AT(pteval_t, 1) << 53) /* PXN */
2012 #define L_PTE_XN (_AT(pteval_t, 1) << 54) /* XN */
2013 #define L_PTE_DIRTY (_AT(pteval_t, 1) << 55)
2014 #define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56)
2015@@ -91,10 +92,12 @@
2016 #define L_PMD_SECT_SPLITTING (_AT(pmdval_t, 1) << 56)
2017 #define L_PMD_SECT_NONE (_AT(pmdval_t, 1) << 57)
2018 #define L_PMD_SECT_RDONLY (_AT(pteval_t, 1) << 58)
2019+#define PMD_SECT_RDONLY PMD_SECT_AP2
2020
2021 /*
2022 * To be used in assembly code with the upper page attributes.
2023 */
2024+#define L_PTE_PXN_HIGH (1 << (53 - 32))
2025 #define L_PTE_XN_HIGH (1 << (54 - 32))
2026 #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
2027
2028diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
2029index f403541..b10df68 100644
2030--- a/arch/arm/include/asm/pgtable.h
2031+++ b/arch/arm/include/asm/pgtable.h
2032@@ -33,6 +33,9 @@
2033 #include <asm/pgtable-2level.h>
2034 #endif
2035
2036+#define ktla_ktva(addr) (addr)
2037+#define ktva_ktla(addr) (addr)
2038+
2039 /*
2040 * Just any arbitrary offset to the start of the vmalloc VM area: the
2041 * current 8MB value just means that there will be a 8MB "hole" after the
2042@@ -48,6 +51,9 @@
2043 #define LIBRARY_TEXT_START 0x0c000000
2044
2045 #ifndef __ASSEMBLY__
2046+extern pteval_t __supported_pte_mask;
2047+extern pmdval_t __supported_pmd_mask;
2048+
2049 extern void __pte_error(const char *file, int line, pte_t);
2050 extern void __pmd_error(const char *file, int line, pmd_t);
2051 extern void __pgd_error(const char *file, int line, pgd_t);
2052@@ -56,6 +62,48 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2053 #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd)
2054 #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd)
2055
2056+#define __HAVE_ARCH_PAX_OPEN_KERNEL
2057+#define __HAVE_ARCH_PAX_CLOSE_KERNEL
2058+
2059+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2060+#include <asm/domain.h>
2061+#include <linux/thread_info.h>
2062+#include <linux/preempt.h>
2063+
2064+static inline int test_domain(int domain, int domaintype)
2065+{
2066+ return ((current_thread_info()->cpu_domain) & domain_val(domain, 3)) == domain_val(domain, domaintype);
2067+}
2068+#endif
2069+
2070+#ifdef CONFIG_PAX_KERNEXEC
2071+static inline unsigned long pax_open_kernel(void) {
2072+#ifdef CONFIG_ARM_LPAE
2073+ /* TODO */
2074+#else
2075+ preempt_disable();
2076+ BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC));
2077+ modify_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC);
2078+#endif
2079+ return 0;
2080+}
2081+
2082+static inline unsigned long pax_close_kernel(void) {
2083+#ifdef CONFIG_ARM_LPAE
2084+ /* TODO */
2085+#else
2086+ BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_MANAGER));
2087+ /* DOMAIN_MANAGER = "client" under KERNEXEC */
2088+ modify_domain(DOMAIN_KERNEL, DOMAIN_MANAGER);
2089+ preempt_enable_no_resched();
2090+#endif
2091+ return 0;
2092+}
2093+#else
2094+static inline unsigned long pax_open_kernel(void) { return 0; }
2095+static inline unsigned long pax_close_kernel(void) { return 0; }
2096+#endif
2097+
2098 /*
2099 * This is the lowest virtual address we can permit any user space
2100 * mapping to be mapped at. This is particularly important for
2101@@ -75,8 +123,8 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2102 /*
2103 * The pgprot_* and protection_map entries will be fixed up in runtime
2104 * to include the cachable and bufferable bits based on memory policy,
2105- * as well as any architecture dependent bits like global/ASID and SMP
2106- * shared mapping bits.
2107+ * as well as any architecture dependent bits like global/ASID, PXN,
2108+ * and SMP shared mapping bits.
2109 */
2110 #define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
2111
2112@@ -307,7 +355,7 @@ static inline pte_t pte_mknexec(pte_t pte)
2113 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
2114 {
2115 const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
2116- L_PTE_NONE | L_PTE_VALID;
2117+ L_PTE_NONE | L_PTE_VALID | __supported_pte_mask;
2118 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
2119 return pte;
2120 }
2121diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h
2122index c25ef3e..735f14b 100644
2123--- a/arch/arm/include/asm/psci.h
2124+++ b/arch/arm/include/asm/psci.h
2125@@ -32,7 +32,7 @@ struct psci_operations {
2126 int (*affinity_info)(unsigned long target_affinity,
2127 unsigned long lowest_affinity_level);
2128 int (*migrate_info_type)(void);
2129-};
2130+} __no_const;
2131
2132 extern struct psci_operations psci_ops;
2133 extern struct smp_operations psci_smp_ops;
2134diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
2135index 18f5a55..5072a40 100644
2136--- a/arch/arm/include/asm/smp.h
2137+++ b/arch/arm/include/asm/smp.h
2138@@ -107,7 +107,7 @@ struct smp_operations {
2139 int (*cpu_disable)(unsigned int cpu);
2140 #endif
2141 #endif
2142-};
2143+} __no_const;
2144
2145 struct of_cpu_method {
2146 const char *method;
2147diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
2148index bd32ede..bd90a0b 100644
2149--- a/arch/arm/include/asm/thread_info.h
2150+++ b/arch/arm/include/asm/thread_info.h
2151@@ -74,9 +74,9 @@ struct thread_info {
2152 .flags = 0, \
2153 .preempt_count = INIT_PREEMPT_COUNT, \
2154 .addr_limit = KERNEL_DS, \
2155- .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2156- domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2157- domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2158+ .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2159+ domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2160+ domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2161 }
2162
2163 #define init_thread_info (init_thread_union.thread_info)
2164@@ -152,7 +152,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2165 #define TIF_SYSCALL_AUDIT 9
2166 #define TIF_SYSCALL_TRACEPOINT 10
2167 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2168-#define TIF_NOHZ 12 /* in adaptive nohz mode */
2169+/* within 8 bits of TIF_SYSCALL_TRACE
2170+ * to meet flexible second operand requirements
2171+ */
2172+#define TIF_GRSEC_SETXID 12
2173+#define TIF_NOHZ 13 /* in adaptive nohz mode */
2174 #define TIF_USING_IWMMXT 17
2175 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2176 #define TIF_RESTORE_SIGMASK 20
2177@@ -166,10 +170,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2178 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2179 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2180 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2181+#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2182
2183 /* Checks for any syscall work in entry-common.S */
2184 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2185- _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2186+ _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2187
2188 /*
2189 * Change these and you break ASM code in entry-common.S
2190diff --git a/arch/arm/include/asm/tls.h b/arch/arm/include/asm/tls.h
2191index 5f833f7..76e6644 100644
2192--- a/arch/arm/include/asm/tls.h
2193+++ b/arch/arm/include/asm/tls.h
2194@@ -3,6 +3,7 @@
2195
2196 #include <linux/compiler.h>
2197 #include <asm/thread_info.h>
2198+#include <asm/pgtable.h>
2199
2200 #ifdef __ASSEMBLY__
2201 #include <asm/asm-offsets.h>
2202@@ -89,7 +90,9 @@ static inline void set_tls(unsigned long val)
2203 * at 0xffff0fe0 must be used instead. (see
2204 * entry-armv.S for details)
2205 */
2206+ pax_open_kernel();
2207 *((unsigned int *)0xffff0ff0) = val;
2208+ pax_close_kernel();
2209 #endif
2210 }
2211
2212diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2213index 74b17d0..57a4bf4 100644
2214--- a/arch/arm/include/asm/uaccess.h
2215+++ b/arch/arm/include/asm/uaccess.h
2216@@ -18,6 +18,7 @@
2217 #include <asm/domain.h>
2218 #include <asm/unified.h>
2219 #include <asm/compiler.h>
2220+#include <asm/pgtable.h>
2221
2222 #ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
2223 #include <asm-generic/uaccess-unaligned.h>
2224@@ -70,11 +71,38 @@ extern int __put_user_bad(void);
2225 static inline void set_fs(mm_segment_t fs)
2226 {
2227 current_thread_info()->addr_limit = fs;
2228- modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2229+ modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2230 }
2231
2232 #define segment_eq(a, b) ((a) == (b))
2233
2234+#define __HAVE_ARCH_PAX_OPEN_USERLAND
2235+#define __HAVE_ARCH_PAX_CLOSE_USERLAND
2236+
2237+static inline void pax_open_userland(void)
2238+{
2239+
2240+#ifdef CONFIG_PAX_MEMORY_UDEREF
2241+ if (segment_eq(get_fs(), USER_DS)) {
2242+ BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2243+ modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2244+ }
2245+#endif
2246+
2247+}
2248+
2249+static inline void pax_close_userland(void)
2250+{
2251+
2252+#ifdef CONFIG_PAX_MEMORY_UDEREF
2253+ if (segment_eq(get_fs(), USER_DS)) {
2254+ BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2255+ modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2256+ }
2257+#endif
2258+
2259+}
2260+
2261 #define __addr_ok(addr) ({ \
2262 unsigned long flag; \
2263 __asm__("cmp %2, %0; movlo %0, #0" \
2264@@ -198,8 +226,12 @@ extern int __get_user_64t_4(void *);
2265
2266 #define get_user(x, p) \
2267 ({ \
2268+ int __e; \
2269 might_fault(); \
2270- __get_user_check(x, p); \
2271+ pax_open_userland(); \
2272+ __e = __get_user_check((x), (p)); \
2273+ pax_close_userland(); \
2274+ __e; \
2275 })
2276
2277 extern int __put_user_1(void *, unsigned int);
2278@@ -244,8 +276,12 @@ extern int __put_user_8(void *, unsigned long long);
2279
2280 #define put_user(x, p) \
2281 ({ \
2282+ int __e; \
2283 might_fault(); \
2284- __put_user_check(x, p); \
2285+ pax_open_userland(); \
2286+ __e = __put_user_check((x), (p)); \
2287+ pax_close_userland(); \
2288+ __e; \
2289 })
2290
2291 #else /* CONFIG_MMU */
2292@@ -269,6 +305,7 @@ static inline void set_fs(mm_segment_t fs)
2293
2294 #endif /* CONFIG_MMU */
2295
2296+#define access_ok_noprefault(type, addr, size) access_ok((type), (addr), (size))
2297 #define access_ok(type, addr, size) (__range_ok(addr, size) == 0)
2298
2299 #define user_addr_max() \
2300@@ -286,13 +323,17 @@ static inline void set_fs(mm_segment_t fs)
2301 #define __get_user(x, ptr) \
2302 ({ \
2303 long __gu_err = 0; \
2304+ pax_open_userland(); \
2305 __get_user_err((x), (ptr), __gu_err); \
2306+ pax_close_userland(); \
2307 __gu_err; \
2308 })
2309
2310 #define __get_user_error(x, ptr, err) \
2311 ({ \
2312+ pax_open_userland(); \
2313 __get_user_err((x), (ptr), err); \
2314+ pax_close_userland(); \
2315 (void) 0; \
2316 })
2317
2318@@ -368,13 +409,17 @@ do { \
2319 #define __put_user(x, ptr) \
2320 ({ \
2321 long __pu_err = 0; \
2322+ pax_open_userland(); \
2323 __put_user_err((x), (ptr), __pu_err); \
2324+ pax_close_userland(); \
2325 __pu_err; \
2326 })
2327
2328 #define __put_user_error(x, ptr, err) \
2329 ({ \
2330+ pax_open_userland(); \
2331 __put_user_err((x), (ptr), err); \
2332+ pax_close_userland(); \
2333 (void) 0; \
2334 })
2335
2336@@ -474,11 +519,44 @@ do { \
2337
2338
2339 #ifdef CONFIG_MMU
2340-extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2341-extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2342+extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
2343+extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
2344+
2345+static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
2346+{
2347+ unsigned long ret;
2348+
2349+ check_object_size(to, n, false);
2350+ pax_open_userland();
2351+ ret = ___copy_from_user(to, from, n);
2352+ pax_close_userland();
2353+ return ret;
2354+}
2355+
2356+static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2357+{
2358+ unsigned long ret;
2359+
2360+ check_object_size(from, n, true);
2361+ pax_open_userland();
2362+ ret = ___copy_to_user(to, from, n);
2363+ pax_close_userland();
2364+ return ret;
2365+}
2366+
2367 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2368-extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
2369+extern unsigned long __must_check ___clear_user(void __user *addr, unsigned long n);
2370 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
2371+
2372+static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2373+{
2374+ unsigned long ret;
2375+ pax_open_userland();
2376+ ret = ___clear_user(addr, n);
2377+ pax_close_userland();
2378+ return ret;
2379+}
2380+
2381 #else
2382 #define __copy_from_user(to, from, n) (memcpy(to, (void __force *)from, n), 0)
2383 #define __copy_to_user(to, from, n) (memcpy((void __force *)to, from, n), 0)
2384@@ -487,6 +565,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2385
2386 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2387 {
2388+ if ((long)n < 0)
2389+ return n;
2390+
2391 if (access_ok(VERIFY_READ, from, n))
2392 n = __copy_from_user(to, from, n);
2393 else /* security hole - plug it */
2394@@ -496,6 +577,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2395
2396 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2397 {
2398+ if ((long)n < 0)
2399+ return n;
2400+
2401 if (access_ok(VERIFY_WRITE, to, n))
2402 n = __copy_to_user(to, from, n);
2403 return n;
2404diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2405index 5af0ed1..cea83883 100644
2406--- a/arch/arm/include/uapi/asm/ptrace.h
2407+++ b/arch/arm/include/uapi/asm/ptrace.h
2408@@ -92,7 +92,7 @@
2409 * ARMv7 groups of PSR bits
2410 */
2411 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2412-#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2413+#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2414 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2415 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2416
2417diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2418index a88671c..1cc895e 100644
2419--- a/arch/arm/kernel/armksyms.c
2420+++ b/arch/arm/kernel/armksyms.c
2421@@ -55,7 +55,7 @@ EXPORT_SYMBOL(arm_delay_ops);
2422
2423 /* networking */
2424 EXPORT_SYMBOL(csum_partial);
2425-EXPORT_SYMBOL(csum_partial_copy_from_user);
2426+EXPORT_SYMBOL(__csum_partial_copy_from_user);
2427 EXPORT_SYMBOL(csum_partial_copy_nocheck);
2428 EXPORT_SYMBOL(__csum_ipv6_magic);
2429
2430@@ -91,9 +91,9 @@ EXPORT_SYMBOL(__memzero);
2431 #ifdef CONFIG_MMU
2432 EXPORT_SYMBOL(copy_page);
2433
2434-EXPORT_SYMBOL(__copy_from_user);
2435-EXPORT_SYMBOL(__copy_to_user);
2436-EXPORT_SYMBOL(__clear_user);
2437+EXPORT_SYMBOL(___copy_from_user);
2438+EXPORT_SYMBOL(___copy_to_user);
2439+EXPORT_SYMBOL(___clear_user);
2440
2441 EXPORT_SYMBOL(__get_user_1);
2442 EXPORT_SYMBOL(__get_user_2);
2443diff --git a/arch/arm/kernel/cpuidle.c b/arch/arm/kernel/cpuidle.c
2444index 318da33..373689f 100644
2445--- a/arch/arm/kernel/cpuidle.c
2446+++ b/arch/arm/kernel/cpuidle.c
2447@@ -19,7 +19,7 @@ extern struct of_cpuidle_method __cpuidle_method_of_table[];
2448 static const struct of_cpuidle_method __cpuidle_method_of_table_sentinel
2449 __used __section(__cpuidle_method_of_table_end);
2450
2451-static struct cpuidle_ops cpuidle_ops[NR_CPUS];
2452+static struct cpuidle_ops cpuidle_ops[NR_CPUS] __read_only;
2453
2454 /**
2455 * arm_cpuidle_simple_enter() - a wrapper to cpu_do_idle()
2456diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2457index 570306c..c87f193 100644
2458--- a/arch/arm/kernel/entry-armv.S
2459+++ b/arch/arm/kernel/entry-armv.S
2460@@ -48,6 +48,87 @@
2461 9997:
2462 .endm
2463
2464+ .macro pax_enter_kernel
2465+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2466+ @ make aligned space for saved DACR
2467+ sub sp, sp, #8
2468+ @ save regs
2469+ stmdb sp!, {r1, r2}
2470+ @ read DACR from cpu_domain into r1
2471+ mov r2, sp
2472+ @ assume 8K pages, since we have to split the immediate in two
2473+ bic r2, r2, #(0x1fc0)
2474+ bic r2, r2, #(0x3f)
2475+ ldr r1, [r2, #TI_CPU_DOMAIN]
2476+ @ store old DACR on stack
2477+ str r1, [sp, #8]
2478+#ifdef CONFIG_PAX_KERNEXEC
2479+ @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2480+ bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2481+ orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2482+#endif
2483+#ifdef CONFIG_PAX_MEMORY_UDEREF
2484+ @ set current DOMAIN_USER to DOMAIN_NOACCESS
2485+ bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2486+#endif
2487+ @ write r1 to current_thread_info()->cpu_domain
2488+ str r1, [r2, #TI_CPU_DOMAIN]
2489+ @ write r1 to DACR
2490+ mcr p15, 0, r1, c3, c0, 0
2491+ @ instruction sync
2492+ instr_sync
2493+ @ restore regs
2494+ ldmia sp!, {r1, r2}
2495+#endif
2496+ .endm
2497+
2498+ .macro pax_open_userland
2499+#ifdef CONFIG_PAX_MEMORY_UDEREF
2500+ @ save regs
2501+ stmdb sp!, {r0, r1}
2502+ @ read DACR from cpu_domain into r1
2503+ mov r0, sp
2504+ @ assume 8K pages, since we have to split the immediate in two
2505+ bic r0, r0, #(0x1fc0)
2506+ bic r0, r0, #(0x3f)
2507+ ldr r1, [r0, #TI_CPU_DOMAIN]
2508+ @ set current DOMAIN_USER to DOMAIN_CLIENT
2509+ bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2510+ orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2511+ @ write r1 to current_thread_info()->cpu_domain
2512+ str r1, [r0, #TI_CPU_DOMAIN]
2513+ @ write r1 to DACR
2514+ mcr p15, 0, r1, c3, c0, 0
2515+ @ instruction sync
2516+ instr_sync
2517+ @ restore regs
2518+ ldmia sp!, {r0, r1}
2519+#endif
2520+ .endm
2521+
2522+ .macro pax_close_userland
2523+#ifdef CONFIG_PAX_MEMORY_UDEREF
2524+ @ save regs
2525+ stmdb sp!, {r0, r1}
2526+ @ read DACR from cpu_domain into r1
2527+ mov r0, sp
2528+ @ assume 8K pages, since we have to split the immediate in two
2529+ bic r0, r0, #(0x1fc0)
2530+ bic r0, r0, #(0x3f)
2531+ ldr r1, [r0, #TI_CPU_DOMAIN]
2532+ @ set current DOMAIN_USER to DOMAIN_NOACCESS
2533+ bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2534+ @ write r1 to current_thread_info()->cpu_domain
2535+ str r1, [r0, #TI_CPU_DOMAIN]
2536+ @ write r1 to DACR
2537+ mcr p15, 0, r1, c3, c0, 0
2538+ @ instruction sync
2539+ instr_sync
2540+ @ restore regs
2541+ ldmia sp!, {r0, r1}
2542+#endif
2543+ .endm
2544+
2545 .macro pabt_helper
2546 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2547 #ifdef MULTI_PABORT
2548@@ -90,11 +171,15 @@
2549 * Invalid mode handlers
2550 */
2551 .macro inv_entry, reason
2552+
2553+ pax_enter_kernel
2554+
2555 sub sp, sp, #S_FRAME_SIZE
2556 ARM( stmib sp, {r1 - lr} )
2557 THUMB( stmia sp, {r0 - r12} )
2558 THUMB( str sp, [sp, #S_SP] )
2559 THUMB( str lr, [sp, #S_LR] )
2560+
2561 mov r1, #\reason
2562 .endm
2563
2564@@ -150,7 +235,11 @@ ENDPROC(__und_invalid)
2565 .macro svc_entry, stack_hole=0, trace=1
2566 UNWIND(.fnstart )
2567 UNWIND(.save {r0 - pc} )
2568+
2569+ pax_enter_kernel
2570+
2571 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2572+
2573 #ifdef CONFIG_THUMB2_KERNEL
2574 SPFIX( str r0, [sp] ) @ temporarily saved
2575 SPFIX( mov r0, sp )
2576@@ -165,7 +254,12 @@ ENDPROC(__und_invalid)
2577 ldmia r0, {r3 - r5}
2578 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2579 mov r6, #-1 @ "" "" "" ""
2580+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2581+ @ offset sp by 8 as done in pax_enter_kernel
2582+ add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2583+#else
2584 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2585+#endif
2586 SPFIX( addeq r2, r2, #4 )
2587 str r3, [sp, #-4]! @ save the "real" r0 copied
2588 @ from the exception stack
2589@@ -369,6 +463,9 @@ ENDPROC(__fiq_abt)
2590 .macro usr_entry, trace=1
2591 UNWIND(.fnstart )
2592 UNWIND(.cantunwind ) @ don't unwind the user space
2593+
2594+ pax_enter_kernel_user
2595+
2596 sub sp, sp, #S_FRAME_SIZE
2597 ARM( stmib sp, {r1 - r12} )
2598 THUMB( stmia sp, {r0 - r12} )
2599@@ -479,7 +576,9 @@ __und_usr:
2600 tst r3, #PSR_T_BIT @ Thumb mode?
2601 bne __und_usr_thumb
2602 sub r4, r2, #4 @ ARM instr at LR - 4
2603+ pax_open_userland
2604 1: ldrt r0, [r4]
2605+ pax_close_userland
2606 ARM_BE8(rev r0, r0) @ little endian instruction
2607
2608 @ r0 = 32-bit ARM instruction which caused the exception
2609@@ -513,11 +612,15 @@ __und_usr_thumb:
2610 */
2611 .arch armv6t2
2612 #endif
2613+ pax_open_userland
2614 2: ldrht r5, [r4]
2615+ pax_close_userland
2616 ARM_BE8(rev16 r5, r5) @ little endian instruction
2617 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2618 blo __und_usr_fault_16 @ 16bit undefined instruction
2619+ pax_open_userland
2620 3: ldrht r0, [r2]
2621+ pax_close_userland
2622 ARM_BE8(rev16 r0, r0) @ little endian instruction
2623 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2624 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2625@@ -547,7 +650,8 @@ ENDPROC(__und_usr)
2626 */
2627 .pushsection .text.fixup, "ax"
2628 .align 2
2629-4: str r4, [sp, #S_PC] @ retry current instruction
2630+4: pax_close_userland
2631+ str r4, [sp, #S_PC] @ retry current instruction
2632 ret r9
2633 .popsection
2634 .pushsection __ex_table,"a"
2635@@ -767,7 +871,7 @@ ENTRY(__switch_to)
2636 THUMB( str lr, [ip], #4 )
2637 ldr r4, [r2, #TI_TP_VALUE]
2638 ldr r5, [r2, #TI_TP_VALUE + 4]
2639-#ifdef CONFIG_CPU_USE_DOMAINS
2640+#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2641 ldr r6, [r2, #TI_CPU_DOMAIN]
2642 #endif
2643 switch_tls r1, r4, r5, r3, r7
2644@@ -776,7 +880,7 @@ ENTRY(__switch_to)
2645 ldr r8, =__stack_chk_guard
2646 ldr r7, [r7, #TSK_STACK_CANARY]
2647 #endif
2648-#ifdef CONFIG_CPU_USE_DOMAINS
2649+#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2650 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2651 #endif
2652 mov r5, r0
2653diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2654index 4e7f40c..0f9ee2c 100644
2655--- a/arch/arm/kernel/entry-common.S
2656+++ b/arch/arm/kernel/entry-common.S
2657@@ -11,18 +11,46 @@
2658 #include <asm/assembler.h>
2659 #include <asm/unistd.h>
2660 #include <asm/ftrace.h>
2661+#include <asm/domain.h>
2662 #include <asm/unwind.h>
2663
2664+#include "entry-header.S"
2665+
2666 #ifdef CONFIG_NEED_RET_TO_USER
2667 #include <mach/entry-macro.S>
2668 #else
2669 .macro arch_ret_to_user, tmp1, tmp2
2670+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2671+ @ save regs
2672+ stmdb sp!, {r1, r2}
2673+ @ read DACR from cpu_domain into r1
2674+ mov r2, sp
2675+ @ assume 8K pages, since we have to split the immediate in two
2676+ bic r2, r2, #(0x1fc0)
2677+ bic r2, r2, #(0x3f)
2678+ ldr r1, [r2, #TI_CPU_DOMAIN]
2679+#ifdef CONFIG_PAX_KERNEXEC
2680+ @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2681+ bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2682+ orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2683+#endif
2684+#ifdef CONFIG_PAX_MEMORY_UDEREF
2685+ @ set current DOMAIN_USER to DOMAIN_UDEREF
2686+ bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2687+ orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2688+#endif
2689+ @ write r1 to current_thread_info()->cpu_domain
2690+ str r1, [r2, #TI_CPU_DOMAIN]
2691+ @ write r1 to DACR
2692+ mcr p15, 0, r1, c3, c0, 0
2693+ @ instruction sync
2694+ instr_sync
2695+ @ restore regs
2696+ ldmia sp!, {r1, r2}
2697+#endif
2698 .endm
2699 #endif
2700
2701-#include "entry-header.S"
2702-
2703-
2704 .align 5
2705 /*
2706 * This is the fast syscall return path. We do as little as
2707@@ -173,6 +201,12 @@ ENTRY(vector_swi)
2708 USER( ldr scno, [lr, #-4] ) @ get SWI instruction
2709 #endif
2710
2711+ /*
2712+ * do this here to avoid a performance hit of wrapping the code above
2713+ * that directly dereferences userland to parse the SWI instruction
2714+ */
2715+ pax_enter_kernel_user
2716+
2717 adr tbl, sys_call_table @ load syscall table pointer
2718
2719 #if defined(CONFIG_OABI_COMPAT)
2720diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2721index 1a0045a..9b4f34d 100644
2722--- a/arch/arm/kernel/entry-header.S
2723+++ b/arch/arm/kernel/entry-header.S
2724@@ -196,6 +196,60 @@
2725 msr cpsr_c, \rtemp @ switch back to the SVC mode
2726 .endm
2727
2728+ .macro pax_enter_kernel_user
2729+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2730+ @ save regs
2731+ stmdb sp!, {r0, r1}
2732+ @ read DACR from cpu_domain into r1
2733+ mov r0, sp
2734+ @ assume 8K pages, since we have to split the immediate in two
2735+ bic r0, r0, #(0x1fc0)
2736+ bic r0, r0, #(0x3f)
2737+ ldr r1, [r0, #TI_CPU_DOMAIN]
2738+#ifdef CONFIG_PAX_MEMORY_UDEREF
2739+ @ set current DOMAIN_USER to DOMAIN_NOACCESS
2740+ bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2741+#endif
2742+#ifdef CONFIG_PAX_KERNEXEC
2743+ @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2744+ bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2745+ orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2746+#endif
2747+ @ write r1 to current_thread_info()->cpu_domain
2748+ str r1, [r0, #TI_CPU_DOMAIN]
2749+ @ write r1 to DACR
2750+ mcr p15, 0, r1, c3, c0, 0
2751+ @ instruction sync
2752+ instr_sync
2753+ @ restore regs
2754+ ldmia sp!, {r0, r1}
2755+#endif
2756+ .endm
2757+
2758+ .macro pax_exit_kernel
2759+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2760+ @ save regs
2761+ stmdb sp!, {r0, r1}
2762+ @ read old DACR from stack into r1
2763+ ldr r1, [sp, #(8 + S_SP)]
2764+ sub r1, r1, #8
2765+ ldr r1, [r1]
2766+
2767+ @ write r1 to current_thread_info()->cpu_domain
2768+ mov r0, sp
2769+ @ assume 8K pages, since we have to split the immediate in two
2770+ bic r0, r0, #(0x1fc0)
2771+ bic r0, r0, #(0x3f)
2772+ str r1, [r0, #TI_CPU_DOMAIN]
2773+ @ write r1 to DACR
2774+ mcr p15, 0, r1, c3, c0, 0
2775+ @ instruction sync
2776+ instr_sync
2777+ @ restore regs
2778+ ldmia sp!, {r0, r1}
2779+#endif
2780+ .endm
2781+
2782 #ifndef CONFIG_THUMB2_KERNEL
2783 .macro svc_exit, rpsr, irq = 0
2784 .if \irq != 0
2785@@ -215,6 +269,9 @@
2786 blne trace_hardirqs_off
2787 #endif
2788 .endif
2789+
2790+ pax_exit_kernel
2791+
2792 msr spsr_cxsf, \rpsr
2793 #if defined(CONFIG_CPU_V6) || defined(CONFIG_CPU_32v6K)
2794 @ We must avoid clrex due to Cortex-A15 erratum #830321
2795@@ -291,6 +348,9 @@
2796 blne trace_hardirqs_off
2797 #endif
2798 .endif
2799+
2800+ pax_exit_kernel
2801+
2802 ldr lr, [sp, #S_SP] @ top of the stack
2803 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2804
2805diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2806index 059c3da..8e45cfc 100644
2807--- a/arch/arm/kernel/fiq.c
2808+++ b/arch/arm/kernel/fiq.c
2809@@ -95,7 +95,10 @@ void set_fiq_handler(void *start, unsigned int length)
2810 void *base = vectors_page;
2811 unsigned offset = FIQ_OFFSET;
2812
2813+ pax_open_kernel();
2814 memcpy(base + offset, start, length);
2815+ pax_close_kernel();
2816+
2817 if (!cache_is_vipt_nonaliasing())
2818 flush_icache_range((unsigned long)base + offset, offset +
2819 length);
2820diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2821index 3637973..cb29657 100644
2822--- a/arch/arm/kernel/head.S
2823+++ b/arch/arm/kernel/head.S
2824@@ -444,7 +444,7 @@ __enable_mmu:
2825 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2826 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2827 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2828- domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2829+ domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2830 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2831 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2832 #endif
2833diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2834index af791f4..3ff9821 100644
2835--- a/arch/arm/kernel/module.c
2836+++ b/arch/arm/kernel/module.c
2837@@ -38,12 +38,39 @@
2838 #endif
2839
2840 #ifdef CONFIG_MMU
2841-void *module_alloc(unsigned long size)
2842+static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2843 {
2844+ if (!size || PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR)
2845+ return NULL;
2846 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2847- GFP_KERNEL, PAGE_KERNEL_EXEC, 0, NUMA_NO_NODE,
2848+ GFP_KERNEL, prot, 0, NUMA_NO_NODE,
2849 __builtin_return_address(0));
2850 }
2851+
2852+void *module_alloc(unsigned long size)
2853+{
2854+
2855+#ifdef CONFIG_PAX_KERNEXEC
2856+ return __module_alloc(size, PAGE_KERNEL);
2857+#else
2858+ return __module_alloc(size, PAGE_KERNEL_EXEC);
2859+#endif
2860+
2861+}
2862+
2863+#ifdef CONFIG_PAX_KERNEXEC
2864+void module_memfree_exec(void *module_region)
2865+{
2866+ module_memfree(module_region);
2867+}
2868+EXPORT_SYMBOL(module_memfree_exec);
2869+
2870+void *module_alloc_exec(unsigned long size)
2871+{
2872+ return __module_alloc(size, PAGE_KERNEL_EXEC);
2873+}
2874+EXPORT_SYMBOL(module_alloc_exec);
2875+#endif
2876 #endif
2877
2878 int
2879diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2880index 69bda1a..755113a 100644
2881--- a/arch/arm/kernel/patch.c
2882+++ b/arch/arm/kernel/patch.c
2883@@ -66,6 +66,7 @@ void __kprobes __patch_text_real(void *addr, unsigned int insn, bool remap)
2884 else
2885 __acquire(&patch_lock);
2886
2887+ pax_open_kernel();
2888 if (thumb2 && __opcode_is_thumb16(insn)) {
2889 *(u16 *)waddr = __opcode_to_mem_thumb16(insn);
2890 size = sizeof(u16);
2891@@ -97,6 +98,7 @@ void __kprobes __patch_text_real(void *addr, unsigned int insn, bool remap)
2892 *(u32 *)waddr = insn;
2893 size = sizeof(u32);
2894 }
2895+ pax_close_kernel();
2896
2897 if (waddr != addr) {
2898 flush_kernel_vmap_range(waddr, twopage ? size / 2 : size);
2899diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2900index f192a2a..1a40523 100644
2901--- a/arch/arm/kernel/process.c
2902+++ b/arch/arm/kernel/process.c
2903@@ -105,8 +105,8 @@ void __show_regs(struct pt_regs *regs)
2904
2905 show_regs_print_info(KERN_DEFAULT);
2906
2907- print_symbol("PC is at %s\n", instruction_pointer(regs));
2908- print_symbol("LR is at %s\n", regs->ARM_lr);
2909+ printk("PC is at %pA\n", (void *)instruction_pointer(regs));
2910+ printk("LR is at %pA\n", (void *)regs->ARM_lr);
2911 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2912 "sp : %08lx ip : %08lx fp : %08lx\n",
2913 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2914@@ -283,12 +283,6 @@ unsigned long get_wchan(struct task_struct *p)
2915 return 0;
2916 }
2917
2918-unsigned long arch_randomize_brk(struct mm_struct *mm)
2919-{
2920- unsigned long range_end = mm->brk + 0x02000000;
2921- return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2922-}
2923-
2924 #ifdef CONFIG_MMU
2925 #ifdef CONFIG_KUSER_HELPERS
2926 /*
2927@@ -304,7 +298,7 @@ static struct vm_area_struct gate_vma = {
2928
2929 static int __init gate_vma_init(void)
2930 {
2931- gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2932+ gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2933 return 0;
2934 }
2935 arch_initcall(gate_vma_init);
2936@@ -333,91 +327,13 @@ const char *arch_vma_name(struct vm_area_struct *vma)
2937 return is_gate_vma(vma) ? "[vectors]" : NULL;
2938 }
2939
2940-/* If possible, provide a placement hint at a random offset from the
2941- * stack for the sigpage and vdso pages.
2942- */
2943-static unsigned long sigpage_addr(const struct mm_struct *mm,
2944- unsigned int npages)
2945-{
2946- unsigned long offset;
2947- unsigned long first;
2948- unsigned long last;
2949- unsigned long addr;
2950- unsigned int slots;
2951-
2952- first = PAGE_ALIGN(mm->start_stack);
2953-
2954- last = TASK_SIZE - (npages << PAGE_SHIFT);
2955-
2956- /* No room after stack? */
2957- if (first > last)
2958- return 0;
2959-
2960- /* Just enough room? */
2961- if (first == last)
2962- return first;
2963-
2964- slots = ((last - first) >> PAGE_SHIFT) + 1;
2965-
2966- offset = get_random_int() % slots;
2967-
2968- addr = first + (offset << PAGE_SHIFT);
2969-
2970- return addr;
2971-}
2972-
2973-static struct page *signal_page;
2974-extern struct page *get_signal_page(void);
2975-
2976-static const struct vm_special_mapping sigpage_mapping = {
2977- .name = "[sigpage]",
2978- .pages = &signal_page,
2979-};
2980-
2981 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
2982 {
2983 struct mm_struct *mm = current->mm;
2984- struct vm_area_struct *vma;
2985- unsigned long npages;
2986- unsigned long addr;
2987- unsigned long hint;
2988- int ret = 0;
2989-
2990- if (!signal_page)
2991- signal_page = get_signal_page();
2992- if (!signal_page)
2993- return -ENOMEM;
2994-
2995- npages = 1; /* for sigpage */
2996- npages += vdso_total_pages;
2997
2998 down_write(&mm->mmap_sem);
2999- hint = sigpage_addr(mm, npages);
3000- addr = get_unmapped_area(NULL, hint, npages << PAGE_SHIFT, 0, 0);
3001- if (IS_ERR_VALUE(addr)) {
3002- ret = addr;
3003- goto up_fail;
3004- }
3005-
3006- vma = _install_special_mapping(mm, addr, PAGE_SIZE,
3007- VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC,
3008- &sigpage_mapping);
3009-
3010- if (IS_ERR(vma)) {
3011- ret = PTR_ERR(vma);
3012- goto up_fail;
3013- }
3014-
3015- mm->context.sigpage = addr;
3016-
3017- /* Unlike the sigpage, failure to install the vdso is unlikely
3018- * to be fatal to the process, so no error check needed
3019- * here.
3020- */
3021- arm_install_vdso(mm, addr + PAGE_SIZE);
3022-
3023- up_fail:
3024+ mm->context.sigpage = (PAGE_OFFSET + (get_random_int() % 0x3FFEFFE0)) & 0xFFFFFFFC;
3025 up_write(&mm->mmap_sem);
3026- return ret;
3027+ return 0;
3028 }
3029 #endif
3030diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
3031index f90fdf4..24e8c84 100644
3032--- a/arch/arm/kernel/psci.c
3033+++ b/arch/arm/kernel/psci.c
3034@@ -26,7 +26,7 @@
3035 #include <asm/psci.h>
3036 #include <asm/system_misc.h>
3037
3038-struct psci_operations psci_ops;
3039+struct psci_operations psci_ops __read_only;
3040
3041 static int (*invoke_psci_fn)(u32, u32, u32, u32);
3042 typedef int (*psci_initcall_t)(const struct device_node *);
3043diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
3044index ef9119f..31995a3 100644
3045--- a/arch/arm/kernel/ptrace.c
3046+++ b/arch/arm/kernel/ptrace.c
3047@@ -928,10 +928,19 @@ static void tracehook_report_syscall(struct pt_regs *regs,
3048 regs->ARM_ip = ip;
3049 }
3050
3051+#ifdef CONFIG_GRKERNSEC_SETXID
3052+extern void gr_delayed_cred_worker(void);
3053+#endif
3054+
3055 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
3056 {
3057 current_thread_info()->syscall = scno;
3058
3059+#ifdef CONFIG_GRKERNSEC_SETXID
3060+ if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
3061+ gr_delayed_cred_worker();
3062+#endif
3063+
3064 /* Do the secure computing check first; failures should be fast. */
3065 #ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER
3066 if (secure_computing() == -1)
3067diff --git a/arch/arm/kernel/reboot.c b/arch/arm/kernel/reboot.c
3068index 1a4d232..2677169 100644
3069--- a/arch/arm/kernel/reboot.c
3070+++ b/arch/arm/kernel/reboot.c
3071@@ -122,6 +122,7 @@ void machine_power_off(void)
3072
3073 if (pm_power_off)
3074 pm_power_off();
3075+ while (1);
3076 }
3077
3078 /*
3079diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
3080index 6c777e9..3d2d0ca 100644
3081--- a/arch/arm/kernel/setup.c
3082+++ b/arch/arm/kernel/setup.c
3083@@ -105,21 +105,23 @@ EXPORT_SYMBOL(elf_hwcap);
3084 unsigned int elf_hwcap2 __read_mostly;
3085 EXPORT_SYMBOL(elf_hwcap2);
3086
3087+pteval_t __supported_pte_mask __read_only;
3088+pmdval_t __supported_pmd_mask __read_only;
3089
3090 #ifdef MULTI_CPU
3091-struct processor processor __read_mostly;
3092+struct processor processor __read_only;
3093 #endif
3094 #ifdef MULTI_TLB
3095-struct cpu_tlb_fns cpu_tlb __read_mostly;
3096+struct cpu_tlb_fns cpu_tlb __read_only;
3097 #endif
3098 #ifdef MULTI_USER
3099-struct cpu_user_fns cpu_user __read_mostly;
3100+struct cpu_user_fns cpu_user __read_only;
3101 #endif
3102 #ifdef MULTI_CACHE
3103-struct cpu_cache_fns cpu_cache __read_mostly;
3104+struct cpu_cache_fns cpu_cache __read_only;
3105 #endif
3106 #ifdef CONFIG_OUTER_CACHE
3107-struct outer_cache_fns outer_cache __read_mostly;
3108+struct outer_cache_fns outer_cache __read_only;
3109 EXPORT_SYMBOL(outer_cache);
3110 #endif
3111
3112@@ -250,9 +252,13 @@ static int __get_cpu_architecture(void)
3113 * Register 0 and check for VMSAv7 or PMSAv7 */
3114 unsigned int mmfr0 = read_cpuid_ext(CPUID_EXT_MMFR0);
3115 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
3116- (mmfr0 & 0x000000f0) >= 0x00000030)
3117+ (mmfr0 & 0x000000f0) >= 0x00000030) {
3118 cpu_arch = CPU_ARCH_ARMv7;
3119- else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3120+ if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
3121+ __supported_pte_mask |= L_PTE_PXN;
3122+ __supported_pmd_mask |= PMD_PXNTABLE;
3123+ }
3124+ } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3125 (mmfr0 & 0x000000f0) == 0x00000020)
3126 cpu_arch = CPU_ARCH_ARMv6;
3127 else
3128diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
3129index 423663e..bfeb0ff 100644
3130--- a/arch/arm/kernel/signal.c
3131+++ b/arch/arm/kernel/signal.c
3132@@ -24,8 +24,6 @@
3133
3134 extern const unsigned long sigreturn_codes[7];
3135
3136-static unsigned long signal_return_offset;
3137-
3138 #ifdef CONFIG_CRUNCH
3139 static int preserve_crunch_context(struct crunch_sigframe __user *frame)
3140 {
3141@@ -385,8 +383,7 @@ setup_return(struct pt_regs *regs, struct ksignal *ksig,
3142 * except when the MPU has protected the vectors
3143 * page from PL0
3144 */
3145- retcode = mm->context.sigpage + signal_return_offset +
3146- (idx << 2) + thumb;
3147+ retcode = mm->context.sigpage + (idx << 2) + thumb;
3148 } else
3149 #endif
3150 {
3151@@ -592,33 +589,3 @@ do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall)
3152 } while (thread_flags & _TIF_WORK_MASK);
3153 return 0;
3154 }
3155-
3156-struct page *get_signal_page(void)
3157-{
3158- unsigned long ptr;
3159- unsigned offset;
3160- struct page *page;
3161- void *addr;
3162-
3163- page = alloc_pages(GFP_KERNEL, 0);
3164-
3165- if (!page)
3166- return NULL;
3167-
3168- addr = page_address(page);
3169-
3170- /* Give the signal return code some randomness */
3171- offset = 0x200 + (get_random_int() & 0x7fc);
3172- signal_return_offset = offset;
3173-
3174- /*
3175- * Copy signal return handlers into the vector page, and
3176- * set sigreturn to be a pointer to these.
3177- */
3178- memcpy(addr + offset, sigreturn_codes, sizeof(sigreturn_codes));
3179-
3180- ptr = (unsigned long)addr + offset;
3181- flush_icache_range(ptr, ptr + sizeof(sigreturn_codes));
3182-
3183- return page;
3184-}
3185diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
3186index cca5b87..68f0f73 100644
3187--- a/arch/arm/kernel/smp.c
3188+++ b/arch/arm/kernel/smp.c
3189@@ -76,7 +76,7 @@ enum ipi_msg_type {
3190
3191 static DECLARE_COMPLETION(cpu_running);
3192
3193-static struct smp_operations smp_ops;
3194+static struct smp_operations smp_ops __read_only;
3195
3196 void __init smp_set_ops(struct smp_operations *ops)
3197 {
3198diff --git a/arch/arm/kernel/tcm.c b/arch/arm/kernel/tcm.c
3199index 7a3be1d..b00c7de 100644
3200--- a/arch/arm/kernel/tcm.c
3201+++ b/arch/arm/kernel/tcm.c
3202@@ -61,7 +61,7 @@ static struct map_desc itcm_iomap[] __initdata = {
3203 .virtual = ITCM_OFFSET,
3204 .pfn = __phys_to_pfn(ITCM_OFFSET),
3205 .length = 0,
3206- .type = MT_MEMORY_RWX_ITCM,
3207+ .type = MT_MEMORY_RX_ITCM,
3208 }
3209 };
3210
3211@@ -267,7 +267,9 @@ no_dtcm:
3212 start = &__sitcm_text;
3213 end = &__eitcm_text;
3214 ram = &__itcm_start;
3215+ pax_open_kernel();
3216 memcpy(start, ram, itcm_code_sz);
3217+ pax_close_kernel();
3218 pr_debug("CPU ITCM: copied code from %p - %p\n",
3219 start, end);
3220 itcm_present = true;
3221diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
3222index 3dce1a3..60e857f 100644
3223--- a/arch/arm/kernel/traps.c
3224+++ b/arch/arm/kernel/traps.c
3225@@ -65,7 +65,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
3226 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
3227 {
3228 #ifdef CONFIG_KALLSYMS
3229- printk("[<%08lx>] (%ps) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
3230+ printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
3231 #else
3232 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
3233 #endif
3234@@ -267,6 +267,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
3235 static int die_owner = -1;
3236 static unsigned int die_nest_count;
3237
3238+extern void gr_handle_kernel_exploit(void);
3239+
3240 static unsigned long oops_begin(void)
3241 {
3242 int cpu;
3243@@ -309,6 +311,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3244 panic("Fatal exception in interrupt");
3245 if (panic_on_oops)
3246 panic("Fatal exception");
3247+
3248+ gr_handle_kernel_exploit();
3249+
3250 if (signr)
3251 do_exit(signr);
3252 }
3253@@ -878,7 +883,11 @@ void __init early_trap_init(void *vectors_base)
3254 kuser_init(vectors_base);
3255
3256 flush_icache_range(vectors, vectors + PAGE_SIZE * 2);
3257- modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3258+
3259+#ifndef CONFIG_PAX_MEMORY_UDEREF
3260+ modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3261+#endif
3262+
3263 #else /* ifndef CONFIG_CPU_V7M */
3264 /*
3265 * on V7-M there is no need to copy the vector table to a dedicated
3266diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3267index 8b60fde..8d986dd 100644
3268--- a/arch/arm/kernel/vmlinux.lds.S
3269+++ b/arch/arm/kernel/vmlinux.lds.S
3270@@ -37,7 +37,7 @@
3271 #endif
3272
3273 #if (defined(CONFIG_SMP_ON_UP) && !defined(CONFIG_DEBUG_SPINLOCK)) || \
3274- defined(CONFIG_GENERIC_BUG)
3275+ defined(CONFIG_GENERIC_BUG) || defined(CONFIG_PAX_REFCOUNT)
3276 #define ARM_EXIT_KEEP(x) x
3277 #define ARM_EXIT_DISCARD(x)
3278 #else
3279@@ -120,6 +120,8 @@ SECTIONS
3280 #ifdef CONFIG_DEBUG_RODATA
3281 . = ALIGN(1<<SECTION_SHIFT);
3282 #endif
3283+ _etext = .; /* End of text section */
3284+
3285 RO_DATA(PAGE_SIZE)
3286
3287 . = ALIGN(4);
3288@@ -150,8 +152,6 @@ SECTIONS
3289
3290 NOTES
3291
3292- _etext = .; /* End of text and rodata section */
3293-
3294 #ifndef CONFIG_XIP_KERNEL
3295 # ifdef CONFIG_ARM_KERNMEM_PERMS
3296 . = ALIGN(1<<SECTION_SHIFT);
3297diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
3298index d9631ec..b0c966c 100644
3299--- a/arch/arm/kvm/arm.c
3300+++ b/arch/arm/kvm/arm.c
3301@@ -57,7 +57,7 @@ static unsigned long hyp_default_vectors;
3302 static DEFINE_PER_CPU(struct kvm_vcpu *, kvm_arm_running_vcpu);
3303
3304 /* The VMID used in the VTTBR */
3305-static atomic64_t kvm_vmid_gen = ATOMIC64_INIT(1);
3306+static atomic64_unchecked_t kvm_vmid_gen = ATOMIC64_INIT(1);
3307 static u8 kvm_next_vmid;
3308 static DEFINE_SPINLOCK(kvm_vmid_lock);
3309
3310@@ -373,7 +373,7 @@ void force_vm_exit(const cpumask_t *mask)
3311 */
3312 static bool need_new_vmid_gen(struct kvm *kvm)
3313 {
3314- return unlikely(kvm->arch.vmid_gen != atomic64_read(&kvm_vmid_gen));
3315+ return unlikely(kvm->arch.vmid_gen != atomic64_read_unchecked(&kvm_vmid_gen));
3316 }
3317
3318 /**
3319@@ -406,7 +406,7 @@ static void update_vttbr(struct kvm *kvm)
3320
3321 /* First user of a new VMID generation? */
3322 if (unlikely(kvm_next_vmid == 0)) {
3323- atomic64_inc(&kvm_vmid_gen);
3324+ atomic64_inc_unchecked(&kvm_vmid_gen);
3325 kvm_next_vmid = 1;
3326
3327 /*
3328@@ -423,7 +423,7 @@ static void update_vttbr(struct kvm *kvm)
3329 kvm_call_hyp(__kvm_flush_vm_context);
3330 }
3331
3332- kvm->arch.vmid_gen = atomic64_read(&kvm_vmid_gen);
3333+ kvm->arch.vmid_gen = atomic64_read_unchecked(&kvm_vmid_gen);
3334 kvm->arch.vmid = kvm_next_vmid;
3335 kvm_next_vmid++;
3336
3337@@ -1098,7 +1098,7 @@ struct kvm_vcpu *kvm_mpidr_to_vcpu(struct kvm *kvm, unsigned long mpidr)
3338 /**
3339 * Initialize Hyp-mode and memory mappings on all CPUs.
3340 */
3341-int kvm_arch_init(void *opaque)
3342+int kvm_arch_init(const void *opaque)
3343 {
3344 int err;
3345 int ret, cpu;
3346diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3347index 1710fd7..ec3e014 100644
3348--- a/arch/arm/lib/clear_user.S
3349+++ b/arch/arm/lib/clear_user.S
3350@@ -12,14 +12,14 @@
3351
3352 .text
3353
3354-/* Prototype: int __clear_user(void *addr, size_t sz)
3355+/* Prototype: int ___clear_user(void *addr, size_t sz)
3356 * Purpose : clear some user memory
3357 * Params : addr - user memory address to clear
3358 * : sz - number of bytes to clear
3359 * Returns : number of bytes NOT cleared
3360 */
3361 ENTRY(__clear_user_std)
3362-WEAK(__clear_user)
3363+WEAK(___clear_user)
3364 stmfd sp!, {r1, lr}
3365 mov r2, #0
3366 cmp r1, #4
3367@@ -44,7 +44,7 @@ WEAK(__clear_user)
3368 USER( strnebt r2, [r0])
3369 mov r0, #0
3370 ldmfd sp!, {r1, pc}
3371-ENDPROC(__clear_user)
3372+ENDPROC(___clear_user)
3373 ENDPROC(__clear_user_std)
3374
3375 .pushsection .text.fixup,"ax"
3376diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3377index 7a235b9..73a0556 100644
3378--- a/arch/arm/lib/copy_from_user.S
3379+++ b/arch/arm/lib/copy_from_user.S
3380@@ -17,7 +17,7 @@
3381 /*
3382 * Prototype:
3383 *
3384- * size_t __copy_from_user(void *to, const void *from, size_t n)
3385+ * size_t ___copy_from_user(void *to, const void *from, size_t n)
3386 *
3387 * Purpose:
3388 *
3389@@ -89,11 +89,11 @@
3390
3391 .text
3392
3393-ENTRY(__copy_from_user)
3394+ENTRY(___copy_from_user)
3395
3396 #include "copy_template.S"
3397
3398-ENDPROC(__copy_from_user)
3399+ENDPROC(___copy_from_user)
3400
3401 .pushsection .fixup,"ax"
3402 .align 0
3403diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3404index 6ee2f67..d1cce76 100644
3405--- a/arch/arm/lib/copy_page.S
3406+++ b/arch/arm/lib/copy_page.S
3407@@ -10,6 +10,7 @@
3408 * ASM optimised string functions
3409 */
3410 #include <linux/linkage.h>
3411+#include <linux/const.h>
3412 #include <asm/assembler.h>
3413 #include <asm/asm-offsets.h>
3414 #include <asm/cache.h>
3415diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3416index 9648b06..19c333c 100644
3417--- a/arch/arm/lib/copy_to_user.S
3418+++ b/arch/arm/lib/copy_to_user.S
3419@@ -17,7 +17,7 @@
3420 /*
3421 * Prototype:
3422 *
3423- * size_t __copy_to_user(void *to, const void *from, size_t n)
3424+ * size_t ___copy_to_user(void *to, const void *from, size_t n)
3425 *
3426 * Purpose:
3427 *
3428@@ -93,11 +93,11 @@
3429 .text
3430
3431 ENTRY(__copy_to_user_std)
3432-WEAK(__copy_to_user)
3433+WEAK(___copy_to_user)
3434
3435 #include "copy_template.S"
3436
3437-ENDPROC(__copy_to_user)
3438+ENDPROC(___copy_to_user)
3439 ENDPROC(__copy_to_user_std)
3440
3441 .pushsection .text.fixup,"ax"
3442diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3443index 1d0957e..f708846 100644
3444--- a/arch/arm/lib/csumpartialcopyuser.S
3445+++ b/arch/arm/lib/csumpartialcopyuser.S
3446@@ -57,8 +57,8 @@
3447 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3448 */
3449
3450-#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3451-#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3452+#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3453+#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3454
3455 #include "csumpartialcopygeneric.S"
3456
3457diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3458index 8044591..c9b2609 100644
3459--- a/arch/arm/lib/delay.c
3460+++ b/arch/arm/lib/delay.c
3461@@ -29,7 +29,7 @@
3462 /*
3463 * Default to the loop-based delay implementation.
3464 */
3465-struct arm_delay_ops arm_delay_ops = {
3466+struct arm_delay_ops arm_delay_ops __read_only = {
3467 .delay = __loop_delay,
3468 .const_udelay = __loop_const_udelay,
3469 .udelay = __loop_udelay,
3470diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3471index 3e58d71..029817c 100644
3472--- a/arch/arm/lib/uaccess_with_memcpy.c
3473+++ b/arch/arm/lib/uaccess_with_memcpy.c
3474@@ -136,7 +136,7 @@ out:
3475 }
3476
3477 unsigned long
3478-__copy_to_user(void __user *to, const void *from, unsigned long n)
3479+___copy_to_user(void __user *to, const void *from, unsigned long n)
3480 {
3481 /*
3482 * This test is stubbed out of the main function above to keep
3483@@ -190,7 +190,7 @@ out:
3484 return n;
3485 }
3486
3487-unsigned long __clear_user(void __user *addr, unsigned long n)
3488+unsigned long ___clear_user(void __user *addr, unsigned long n)
3489 {
3490 /* See rational for this in __copy_to_user() above. */
3491 if (n < 64)
3492diff --git a/arch/arm/mach-exynos/suspend.c b/arch/arm/mach-exynos/suspend.c
3493index 7d23ce0..5ef383a 100644
3494--- a/arch/arm/mach-exynos/suspend.c
3495+++ b/arch/arm/mach-exynos/suspend.c
3496@@ -738,8 +738,10 @@ void __init exynos_pm_init(void)
3497 tmp |= pm_data->wake_disable_mask;
3498 pmu_raw_writel(tmp, S5P_WAKEUP_MASK);
3499
3500- exynos_pm_syscore_ops.suspend = pm_data->pm_suspend;
3501- exynos_pm_syscore_ops.resume = pm_data->pm_resume;
3502+ pax_open_kernel();
3503+ *(void **)&exynos_pm_syscore_ops.suspend = pm_data->pm_suspend;
3504+ *(void **)&exynos_pm_syscore_ops.resume = pm_data->pm_resume;
3505+ pax_close_kernel();
3506
3507 register_syscore_ops(&exynos_pm_syscore_ops);
3508 suspend_set_ops(&exynos_suspend_ops);
3509diff --git a/arch/arm/mach-keystone/keystone.c b/arch/arm/mach-keystone/keystone.c
3510index 0662087..004d163 100644
3511--- a/arch/arm/mach-keystone/keystone.c
3512+++ b/arch/arm/mach-keystone/keystone.c
3513@@ -27,7 +27,7 @@
3514
3515 #include "keystone.h"
3516
3517-static struct notifier_block platform_nb;
3518+static notifier_block_no_const platform_nb;
3519 static unsigned long keystone_dma_pfn_offset __read_mostly;
3520
3521 static int keystone_platform_notifier(struct notifier_block *nb,
3522diff --git a/arch/arm/mach-mvebu/coherency.c b/arch/arm/mach-mvebu/coherency.c
3523index e46e9ea..9141c83 100644
3524--- a/arch/arm/mach-mvebu/coherency.c
3525+++ b/arch/arm/mach-mvebu/coherency.c
3526@@ -117,7 +117,7 @@ static void __init armada_370_coherency_init(struct device_node *np)
3527
3528 /*
3529 * This ioremap hook is used on Armada 375/38x to ensure that PCIe
3530- * memory areas are mapped as MT_UNCACHED instead of MT_DEVICE. This
3531+ * memory areas are mapped as MT_UNCACHED_RW instead of MT_DEVICE. This
3532 * is needed as a workaround for a deadlock issue between the PCIe
3533 * interface and the cache controller.
3534 */
3535@@ -130,7 +130,7 @@ armada_pcie_wa_ioremap_caller(phys_addr_t phys_addr, size_t size,
3536 mvebu_mbus_get_pcie_mem_aperture(&pcie_mem);
3537
3538 if (pcie_mem.start <= phys_addr && (phys_addr + size) <= pcie_mem.end)
3539- mtype = MT_UNCACHED;
3540+ mtype = MT_UNCACHED_RW;
3541
3542 return __arm_ioremap_caller(phys_addr, size, mtype, caller);
3543 }
3544diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3545index b6443a4..20a0b74 100644
3546--- a/arch/arm/mach-omap2/board-n8x0.c
3547+++ b/arch/arm/mach-omap2/board-n8x0.c
3548@@ -569,7 +569,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3549 }
3550 #endif
3551
3552-struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3553+struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3554 .late_init = n8x0_menelaus_late_init,
3555 };
3556
3557diff --git a/arch/arm/mach-omap2/omap-mpuss-lowpower.c b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3558index 79f49d9..70bf184 100644
3559--- a/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3560+++ b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3561@@ -86,7 +86,7 @@ struct cpu_pm_ops {
3562 void (*resume)(void);
3563 void (*scu_prepare)(unsigned int cpu_id, unsigned int cpu_state);
3564 void (*hotplug_restart)(void);
3565-};
3566+} __no_const;
3567
3568 static DEFINE_PER_CPU(struct omap4_cpu_pm_info, omap4_pm_info);
3569 static struct powerdomain *mpuss_pd;
3570@@ -105,7 +105,7 @@ static void dummy_cpu_resume(void)
3571 static void dummy_scu_prepare(unsigned int cpu_id, unsigned int cpu_state)
3572 {}
3573
3574-struct cpu_pm_ops omap_pm_ops = {
3575+static struct cpu_pm_ops omap_pm_ops __read_only = {
3576 .finish_suspend = default_finish_suspend,
3577 .resume = dummy_cpu_resume,
3578 .scu_prepare = dummy_scu_prepare,
3579diff --git a/arch/arm/mach-omap2/omap-smp.c b/arch/arm/mach-omap2/omap-smp.c
3580index 5305ec7..6d74045 100644
3581--- a/arch/arm/mach-omap2/omap-smp.c
3582+++ b/arch/arm/mach-omap2/omap-smp.c
3583@@ -19,6 +19,7 @@
3584 #include <linux/device.h>
3585 #include <linux/smp.h>
3586 #include <linux/io.h>
3587+#include <linux/irq.h>
3588 #include <linux/irqchip/arm-gic.h>
3589
3590 #include <asm/smp_scu.h>
3591diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3592index 3b56722..33ac281 100644
3593--- a/arch/arm/mach-omap2/omap-wakeupgen.c
3594+++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3595@@ -330,7 +330,7 @@ static int irq_cpu_hotplug_notify(struct notifier_block *self,
3596 return NOTIFY_OK;
3597 }
3598
3599-static struct notifier_block __refdata irq_hotplug_notifier = {
3600+static struct notifier_block irq_hotplug_notifier = {
3601 .notifier_call = irq_cpu_hotplug_notify,
3602 };
3603
3604diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3605index 166b18f..f985f04 100644
3606--- a/arch/arm/mach-omap2/omap_device.c
3607+++ b/arch/arm/mach-omap2/omap_device.c
3608@@ -510,7 +510,7 @@ void omap_device_delete(struct omap_device *od)
3609 struct platform_device __init *omap_device_build(const char *pdev_name,
3610 int pdev_id,
3611 struct omap_hwmod *oh,
3612- void *pdata, int pdata_len)
3613+ const void *pdata, int pdata_len)
3614 {
3615 struct omap_hwmod *ohs[] = { oh };
3616
3617@@ -538,7 +538,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name,
3618 struct platform_device __init *omap_device_build_ss(const char *pdev_name,
3619 int pdev_id,
3620 struct omap_hwmod **ohs,
3621- int oh_cnt, void *pdata,
3622+ int oh_cnt, const void *pdata,
3623 int pdata_len)
3624 {
3625 int ret = -ENOMEM;
3626diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3627index 78c02b3..c94109a 100644
3628--- a/arch/arm/mach-omap2/omap_device.h
3629+++ b/arch/arm/mach-omap2/omap_device.h
3630@@ -72,12 +72,12 @@ int omap_device_idle(struct platform_device *pdev);
3631 /* Core code interface */
3632
3633 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3634- struct omap_hwmod *oh, void *pdata,
3635+ struct omap_hwmod *oh, const void *pdata,
3636 int pdata_len);
3637
3638 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3639 struct omap_hwmod **oh, int oh_cnt,
3640- void *pdata, int pdata_len);
3641+ const void *pdata, int pdata_len);
3642
3643 struct omap_device *omap_device_alloc(struct platform_device *pdev,
3644 struct omap_hwmod **ohs, int oh_cnt);
3645diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3646index 752969f..a34b446 100644
3647--- a/arch/arm/mach-omap2/omap_hwmod.c
3648+++ b/arch/arm/mach-omap2/omap_hwmod.c
3649@@ -199,10 +199,10 @@ struct omap_hwmod_soc_ops {
3650 int (*init_clkdm)(struct omap_hwmod *oh);
3651 void (*update_context_lost)(struct omap_hwmod *oh);
3652 int (*get_context_lost)(struct omap_hwmod *oh);
3653-};
3654+} __no_const;
3655
3656 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3657-static struct omap_hwmod_soc_ops soc_ops;
3658+static struct omap_hwmod_soc_ops soc_ops __read_only;
3659
3660 /* omap_hwmod_list contains all registered struct omap_hwmods */
3661 static LIST_HEAD(omap_hwmod_list);
3662diff --git a/arch/arm/mach-omap2/powerdomains43xx_data.c b/arch/arm/mach-omap2/powerdomains43xx_data.c
3663index 95fee54..cfa9cf1 100644
3664--- a/arch/arm/mach-omap2/powerdomains43xx_data.c
3665+++ b/arch/arm/mach-omap2/powerdomains43xx_data.c
3666@@ -10,6 +10,7 @@
3667
3668 #include <linux/kernel.h>
3669 #include <linux/init.h>
3670+#include <asm/pgtable.h>
3671
3672 #include "powerdomain.h"
3673
3674@@ -129,7 +130,9 @@ static int am43xx_check_vcvp(void)
3675
3676 void __init am43xx_powerdomains_init(void)
3677 {
3678- omap4_pwrdm_operations.pwrdm_has_voltdm = am43xx_check_vcvp;
3679+ pax_open_kernel();
3680+ *(void **)&omap4_pwrdm_operations.pwrdm_has_voltdm = am43xx_check_vcvp;
3681+ pax_close_kernel();
3682 pwrdm_register_platform_funcs(&omap4_pwrdm_operations);
3683 pwrdm_register_pwrdms(powerdomains_am43xx);
3684 pwrdm_complete_init();
3685diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3686index ff0a68c..b312aa0 100644
3687--- a/arch/arm/mach-omap2/wd_timer.c
3688+++ b/arch/arm/mach-omap2/wd_timer.c
3689@@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3690 struct omap_hwmod *oh;
3691 char *oh_name = "wd_timer2";
3692 char *dev_name = "omap_wdt";
3693- struct omap_wd_timer_platform_data pdata;
3694+ static struct omap_wd_timer_platform_data pdata = {
3695+ .read_reset_sources = prm_read_reset_sources
3696+ };
3697
3698 if (!cpu_class_is_omap2() || of_have_populated_dt())
3699 return 0;
3700@@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3701 return -EINVAL;
3702 }
3703
3704- pdata.read_reset_sources = prm_read_reset_sources;
3705-
3706 pdev = omap_device_build(dev_name, id, oh, &pdata,
3707 sizeof(struct omap_wd_timer_platform_data));
3708 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
3709diff --git a/arch/arm/mach-tegra/cpuidle-tegra20.c b/arch/arm/mach-tegra/cpuidle-tegra20.c
3710index 7469347..1ecc350 100644
3711--- a/arch/arm/mach-tegra/cpuidle-tegra20.c
3712+++ b/arch/arm/mach-tegra/cpuidle-tegra20.c
3713@@ -177,7 +177,7 @@ static int tegra20_idle_lp2_coupled(struct cpuidle_device *dev,
3714 bool entered_lp2 = false;
3715
3716 if (tegra_pending_sgi())
3717- ACCESS_ONCE(abort_flag) = true;
3718+ ACCESS_ONCE_RW(abort_flag) = true;
3719
3720 cpuidle_coupled_parallel_barrier(dev, &abort_barrier);
3721
3722diff --git a/arch/arm/mach-tegra/irq.c b/arch/arm/mach-tegra/irq.c
3723index 3b9098d..15b390f 100644
3724--- a/arch/arm/mach-tegra/irq.c
3725+++ b/arch/arm/mach-tegra/irq.c
3726@@ -20,6 +20,7 @@
3727 #include <linux/cpu_pm.h>
3728 #include <linux/interrupt.h>
3729 #include <linux/io.h>
3730+#include <linux/irq.h>
3731 #include <linux/irqchip/arm-gic.h>
3732 #include <linux/irq.h>
3733 #include <linux/kernel.h>
3734diff --git a/arch/arm/mach-ux500/pm.c b/arch/arm/mach-ux500/pm.c
3735index 2cb587b..6ddfebf 100644
3736--- a/arch/arm/mach-ux500/pm.c
3737+++ b/arch/arm/mach-ux500/pm.c
3738@@ -10,6 +10,7 @@
3739 */
3740
3741 #include <linux/kernel.h>
3742+#include <linux/irq.h>
3743 #include <linux/irqchip/arm-gic.h>
3744 #include <linux/delay.h>
3745 #include <linux/io.h>
3746diff --git a/arch/arm/mach-ux500/setup.h b/arch/arm/mach-ux500/setup.h
3747index 2dea8b5..6499da2 100644
3748--- a/arch/arm/mach-ux500/setup.h
3749+++ b/arch/arm/mach-ux500/setup.h
3750@@ -33,13 +33,6 @@ extern void ux500_timer_init(void);
3751 .type = MT_DEVICE, \
3752 }
3753
3754-#define __MEM_DEV_DESC(x, sz) { \
3755- .virtual = IO_ADDRESS(x), \
3756- .pfn = __phys_to_pfn(x), \
3757- .length = sz, \
3758- .type = MT_MEMORY_RWX, \
3759-}
3760-
3761 extern struct smp_operations ux500_smp_ops;
3762 extern void ux500_cpu_die(unsigned int cpu);
3763
3764diff --git a/arch/arm/mach-zynq/platsmp.c b/arch/arm/mach-zynq/platsmp.c
3765index 52d768f..5f93180 100644
3766--- a/arch/arm/mach-zynq/platsmp.c
3767+++ b/arch/arm/mach-zynq/platsmp.c
3768@@ -24,6 +24,7 @@
3769 #include <linux/io.h>
3770 #include <asm/cacheflush.h>
3771 #include <asm/smp_scu.h>
3772+#include <linux/irq.h>
3773 #include <linux/irqchip/arm-gic.h>
3774 #include "common.h"
3775
3776diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3777index b4f92b9..ffefea9 100644
3778--- a/arch/arm/mm/Kconfig
3779+++ b/arch/arm/mm/Kconfig
3780@@ -446,6 +446,7 @@ config CPU_32v5
3781
3782 config CPU_32v6
3783 bool
3784+ select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3785 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3786
3787 config CPU_32v6K
3788@@ -600,6 +601,7 @@ config CPU_CP15_MPU
3789
3790 config CPU_USE_DOMAINS
3791 bool
3792+ depends on !ARM_LPAE && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3793 help
3794 This option enables or disables the use of domain switching
3795 via the set_fs() function.
3796@@ -798,7 +800,7 @@ config NEED_KUSER_HELPERS
3797
3798 config KUSER_HELPERS
3799 bool "Enable kuser helpers in vector page" if !NEED_KUSER_HELPERS
3800- depends on MMU
3801+ depends on MMU && (!(CPU_V6 || CPU_V6K || CPU_V7) || GRKERNSEC_OLD_ARM_USERLAND)
3802 default y
3803 help
3804 Warning: disabling this option may break user programs.
3805@@ -812,7 +814,7 @@ config KUSER_HELPERS
3806 See Documentation/arm/kernel_user_helpers.txt for details.
3807
3808 However, the fixed address nature of these helpers can be used
3809- by ROP (return orientated programming) authors when creating
3810+ by ROP (Return Oriented Programming) authors when creating
3811 exploits.
3812
3813 If all of the binaries and libraries which run on your platform
3814diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3815index 9769f1e..16aaa55 100644
3816--- a/arch/arm/mm/alignment.c
3817+++ b/arch/arm/mm/alignment.c
3818@@ -216,10 +216,12 @@ union offset_union {
3819 #define __get16_unaligned_check(ins,val,addr) \
3820 do { \
3821 unsigned int err = 0, v, a = addr; \
3822+ pax_open_userland(); \
3823 __get8_unaligned_check(ins,v,a,err); \
3824 val = v << ((BE) ? 8 : 0); \
3825 __get8_unaligned_check(ins,v,a,err); \
3826 val |= v << ((BE) ? 0 : 8); \
3827+ pax_close_userland(); \
3828 if (err) \
3829 goto fault; \
3830 } while (0)
3831@@ -233,6 +235,7 @@ union offset_union {
3832 #define __get32_unaligned_check(ins,val,addr) \
3833 do { \
3834 unsigned int err = 0, v, a = addr; \
3835+ pax_open_userland(); \
3836 __get8_unaligned_check(ins,v,a,err); \
3837 val = v << ((BE) ? 24 : 0); \
3838 __get8_unaligned_check(ins,v,a,err); \
3839@@ -241,6 +244,7 @@ union offset_union {
3840 val |= v << ((BE) ? 8 : 16); \
3841 __get8_unaligned_check(ins,v,a,err); \
3842 val |= v << ((BE) ? 0 : 24); \
3843+ pax_close_userland(); \
3844 if (err) \
3845 goto fault; \
3846 } while (0)
3847@@ -254,6 +258,7 @@ union offset_union {
3848 #define __put16_unaligned_check(ins,val,addr) \
3849 do { \
3850 unsigned int err = 0, v = val, a = addr; \
3851+ pax_open_userland(); \
3852 __asm__( FIRST_BYTE_16 \
3853 ARM( "1: "ins" %1, [%2], #1\n" ) \
3854 THUMB( "1: "ins" %1, [%2]\n" ) \
3855@@ -273,6 +278,7 @@ union offset_union {
3856 " .popsection\n" \
3857 : "=r" (err), "=&r" (v), "=&r" (a) \
3858 : "0" (err), "1" (v), "2" (a)); \
3859+ pax_close_userland(); \
3860 if (err) \
3861 goto fault; \
3862 } while (0)
3863@@ -286,6 +292,7 @@ union offset_union {
3864 #define __put32_unaligned_check(ins,val,addr) \
3865 do { \
3866 unsigned int err = 0, v = val, a = addr; \
3867+ pax_open_userland(); \
3868 __asm__( FIRST_BYTE_32 \
3869 ARM( "1: "ins" %1, [%2], #1\n" ) \
3870 THUMB( "1: "ins" %1, [%2]\n" ) \
3871@@ -315,6 +322,7 @@ union offset_union {
3872 " .popsection\n" \
3873 : "=r" (err), "=&r" (v), "=&r" (a) \
3874 : "0" (err), "1" (v), "2" (a)); \
3875+ pax_close_userland(); \
3876 if (err) \
3877 goto fault; \
3878 } while (0)
3879diff --git a/arch/arm/mm/cache-l2x0.c b/arch/arm/mm/cache-l2x0.c
3880index e309c8f..f8965e8 100644
3881--- a/arch/arm/mm/cache-l2x0.c
3882+++ b/arch/arm/mm/cache-l2x0.c
3883@@ -43,7 +43,7 @@ struct l2c_init_data {
3884 void (*save)(void __iomem *);
3885 void (*configure)(void __iomem *);
3886 struct outer_cache_fns outer_cache;
3887-};
3888+} __do_const;
3889
3890 #define CACHE_LINE_SIZE 32
3891
3892diff --git a/arch/arm/mm/context.c b/arch/arm/mm/context.c
3893index 845769e..4278fd7 100644
3894--- a/arch/arm/mm/context.c
3895+++ b/arch/arm/mm/context.c
3896@@ -43,7 +43,7 @@
3897 #define NUM_USER_ASIDS ASID_FIRST_VERSION
3898
3899 static DEFINE_RAW_SPINLOCK(cpu_asid_lock);
3900-static atomic64_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3901+static atomic64_unchecked_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3902 static DECLARE_BITMAP(asid_map, NUM_USER_ASIDS);
3903
3904 static DEFINE_PER_CPU(atomic64_t, active_asids);
3905@@ -178,7 +178,7 @@ static u64 new_context(struct mm_struct *mm, unsigned int cpu)
3906 {
3907 static u32 cur_idx = 1;
3908 u64 asid = atomic64_read(&mm->context.id);
3909- u64 generation = atomic64_read(&asid_generation);
3910+ u64 generation = atomic64_read_unchecked(&asid_generation);
3911
3912 if (asid != 0) {
3913 /*
3914@@ -208,7 +208,7 @@ static u64 new_context(struct mm_struct *mm, unsigned int cpu)
3915 */
3916 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, cur_idx);
3917 if (asid == NUM_USER_ASIDS) {
3918- generation = atomic64_add_return(ASID_FIRST_VERSION,
3919+ generation = atomic64_add_return_unchecked(ASID_FIRST_VERSION,
3920 &asid_generation);
3921 flush_context(cpu);
3922 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, 1);
3923@@ -240,14 +240,14 @@ void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk)
3924 cpu_set_reserved_ttbr0();
3925
3926 asid = atomic64_read(&mm->context.id);
3927- if (!((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS)
3928+ if (!((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS)
3929 && atomic64_xchg(&per_cpu(active_asids, cpu), asid))
3930 goto switch_mm_fastpath;
3931
3932 raw_spin_lock_irqsave(&cpu_asid_lock, flags);
3933 /* Check that our ASID belongs to the current generation. */
3934 asid = atomic64_read(&mm->context.id);
3935- if ((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS) {
3936+ if ((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS) {
3937 asid = new_context(mm, cpu);
3938 atomic64_set(&mm->context.id, asid);
3939 }
3940diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
3941index 6333d9c..3bb19f2 100644
3942--- a/arch/arm/mm/fault.c
3943+++ b/arch/arm/mm/fault.c
3944@@ -25,6 +25,7 @@
3945 #include <asm/system_misc.h>
3946 #include <asm/system_info.h>
3947 #include <asm/tlbflush.h>
3948+#include <asm/sections.h>
3949
3950 #include "fault.h"
3951
3952@@ -138,6 +139,31 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
3953 if (fixup_exception(regs))
3954 return;
3955
3956+#ifdef CONFIG_PAX_MEMORY_UDEREF
3957+ if (addr < TASK_SIZE) {
3958+ if (current->signal->curr_ip)
3959+ printk(KERN_EMERG "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),
3960+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3961+ else
3962+ printk(KERN_EMERG "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3963+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3964+ }
3965+#endif
3966+
3967+#ifdef CONFIG_PAX_KERNEXEC
3968+ if ((fsr & FSR_WRITE) &&
3969+ (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
3970+ (MODULES_VADDR <= addr && addr < MODULES_END)))
3971+ {
3972+ if (current->signal->curr_ip)
3973+ printk(KERN_EMERG "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),
3974+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3975+ else
3976+ printk(KERN_EMERG "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
3977+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3978+ }
3979+#endif
3980+
3981 /*
3982 * No handler, we'll have to terminate things with extreme prejudice.
3983 */
3984@@ -173,6 +199,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
3985 }
3986 #endif
3987
3988+#ifdef CONFIG_PAX_PAGEEXEC
3989+ if (fsr & FSR_LNX_PF) {
3990+ pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
3991+ do_group_exit(SIGKILL);
3992+ }
3993+#endif
3994+
3995 tsk->thread.address = addr;
3996 tsk->thread.error_code = fsr;
3997 tsk->thread.trap_no = 14;
3998@@ -400,6 +433,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3999 }
4000 #endif /* CONFIG_MMU */
4001
4002+#ifdef CONFIG_PAX_PAGEEXEC
4003+void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4004+{
4005+ long i;
4006+
4007+ printk(KERN_ERR "PAX: bytes at PC: ");
4008+ for (i = 0; i < 20; i++) {
4009+ unsigned char c;
4010+ if (get_user(c, (__force unsigned char __user *)pc+i))
4011+ printk(KERN_CONT "?? ");
4012+ else
4013+ printk(KERN_CONT "%02x ", c);
4014+ }
4015+ printk("\n");
4016+
4017+ printk(KERN_ERR "PAX: bytes at SP-4: ");
4018+ for (i = -1; i < 20; i++) {
4019+ unsigned long c;
4020+ if (get_user(c, (__force unsigned long __user *)sp+i))
4021+ printk(KERN_CONT "???????? ");
4022+ else
4023+ printk(KERN_CONT "%08lx ", c);
4024+ }
4025+ printk("\n");
4026+}
4027+#endif
4028+
4029 /*
4030 * First Level Translation Fault Handler
4031 *
4032@@ -547,9 +607,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
4033 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
4034 struct siginfo info;
4035
4036+#ifdef CONFIG_PAX_MEMORY_UDEREF
4037+ if (addr < TASK_SIZE && is_domain_fault(fsr)) {
4038+ if (current->signal->curr_ip)
4039+ printk(KERN_EMERG "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),
4040+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
4041+ else
4042+ printk(KERN_EMERG "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
4043+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
4044+ goto die;
4045+ }
4046+#endif
4047+
4048 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
4049 return;
4050
4051+die:
4052 pr_alert("Unhandled fault: %s (0x%03x) at 0x%08lx\n",
4053 inf->name, fsr, addr);
4054 show_pte(current->mm, addr);
4055@@ -574,15 +647,104 @@ hook_ifault_code(int nr, int (*fn)(unsigned long, unsigned int, struct pt_regs *
4056 ifsr_info[nr].name = name;
4057 }
4058
4059+asmlinkage int sys_sigreturn(struct pt_regs *regs);
4060+asmlinkage int sys_rt_sigreturn(struct pt_regs *regs);
4061+
4062 asmlinkage void __exception
4063 do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
4064 {
4065 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
4066 struct siginfo info;
4067+ unsigned long pc = instruction_pointer(regs);
4068+
4069+ if (user_mode(regs)) {
4070+ unsigned long sigpage = current->mm->context.sigpage;
4071+
4072+ if (sigpage <= pc && pc < sigpage + 7*4) {
4073+ if (pc < sigpage + 3*4)
4074+ sys_sigreturn(regs);
4075+ else
4076+ sys_rt_sigreturn(regs);
4077+ return;
4078+ }
4079+ if (pc == 0xffff0f60UL) {
4080+ /*
4081+ * PaX: __kuser_cmpxchg64 emulation
4082+ */
4083+ // TODO
4084+ //regs->ARM_pc = regs->ARM_lr;
4085+ //return;
4086+ }
4087+ if (pc == 0xffff0fa0UL) {
4088+ /*
4089+ * PaX: __kuser_memory_barrier emulation
4090+ */
4091+ // dmb(); implied by the exception
4092+ regs->ARM_pc = regs->ARM_lr;
4093+ return;
4094+ }
4095+ if (pc == 0xffff0fc0UL) {
4096+ /*
4097+ * PaX: __kuser_cmpxchg emulation
4098+ */
4099+ // TODO
4100+ //long new;
4101+ //int op;
4102+
4103+ //op = FUTEX_OP_SET << 28;
4104+ //new = futex_atomic_op_inuser(op, regs->ARM_r2);
4105+ //regs->ARM_r0 = old != new;
4106+ //regs->ARM_pc = regs->ARM_lr;
4107+ //return;
4108+ }
4109+ if (pc == 0xffff0fe0UL) {
4110+ /*
4111+ * PaX: __kuser_get_tls emulation
4112+ */
4113+ regs->ARM_r0 = current_thread_info()->tp_value[0];
4114+ regs->ARM_pc = regs->ARM_lr;
4115+ return;
4116+ }
4117+ }
4118+
4119+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
4120+ else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
4121+ if (current->signal->curr_ip)
4122+ printk(KERN_EMERG "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),
4123+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
4124+ pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
4125+ else
4126+ printk(KERN_EMERG "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
4127+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
4128+ pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
4129+ goto die;
4130+ }
4131+#endif
4132+
4133+#ifdef CONFIG_PAX_REFCOUNT
4134+ if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
4135+#ifdef CONFIG_THUMB2_KERNEL
4136+ unsigned short bkpt;
4137+
4138+ if (!probe_kernel_address(pc, bkpt) && cpu_to_le16(bkpt) == 0xbef1) {
4139+#else
4140+ unsigned int bkpt;
4141+
4142+ if (!probe_kernel_address(pc, bkpt) && cpu_to_le32(bkpt) == 0xe12f1073) {
4143+#endif
4144+ current->thread.error_code = ifsr;
4145+ current->thread.trap_no = 0;
4146+ pax_report_refcount_overflow(regs);
4147+ fixup_exception(regs);
4148+ return;
4149+ }
4150+ }
4151+#endif
4152
4153 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
4154 return;
4155
4156+die:
4157 pr_alert("Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
4158 inf->name, ifsr, addr);
4159
4160diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
4161index cf08bdf..772656c 100644
4162--- a/arch/arm/mm/fault.h
4163+++ b/arch/arm/mm/fault.h
4164@@ -3,6 +3,7 @@
4165
4166 /*
4167 * Fault status register encodings. We steal bit 31 for our own purposes.
4168+ * Set when the FSR value is from an instruction fault.
4169 */
4170 #define FSR_LNX_PF (1 << 31)
4171 #define FSR_WRITE (1 << 11)
4172@@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
4173 }
4174 #endif
4175
4176+/* valid for LPAE and !LPAE */
4177+static inline int is_xn_fault(unsigned int fsr)
4178+{
4179+ return ((fsr_fs(fsr) & 0x3c) == 0xc);
4180+}
4181+
4182+static inline int is_domain_fault(unsigned int fsr)
4183+{
4184+ return ((fsr_fs(fsr) & 0xD) == 0x9);
4185+}
4186+
4187 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
4188 unsigned long search_exception_table(unsigned long addr);
4189
4190diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
4191index be92fa0..5252d7e 100644
4192--- a/arch/arm/mm/init.c
4193+++ b/arch/arm/mm/init.c
4194@@ -709,7 +709,46 @@ void free_tcmmem(void)
4195 {
4196 #ifdef CONFIG_HAVE_TCM
4197 extern char __tcm_start, __tcm_end;
4198+#endif
4199
4200+#ifdef CONFIG_PAX_KERNEXEC
4201+ unsigned long addr;
4202+ pgd_t *pgd;
4203+ pud_t *pud;
4204+ pmd_t *pmd;
4205+ int cpu_arch = cpu_architecture();
4206+ unsigned int cr = get_cr();
4207+
4208+ if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
4209+ /* make pages tables, etc before .text NX */
4210+ for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
4211+ pgd = pgd_offset_k(addr);
4212+ pud = pud_offset(pgd, addr);
4213+ pmd = pmd_offset(pud, addr);
4214+ __section_update(pmd, addr, PMD_SECT_XN);
4215+ }
4216+ /* make init NX */
4217+ for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
4218+ pgd = pgd_offset_k(addr);
4219+ pud = pud_offset(pgd, addr);
4220+ pmd = pmd_offset(pud, addr);
4221+ __section_update(pmd, addr, PMD_SECT_XN);
4222+ }
4223+ /* make kernel code/rodata RX */
4224+ for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
4225+ pgd = pgd_offset_k(addr);
4226+ pud = pud_offset(pgd, addr);
4227+ pmd = pmd_offset(pud, addr);
4228+#ifdef CONFIG_ARM_LPAE
4229+ __section_update(pmd, addr, PMD_SECT_RDONLY);
4230+#else
4231+ __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
4232+#endif
4233+ }
4234+ }
4235+#endif
4236+
4237+#ifdef CONFIG_HAVE_TCM
4238 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
4239 free_reserved_area(&__tcm_start, &__tcm_end, -1, "TCM link");
4240 #endif
4241diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
4242index d1e5ad7..84dcbf2 100644
4243--- a/arch/arm/mm/ioremap.c
4244+++ b/arch/arm/mm/ioremap.c
4245@@ -392,9 +392,9 @@ __arm_ioremap_exec(phys_addr_t phys_addr, size_t size, bool cached)
4246 unsigned int mtype;
4247
4248 if (cached)
4249- mtype = MT_MEMORY_RWX;
4250+ mtype = MT_MEMORY_RX;
4251 else
4252- mtype = MT_MEMORY_RWX_NONCACHED;
4253+ mtype = MT_MEMORY_RX_NONCACHED;
4254
4255 return __arm_ioremap_caller(phys_addr, size, mtype,
4256 __builtin_return_address(0));
4257diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
4258index 407dc78..047ce9d 100644
4259--- a/arch/arm/mm/mmap.c
4260+++ b/arch/arm/mm/mmap.c
4261@@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4262 struct vm_area_struct *vma;
4263 int do_align = 0;
4264 int aliasing = cache_is_vipt_aliasing();
4265+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4266 struct vm_unmapped_area_info info;
4267
4268 /*
4269@@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4270 if (len > TASK_SIZE)
4271 return -ENOMEM;
4272
4273+#ifdef CONFIG_PAX_RANDMMAP
4274+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4275+#endif
4276+
4277 if (addr) {
4278 if (do_align)
4279 addr = COLOUR_ALIGN(addr, pgoff);
4280@@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4281 addr = PAGE_ALIGN(addr);
4282
4283 vma = find_vma(mm, addr);
4284- if (TASK_SIZE - len >= addr &&
4285- (!vma || addr + len <= vma->vm_start))
4286+ if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4287 return addr;
4288 }
4289
4290@@ -99,6 +103,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4291 info.high_limit = TASK_SIZE;
4292 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4293 info.align_offset = pgoff << PAGE_SHIFT;
4294+ info.threadstack_offset = offset;
4295 return vm_unmapped_area(&info);
4296 }
4297
4298@@ -112,6 +117,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4299 unsigned long addr = addr0;
4300 int do_align = 0;
4301 int aliasing = cache_is_vipt_aliasing();
4302+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4303 struct vm_unmapped_area_info info;
4304
4305 /*
4306@@ -132,6 +138,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4307 return addr;
4308 }
4309
4310+#ifdef CONFIG_PAX_RANDMMAP
4311+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4312+#endif
4313+
4314 /* requesting a specific address */
4315 if (addr) {
4316 if (do_align)
4317@@ -139,8 +149,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4318 else
4319 addr = PAGE_ALIGN(addr);
4320 vma = find_vma(mm, addr);
4321- if (TASK_SIZE - len >= addr &&
4322- (!vma || addr + len <= vma->vm_start))
4323+ if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4324 return addr;
4325 }
4326
4327@@ -150,6 +159,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4328 info.high_limit = mm->mmap_base;
4329 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4330 info.align_offset = pgoff << PAGE_SHIFT;
4331+ info.threadstack_offset = offset;
4332 addr = vm_unmapped_area(&info);
4333
4334 /*
4335@@ -183,14 +193,30 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4336 {
4337 unsigned long random_factor = 0UL;
4338
4339+#ifdef CONFIG_PAX_RANDMMAP
4340+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4341+#endif
4342+
4343 if (current->flags & PF_RANDOMIZE)
4344 random_factor = arch_mmap_rnd();
4345
4346 if (mmap_is_legacy()) {
4347 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
4348+
4349+#ifdef CONFIG_PAX_RANDMMAP
4350+ if (mm->pax_flags & MF_PAX_RANDMMAP)
4351+ mm->mmap_base += mm->delta_mmap;
4352+#endif
4353+
4354 mm->get_unmapped_area = arch_get_unmapped_area;
4355 } else {
4356 mm->mmap_base = mmap_base(random_factor);
4357+
4358+#ifdef CONFIG_PAX_RANDMMAP
4359+ if (mm->pax_flags & MF_PAX_RANDMMAP)
4360+ mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
4361+#endif
4362+
4363 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
4364 }
4365 }
4366diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
4367index 7186382..0c145cf 100644
4368--- a/arch/arm/mm/mmu.c
4369+++ b/arch/arm/mm/mmu.c
4370@@ -41,6 +41,22 @@
4371 #include "mm.h"
4372 #include "tcm.h"
4373
4374+#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
4375+void modify_domain(unsigned int dom, unsigned int type)
4376+{
4377+ struct thread_info *thread = current_thread_info();
4378+ unsigned int domain = thread->cpu_domain;
4379+ /*
4380+ * DOMAIN_MANAGER might be defined to some other value,
4381+ * use the arch-defined constant
4382+ */
4383+ domain &= ~domain_val(dom, 3);
4384+ thread->cpu_domain = domain | domain_val(dom, type);
4385+ set_domain(thread->cpu_domain);
4386+}
4387+EXPORT_SYMBOL(modify_domain);
4388+#endif
4389+
4390 /*
4391 * empty_zero_page is a special page that is used for
4392 * zero-initialized data and COW.
4393@@ -242,7 +258,15 @@ __setup("noalign", noalign_setup);
4394 #define PROT_PTE_S2_DEVICE PROT_PTE_DEVICE
4395 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
4396
4397-static struct mem_type mem_types[] = {
4398+#ifdef CONFIG_PAX_KERNEXEC
4399+#define L_PTE_KERNEXEC L_PTE_RDONLY
4400+#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
4401+#else
4402+#define L_PTE_KERNEXEC L_PTE_DIRTY
4403+#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
4404+#endif
4405+
4406+static struct mem_type mem_types[] __read_only = {
4407 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
4408 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
4409 L_PTE_SHARED,
4410@@ -271,19 +295,19 @@ static struct mem_type mem_types[] = {
4411 .prot_sect = PROT_SECT_DEVICE,
4412 .domain = DOMAIN_IO,
4413 },
4414- [MT_UNCACHED] = {
4415+ [MT_UNCACHED_RW] = {
4416 .prot_pte = PROT_PTE_DEVICE,
4417 .prot_l1 = PMD_TYPE_TABLE,
4418 .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4419 .domain = DOMAIN_IO,
4420 },
4421- [MT_CACHECLEAN] = {
4422- .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4423+ [MT_CACHECLEAN_RO] = {
4424+ .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_RDONLY,
4425 .domain = DOMAIN_KERNEL,
4426 },
4427 #ifndef CONFIG_ARM_LPAE
4428- [MT_MINICLEAN] = {
4429- .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
4430+ [MT_MINICLEAN_RO] = {
4431+ .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_XN | PMD_SECT_RDONLY,
4432 .domain = DOMAIN_KERNEL,
4433 },
4434 #endif
4435@@ -291,15 +315,15 @@ static struct mem_type mem_types[] = {
4436 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4437 L_PTE_RDONLY,
4438 .prot_l1 = PMD_TYPE_TABLE,
4439- .domain = DOMAIN_USER,
4440+ .domain = DOMAIN_VECTORS,
4441 },
4442 [MT_HIGH_VECTORS] = {
4443 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4444 L_PTE_USER | L_PTE_RDONLY,
4445 .prot_l1 = PMD_TYPE_TABLE,
4446- .domain = DOMAIN_USER,
4447+ .domain = DOMAIN_VECTORS,
4448 },
4449- [MT_MEMORY_RWX] = {
4450+ [__MT_MEMORY_RWX] = {
4451 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4452 .prot_l1 = PMD_TYPE_TABLE,
4453 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4454@@ -312,17 +336,30 @@ static struct mem_type mem_types[] = {
4455 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4456 .domain = DOMAIN_KERNEL,
4457 },
4458- [MT_ROM] = {
4459- .prot_sect = PMD_TYPE_SECT,
4460+ [MT_MEMORY_RX] = {
4461+ .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4462+ .prot_l1 = PMD_TYPE_TABLE,
4463+ .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4464+ .domain = DOMAIN_KERNEL,
4465+ },
4466+ [MT_ROM_RX] = {
4467+ .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4468 .domain = DOMAIN_KERNEL,
4469 },
4470- [MT_MEMORY_RWX_NONCACHED] = {
4471+ [MT_MEMORY_RW_NONCACHED] = {
4472 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4473 L_PTE_MT_BUFFERABLE,
4474 .prot_l1 = PMD_TYPE_TABLE,
4475 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4476 .domain = DOMAIN_KERNEL,
4477 },
4478+ [MT_MEMORY_RX_NONCACHED] = {
4479+ .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4480+ L_PTE_MT_BUFFERABLE,
4481+ .prot_l1 = PMD_TYPE_TABLE,
4482+ .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4483+ .domain = DOMAIN_KERNEL,
4484+ },
4485 [MT_MEMORY_RW_DTCM] = {
4486 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4487 L_PTE_XN,
4488@@ -330,9 +367,10 @@ static struct mem_type mem_types[] = {
4489 .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4490 .domain = DOMAIN_KERNEL,
4491 },
4492- [MT_MEMORY_RWX_ITCM] = {
4493- .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4494+ [MT_MEMORY_RX_ITCM] = {
4495+ .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4496 .prot_l1 = PMD_TYPE_TABLE,
4497+ .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4498 .domain = DOMAIN_KERNEL,
4499 },
4500 [MT_MEMORY_RW_SO] = {
4501@@ -544,9 +582,14 @@ static void __init build_mem_type_table(void)
4502 * Mark cache clean areas and XIP ROM read only
4503 * from SVC mode and no access from userspace.
4504 */
4505- mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4506- mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4507- mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4508+ mem_types[MT_ROM_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4509+#ifdef CONFIG_PAX_KERNEXEC
4510+ mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4511+ mem_types[MT_MEMORY_RX_NONCACHED].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4512+ mem_types[MT_MEMORY_RX_ITCM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4513+#endif
4514+ mem_types[MT_MINICLEAN_RO].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4515+ mem_types[MT_CACHECLEAN_RO].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4516 #endif
4517
4518 /*
4519@@ -563,13 +606,17 @@ static void __init build_mem_type_table(void)
4520 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4521 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4522 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4523- mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4524- mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4525+ mem_types[__MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4526+ mem_types[__MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4527 mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4528 mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4529+ mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4530+ mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4531 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4532- mem_types[MT_MEMORY_RWX_NONCACHED].prot_sect |= PMD_SECT_S;
4533- mem_types[MT_MEMORY_RWX_NONCACHED].prot_pte |= L_PTE_SHARED;
4534+ mem_types[MT_MEMORY_RW_NONCACHED].prot_sect |= PMD_SECT_S;
4535+ mem_types[MT_MEMORY_RW_NONCACHED].prot_pte |= L_PTE_SHARED;
4536+ mem_types[MT_MEMORY_RX_NONCACHED].prot_sect |= PMD_SECT_S;
4537+ mem_types[MT_MEMORY_RX_NONCACHED].prot_pte |= L_PTE_SHARED;
4538 }
4539 }
4540
4541@@ -580,15 +627,20 @@ static void __init build_mem_type_table(void)
4542 if (cpu_arch >= CPU_ARCH_ARMv6) {
4543 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4544 /* Non-cacheable Normal is XCB = 001 */
4545- mem_types[MT_MEMORY_RWX_NONCACHED].prot_sect |=
4546+ mem_types[MT_MEMORY_RW_NONCACHED].prot_sect |=
4547+ PMD_SECT_BUFFERED;
4548+ mem_types[MT_MEMORY_RX_NONCACHED].prot_sect |=
4549 PMD_SECT_BUFFERED;
4550 } else {
4551 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4552- mem_types[MT_MEMORY_RWX_NONCACHED].prot_sect |=
4553+ mem_types[MT_MEMORY_RW_NONCACHED].prot_sect |=
4554+ PMD_SECT_TEX(1);
4555+ mem_types[MT_MEMORY_RX_NONCACHED].prot_sect |=
4556 PMD_SECT_TEX(1);
4557 }
4558 } else {
4559- mem_types[MT_MEMORY_RWX_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4560+ mem_types[MT_MEMORY_RW_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4561+ mem_types[MT_MEMORY_RX_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4562 }
4563
4564 #ifdef CONFIG_ARM_LPAE
4565@@ -609,6 +661,8 @@ static void __init build_mem_type_table(void)
4566 user_pgprot |= PTE_EXT_PXN;
4567 #endif
4568
4569+ user_pgprot |= __supported_pte_mask;
4570+
4571 for (i = 0; i < 16; i++) {
4572 pteval_t v = pgprot_val(protection_map[i]);
4573 protection_map[i] = __pgprot(v | user_pgprot);
4574@@ -626,21 +680,24 @@ static void __init build_mem_type_table(void)
4575
4576 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4577 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4578- mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4579- mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4580+ mem_types[__MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4581+ mem_types[__MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4582 mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4583 mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4584+ mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4585+ mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4586 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4587- mem_types[MT_MEMORY_RWX_NONCACHED].prot_sect |= ecc_mask;
4588- mem_types[MT_ROM].prot_sect |= cp->pmd;
4589+ mem_types[MT_MEMORY_RW_NONCACHED].prot_sect |= ecc_mask;
4590+ mem_types[MT_MEMORY_RX_NONCACHED].prot_sect |= ecc_mask;
4591+ mem_types[MT_ROM_RX].prot_sect |= cp->pmd;
4592
4593 switch (cp->pmd) {
4594 case PMD_SECT_WT:
4595- mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_WT;
4596+ mem_types[MT_CACHECLEAN_RO].prot_sect |= PMD_SECT_WT;
4597 break;
4598 case PMD_SECT_WB:
4599 case PMD_SECT_WBWA:
4600- mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_WB;
4601+ mem_types[MT_CACHECLEAN_RO].prot_sect |= PMD_SECT_WB;
4602 break;
4603 }
4604 pr_info("Memory policy: %sData cache %s\n",
4605@@ -854,7 +911,7 @@ static void __init create_mapping(struct map_desc *md)
4606 return;
4607 }
4608
4609- if ((md->type == MT_DEVICE || md->type == MT_ROM) &&
4610+ if ((md->type == MT_DEVICE || md->type == MT_ROM_RX) &&
4611 md->virtual >= PAGE_OFFSET &&
4612 (md->virtual < VMALLOC_START || md->virtual >= VMALLOC_END)) {
4613 pr_warn("BUG: mapping for 0x%08llx at 0x%08lx out of vmalloc space\n",
4614@@ -1218,18 +1275,15 @@ void __init arm_mm_memblock_reserve(void)
4615 * called function. This means you can't use any function or debugging
4616 * method which may touch any device, otherwise the kernel _will_ crash.
4617 */
4618+
4619+static char vectors[PAGE_SIZE * 2] __read_only __aligned(PAGE_SIZE);
4620+
4621 static void __init devicemaps_init(const struct machine_desc *mdesc)
4622 {
4623 struct map_desc map;
4624 unsigned long addr;
4625- void *vectors;
4626
4627- /*
4628- * Allocate the vector page early.
4629- */
4630- vectors = early_alloc(PAGE_SIZE * 2);
4631-
4632- early_trap_init(vectors);
4633+ early_trap_init(&vectors);
4634
4635 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4636 pmd_clear(pmd_off_k(addr));
4637@@ -1242,7 +1296,7 @@ static void __init devicemaps_init(const struct machine_desc *mdesc)
4638 map.pfn = __phys_to_pfn(CONFIG_XIP_PHYS_ADDR & SECTION_MASK);
4639 map.virtual = MODULES_VADDR;
4640 map.length = ((unsigned long)_etext - map.virtual + ~SECTION_MASK) & SECTION_MASK;
4641- map.type = MT_ROM;
4642+ map.type = MT_ROM_RX;
4643 create_mapping(&map);
4644 #endif
4645
4646@@ -1253,14 +1307,14 @@ static void __init devicemaps_init(const struct machine_desc *mdesc)
4647 map.pfn = __phys_to_pfn(FLUSH_BASE_PHYS);
4648 map.virtual = FLUSH_BASE;
4649 map.length = SZ_1M;
4650- map.type = MT_CACHECLEAN;
4651+ map.type = MT_CACHECLEAN_RO;
4652 create_mapping(&map);
4653 #endif
4654 #ifdef FLUSH_BASE_MINICACHE
4655 map.pfn = __phys_to_pfn(FLUSH_BASE_PHYS + SZ_1M);
4656 map.virtual = FLUSH_BASE_MINICACHE;
4657 map.length = SZ_1M;
4658- map.type = MT_MINICLEAN;
4659+ map.type = MT_MINICLEAN_RO;
4660 create_mapping(&map);
4661 #endif
4662
4663@@ -1269,7 +1323,7 @@ static void __init devicemaps_init(const struct machine_desc *mdesc)
4664 * location (0xffff0000). If we aren't using high-vectors, also
4665 * create a mapping at the low-vectors virtual address.
4666 */
4667- map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4668+ map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4669 map.virtual = 0xffff0000;
4670 map.length = PAGE_SIZE;
4671 #ifdef CONFIG_KUSER_HELPERS
4672@@ -1329,8 +1383,10 @@ static void __init kmap_init(void)
4673 static void __init map_lowmem(void)
4674 {
4675 struct memblock_region *reg;
4676+#ifndef CONFIG_PAX_KERNEXEC
4677 phys_addr_t kernel_x_start = round_down(__pa(_stext), SECTION_SIZE);
4678 phys_addr_t kernel_x_end = round_up(__pa(__init_end), SECTION_SIZE);
4679+#endif
4680
4681 /* Map all the lowmem memory banks. */
4682 for_each_memblock(memory, reg) {
4683@@ -1343,11 +1399,48 @@ static void __init map_lowmem(void)
4684 if (start >= end)
4685 break;
4686
4687+#ifdef CONFIG_PAX_KERNEXEC
4688+ map.pfn = __phys_to_pfn(start);
4689+ map.virtual = __phys_to_virt(start);
4690+ map.length = end - start;
4691+
4692+ if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4693+ struct map_desc kernel;
4694+ struct map_desc initmap;
4695+
4696+ /* when freeing initmem we will make this RW */
4697+ initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4698+ initmap.virtual = (unsigned long)__init_begin;
4699+ initmap.length = _sdata - __init_begin;
4700+ initmap.type = __MT_MEMORY_RWX;
4701+ create_mapping(&initmap);
4702+
4703+ /* when freeing initmem we will make this RX */
4704+ kernel.pfn = __phys_to_pfn(__pa(_stext));
4705+ kernel.virtual = (unsigned long)_stext;
4706+ kernel.length = __init_begin - _stext;
4707+ kernel.type = __MT_MEMORY_RWX;
4708+ create_mapping(&kernel);
4709+
4710+ if (map.virtual < (unsigned long)_stext) {
4711+ map.length = (unsigned long)_stext - map.virtual;
4712+ map.type = __MT_MEMORY_RWX;
4713+ create_mapping(&map);
4714+ }
4715+
4716+ map.pfn = __phys_to_pfn(__pa(_sdata));
4717+ map.virtual = (unsigned long)_sdata;
4718+ map.length = end - __pa(_sdata);
4719+ }
4720+
4721+ map.type = MT_MEMORY_RW;
4722+ create_mapping(&map);
4723+#else
4724 if (end < kernel_x_start) {
4725 map.pfn = __phys_to_pfn(start);
4726 map.virtual = __phys_to_virt(start);
4727 map.length = end - start;
4728- map.type = MT_MEMORY_RWX;
4729+ map.type = __MT_MEMORY_RWX;
4730
4731 create_mapping(&map);
4732 } else if (start >= kernel_x_end) {
4733@@ -1371,7 +1464,7 @@ static void __init map_lowmem(void)
4734 map.pfn = __phys_to_pfn(kernel_x_start);
4735 map.virtual = __phys_to_virt(kernel_x_start);
4736 map.length = kernel_x_end - kernel_x_start;
4737- map.type = MT_MEMORY_RWX;
4738+ map.type = __MT_MEMORY_RWX;
4739
4740 create_mapping(&map);
4741
4742@@ -1384,6 +1477,7 @@ static void __init map_lowmem(void)
4743 create_mapping(&map);
4744 }
4745 }
4746+#endif
4747 }
4748 }
4749
4750diff --git a/arch/arm/net/bpf_jit_32.c b/arch/arm/net/bpf_jit_32.c
4751index e0e2358..a4ee460 100644
4752--- a/arch/arm/net/bpf_jit_32.c
4753+++ b/arch/arm/net/bpf_jit_32.c
4754@@ -20,6 +20,7 @@
4755 #include <asm/cacheflush.h>
4756 #include <asm/hwcap.h>
4757 #include <asm/opcodes.h>
4758+#include <asm/pgtable.h>
4759
4760 #include "bpf_jit_32.h"
4761
4762@@ -72,34 +73,58 @@ struct jit_ctx {
4763 #endif
4764 };
4765
4766+#ifdef CONFIG_GRKERNSEC_BPF_HARDEN
4767+int bpf_jit_enable __read_only;
4768+#else
4769 int bpf_jit_enable __read_mostly;
4770+#endif
4771
4772-static u64 jit_get_skb_b(struct sk_buff *skb, unsigned offset)
4773+static inline int call_neg_helper(struct sk_buff *skb, int offset, void *ret,
4774+ unsigned int size)
4775+{
4776+ void *ptr = bpf_internal_load_pointer_neg_helper(skb, offset, size);
4777+
4778+ if (!ptr)
4779+ return -EFAULT;
4780+ memcpy(ret, ptr, size);
4781+ return 0;
4782+}
4783+
4784+static u64 jit_get_skb_b(struct sk_buff *skb, int offset)
4785 {
4786 u8 ret;
4787 int err;
4788
4789- err = skb_copy_bits(skb, offset, &ret, 1);
4790+ if (offset < 0)
4791+ err = call_neg_helper(skb, offset, &ret, 1);
4792+ else
4793+ err = skb_copy_bits(skb, offset, &ret, 1);
4794
4795 return (u64)err << 32 | ret;
4796 }
4797
4798-static u64 jit_get_skb_h(struct sk_buff *skb, unsigned offset)
4799+static u64 jit_get_skb_h(struct sk_buff *skb, int offset)
4800 {
4801 u16 ret;
4802 int err;
4803
4804- err = skb_copy_bits(skb, offset, &ret, 2);
4805+ if (offset < 0)
4806+ err = call_neg_helper(skb, offset, &ret, 2);
4807+ else
4808+ err = skb_copy_bits(skb, offset, &ret, 2);
4809
4810 return (u64)err << 32 | ntohs(ret);
4811 }
4812
4813-static u64 jit_get_skb_w(struct sk_buff *skb, unsigned offset)
4814+static u64 jit_get_skb_w(struct sk_buff *skb, int offset)
4815 {
4816 u32 ret;
4817 int err;
4818
4819- err = skb_copy_bits(skb, offset, &ret, 4);
4820+ if (offset < 0)
4821+ err = call_neg_helper(skb, offset, &ret, 4);
4822+ else
4823+ err = skb_copy_bits(skb, offset, &ret, 4);
4824
4825 return (u64)err << 32 | ntohl(ret);
4826 }
4827@@ -179,8 +204,10 @@ static void jit_fill_hole(void *area, unsigned int size)
4828 {
4829 u32 *ptr;
4830 /* We are guaranteed to have aligned memory. */
4831+ pax_open_kernel();
4832 for (ptr = area; size >= sizeof(u32); size -= sizeof(u32))
4833 *ptr++ = __opcode_to_mem_arm(ARM_INST_UDF);
4834+ pax_close_kernel();
4835 }
4836
4837 static void build_prologue(struct jit_ctx *ctx)
4838@@ -536,9 +563,6 @@ static int build_body(struct jit_ctx *ctx)
4839 case BPF_LD | BPF_B | BPF_ABS:
4840 load_order = 0;
4841 load:
4842- /* the interpreter will deal with the negative K */
4843- if ((int)k < 0)
4844- return -ENOTSUPP;
4845 emit_mov_i(r_off, k, ctx);
4846 load_common:
4847 ctx->seen |= SEEN_DATA | SEEN_CALL;
4848@@ -547,12 +571,24 @@ load_common:
4849 emit(ARM_SUB_I(r_scratch, r_skb_hl,
4850 1 << load_order), ctx);
4851 emit(ARM_CMP_R(r_scratch, r_off), ctx);
4852- condt = ARM_COND_HS;
4853+ condt = ARM_COND_GE;
4854 } else {
4855 emit(ARM_CMP_R(r_skb_hl, r_off), ctx);
4856 condt = ARM_COND_HI;
4857 }
4858
4859+ /*
4860+ * test for negative offset, only if we are
4861+ * currently scheduled to take the fast
4862+ * path. this will update the flags so that
4863+ * the slowpath instruction are ignored if the
4864+ * offset is negative.
4865+ *
4866+ * for loard_order == 0 the HI condition will
4867+ * make loads at offset 0 take the slow path too.
4868+ */
4869+ _emit(condt, ARM_CMP_I(r_off, 0), ctx);
4870+
4871 _emit(condt, ARM_ADD_R(r_scratch, r_off, r_skb_data),
4872 ctx);
4873
4874@@ -860,9 +896,11 @@ b_epilogue:
4875 off = offsetof(struct sk_buff, vlan_tci);
4876 emit(ARM_LDRH_I(r_A, r_skb, off), ctx);
4877 if (code == (BPF_ANC | SKF_AD_VLAN_TAG))
4878- OP_IMM3(ARM_AND, r_A, r_A, VLAN_VID_MASK, ctx);
4879- else
4880- OP_IMM3(ARM_AND, r_A, r_A, VLAN_TAG_PRESENT, ctx);
4881+ OP_IMM3(ARM_AND, r_A, r_A, ~VLAN_TAG_PRESENT, ctx);
4882+ else {
4883+ OP_IMM3(ARM_LSR, r_A, r_A, 12, ctx);
4884+ OP_IMM3(ARM_AND, r_A, r_A, 0x1, ctx);
4885+ }
4886 break;
4887 case BPF_ANC | SKF_AD_QUEUE:
4888 ctx->seen |= SEEN_SKB;
4889diff --git a/arch/arm/plat-iop/setup.c b/arch/arm/plat-iop/setup.c
4890index 5b217f4..c23f40e 100644
4891--- a/arch/arm/plat-iop/setup.c
4892+++ b/arch/arm/plat-iop/setup.c
4893@@ -24,7 +24,7 @@ static struct map_desc iop3xx_std_desc[] __initdata = {
4894 .virtual = IOP3XX_PERIPHERAL_VIRT_BASE,
4895 .pfn = __phys_to_pfn(IOP3XX_PERIPHERAL_PHYS_BASE),
4896 .length = IOP3XX_PERIPHERAL_SIZE,
4897- .type = MT_UNCACHED,
4898+ .type = MT_UNCACHED_RW,
4899 },
4900 };
4901
4902diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4903index a5bc92d..0bb4730 100644
4904--- a/arch/arm/plat-omap/sram.c
4905+++ b/arch/arm/plat-omap/sram.c
4906@@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4907 * Looks like we need to preserve some bootloader code at the
4908 * beginning of SRAM for jumping to flash for reboot to work...
4909 */
4910+ pax_open_kernel();
4911 memset_io(omap_sram_base + omap_sram_skip, 0,
4912 omap_sram_size - omap_sram_skip);
4913+ pax_close_kernel();
4914 }
4915diff --git a/arch/arm64/include/asm/atomic.h b/arch/arm64/include/asm/atomic.h
4916index 7047051..44e8675 100644
4917--- a/arch/arm64/include/asm/atomic.h
4918+++ b/arch/arm64/include/asm/atomic.h
4919@@ -252,5 +252,15 @@ static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
4920 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
4921 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
4922
4923+#define atomic64_read_unchecked(v) atomic64_read(v)
4924+#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4925+#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4926+#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4927+#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4928+#define atomic64_inc_unchecked(v) atomic64_inc(v)
4929+#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4930+#define atomic64_dec_unchecked(v) atomic64_dec(v)
4931+#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4932+
4933 #endif
4934 #endif
4935diff --git a/arch/arm64/include/asm/barrier.h b/arch/arm64/include/asm/barrier.h
4936index 71f19c4..2b13cfe 100644
4937--- a/arch/arm64/include/asm/barrier.h
4938+++ b/arch/arm64/include/asm/barrier.h
4939@@ -44,7 +44,7 @@
4940 do { \
4941 compiletime_assert_atomic_type(*p); \
4942 barrier(); \
4943- ACCESS_ONCE(*p) = (v); \
4944+ ACCESS_ONCE_RW(*p) = (v); \
4945 } while (0)
4946
4947 #define smp_load_acquire(p) \
4948diff --git a/arch/arm64/include/asm/percpu.h b/arch/arm64/include/asm/percpu.h
4949index 4fde8c1..441f84f 100644
4950--- a/arch/arm64/include/asm/percpu.h
4951+++ b/arch/arm64/include/asm/percpu.h
4952@@ -135,16 +135,16 @@ static inline void __percpu_write(void *ptr, unsigned long val, int size)
4953 {
4954 switch (size) {
4955 case 1:
4956- ACCESS_ONCE(*(u8 *)ptr) = (u8)val;
4957+ ACCESS_ONCE_RW(*(u8 *)ptr) = (u8)val;
4958 break;
4959 case 2:
4960- ACCESS_ONCE(*(u16 *)ptr) = (u16)val;
4961+ ACCESS_ONCE_RW(*(u16 *)ptr) = (u16)val;
4962 break;
4963 case 4:
4964- ACCESS_ONCE(*(u32 *)ptr) = (u32)val;
4965+ ACCESS_ONCE_RW(*(u32 *)ptr) = (u32)val;
4966 break;
4967 case 8:
4968- ACCESS_ONCE(*(u64 *)ptr) = (u64)val;
4969+ ACCESS_ONCE_RW(*(u64 *)ptr) = (u64)val;
4970 break;
4971 default:
4972 BUILD_BUG();
4973diff --git a/arch/arm64/include/asm/pgalloc.h b/arch/arm64/include/asm/pgalloc.h
4974index 7642056..bffc904 100644
4975--- a/arch/arm64/include/asm/pgalloc.h
4976+++ b/arch/arm64/include/asm/pgalloc.h
4977@@ -46,6 +46,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
4978 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
4979 }
4980
4981+static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
4982+{
4983+ pud_populate(mm, pud, pmd);
4984+}
4985+
4986 #endif /* CONFIG_PGTABLE_LEVELS > 2 */
4987
4988 #if CONFIG_PGTABLE_LEVELS > 3
4989diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h
4990index 07e1ba44..ec8cbbb 100644
4991--- a/arch/arm64/include/asm/uaccess.h
4992+++ b/arch/arm64/include/asm/uaccess.h
4993@@ -99,6 +99,7 @@ static inline void set_fs(mm_segment_t fs)
4994 flag; \
4995 })
4996
4997+#define access_ok_noprefault(type, addr, size) access_ok((type), (addr), (size))
4998 #define access_ok(type, addr, size) __range_ok(addr, size)
4999 #define user_addr_max get_fs
5000
5001diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
5002index b0bd4e5..54e82f6 100644
5003--- a/arch/arm64/mm/dma-mapping.c
5004+++ b/arch/arm64/mm/dma-mapping.c
5005@@ -134,7 +134,7 @@ static void __dma_free_coherent(struct device *dev, size_t size,
5006 phys_to_page(paddr),
5007 size >> PAGE_SHIFT);
5008 if (!freed)
5009- swiotlb_free_coherent(dev, size, vaddr, dma_handle);
5010+ swiotlb_free_coherent(dev, size, vaddr, dma_handle, attrs);
5011 }
5012
5013 static void *__dma_alloc(struct device *dev, size_t size,
5014diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
5015index c3a58a1..78fbf54 100644
5016--- a/arch/avr32/include/asm/cache.h
5017+++ b/arch/avr32/include/asm/cache.h
5018@@ -1,8 +1,10 @@
5019 #ifndef __ASM_AVR32_CACHE_H
5020 #define __ASM_AVR32_CACHE_H
5021
5022+#include <linux/const.h>
5023+
5024 #define L1_CACHE_SHIFT 5
5025-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5026+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5027
5028 /*
5029 * Memory returned by kmalloc() may be used for DMA, so we must make
5030diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
5031index 0388ece..87c8df1 100644
5032--- a/arch/avr32/include/asm/elf.h
5033+++ b/arch/avr32/include/asm/elf.h
5034@@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
5035 the loader. We need to make sure that it is out of the way of the program
5036 that it will "exec", and that there is sufficient room for the brk. */
5037
5038-#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
5039+#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
5040
5041+#ifdef CONFIG_PAX_ASLR
5042+#define PAX_ELF_ET_DYN_BASE 0x00001000UL
5043+
5044+#define PAX_DELTA_MMAP_LEN 15
5045+#define PAX_DELTA_STACK_LEN 15
5046+#endif
5047
5048 /* This yields a mask that user programs can use to figure out what
5049 instruction set this CPU supports. This could be done in user space,
5050diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
5051index 479330b..53717a8 100644
5052--- a/arch/avr32/include/asm/kmap_types.h
5053+++ b/arch/avr32/include/asm/kmap_types.h
5054@@ -2,9 +2,9 @@
5055 #define __ASM_AVR32_KMAP_TYPES_H
5056
5057 #ifdef CONFIG_DEBUG_HIGHMEM
5058-# define KM_TYPE_NR 29
5059+# define KM_TYPE_NR 30
5060 #else
5061-# define KM_TYPE_NR 14
5062+# define KM_TYPE_NR 15
5063 #endif
5064
5065 #endif /* __ASM_AVR32_KMAP_TYPES_H */
5066diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
5067index d223a8b..69c5210 100644
5068--- a/arch/avr32/mm/fault.c
5069+++ b/arch/avr32/mm/fault.c
5070@@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
5071
5072 int exception_trace = 1;
5073
5074+#ifdef CONFIG_PAX_PAGEEXEC
5075+void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5076+{
5077+ unsigned long i;
5078+
5079+ printk(KERN_ERR "PAX: bytes at PC: ");
5080+ for (i = 0; i < 20; i++) {
5081+ unsigned char c;
5082+ if (get_user(c, (unsigned char *)pc+i))
5083+ printk(KERN_CONT "???????? ");
5084+ else
5085+ printk(KERN_CONT "%02x ", c);
5086+ }
5087+ printk("\n");
5088+}
5089+#endif
5090+
5091 /*
5092 * This routine handles page faults. It determines the address and the
5093 * problem, and then passes it off to one of the appropriate routines.
5094@@ -178,6 +195,16 @@ bad_area:
5095 up_read(&mm->mmap_sem);
5096
5097 if (user_mode(regs)) {
5098+
5099+#ifdef CONFIG_PAX_PAGEEXEC
5100+ if (mm->pax_flags & MF_PAX_PAGEEXEC) {
5101+ if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
5102+ pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
5103+ do_group_exit(SIGKILL);
5104+ }
5105+ }
5106+#endif
5107+
5108 if (exception_trace && printk_ratelimit())
5109 printk("%s%s[%d]: segfault at %08lx pc %08lx "
5110 "sp %08lx ecr %lu\n",
5111diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
5112index 568885a..f8008df 100644
5113--- a/arch/blackfin/include/asm/cache.h
5114+++ b/arch/blackfin/include/asm/cache.h
5115@@ -7,6 +7,7 @@
5116 #ifndef __ARCH_BLACKFIN_CACHE_H
5117 #define __ARCH_BLACKFIN_CACHE_H
5118
5119+#include <linux/const.h>
5120 #include <linux/linkage.h> /* for asmlinkage */
5121
5122 /*
5123@@ -14,7 +15,7 @@
5124 * Blackfin loads 32 bytes for cache
5125 */
5126 #define L1_CACHE_SHIFT 5
5127-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5128+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5129 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5130
5131 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5132diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
5133index aea2718..3639a60 100644
5134--- a/arch/cris/include/arch-v10/arch/cache.h
5135+++ b/arch/cris/include/arch-v10/arch/cache.h
5136@@ -1,8 +1,9 @@
5137 #ifndef _ASM_ARCH_CACHE_H
5138 #define _ASM_ARCH_CACHE_H
5139
5140+#include <linux/const.h>
5141 /* Etrax 100LX have 32-byte cache-lines. */
5142-#define L1_CACHE_BYTES 32
5143 #define L1_CACHE_SHIFT 5
5144+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5145
5146 #endif /* _ASM_ARCH_CACHE_H */
5147diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
5148index 7caf25d..ee65ac5 100644
5149--- a/arch/cris/include/arch-v32/arch/cache.h
5150+++ b/arch/cris/include/arch-v32/arch/cache.h
5151@@ -1,11 +1,12 @@
5152 #ifndef _ASM_CRIS_ARCH_CACHE_H
5153 #define _ASM_CRIS_ARCH_CACHE_H
5154
5155+#include <linux/const.h>
5156 #include <arch/hwregs/dma.h>
5157
5158 /* A cache-line is 32 bytes. */
5159-#define L1_CACHE_BYTES 32
5160 #define L1_CACHE_SHIFT 5
5161+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5162
5163 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
5164
5165diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
5166index 102190a..5334cea 100644
5167--- a/arch/frv/include/asm/atomic.h
5168+++ b/arch/frv/include/asm/atomic.h
5169@@ -181,6 +181,16 @@ static inline void atomic64_dec(atomic64_t *v)
5170 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
5171 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
5172
5173+#define atomic64_read_unchecked(v) atomic64_read(v)
5174+#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5175+#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5176+#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5177+#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5178+#define atomic64_inc_unchecked(v) atomic64_inc(v)
5179+#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5180+#define atomic64_dec_unchecked(v) atomic64_dec(v)
5181+#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5182+
5183 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5184 {
5185 int c, old;
5186diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
5187index 2797163..c2a401df9 100644
5188--- a/arch/frv/include/asm/cache.h
5189+++ b/arch/frv/include/asm/cache.h
5190@@ -12,10 +12,11 @@
5191 #ifndef __ASM_CACHE_H
5192 #define __ASM_CACHE_H
5193
5194+#include <linux/const.h>
5195
5196 /* bytes per L1 cache line */
5197 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
5198-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5199+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5200
5201 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
5202 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
5203diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
5204index 43901f2..0d8b865 100644
5205--- a/arch/frv/include/asm/kmap_types.h
5206+++ b/arch/frv/include/asm/kmap_types.h
5207@@ -2,6 +2,6 @@
5208 #ifndef _ASM_KMAP_TYPES_H
5209 #define _ASM_KMAP_TYPES_H
5210
5211-#define KM_TYPE_NR 17
5212+#define KM_TYPE_NR 18
5213
5214 #endif
5215diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
5216index 836f147..4cf23f5 100644
5217--- a/arch/frv/mm/elf-fdpic.c
5218+++ b/arch/frv/mm/elf-fdpic.c
5219@@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
5220 {
5221 struct vm_area_struct *vma;
5222 struct vm_unmapped_area_info info;
5223+ unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
5224
5225 if (len > TASK_SIZE)
5226 return -ENOMEM;
5227@@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
5228 if (addr) {
5229 addr = PAGE_ALIGN(addr);
5230 vma = find_vma(current->mm, addr);
5231- if (TASK_SIZE - len >= addr &&
5232- (!vma || addr + len <= vma->vm_start))
5233+ if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
5234 goto success;
5235 }
5236
5237@@ -85,6 +85,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
5238 info.high_limit = (current->mm->start_stack - 0x00200000);
5239 info.align_mask = 0;
5240 info.align_offset = 0;
5241+ info.threadstack_offset = offset;
5242 addr = vm_unmapped_area(&info);
5243 if (!(addr & ~PAGE_MASK))
5244 goto success;
5245diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
5246index 69952c18..4fa2908 100644
5247--- a/arch/hexagon/include/asm/cache.h
5248+++ b/arch/hexagon/include/asm/cache.h
5249@@ -21,9 +21,11 @@
5250 #ifndef __ASM_CACHE_H
5251 #define __ASM_CACHE_H
5252
5253+#include <linux/const.h>
5254+
5255 /* Bytes per L1 cache line */
5256-#define L1_CACHE_SHIFT (5)
5257-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5258+#define L1_CACHE_SHIFT 5
5259+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5260
5261 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5262
5263diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
5264index 76d25b2..d3793a0f 100644
5265--- a/arch/ia64/Kconfig
5266+++ b/arch/ia64/Kconfig
5267@@ -541,6 +541,7 @@ source "drivers/sn/Kconfig"
5268 config KEXEC
5269 bool "kexec system call"
5270 depends on !IA64_HP_SIM && (!SMP || HOTPLUG_CPU)
5271+ depends on !GRKERNSEC_KMEM
5272 help
5273 kexec is a system call that implements the ability to shutdown your
5274 current kernel, and to start another kernel. It is like a reboot
5275diff --git a/arch/ia64/Makefile b/arch/ia64/Makefile
5276index 970d0bd..e750b9b 100644
5277--- a/arch/ia64/Makefile
5278+++ b/arch/ia64/Makefile
5279@@ -98,5 +98,6 @@ endef
5280 archprepare: make_nr_irqs_h FORCE
5281 PHONY += make_nr_irqs_h FORCE
5282
5283+make_nr_irqs_h: KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
5284 make_nr_irqs_h: FORCE
5285 $(Q)$(MAKE) $(build)=arch/ia64/kernel include/generated/nr-irqs.h
5286diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
5287index 0bf0350..2ad1957 100644
5288--- a/arch/ia64/include/asm/atomic.h
5289+++ b/arch/ia64/include/asm/atomic.h
5290@@ -193,4 +193,14 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
5291 #define atomic64_inc(v) atomic64_add(1, (v))
5292 #define atomic64_dec(v) atomic64_sub(1, (v))
5293
5294+#define atomic64_read_unchecked(v) atomic64_read(v)
5295+#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5296+#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5297+#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5298+#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5299+#define atomic64_inc_unchecked(v) atomic64_inc(v)
5300+#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5301+#define atomic64_dec_unchecked(v) atomic64_dec(v)
5302+#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5303+
5304 #endif /* _ASM_IA64_ATOMIC_H */
5305diff --git a/arch/ia64/include/asm/barrier.h b/arch/ia64/include/asm/barrier.h
5306index f6769eb..1cdb590 100644
5307--- a/arch/ia64/include/asm/barrier.h
5308+++ b/arch/ia64/include/asm/barrier.h
5309@@ -66,7 +66,7 @@
5310 do { \
5311 compiletime_assert_atomic_type(*p); \
5312 barrier(); \
5313- ACCESS_ONCE(*p) = (v); \
5314+ ACCESS_ONCE_RW(*p) = (v); \
5315 } while (0)
5316
5317 #define smp_load_acquire(p) \
5318diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
5319index 988254a..e1ee885 100644
5320--- a/arch/ia64/include/asm/cache.h
5321+++ b/arch/ia64/include/asm/cache.h
5322@@ -1,6 +1,7 @@
5323 #ifndef _ASM_IA64_CACHE_H
5324 #define _ASM_IA64_CACHE_H
5325
5326+#include <linux/const.h>
5327
5328 /*
5329 * Copyright (C) 1998-2000 Hewlett-Packard Co
5330@@ -9,7 +10,7 @@
5331
5332 /* Bytes per L1 (data) cache line. */
5333 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
5334-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5335+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5336
5337 #ifdef CONFIG_SMP
5338 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
5339diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
5340index 5a83c5c..4d7f553 100644
5341--- a/arch/ia64/include/asm/elf.h
5342+++ b/arch/ia64/include/asm/elf.h
5343@@ -42,6 +42,13 @@
5344 */
5345 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
5346
5347+#ifdef CONFIG_PAX_ASLR
5348+#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
5349+
5350+#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
5351+#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
5352+#endif
5353+
5354 #define PT_IA_64_UNWIND 0x70000001
5355
5356 /* IA-64 relocations: */
5357diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
5358index f5e70e9..624fad5 100644
5359--- a/arch/ia64/include/asm/pgalloc.h
5360+++ b/arch/ia64/include/asm/pgalloc.h
5361@@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
5362 pgd_val(*pgd_entry) = __pa(pud);
5363 }
5364
5365+static inline void
5366+pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
5367+{
5368+ pgd_populate(mm, pgd_entry, pud);
5369+}
5370+
5371 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
5372 {
5373 return quicklist_alloc(0, GFP_KERNEL, NULL);
5374@@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
5375 pud_val(*pud_entry) = __pa(pmd);
5376 }
5377
5378+static inline void
5379+pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
5380+{
5381+ pud_populate(mm, pud_entry, pmd);
5382+}
5383+
5384 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
5385 {
5386 return quicklist_alloc(0, GFP_KERNEL, NULL);
5387diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
5388index 9f3ed9e..c99b418 100644
5389--- a/arch/ia64/include/asm/pgtable.h
5390+++ b/arch/ia64/include/asm/pgtable.h
5391@@ -12,7 +12,7 @@
5392 * David Mosberger-Tang <davidm@hpl.hp.com>
5393 */
5394
5395-
5396+#include <linux/const.h>
5397 #include <asm/mman.h>
5398 #include <asm/page.h>
5399 #include <asm/processor.h>
5400@@ -139,6 +139,17 @@
5401 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
5402 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
5403 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
5404+
5405+#ifdef CONFIG_PAX_PAGEEXEC
5406+# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
5407+# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
5408+# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
5409+#else
5410+# define PAGE_SHARED_NOEXEC PAGE_SHARED
5411+# define PAGE_READONLY_NOEXEC PAGE_READONLY
5412+# define PAGE_COPY_NOEXEC PAGE_COPY
5413+#endif
5414+
5415 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
5416 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
5417 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
5418diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
5419index 45698cd..e8e2dbc 100644
5420--- a/arch/ia64/include/asm/spinlock.h
5421+++ b/arch/ia64/include/asm/spinlock.h
5422@@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
5423 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
5424
5425 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
5426- ACCESS_ONCE(*p) = (tmp + 2) & ~1;
5427+ ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
5428 }
5429
5430 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
5431diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
5432index 4f3fb6cc..254055e 100644
5433--- a/arch/ia64/include/asm/uaccess.h
5434+++ b/arch/ia64/include/asm/uaccess.h
5435@@ -70,6 +70,7 @@
5436 && ((segment).seg == KERNEL_DS.seg \
5437 || likely(REGION_OFFSET((unsigned long) (addr)) < RGN_MAP_LIMIT))); \
5438 })
5439+#define access_ok_noprefault(type, addr, size) access_ok((type), (addr), (size))
5440 #define access_ok(type, addr, size) __access_ok((addr), (size), get_fs())
5441
5442 /*
5443@@ -241,12 +242,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
5444 static inline unsigned long
5445 __copy_to_user (void __user *to, const void *from, unsigned long count)
5446 {
5447+ if (count > INT_MAX)
5448+ return count;
5449+
5450+ if (!__builtin_constant_p(count))
5451+ check_object_size(from, count, true);
5452+
5453 return __copy_user(to, (__force void __user *) from, count);
5454 }
5455
5456 static inline unsigned long
5457 __copy_from_user (void *to, const void __user *from, unsigned long count)
5458 {
5459+ if (count > INT_MAX)
5460+ return count;
5461+
5462+ if (!__builtin_constant_p(count))
5463+ check_object_size(to, count, false);
5464+
5465 return __copy_user((__force void __user *) to, from, count);
5466 }
5467
5468@@ -256,10 +269,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5469 ({ \
5470 void __user *__cu_to = (to); \
5471 const void *__cu_from = (from); \
5472- long __cu_len = (n); \
5473+ unsigned long __cu_len = (n); \
5474 \
5475- if (__access_ok(__cu_to, __cu_len, get_fs())) \
5476+ if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
5477+ if (!__builtin_constant_p(n)) \
5478+ check_object_size(__cu_from, __cu_len, true); \
5479 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
5480+ } \
5481 __cu_len; \
5482 })
5483
5484@@ -267,11 +283,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5485 ({ \
5486 void *__cu_to = (to); \
5487 const void __user *__cu_from = (from); \
5488- long __cu_len = (n); \
5489+ unsigned long __cu_len = (n); \
5490 \
5491 __chk_user_ptr(__cu_from); \
5492- if (__access_ok(__cu_from, __cu_len, get_fs())) \
5493+ if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
5494+ if (!__builtin_constant_p(n)) \
5495+ check_object_size(__cu_to, __cu_len, false); \
5496 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
5497+ } \
5498 __cu_len; \
5499 })
5500
5501diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
5502index 29754aa..06d2838 100644
5503--- a/arch/ia64/kernel/module.c
5504+++ b/arch/ia64/kernel/module.c
5505@@ -492,15 +492,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
5506 }
5507
5508 static inline int
5509+in_init_rx (const struct module *mod, uint64_t addr)
5510+{
5511+ return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
5512+}
5513+
5514+static inline int
5515+in_init_rw (const struct module *mod, uint64_t addr)
5516+{
5517+ return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
5518+}
5519+
5520+static inline int
5521 in_init (const struct module *mod, uint64_t addr)
5522 {
5523- return addr - (uint64_t) mod->module_init < mod->init_size;
5524+ return in_init_rx(mod, addr) || in_init_rw(mod, addr);
5525+}
5526+
5527+static inline int
5528+in_core_rx (const struct module *mod, uint64_t addr)
5529+{
5530+ return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
5531+}
5532+
5533+static inline int
5534+in_core_rw (const struct module *mod, uint64_t addr)
5535+{
5536+ return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
5537 }
5538
5539 static inline int
5540 in_core (const struct module *mod, uint64_t addr)
5541 {
5542- return addr - (uint64_t) mod->module_core < mod->core_size;
5543+ return in_core_rx(mod, addr) || in_core_rw(mod, addr);
5544 }
5545
5546 static inline int
5547@@ -683,7 +707,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
5548 break;
5549
5550 case RV_BDREL:
5551- val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
5552+ if (in_init_rx(mod, val))
5553+ val -= (uint64_t) mod->module_init_rx;
5554+ else if (in_init_rw(mod, val))
5555+ val -= (uint64_t) mod->module_init_rw;
5556+ else if (in_core_rx(mod, val))
5557+ val -= (uint64_t) mod->module_core_rx;
5558+ else if (in_core_rw(mod, val))
5559+ val -= (uint64_t) mod->module_core_rw;
5560 break;
5561
5562 case RV_LTV:
5563@@ -818,15 +849,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
5564 * addresses have been selected...
5565 */
5566 uint64_t gp;
5567- if (mod->core_size > MAX_LTOFF)
5568+ if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
5569 /*
5570 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
5571 * at the end of the module.
5572 */
5573- gp = mod->core_size - MAX_LTOFF / 2;
5574+ gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
5575 else
5576- gp = mod->core_size / 2;
5577- gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
5578+ gp = (mod->core_size_rx + mod->core_size_rw) / 2;
5579+ gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
5580 mod->arch.gp = gp;
5581 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
5582 }
5583diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
5584index c39c3cd..3c77738 100644
5585--- a/arch/ia64/kernel/palinfo.c
5586+++ b/arch/ia64/kernel/palinfo.c
5587@@ -980,7 +980,7 @@ static int palinfo_cpu_callback(struct notifier_block *nfb,
5588 return NOTIFY_OK;
5589 }
5590
5591-static struct notifier_block __refdata palinfo_cpu_notifier =
5592+static struct notifier_block palinfo_cpu_notifier =
5593 {
5594 .notifier_call = palinfo_cpu_callback,
5595 .priority = 0,
5596diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
5597index 41e33f8..65180b2a 100644
5598--- a/arch/ia64/kernel/sys_ia64.c
5599+++ b/arch/ia64/kernel/sys_ia64.c
5600@@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5601 unsigned long align_mask = 0;
5602 struct mm_struct *mm = current->mm;
5603 struct vm_unmapped_area_info info;
5604+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5605
5606 if (len > RGN_MAP_LIMIT)
5607 return -ENOMEM;
5608@@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5609 if (REGION_NUMBER(addr) == RGN_HPAGE)
5610 addr = 0;
5611 #endif
5612+
5613+#ifdef CONFIG_PAX_RANDMMAP
5614+ if (mm->pax_flags & MF_PAX_RANDMMAP)
5615+ addr = mm->free_area_cache;
5616+ else
5617+#endif
5618+
5619 if (!addr)
5620 addr = TASK_UNMAPPED_BASE;
5621
5622@@ -61,6 +69,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5623 info.high_limit = TASK_SIZE;
5624 info.align_mask = align_mask;
5625 info.align_offset = 0;
5626+ info.threadstack_offset = offset;
5627 return vm_unmapped_area(&info);
5628 }
5629
5630diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
5631index 84f8a52..7c76178 100644
5632--- a/arch/ia64/kernel/vmlinux.lds.S
5633+++ b/arch/ia64/kernel/vmlinux.lds.S
5634@@ -192,7 +192,7 @@ SECTIONS {
5635 /* Per-cpu data: */
5636 . = ALIGN(PERCPU_PAGE_SIZE);
5637 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
5638- __phys_per_cpu_start = __per_cpu_load;
5639+ __phys_per_cpu_start = per_cpu_load;
5640 /*
5641 * ensure percpu data fits
5642 * into percpu page size
5643diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
5644index ba5ba7a..36e9d3a 100644
5645--- a/arch/ia64/mm/fault.c
5646+++ b/arch/ia64/mm/fault.c
5647@@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
5648 return pte_present(pte);
5649 }
5650
5651+#ifdef CONFIG_PAX_PAGEEXEC
5652+void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5653+{
5654+ unsigned long i;
5655+
5656+ printk(KERN_ERR "PAX: bytes at PC: ");
5657+ for (i = 0; i < 8; i++) {
5658+ unsigned int c;
5659+ if (get_user(c, (unsigned int *)pc+i))
5660+ printk(KERN_CONT "???????? ");
5661+ else
5662+ printk(KERN_CONT "%08x ", c);
5663+ }
5664+ printk("\n");
5665+}
5666+#endif
5667+
5668 # define VM_READ_BIT 0
5669 # define VM_WRITE_BIT 1
5670 # define VM_EXEC_BIT 2
5671@@ -151,8 +168,21 @@ retry:
5672 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5673 goto bad_area;
5674
5675- if ((vma->vm_flags & mask) != mask)
5676+ if ((vma->vm_flags & mask) != mask) {
5677+
5678+#ifdef CONFIG_PAX_PAGEEXEC
5679+ if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5680+ if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5681+ goto bad_area;
5682+
5683+ up_read(&mm->mmap_sem);
5684+ pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5685+ do_group_exit(SIGKILL);
5686+ }
5687+#endif
5688+
5689 goto bad_area;
5690+ }
5691
5692 /*
5693 * If for any reason at all we couldn't handle the fault, make
5694diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5695index 52b7604b..455cb85 100644
5696--- a/arch/ia64/mm/hugetlbpage.c
5697+++ b/arch/ia64/mm/hugetlbpage.c
5698@@ -143,6 +143,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5699 unsigned long pgoff, unsigned long flags)
5700 {
5701 struct vm_unmapped_area_info info;
5702+ unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5703
5704 if (len > RGN_MAP_LIMIT)
5705 return -ENOMEM;
5706@@ -166,6 +167,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5707 info.high_limit = HPAGE_REGION_BASE + RGN_MAP_LIMIT;
5708 info.align_mask = PAGE_MASK & (HPAGE_SIZE - 1);
5709 info.align_offset = 0;
5710+ info.threadstack_offset = offset;
5711 return vm_unmapped_area(&info);
5712 }
5713
5714diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5715index a9b65cf..49ae1cf 100644
5716--- a/arch/ia64/mm/init.c
5717+++ b/arch/ia64/mm/init.c
5718@@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5719 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5720 vma->vm_end = vma->vm_start + PAGE_SIZE;
5721 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5722+
5723+#ifdef CONFIG_PAX_PAGEEXEC
5724+ if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5725+ vma->vm_flags &= ~VM_EXEC;
5726+
5727+#ifdef CONFIG_PAX_MPROTECT
5728+ if (current->mm->pax_flags & MF_PAX_MPROTECT)
5729+ vma->vm_flags &= ~VM_MAYEXEC;
5730+#endif
5731+
5732+ }
5733+#endif
5734+
5735 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5736 down_write(&current->mm->mmap_sem);
5737 if (insert_vm_struct(current->mm, vma)) {
5738@@ -286,7 +299,7 @@ static int __init gate_vma_init(void)
5739 gate_vma.vm_start = FIXADDR_USER_START;
5740 gate_vma.vm_end = FIXADDR_USER_END;
5741 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
5742- gate_vma.vm_page_prot = __P101;
5743+ gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
5744
5745 return 0;
5746 }
5747diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5748index 40b3ee98..8c2c112 100644
5749--- a/arch/m32r/include/asm/cache.h
5750+++ b/arch/m32r/include/asm/cache.h
5751@@ -1,8 +1,10 @@
5752 #ifndef _ASM_M32R_CACHE_H
5753 #define _ASM_M32R_CACHE_H
5754
5755+#include <linux/const.h>
5756+
5757 /* L1 cache line size */
5758 #define L1_CACHE_SHIFT 4
5759-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5760+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5761
5762 #endif /* _ASM_M32R_CACHE_H */
5763diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5764index 82abd15..d95ae5d 100644
5765--- a/arch/m32r/lib/usercopy.c
5766+++ b/arch/m32r/lib/usercopy.c
5767@@ -14,6 +14,9 @@
5768 unsigned long
5769 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5770 {
5771+ if ((long)n < 0)
5772+ return n;
5773+
5774 prefetch(from);
5775 if (access_ok(VERIFY_WRITE, to, n))
5776 __copy_user(to,from,n);
5777@@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5778 unsigned long
5779 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5780 {
5781+ if ((long)n < 0)
5782+ return n;
5783+
5784 prefetchw(to);
5785 if (access_ok(VERIFY_READ, from, n))
5786 __copy_user_zeroing(to,from,n);
5787diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5788index 0395c51..5f26031 100644
5789--- a/arch/m68k/include/asm/cache.h
5790+++ b/arch/m68k/include/asm/cache.h
5791@@ -4,9 +4,11 @@
5792 #ifndef __ARCH_M68K_CACHE_H
5793 #define __ARCH_M68K_CACHE_H
5794
5795+#include <linux/const.h>
5796+
5797 /* bytes per L1 cache line */
5798 #define L1_CACHE_SHIFT 4
5799-#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5800+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5801
5802 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5803
5804diff --git a/arch/metag/include/asm/barrier.h b/arch/metag/include/asm/barrier.h
5805index d703d8e..a8e2d70 100644
5806--- a/arch/metag/include/asm/barrier.h
5807+++ b/arch/metag/include/asm/barrier.h
5808@@ -90,7 +90,7 @@ static inline void fence(void)
5809 do { \
5810 compiletime_assert_atomic_type(*p); \
5811 smp_mb(); \
5812- ACCESS_ONCE(*p) = (v); \
5813+ ACCESS_ONCE_RW(*p) = (v); \
5814 } while (0)
5815
5816 #define smp_load_acquire(p) \
5817diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
5818index 7ca80ac..794ba72 100644
5819--- a/arch/metag/mm/hugetlbpage.c
5820+++ b/arch/metag/mm/hugetlbpage.c
5821@@ -194,6 +194,7 @@ hugetlb_get_unmapped_area_new_pmd(unsigned long len)
5822 info.high_limit = TASK_SIZE;
5823 info.align_mask = PAGE_MASK & HUGEPT_MASK;
5824 info.align_offset = 0;
5825+ info.threadstack_offset = 0;
5826 return vm_unmapped_area(&info);
5827 }
5828
5829diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5830index 4efe96a..60e8699 100644
5831--- a/arch/microblaze/include/asm/cache.h
5832+++ b/arch/microblaze/include/asm/cache.h
5833@@ -13,11 +13,12 @@
5834 #ifndef _ASM_MICROBLAZE_CACHE_H
5835 #define _ASM_MICROBLAZE_CACHE_H
5836
5837+#include <linux/const.h>
5838 #include <asm/registers.h>
5839
5840 #define L1_CACHE_SHIFT 5
5841 /* word-granular cache in microblaze */
5842-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5843+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5844
5845 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5846
5847diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
5848index f501665..b107753 100644
5849--- a/arch/mips/Kconfig
5850+++ b/arch/mips/Kconfig
5851@@ -2585,6 +2585,7 @@ source "kernel/Kconfig.preempt"
5852
5853 config KEXEC
5854 bool "Kexec system call"
5855+ depends on !GRKERNSEC_KMEM
5856 help
5857 kexec is a system call that implements the ability to shutdown your
5858 current kernel, and to start another kernel. It is like a reboot
5859diff --git a/arch/mips/cavium-octeon/dma-octeon.c b/arch/mips/cavium-octeon/dma-octeon.c
5860index d8960d4..77dbd31 100644
5861--- a/arch/mips/cavium-octeon/dma-octeon.c
5862+++ b/arch/mips/cavium-octeon/dma-octeon.c
5863@@ -199,7 +199,7 @@ static void octeon_dma_free_coherent(struct device *dev, size_t size,
5864 if (dma_release_from_coherent(dev, order, vaddr))
5865 return;
5866
5867- swiotlb_free_coherent(dev, size, vaddr, dma_handle);
5868+ swiotlb_free_coherent(dev, size, vaddr, dma_handle, attrs);
5869 }
5870
5871 static dma_addr_t octeon_unity_phys_to_dma(struct device *dev, phys_addr_t paddr)
5872diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5873index 26d4363..3c9a82e 100644
5874--- a/arch/mips/include/asm/atomic.h
5875+++ b/arch/mips/include/asm/atomic.h
5876@@ -22,15 +22,39 @@
5877 #include <asm/cmpxchg.h>
5878 #include <asm/war.h>
5879
5880+#ifdef CONFIG_GENERIC_ATOMIC64
5881+#include <asm-generic/atomic64.h>
5882+#endif
5883+
5884 #define ATOMIC_INIT(i) { (i) }
5885
5886+#ifdef CONFIG_64BIT
5887+#define _ASM_EXTABLE(from, to) \
5888+" .section __ex_table,\"a\"\n" \
5889+" .dword " #from ", " #to"\n" \
5890+" .previous\n"
5891+#else
5892+#define _ASM_EXTABLE(from, to) \
5893+" .section __ex_table,\"a\"\n" \
5894+" .word " #from ", " #to"\n" \
5895+" .previous\n"
5896+#endif
5897+
5898 /*
5899 * atomic_read - read atomic variable
5900 * @v: pointer of type atomic_t
5901 *
5902 * Atomically reads the value of @v.
5903 */
5904-#define atomic_read(v) ACCESS_ONCE((v)->counter)
5905+static inline int atomic_read(const atomic_t *v)
5906+{
5907+ return ACCESS_ONCE(v->counter);
5908+}
5909+
5910+static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
5911+{
5912+ return ACCESS_ONCE(v->counter);
5913+}
5914
5915 /*
5916 * atomic_set - set atomic variable
5917@@ -39,47 +63,77 @@
5918 *
5919 * Atomically sets the value of @v to @i.
5920 */
5921-#define atomic_set(v, i) ((v)->counter = (i))
5922+static inline void atomic_set(atomic_t *v, int i)
5923+{
5924+ v->counter = i;
5925+}
5926
5927-#define ATOMIC_OP(op, c_op, asm_op) \
5928-static __inline__ void atomic_##op(int i, atomic_t * v) \
5929+static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
5930+{
5931+ v->counter = i;
5932+}
5933+
5934+#ifdef CONFIG_PAX_REFCOUNT
5935+#define __OVERFLOW_POST \
5936+ " b 4f \n" \
5937+ " .set noreorder \n" \
5938+ "3: b 5f \n" \
5939+ " move %0, %1 \n" \
5940+ " .set reorder \n"
5941+#define __OVERFLOW_EXTABLE \
5942+ "3:\n" \
5943+ _ASM_EXTABLE(2b, 3b)
5944+#else
5945+#define __OVERFLOW_POST
5946+#define __OVERFLOW_EXTABLE
5947+#endif
5948+
5949+#define __ATOMIC_OP(op, suffix, asm_op, extable) \
5950+static inline void atomic_##op##suffix(int i, atomic##suffix##_t * v) \
5951 { \
5952 if (kernel_uses_llsc && R10000_LLSC_WAR) { \
5953 int temp; \
5954 \
5955 __asm__ __volatile__( \
5956- " .set arch=r4000 \n" \
5957- "1: ll %0, %1 # atomic_" #op " \n" \
5958- " " #asm_op " %0, %2 \n" \
5959+ " .set mips3 \n" \
5960+ "1: ll %0, %1 # atomic_" #op #suffix "\n" \
5961+ "2: " #asm_op " %0, %2 \n" \
5962 " sc %0, %1 \n" \
5963 " beqzl %0, 1b \n" \
5964+ extable \
5965 " .set mips0 \n" \
5966 : "=&r" (temp), "+" GCC_OFF_SMALL_ASM() (v->counter) \
5967 : "Ir" (i)); \
5968 } else if (kernel_uses_llsc) { \
5969 int temp; \
5970 \
5971- do { \
5972- __asm__ __volatile__( \
5973- " .set "MIPS_ISA_LEVEL" \n" \
5974- " ll %0, %1 # atomic_" #op "\n" \
5975- " " #asm_op " %0, %2 \n" \
5976- " sc %0, %1 \n" \
5977- " .set mips0 \n" \
5978- : "=&r" (temp), "+" GCC_OFF_SMALL_ASM() (v->counter) \
5979- : "Ir" (i)); \
5980- } while (unlikely(!temp)); \
5981+ __asm__ __volatile__( \
5982+ " .set "MIPS_ISA_LEVEL" \n" \
5983+ "1: ll %0, %1 # atomic_" #op #suffix "\n" \
5984+ "2: " #asm_op " %0, %2 \n" \
5985+ " sc %0, %1 \n" \
5986+ " beqz %0, 1b \n" \
5987+ extable \
5988+ " .set mips0 \n" \
5989+ : "=&r" (temp), "+" GCC_OFF_SMALL_ASM() (v->counter) \
5990+ : "Ir" (i)); \
5991 } else { \
5992 unsigned long flags; \
5993 \
5994 raw_local_irq_save(flags); \
5995- v->counter c_op i; \
5996+ __asm__ __volatile__( \
5997+ "2: " #asm_op " %0, %1 \n" \
5998+ extable \
5999+ : "+r" (v->counter) : "Ir" (i)); \
6000 raw_local_irq_restore(flags); \
6001 } \
6002 }
6003
6004-#define ATOMIC_OP_RETURN(op, c_op, asm_op) \
6005-static __inline__ int atomic_##op##_return(int i, atomic_t * v) \
6006+#define ATOMIC_OP(op, asm_op) __ATOMIC_OP(op, _unchecked, asm_op##u, ) \
6007+ __ATOMIC_OP(op, , asm_op, __OVERFLOW_EXTABLE)
6008+
6009+#define __ATOMIC_OP_RETURN(op, suffix, asm_op, post_op, extable) \
6010+static inline int atomic_##op##_return##suffix(int i, atomic##suffix##_t * v) \
6011 { \
6012 int result; \
6013 \
6014@@ -89,12 +143,15 @@ static __inline__ int atomic_##op##_return(int i, atomic_t * v) \
6015 int temp; \
6016 \
6017 __asm__ __volatile__( \
6018- " .set arch=r4000 \n" \
6019- "1: ll %1, %2 # atomic_" #op "_return \n" \
6020- " " #asm_op " %0, %1, %3 \n" \
6021+ " .set mips3 \n" \
6022+ "1: ll %1, %2 # atomic_" #op "_return" #suffix"\n" \
6023+ "2: " #asm_op " %0, %1, %3 \n" \
6024 " sc %0, %2 \n" \
6025 " beqzl %0, 1b \n" \
6026- " " #asm_op " %0, %1, %3 \n" \
6027+ post_op \
6028+ extable \
6029+ "4: " #asm_op " %0, %1, %3 \n" \
6030+ "5: \n" \
6031 " .set mips0 \n" \
6032 : "=&r" (result), "=&r" (temp), \
6033 "+" GCC_OFF_SMALL_ASM() (v->counter) \
6034@@ -102,26 +159,33 @@ static __inline__ int atomic_##op##_return(int i, atomic_t * v) \
6035 } else if (kernel_uses_llsc) { \
6036 int temp; \
6037 \
6038- do { \
6039- __asm__ __volatile__( \
6040- " .set "MIPS_ISA_LEVEL" \n" \
6041- " ll %1, %2 # atomic_" #op "_return \n" \
6042- " " #asm_op " %0, %1, %3 \n" \
6043- " sc %0, %2 \n" \
6044- " .set mips0 \n" \
6045- : "=&r" (result), "=&r" (temp), \
6046- "+" GCC_OFF_SMALL_ASM() (v->counter) \
6047- : "Ir" (i)); \
6048- } while (unlikely(!result)); \
6049+ __asm__ __volatile__( \
6050+ " .set "MIPS_ISA_LEVEL" \n" \
6051+ "1: ll %1, %2 # atomic_" #op "_return" #suffix "\n" \
6052+ "2: " #asm_op " %0, %1, %3 \n" \
6053+ " sc %0, %2 \n" \
6054+ post_op \
6055+ extable \
6056+ "4: " #asm_op " %0, %1, %3 \n" \
6057+ "5: \n" \
6058+ " .set mips0 \n" \
6059+ : "=&r" (result), "=&r" (temp), \
6060+ "+" GCC_OFF_SMALL_ASM() (v->counter) \
6061+ : "Ir" (i)); \
6062 \
6063 result = temp; result c_op i; \
6064 } else { \
6065 unsigned long flags; \
6066 \
6067 raw_local_irq_save(flags); \
6068- result = v->counter; \
6069- result c_op i; \
6070- v->counter = result; \
6071+ __asm__ __volatile__( \
6072+ " lw %0, %1 \n" \
6073+ "2: " #asm_op " %0, %1, %2 \n" \
6074+ " sw %0, %1 \n" \
6075+ "3: \n" \
6076+ extable \
6077+ : "=&r" (result), "+" GCC_OFF_SMALL_ASM() (v->counter) \
6078+ : "Ir" (i)); \
6079 raw_local_irq_restore(flags); \
6080 } \
6081 \
6082@@ -130,16 +194,21 @@ static __inline__ int atomic_##op##_return(int i, atomic_t * v) \
6083 return result; \
6084 }
6085
6086-#define ATOMIC_OPS(op, c_op, asm_op) \
6087- ATOMIC_OP(op, c_op, asm_op) \
6088- ATOMIC_OP_RETURN(op, c_op, asm_op)
6089+#define ATOMIC_OP_RETURN(op, asm_op) __ATOMIC_OP_RETURN(op, _unchecked, asm_op##u, , ) \
6090+ __ATOMIC_OP_RETURN(op, , asm_op, __OVERFLOW_POST, __OVERFLOW_EXTABLE)
6091
6092-ATOMIC_OPS(add, +=, addu)
6093-ATOMIC_OPS(sub, -=, subu)
6094+#define ATOMIC_OPS(op, asm_op) \
6095+ ATOMIC_OP(op, asm_op) \
6096+ ATOMIC_OP_RETURN(op, asm_op)
6097+
6098+ATOMIC_OPS(add, add)
6099+ATOMIC_OPS(sub, sub)
6100
6101 #undef ATOMIC_OPS
6102 #undef ATOMIC_OP_RETURN
6103+#undef __ATOMIC_OP_RETURN
6104 #undef ATOMIC_OP
6105+#undef __ATOMIC_OP
6106
6107 /*
6108 * atomic_sub_if_positive - conditionally subtract integer from atomic variable
6109@@ -149,7 +218,7 @@ ATOMIC_OPS(sub, -=, subu)
6110 * Atomically test @v and subtract @i if @v is greater or equal than @i.
6111 * The function returns the old value of @v minus @i.
6112 */
6113-static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
6114+static __inline__ int atomic_sub_if_positive(int i, atomic_t *v)
6115 {
6116 int result;
6117
6118@@ -159,7 +228,7 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
6119 int temp;
6120
6121 __asm__ __volatile__(
6122- " .set arch=r4000 \n"
6123+ " .set "MIPS_ISA_LEVEL" \n"
6124 "1: ll %1, %2 # atomic_sub_if_positive\n"
6125 " subu %0, %1, %3 \n"
6126 " bltz %0, 1f \n"
6127@@ -208,8 +277,26 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
6128 return result;
6129 }
6130
6131-#define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
6132-#define atomic_xchg(v, new) (xchg(&((v)->counter), (new)))
6133+static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
6134+{
6135+ return cmpxchg(&v->counter, old, new);
6136+}
6137+
6138+static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old,
6139+ int new)
6140+{
6141+ return cmpxchg(&(v->counter), old, new);
6142+}
6143+
6144+static inline int atomic_xchg(atomic_t *v, int new)
6145+{
6146+ return xchg(&v->counter, new);
6147+}
6148+
6149+static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
6150+{
6151+ return xchg(&(v->counter), new);
6152+}
6153
6154 /**
6155 * __atomic_add_unless - add unless the number is a given value
6156@@ -237,6 +324,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
6157
6158 #define atomic_dec_return(v) atomic_sub_return(1, (v))
6159 #define atomic_inc_return(v) atomic_add_return(1, (v))
6160+static __inline__ int atomic_inc_return_unchecked(atomic_unchecked_t *v)
6161+{
6162+ return atomic_add_return_unchecked(1, v);
6163+}
6164
6165 /*
6166 * atomic_sub_and_test - subtract value from variable and test result
6167@@ -258,6 +349,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
6168 * other cases.
6169 */
6170 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
6171+static __inline__ int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
6172+{
6173+ return atomic_add_return_unchecked(1, v) == 0;
6174+}
6175
6176 /*
6177 * atomic_dec_and_test - decrement by 1 and test
6178@@ -282,6 +377,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
6179 * Atomically increments @v by 1.
6180 */
6181 #define atomic_inc(v) atomic_add(1, (v))
6182+static __inline__ void atomic_inc_unchecked(atomic_unchecked_t *v)
6183+{
6184+ atomic_add_unchecked(1, v);
6185+}
6186
6187 /*
6188 * atomic_dec - decrement and test
6189@@ -290,6 +389,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
6190 * Atomically decrements @v by 1.
6191 */
6192 #define atomic_dec(v) atomic_sub(1, (v))
6193+static __inline__ void atomic_dec_unchecked(atomic_unchecked_t *v)
6194+{
6195+ atomic_sub_unchecked(1, v);
6196+}
6197
6198 /*
6199 * atomic_add_negative - add and test if negative
6200@@ -311,54 +414,77 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
6201 * @v: pointer of type atomic64_t
6202 *
6203 */
6204-#define atomic64_read(v) ACCESS_ONCE((v)->counter)
6205+static inline long atomic64_read(const atomic64_t *v)
6206+{
6207+ return ACCESS_ONCE(v->counter);
6208+}
6209+
6210+static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
6211+{
6212+ return ACCESS_ONCE(v->counter);
6213+}
6214
6215 /*
6216 * atomic64_set - set atomic variable
6217 * @v: pointer of type atomic64_t
6218 * @i: required value
6219 */
6220-#define atomic64_set(v, i) ((v)->counter = (i))
6221+static inline void atomic64_set(atomic64_t *v, long i)
6222+{
6223+ v->counter = i;
6224+}
6225
6226-#define ATOMIC64_OP(op, c_op, asm_op) \
6227-static __inline__ void atomic64_##op(long i, atomic64_t * v) \
6228+static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
6229+{
6230+ v->counter = i;
6231+}
6232+
6233+#define __ATOMIC64_OP(op, suffix, asm_op, extable) \
6234+static inline void atomic64_##op##suffix(long i, atomic64##suffix##_t * v) \
6235 { \
6236 if (kernel_uses_llsc && R10000_LLSC_WAR) { \
6237 long temp; \
6238 \
6239 __asm__ __volatile__( \
6240- " .set arch=r4000 \n" \
6241- "1: lld %0, %1 # atomic64_" #op " \n" \
6242- " " #asm_op " %0, %2 \n" \
6243+ " .set "MIPS_ISA_LEVEL" \n" \
6244+ "1: lld %0, %1 # atomic64_" #op #suffix "\n" \
6245+ "2: " #asm_op " %0, %2 \n" \
6246 " scd %0, %1 \n" \
6247 " beqzl %0, 1b \n" \
6248+ extable \
6249 " .set mips0 \n" \
6250 : "=&r" (temp), "+" GCC_OFF_SMALL_ASM() (v->counter) \
6251 : "Ir" (i)); \
6252 } else if (kernel_uses_llsc) { \
6253 long temp; \
6254 \
6255- do { \
6256- __asm__ __volatile__( \
6257- " .set "MIPS_ISA_LEVEL" \n" \
6258- " lld %0, %1 # atomic64_" #op "\n" \
6259- " " #asm_op " %0, %2 \n" \
6260- " scd %0, %1 \n" \
6261- " .set mips0 \n" \
6262- : "=&r" (temp), "+" GCC_OFF_SMALL_ASM() (v->counter) \
6263- : "Ir" (i)); \
6264- } while (unlikely(!temp)); \
6265+ __asm__ __volatile__( \
6266+ " .set "MIPS_ISA_LEVEL" \n" \
6267+ "1: lld %0, %1 # atomic64_" #op #suffix "\n" \
6268+ "2: " #asm_op " %0, %2 \n" \
6269+ " scd %0, %1 \n" \
6270+ " beqz %0, 1b \n" \
6271+ extable \
6272+ " .set mips0 \n" \
6273+ : "=&r" (temp), "+" GCC_OFF_SMALL_ASM() (v->counter) \
6274+ : "Ir" (i)); \
6275 } else { \
6276 unsigned long flags; \
6277 \
6278 raw_local_irq_save(flags); \
6279- v->counter c_op i; \
6280+ __asm__ __volatile__( \
6281+ "2: " #asm_op " %0, %1 \n" \
6282+ extable \
6283+ : "+" GCC_OFF_SMALL_ASM() (v->counter) : "Ir" (i)); \
6284 raw_local_irq_restore(flags); \
6285 } \
6286 }
6287
6288-#define ATOMIC64_OP_RETURN(op, c_op, asm_op) \
6289-static __inline__ long atomic64_##op##_return(long i, atomic64_t * v) \
6290+#define ATOMIC64_OP(op, asm_op) __ATOMIC64_OP(op, _unchecked, asm_op##u, ) \
6291+ __ATOMIC64_OP(op, , asm_op, __OVERFLOW_EXTABLE)
6292+
6293+#define __ATOMIC64_OP_RETURN(op, suffix, asm_op, post_op, extable) \
6294+static inline long atomic64_##op##_return##suffix(long i, atomic64##suffix##_t * v)\
6295 { \
6296 long result; \
6297 \
6298@@ -368,12 +494,15 @@ static __inline__ long atomic64_##op##_return(long i, atomic64_t * v) \
6299 long temp; \
6300 \
6301 __asm__ __volatile__( \
6302- " .set arch=r4000 \n" \
6303+ " .set mips3 \n" \
6304 "1: lld %1, %2 # atomic64_" #op "_return\n" \
6305- " " #asm_op " %0, %1, %3 \n" \
6306+ "2: " #asm_op " %0, %1, %3 \n" \
6307 " scd %0, %2 \n" \
6308 " beqzl %0, 1b \n" \
6309- " " #asm_op " %0, %1, %3 \n" \
6310+ post_op \
6311+ extable \
6312+ "4: " #asm_op " %0, %1, %3 \n" \
6313+ "5: \n" \
6314 " .set mips0 \n" \
6315 : "=&r" (result), "=&r" (temp), \
6316 "+" GCC_OFF_SMALL_ASM() (v->counter) \
6317@@ -381,27 +510,35 @@ static __inline__ long atomic64_##op##_return(long i, atomic64_t * v) \
6318 } else if (kernel_uses_llsc) { \
6319 long temp; \
6320 \
6321- do { \
6322- __asm__ __volatile__( \
6323- " .set "MIPS_ISA_LEVEL" \n" \
6324- " lld %1, %2 # atomic64_" #op "_return\n" \
6325- " " #asm_op " %0, %1, %3 \n" \
6326- " scd %0, %2 \n" \
6327- " .set mips0 \n" \
6328- : "=&r" (result), "=&r" (temp), \
6329- "=" GCC_OFF_SMALL_ASM() (v->counter) \
6330- : "Ir" (i), GCC_OFF_SMALL_ASM() (v->counter) \
6331- : "memory"); \
6332- } while (unlikely(!result)); \
6333+ __asm__ __volatile__( \
6334+ " .set "MIPS_ISA_LEVEL" \n" \
6335+ "1: lld %1, %2 # atomic64_" #op "_return" #suffix "\n"\
6336+ "2: " #asm_op " %0, %1, %3 \n" \
6337+ " scd %0, %2 \n" \
6338+ " beqz %0, 1b \n" \
6339+ post_op \
6340+ extable \
6341+ "4: " #asm_op " %0, %1, %3 \n" \
6342+ "5: \n" \
6343+ " .set mips0 \n" \
6344+ : "=&r" (result), "=&r" (temp), \
6345+ "=" GCC_OFF_SMALL_ASM() (v->counter) \
6346+ : "Ir" (i), GCC_OFF_SMALL_ASM() (v->counter) \
6347+ : "memory"); \
6348 \
6349 result = temp; result c_op i; \
6350 } else { \
6351 unsigned long flags; \
6352 \
6353 raw_local_irq_save(flags); \
6354- result = v->counter; \
6355- result c_op i; \
6356- v->counter = result; \
6357+ __asm__ __volatile__( \
6358+ " ld %0, %1 \n" \
6359+ "2: " #asm_op " %0, %1, %2 \n" \
6360+ " sd %0, %1 \n" \
6361+ "3: \n" \
6362+ extable \
6363+ : "=&r" (result), "+" GCC_OFF_SMALL_ASM() (v->counter) \
6364+ : "Ir" (i)); \
6365 raw_local_irq_restore(flags); \
6366 } \
6367 \
6368@@ -410,16 +547,23 @@ static __inline__ long atomic64_##op##_return(long i, atomic64_t * v) \
6369 return result; \
6370 }
6371
6372-#define ATOMIC64_OPS(op, c_op, asm_op) \
6373- ATOMIC64_OP(op, c_op, asm_op) \
6374- ATOMIC64_OP_RETURN(op, c_op, asm_op)
6375+#define ATOMIC64_OP_RETURN(op, asm_op) __ATOMIC64_OP_RETURN(op, _unchecked, asm_op##u, , ) \
6376+ __ATOMIC64_OP_RETURN(op, , asm_op, __OVERFLOW_POST, __OVERFLOW_EXTABLE)
6377
6378-ATOMIC64_OPS(add, +=, daddu)
6379-ATOMIC64_OPS(sub, -=, dsubu)
6380+#define ATOMIC64_OPS(op, asm_op) \
6381+ ATOMIC64_OP(op, asm_op) \
6382+ ATOMIC64_OP_RETURN(op, asm_op)
6383+
6384+ATOMIC64_OPS(add, dadd)
6385+ATOMIC64_OPS(sub, dsub)
6386
6387 #undef ATOMIC64_OPS
6388 #undef ATOMIC64_OP_RETURN
6389+#undef __ATOMIC64_OP_RETURN
6390 #undef ATOMIC64_OP
6391+#undef __ATOMIC64_OP
6392+#undef __OVERFLOW_EXTABLE
6393+#undef __OVERFLOW_POST
6394
6395 /*
6396 * atomic64_sub_if_positive - conditionally subtract integer from atomic
6397@@ -430,7 +574,7 @@ ATOMIC64_OPS(sub, -=, dsubu)
6398 * Atomically test @v and subtract @i if @v is greater or equal than @i.
6399 * The function returns the old value of @v minus @i.
6400 */
6401-static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6402+static __inline__ long atomic64_sub_if_positive(long i, atomic64_t *v)
6403 {
6404 long result;
6405
6406@@ -440,7 +584,7 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6407 long temp;
6408
6409 __asm__ __volatile__(
6410- " .set arch=r4000 \n"
6411+ " .set "MIPS_ISA_LEVEL" \n"
6412 "1: lld %1, %2 # atomic64_sub_if_positive\n"
6413 " dsubu %0, %1, %3 \n"
6414 " bltz %0, 1f \n"
6415@@ -489,9 +633,26 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6416 return result;
6417 }
6418
6419-#define atomic64_cmpxchg(v, o, n) \
6420- ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
6421-#define atomic64_xchg(v, new) (xchg(&((v)->counter), (new)))
6422+static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
6423+{
6424+ return cmpxchg(&v->counter, old, new);
6425+}
6426+
6427+static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old,
6428+ long new)
6429+{
6430+ return cmpxchg(&(v->counter), old, new);
6431+}
6432+
6433+static inline long atomic64_xchg(atomic64_t *v, long new)
6434+{
6435+ return xchg(&v->counter, new);
6436+}
6437+
6438+static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
6439+{
6440+ return xchg(&(v->counter), new);
6441+}
6442
6443 /**
6444 * atomic64_add_unless - add unless the number is a given value
6445@@ -521,6 +682,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6446
6447 #define atomic64_dec_return(v) atomic64_sub_return(1, (v))
6448 #define atomic64_inc_return(v) atomic64_add_return(1, (v))
6449+#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1, (v))
6450
6451 /*
6452 * atomic64_sub_and_test - subtract value from variable and test result
6453@@ -542,6 +704,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6454 * other cases.
6455 */
6456 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
6457+#define atomic64_inc_and_test_unchecked(v) atomic64_add_return_unchecked(1, (v)) == 0)
6458
6459 /*
6460 * atomic64_dec_and_test - decrement by 1 and test
6461@@ -566,6 +729,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6462 * Atomically increments @v by 1.
6463 */
6464 #define atomic64_inc(v) atomic64_add(1, (v))
6465+#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1, (v))
6466
6467 /*
6468 * atomic64_dec - decrement and test
6469@@ -574,6 +738,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6470 * Atomically decrements @v by 1.
6471 */
6472 #define atomic64_dec(v) atomic64_sub(1, (v))
6473+#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1, (v))
6474
6475 /*
6476 * atomic64_add_negative - add and test if negative
6477diff --git a/arch/mips/include/asm/barrier.h b/arch/mips/include/asm/barrier.h
6478index 2b8bbbc..4556df6 100644
6479--- a/arch/mips/include/asm/barrier.h
6480+++ b/arch/mips/include/asm/barrier.h
6481@@ -133,7 +133,7 @@
6482 do { \
6483 compiletime_assert_atomic_type(*p); \
6484 smp_mb(); \
6485- ACCESS_ONCE(*p) = (v); \
6486+ ACCESS_ONCE_RW(*p) = (v); \
6487 } while (0)
6488
6489 #define smp_load_acquire(p) \
6490diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
6491index b4db69f..8f3b093 100644
6492--- a/arch/mips/include/asm/cache.h
6493+++ b/arch/mips/include/asm/cache.h
6494@@ -9,10 +9,11 @@
6495 #ifndef _ASM_CACHE_H
6496 #define _ASM_CACHE_H
6497
6498+#include <linux/const.h>
6499 #include <kmalloc.h>
6500
6501 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
6502-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6503+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6504
6505 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
6506 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6507diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
6508index f19e890..a4f8177 100644
6509--- a/arch/mips/include/asm/elf.h
6510+++ b/arch/mips/include/asm/elf.h
6511@@ -417,6 +417,13 @@ extern const char *__elf_platform;
6512 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
6513 #endif
6514
6515+#ifdef CONFIG_PAX_ASLR
6516+#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6517+
6518+#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6519+#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6520+#endif
6521+
6522 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
6523 struct linux_binprm;
6524 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6525diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
6526index c1f6afa..38cc6e9 100644
6527--- a/arch/mips/include/asm/exec.h
6528+++ b/arch/mips/include/asm/exec.h
6529@@ -12,6 +12,6 @@
6530 #ifndef _ASM_EXEC_H
6531 #define _ASM_EXEC_H
6532
6533-extern unsigned long arch_align_stack(unsigned long sp);
6534+#define arch_align_stack(x) ((x) & ~0xfUL)
6535
6536 #endif /* _ASM_EXEC_H */
6537diff --git a/arch/mips/include/asm/hw_irq.h b/arch/mips/include/asm/hw_irq.h
6538index 9e8ef59..1139d6b 100644
6539--- a/arch/mips/include/asm/hw_irq.h
6540+++ b/arch/mips/include/asm/hw_irq.h
6541@@ -10,7 +10,7 @@
6542
6543 #include <linux/atomic.h>
6544
6545-extern atomic_t irq_err_count;
6546+extern atomic_unchecked_t irq_err_count;
6547
6548 /*
6549 * interrupt-retrigger: NOP for now. This may not be appropriate for all
6550diff --git a/arch/mips/include/asm/local.h b/arch/mips/include/asm/local.h
6551index 8feaed6..1bd8a64 100644
6552--- a/arch/mips/include/asm/local.h
6553+++ b/arch/mips/include/asm/local.h
6554@@ -13,15 +13,25 @@ typedef struct
6555 atomic_long_t a;
6556 } local_t;
6557
6558+typedef struct {
6559+ atomic_long_unchecked_t a;
6560+} local_unchecked_t;
6561+
6562 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
6563
6564 #define local_read(l) atomic_long_read(&(l)->a)
6565+#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
6566 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
6567+#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
6568
6569 #define local_add(i, l) atomic_long_add((i), (&(l)->a))
6570+#define local_add_unchecked(i, l) atomic_long_add_unchecked((i), (&(l)->a))
6571 #define local_sub(i, l) atomic_long_sub((i), (&(l)->a))
6572+#define local_sub_unchecked(i, l) atomic_long_sub_unchecked((i), (&(l)->a))
6573 #define local_inc(l) atomic_long_inc(&(l)->a)
6574+#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
6575 #define local_dec(l) atomic_long_dec(&(l)->a)
6576+#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
6577
6578 /*
6579 * Same as above, but return the result value
6580@@ -71,6 +81,51 @@ static __inline__ long local_add_return(long i, local_t * l)
6581 return result;
6582 }
6583
6584+static __inline__ long local_add_return_unchecked(long i, local_unchecked_t * l)
6585+{
6586+ unsigned long result;
6587+
6588+ if (kernel_uses_llsc && R10000_LLSC_WAR) {
6589+ unsigned long temp;
6590+
6591+ __asm__ __volatile__(
6592+ " .set mips3 \n"
6593+ "1:" __LL "%1, %2 # local_add_return \n"
6594+ " addu %0, %1, %3 \n"
6595+ __SC "%0, %2 \n"
6596+ " beqzl %0, 1b \n"
6597+ " addu %0, %1, %3 \n"
6598+ " .set mips0 \n"
6599+ : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6600+ : "Ir" (i), "m" (l->a.counter)
6601+ : "memory");
6602+ } else if (kernel_uses_llsc) {
6603+ unsigned long temp;
6604+
6605+ __asm__ __volatile__(
6606+ " .set mips3 \n"
6607+ "1:" __LL "%1, %2 # local_add_return \n"
6608+ " addu %0, %1, %3 \n"
6609+ __SC "%0, %2 \n"
6610+ " beqz %0, 1b \n"
6611+ " addu %0, %1, %3 \n"
6612+ " .set mips0 \n"
6613+ : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6614+ : "Ir" (i), "m" (l->a.counter)
6615+ : "memory");
6616+ } else {
6617+ unsigned long flags;
6618+
6619+ local_irq_save(flags);
6620+ result = l->a.counter;
6621+ result += i;
6622+ l->a.counter = result;
6623+ local_irq_restore(flags);
6624+ }
6625+
6626+ return result;
6627+}
6628+
6629 static __inline__ long local_sub_return(long i, local_t * l)
6630 {
6631 unsigned long result;
6632@@ -118,6 +173,8 @@ static __inline__ long local_sub_return(long i, local_t * l)
6633
6634 #define local_cmpxchg(l, o, n) \
6635 ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6636+#define local_cmpxchg_unchecked(l, o, n) \
6637+ ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6638 #define local_xchg(l, n) (atomic_long_xchg((&(l)->a), (n)))
6639
6640 /**
6641diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
6642index 89dd7fe..a123c97 100644
6643--- a/arch/mips/include/asm/page.h
6644+++ b/arch/mips/include/asm/page.h
6645@@ -118,7 +118,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
6646 #ifdef CONFIG_CPU_MIPS32
6647 typedef struct { unsigned long pte_low, pte_high; } pte_t;
6648 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
6649- #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
6650+ #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
6651 #else
6652 typedef struct { unsigned long long pte; } pte_t;
6653 #define pte_val(x) ((x).pte)
6654diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
6655index b336037..5b874cc 100644
6656--- a/arch/mips/include/asm/pgalloc.h
6657+++ b/arch/mips/include/asm/pgalloc.h
6658@@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6659 {
6660 set_pud(pud, __pud((unsigned long)pmd));
6661 }
6662+
6663+static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6664+{
6665+ pud_populate(mm, pud, pmd);
6666+}
6667 #endif
6668
6669 /*
6670diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtable.h
6671index 819af9d..439839d 100644
6672--- a/arch/mips/include/asm/pgtable.h
6673+++ b/arch/mips/include/asm/pgtable.h
6674@@ -20,6 +20,9 @@
6675 #include <asm/io.h>
6676 #include <asm/pgtable-bits.h>
6677
6678+#define ktla_ktva(addr) (addr)
6679+#define ktva_ktla(addr) (addr)
6680+
6681 struct mm_struct;
6682 struct vm_area_struct;
6683
6684diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
6685index 9c0014e..5101ef5 100644
6686--- a/arch/mips/include/asm/thread_info.h
6687+++ b/arch/mips/include/asm/thread_info.h
6688@@ -100,6 +100,9 @@ static inline struct thread_info *current_thread_info(void)
6689 #define TIF_SECCOMP 4 /* secure computing */
6690 #define TIF_NOTIFY_RESUME 5 /* callback before returning to user */
6691 #define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal() */
6692+/* li takes a 32bit immediate */
6693+#define TIF_GRSEC_SETXID 10 /* update credentials on syscall entry/exit */
6694+
6695 #define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */
6696 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
6697 #define TIF_NOHZ 19 /* in adaptive nohz mode */
6698@@ -135,14 +138,16 @@ static inline struct thread_info *current_thread_info(void)
6699 #define _TIF_USEDMSA (1<<TIF_USEDMSA)
6700 #define _TIF_MSA_CTX_LIVE (1<<TIF_MSA_CTX_LIVE)
6701 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
6702+#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6703
6704 #define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6705 _TIF_SYSCALL_AUDIT | \
6706- _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
6707+ _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | \
6708+ _TIF_GRSEC_SETXID)
6709
6710 /* work to do in syscall_trace_leave() */
6711 #define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6712- _TIF_SYSCALL_AUDIT | _TIF_SYSCALL_TRACEPOINT)
6713+ _TIF_SYSCALL_AUDIT | _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
6714
6715 /* work to do on interrupt/exception return */
6716 #define _TIF_WORK_MASK \
6717@@ -150,7 +155,7 @@ static inline struct thread_info *current_thread_info(void)
6718 /* work to do on any return to u-space */
6719 #define _TIF_ALLWORK_MASK (_TIF_NOHZ | _TIF_WORK_MASK | \
6720 _TIF_WORK_SYSCALL_EXIT | \
6721- _TIF_SYSCALL_TRACEPOINT)
6722+ _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
6723
6724 /*
6725 * We stash processor id into a COP0 register to retrieve it fast
6726diff --git a/arch/mips/include/asm/uaccess.h b/arch/mips/include/asm/uaccess.h
6727index bf8b324..cec5705 100644
6728--- a/arch/mips/include/asm/uaccess.h
6729+++ b/arch/mips/include/asm/uaccess.h
6730@@ -130,6 +130,7 @@ extern u64 __ua_limit;
6731 __ok == 0; \
6732 })
6733
6734+#define access_ok_noprefault(type, addr, size) access_ok((type), (addr), (size))
6735 #define access_ok(type, addr, size) \
6736 likely(__access_ok((addr), (size), __access_mask))
6737
6738diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
6739index 1188e00..41cf144 100644
6740--- a/arch/mips/kernel/binfmt_elfn32.c
6741+++ b/arch/mips/kernel/binfmt_elfn32.c
6742@@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6743 #undef ELF_ET_DYN_BASE
6744 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6745
6746+#ifdef CONFIG_PAX_ASLR
6747+#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6748+
6749+#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6750+#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6751+#endif
6752+
6753 #include <asm/processor.h>
6754 #include <linux/module.h>
6755 #include <linux/elfcore.h>
6756diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
6757index 9287678..f870e47 100644
6758--- a/arch/mips/kernel/binfmt_elfo32.c
6759+++ b/arch/mips/kernel/binfmt_elfo32.c
6760@@ -70,6 +70,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6761 #undef ELF_ET_DYN_BASE
6762 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6763
6764+#ifdef CONFIG_PAX_ASLR
6765+#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6766+
6767+#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6768+#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6769+#endif
6770+
6771 #include <asm/processor.h>
6772
6773 #include <linux/module.h>
6774diff --git a/arch/mips/kernel/i8259.c b/arch/mips/kernel/i8259.c
6775index a74ec3a..4f06f18 100644
6776--- a/arch/mips/kernel/i8259.c
6777+++ b/arch/mips/kernel/i8259.c
6778@@ -202,7 +202,7 @@ spurious_8259A_irq:
6779 printk(KERN_DEBUG "spurious 8259A interrupt: IRQ%d.\n", irq);
6780 spurious_irq_mask |= irqmask;
6781 }
6782- atomic_inc(&irq_err_count);
6783+ atomic_inc_unchecked(&irq_err_count);
6784 /*
6785 * Theoretically we do not have to handle this IRQ,
6786 * but in Linux this does not cause problems and is
6787diff --git a/arch/mips/kernel/irq-gt641xx.c b/arch/mips/kernel/irq-gt641xx.c
6788index 44a1f79..2bd6aa3 100644
6789--- a/arch/mips/kernel/irq-gt641xx.c
6790+++ b/arch/mips/kernel/irq-gt641xx.c
6791@@ -110,7 +110,7 @@ void gt641xx_irq_dispatch(void)
6792 }
6793 }
6794
6795- atomic_inc(&irq_err_count);
6796+ atomic_inc_unchecked(&irq_err_count);
6797 }
6798
6799 void __init gt641xx_irq_init(void)
6800diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c
6801index 3c8a18a..b4929b6 100644
6802--- a/arch/mips/kernel/irq.c
6803+++ b/arch/mips/kernel/irq.c
6804@@ -76,17 +76,17 @@ void ack_bad_irq(unsigned int irq)
6805 printk("unexpected IRQ # %d\n", irq);
6806 }
6807
6808-atomic_t irq_err_count;
6809+atomic_unchecked_t irq_err_count;
6810
6811 int arch_show_interrupts(struct seq_file *p, int prec)
6812 {
6813- seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
6814+ seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
6815 return 0;
6816 }
6817
6818 asmlinkage void spurious_interrupt(void)
6819 {
6820- atomic_inc(&irq_err_count);
6821+ atomic_inc_unchecked(&irq_err_count);
6822 }
6823
6824 void __init init_IRQ(void)
6825@@ -110,6 +110,8 @@ void __init init_IRQ(void)
6826 }
6827
6828 #ifdef CONFIG_DEBUG_STACKOVERFLOW
6829+
6830+extern void gr_handle_kernel_exploit(void);
6831 static inline void check_stack_overflow(void)
6832 {
6833 unsigned long sp;
6834@@ -125,6 +127,7 @@ static inline void check_stack_overflow(void)
6835 printk("do_IRQ: stack overflow: %ld\n",
6836 sp - sizeof(struct thread_info));
6837 dump_stack();
6838+ gr_handle_kernel_exploit();
6839 }
6840 }
6841 #else
6842diff --git a/arch/mips/kernel/pm-cps.c b/arch/mips/kernel/pm-cps.c
6843index 0614717..002fa43 100644
6844--- a/arch/mips/kernel/pm-cps.c
6845+++ b/arch/mips/kernel/pm-cps.c
6846@@ -172,7 +172,7 @@ int cps_pm_enter_state(enum cps_pm_state state)
6847 nc_core_ready_count = nc_addr;
6848
6849 /* Ensure ready_count is zero-initialised before the assembly runs */
6850- ACCESS_ONCE(*nc_core_ready_count) = 0;
6851+ ACCESS_ONCE_RW(*nc_core_ready_count) = 0;
6852 coupled_barrier(&per_cpu(pm_barrier, core), online);
6853
6854 /* Run the generated entry code */
6855diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
6856index f2975d4..f61d355 100644
6857--- a/arch/mips/kernel/process.c
6858+++ b/arch/mips/kernel/process.c
6859@@ -541,18 +541,6 @@ out:
6860 return pc;
6861 }
6862
6863-/*
6864- * Don't forget that the stack pointer must be aligned on a 8 bytes
6865- * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
6866- */
6867-unsigned long arch_align_stack(unsigned long sp)
6868-{
6869- if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
6870- sp -= get_random_int() & ~PAGE_MASK;
6871-
6872- return sp & ALMASK;
6873-}
6874-
6875 static void arch_dump_stack(void *info)
6876 {
6877 struct pt_regs *regs;
6878diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
6879index e933a30..0d02625 100644
6880--- a/arch/mips/kernel/ptrace.c
6881+++ b/arch/mips/kernel/ptrace.c
6882@@ -785,6 +785,10 @@ long arch_ptrace(struct task_struct *child, long request,
6883 return ret;
6884 }
6885
6886+#ifdef CONFIG_GRKERNSEC_SETXID
6887+extern void gr_delayed_cred_worker(void);
6888+#endif
6889+
6890 /*
6891 * Notification of system call entry/exit
6892 * - triggered by current->work.syscall_trace
6893@@ -803,6 +807,11 @@ asmlinkage long syscall_trace_enter(struct pt_regs *regs, long syscall)
6894 tracehook_report_syscall_entry(regs))
6895 ret = -1;
6896
6897+#ifdef CONFIG_GRKERNSEC_SETXID
6898+ if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6899+ gr_delayed_cred_worker();
6900+#endif
6901+
6902 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
6903 trace_sys_enter(regs, regs->regs[2]);
6904
6905diff --git a/arch/mips/kernel/sync-r4k.c b/arch/mips/kernel/sync-r4k.c
6906index 2242bdd..b284048 100644
6907--- a/arch/mips/kernel/sync-r4k.c
6908+++ b/arch/mips/kernel/sync-r4k.c
6909@@ -18,8 +18,8 @@
6910 #include <asm/mipsregs.h>
6911
6912 static atomic_t count_start_flag = ATOMIC_INIT(0);
6913-static atomic_t count_count_start = ATOMIC_INIT(0);
6914-static atomic_t count_count_stop = ATOMIC_INIT(0);
6915+static atomic_unchecked_t count_count_start = ATOMIC_INIT(0);
6916+static atomic_unchecked_t count_count_stop = ATOMIC_INIT(0);
6917 static atomic_t count_reference = ATOMIC_INIT(0);
6918
6919 #define COUNTON 100
6920@@ -58,13 +58,13 @@ void synchronise_count_master(int cpu)
6921
6922 for (i = 0; i < NR_LOOPS; i++) {
6923 /* slaves loop on '!= 2' */
6924- while (atomic_read(&count_count_start) != 1)
6925+ while (atomic_read_unchecked(&count_count_start) != 1)
6926 mb();
6927- atomic_set(&count_count_stop, 0);
6928+ atomic_set_unchecked(&count_count_stop, 0);
6929 smp_wmb();
6930
6931 /* this lets the slaves write their count register */
6932- atomic_inc(&count_count_start);
6933+ atomic_inc_unchecked(&count_count_start);
6934
6935 /*
6936 * Everyone initialises count in the last loop:
6937@@ -75,11 +75,11 @@ void synchronise_count_master(int cpu)
6938 /*
6939 * Wait for all slaves to leave the synchronization point:
6940 */
6941- while (atomic_read(&count_count_stop) != 1)
6942+ while (atomic_read_unchecked(&count_count_stop) != 1)
6943 mb();
6944- atomic_set(&count_count_start, 0);
6945+ atomic_set_unchecked(&count_count_start, 0);
6946 smp_wmb();
6947- atomic_inc(&count_count_stop);
6948+ atomic_inc_unchecked(&count_count_stop);
6949 }
6950 /* Arrange for an interrupt in a short while */
6951 write_c0_compare(read_c0_count() + COUNTON);
6952@@ -112,8 +112,8 @@ void synchronise_count_slave(int cpu)
6953 initcount = atomic_read(&count_reference);
6954
6955 for (i = 0; i < NR_LOOPS; i++) {
6956- atomic_inc(&count_count_start);
6957- while (atomic_read(&count_count_start) != 2)
6958+ atomic_inc_unchecked(&count_count_start);
6959+ while (atomic_read_unchecked(&count_count_start) != 2)
6960 mb();
6961
6962 /*
6963@@ -122,8 +122,8 @@ void synchronise_count_slave(int cpu)
6964 if (i == NR_LOOPS-1)
6965 write_c0_count(initcount);
6966
6967- atomic_inc(&count_count_stop);
6968- while (atomic_read(&count_count_stop) != 2)
6969+ atomic_inc_unchecked(&count_count_stop);
6970+ while (atomic_read_unchecked(&count_count_stop) != 2)
6971 mb();
6972 }
6973 /* Arrange for an interrupt in a short while */
6974diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
6975index d2d1c19..3e21d8d 100644
6976--- a/arch/mips/kernel/traps.c
6977+++ b/arch/mips/kernel/traps.c
6978@@ -689,7 +689,18 @@ asmlinkage void do_ov(struct pt_regs *regs)
6979 siginfo_t info;
6980
6981 prev_state = exception_enter();
6982- die_if_kernel("Integer overflow", regs);
6983+ if (unlikely(!user_mode(regs))) {
6984+
6985+#ifdef CONFIG_PAX_REFCOUNT
6986+ if (fixup_exception(regs)) {
6987+ pax_report_refcount_overflow(regs);
6988+ exception_exit(prev_state);
6989+ return;
6990+ }
6991+#endif
6992+
6993+ die("Integer overflow", regs);
6994+ }
6995
6996 info.si_code = FPE_INTOVF;
6997 info.si_signo = SIGFPE;
6998diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c
6999index 52f205a..335927c 100644
7000--- a/arch/mips/kvm/mips.c
7001+++ b/arch/mips/kvm/mips.c
7002@@ -1013,7 +1013,7 @@ long kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg)
7003 return r;
7004 }
7005
7006-int kvm_arch_init(void *opaque)
7007+int kvm_arch_init(const void *opaque)
7008 {
7009 if (kvm_mips_callbacks) {
7010 kvm_err("kvm: module already exists\n");
7011diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
7012index 7ff8637..6004edb 100644
7013--- a/arch/mips/mm/fault.c
7014+++ b/arch/mips/mm/fault.c
7015@@ -31,6 +31,23 @@
7016
7017 int show_unhandled_signals = 1;
7018
7019+#ifdef CONFIG_PAX_PAGEEXEC
7020+void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7021+{
7022+ unsigned long i;
7023+
7024+ printk(KERN_ERR "PAX: bytes at PC: ");
7025+ for (i = 0; i < 5; i++) {
7026+ unsigned int c;
7027+ if (get_user(c, (unsigned int *)pc+i))
7028+ printk(KERN_CONT "???????? ");
7029+ else
7030+ printk(KERN_CONT "%08x ", c);
7031+ }
7032+ printk("\n");
7033+}
7034+#endif
7035+
7036 /*
7037 * This routine handles page faults. It determines the address,
7038 * and the problem, and then passes it off to one of the appropriate
7039@@ -206,6 +223,14 @@ bad_area:
7040 bad_area_nosemaphore:
7041 /* User mode accesses just cause a SIGSEGV */
7042 if (user_mode(regs)) {
7043+
7044+#ifdef CONFIG_PAX_PAGEEXEC
7045+ if (cpu_has_rixi && (mm->pax_flags & MF_PAX_PAGEEXEC) && !write && address == instruction_pointer(regs)) {
7046+ pax_report_fault(regs, (void *)address, (void *)user_stack_pointer(regs));
7047+ do_group_exit(SIGKILL);
7048+ }
7049+#endif
7050+
7051 tsk->thread.cp0_badvaddr = address;
7052 tsk->thread.error_code = write;
7053 if (show_unhandled_signals &&
7054diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
7055index 5c81fdd..db158d3 100644
7056--- a/arch/mips/mm/mmap.c
7057+++ b/arch/mips/mm/mmap.c
7058@@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
7059 struct vm_area_struct *vma;
7060 unsigned long addr = addr0;
7061 int do_color_align;
7062+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7063 struct vm_unmapped_area_info info;
7064
7065 if (unlikely(len > TASK_SIZE))
7066@@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
7067 do_color_align = 1;
7068
7069 /* requesting a specific address */
7070+
7071+#ifdef CONFIG_PAX_RANDMMAP
7072+ if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
7073+#endif
7074+
7075 if (addr) {
7076 if (do_color_align)
7077 addr = COLOUR_ALIGN(addr, pgoff);
7078@@ -91,14 +97,14 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
7079 addr = PAGE_ALIGN(addr);
7080
7081 vma = find_vma(mm, addr);
7082- if (TASK_SIZE - len >= addr &&
7083- (!vma || addr + len <= vma->vm_start))
7084+ if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7085 return addr;
7086 }
7087
7088 info.length = len;
7089 info.align_mask = do_color_align ? (PAGE_MASK & shm_align_mask) : 0;
7090 info.align_offset = pgoff << PAGE_SHIFT;
7091+ info.threadstack_offset = offset;
7092
7093 if (dir == DOWN) {
7094 info.flags = VM_UNMAPPED_AREA_TOPDOWN;
7095@@ -160,45 +166,34 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7096 {
7097 unsigned long random_factor = 0UL;
7098
7099+#ifdef CONFIG_PAX_RANDMMAP
7100+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7101+#endif
7102+
7103 if (current->flags & PF_RANDOMIZE)
7104 random_factor = arch_mmap_rnd();
7105
7106 if (mmap_is_legacy()) {
7107 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
7108+
7109+#ifdef CONFIG_PAX_RANDMMAP
7110+ if (mm->pax_flags & MF_PAX_RANDMMAP)
7111+ mm->mmap_base += mm->delta_mmap;
7112+#endif
7113+
7114 mm->get_unmapped_area = arch_get_unmapped_area;
7115 } else {
7116 mm->mmap_base = mmap_base(random_factor);
7117+
7118+#ifdef CONFIG_PAX_RANDMMAP
7119+ if (mm->pax_flags & MF_PAX_RANDMMAP)
7120+ mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7121+#endif
7122+
7123 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7124 }
7125 }
7126
7127-static inline unsigned long brk_rnd(void)
7128-{
7129- unsigned long rnd = get_random_int();
7130-
7131- rnd = rnd << PAGE_SHIFT;
7132- /* 8MB for 32bit, 256MB for 64bit */
7133- if (TASK_IS_32BIT_ADDR)
7134- rnd = rnd & 0x7ffffful;
7135- else
7136- rnd = rnd & 0xffffffful;
7137-
7138- return rnd;
7139-}
7140-
7141-unsigned long arch_randomize_brk(struct mm_struct *mm)
7142-{
7143- unsigned long base = mm->brk;
7144- unsigned long ret;
7145-
7146- ret = PAGE_ALIGN(base + brk_rnd());
7147-
7148- if (ret < mm->brk)
7149- return mm->brk;
7150-
7151- return ret;
7152-}
7153-
7154 int __virt_addr_valid(const volatile void *kaddr)
7155 {
7156 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
7157diff --git a/arch/mips/sgi-ip27/ip27-nmi.c b/arch/mips/sgi-ip27/ip27-nmi.c
7158index a2358b4..7cead4f 100644
7159--- a/arch/mips/sgi-ip27/ip27-nmi.c
7160+++ b/arch/mips/sgi-ip27/ip27-nmi.c
7161@@ -187,9 +187,9 @@ void
7162 cont_nmi_dump(void)
7163 {
7164 #ifndef REAL_NMI_SIGNAL
7165- static atomic_t nmied_cpus = ATOMIC_INIT(0);
7166+ static atomic_unchecked_t nmied_cpus = ATOMIC_INIT(0);
7167
7168- atomic_inc(&nmied_cpus);
7169+ atomic_inc_unchecked(&nmied_cpus);
7170 #endif
7171 /*
7172 * Only allow 1 cpu to proceed
7173@@ -233,7 +233,7 @@ cont_nmi_dump(void)
7174 udelay(10000);
7175 }
7176 #else
7177- while (atomic_read(&nmied_cpus) != num_online_cpus());
7178+ while (atomic_read_unchecked(&nmied_cpus) != num_online_cpus());
7179 #endif
7180
7181 /*
7182diff --git a/arch/mips/sni/rm200.c b/arch/mips/sni/rm200.c
7183index a046b30..6799527 100644
7184--- a/arch/mips/sni/rm200.c
7185+++ b/arch/mips/sni/rm200.c
7186@@ -270,7 +270,7 @@ spurious_8259A_irq:
7187 "spurious RM200 8259A interrupt: IRQ%d.\n", irq);
7188 spurious_irq_mask |= irqmask;
7189 }
7190- atomic_inc(&irq_err_count);
7191+ atomic_inc_unchecked(&irq_err_count);
7192 /*
7193 * Theoretically we do not have to handle this IRQ,
7194 * but in Linux this does not cause problems and is
7195diff --git a/arch/mips/vr41xx/common/icu.c b/arch/mips/vr41xx/common/icu.c
7196index 41e873b..34d33a7 100644
7197--- a/arch/mips/vr41xx/common/icu.c
7198+++ b/arch/mips/vr41xx/common/icu.c
7199@@ -653,7 +653,7 @@ static int icu_get_irq(unsigned int irq)
7200
7201 printk(KERN_ERR "spurious ICU interrupt: %04x,%04x\n", pend1, pend2);
7202
7203- atomic_inc(&irq_err_count);
7204+ atomic_inc_unchecked(&irq_err_count);
7205
7206 return -1;
7207 }
7208diff --git a/arch/mips/vr41xx/common/irq.c b/arch/mips/vr41xx/common/irq.c
7209index ae0e4ee..e8f0692 100644
7210--- a/arch/mips/vr41xx/common/irq.c
7211+++ b/arch/mips/vr41xx/common/irq.c
7212@@ -64,7 +64,7 @@ static void irq_dispatch(unsigned int irq)
7213 irq_cascade_t *cascade;
7214
7215 if (irq >= NR_IRQS) {
7216- atomic_inc(&irq_err_count);
7217+ atomic_inc_unchecked(&irq_err_count);
7218 return;
7219 }
7220
7221@@ -84,7 +84,7 @@ static void irq_dispatch(unsigned int irq)
7222 ret = cascade->get_irq(irq);
7223 irq = ret;
7224 if (ret < 0)
7225- atomic_inc(&irq_err_count);
7226+ atomic_inc_unchecked(&irq_err_count);
7227 else
7228 irq_dispatch(irq);
7229 if (!irqd_irq_disabled(idata) && chip->irq_unmask)
7230diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
7231index 967d144..db12197 100644
7232--- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
7233+++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
7234@@ -11,12 +11,14 @@
7235 #ifndef _ASM_PROC_CACHE_H
7236 #define _ASM_PROC_CACHE_H
7237
7238+#include <linux/const.h>
7239+
7240 /* L1 cache */
7241
7242 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
7243 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
7244-#define L1_CACHE_BYTES 16 /* bytes per entry */
7245 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
7246+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
7247 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
7248
7249 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
7250diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
7251index bcb5df2..84fabd2 100644
7252--- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
7253+++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
7254@@ -16,13 +16,15 @@
7255 #ifndef _ASM_PROC_CACHE_H
7256 #define _ASM_PROC_CACHE_H
7257
7258+#include <linux/const.h>
7259+
7260 /*
7261 * L1 cache
7262 */
7263 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
7264 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
7265-#define L1_CACHE_BYTES 32 /* bytes per entry */
7266 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
7267+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
7268 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
7269
7270 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
7271diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
7272index 4ce7a01..449202a 100644
7273--- a/arch/openrisc/include/asm/cache.h
7274+++ b/arch/openrisc/include/asm/cache.h
7275@@ -19,11 +19,13 @@
7276 #ifndef __ASM_OPENRISC_CACHE_H
7277 #define __ASM_OPENRISC_CACHE_H
7278
7279+#include <linux/const.h>
7280+
7281 /* FIXME: How can we replace these with values from the CPU...
7282 * they shouldn't be hard-coded!
7283 */
7284
7285-#define L1_CACHE_BYTES 16
7286 #define L1_CACHE_SHIFT 4
7287+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7288
7289 #endif /* __ASM_OPENRISC_CACHE_H */
7290diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
7291index 226f8ca9..9d9b87d 100644
7292--- a/arch/parisc/include/asm/atomic.h
7293+++ b/arch/parisc/include/asm/atomic.h
7294@@ -273,6 +273,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
7295 return dec;
7296 }
7297
7298+#define atomic64_read_unchecked(v) atomic64_read(v)
7299+#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7300+#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7301+#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7302+#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7303+#define atomic64_inc_unchecked(v) atomic64_inc(v)
7304+#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7305+#define atomic64_dec_unchecked(v) atomic64_dec(v)
7306+#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7307+
7308 #endif /* !CONFIG_64BIT */
7309
7310
7311diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
7312index 47f11c7..3420df2 100644
7313--- a/arch/parisc/include/asm/cache.h
7314+++ b/arch/parisc/include/asm/cache.h
7315@@ -5,6 +5,7 @@
7316 #ifndef __ARCH_PARISC_CACHE_H
7317 #define __ARCH_PARISC_CACHE_H
7318
7319+#include <linux/const.h>
7320
7321 /*
7322 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
7323@@ -15,13 +16,13 @@
7324 * just ruin performance.
7325 */
7326 #ifdef CONFIG_PA20
7327-#define L1_CACHE_BYTES 64
7328 #define L1_CACHE_SHIFT 6
7329 #else
7330-#define L1_CACHE_BYTES 32
7331 #define L1_CACHE_SHIFT 5
7332 #endif
7333
7334+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7335+
7336 #ifndef __ASSEMBLY__
7337
7338 #define SMP_CACHE_BYTES L1_CACHE_BYTES
7339diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
7340index 78c9fd3..42fa66a 100644
7341--- a/arch/parisc/include/asm/elf.h
7342+++ b/arch/parisc/include/asm/elf.h
7343@@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
7344
7345 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
7346
7347+#ifdef CONFIG_PAX_ASLR
7348+#define PAX_ELF_ET_DYN_BASE 0x10000UL
7349+
7350+#define PAX_DELTA_MMAP_LEN 16
7351+#define PAX_DELTA_STACK_LEN 16
7352+#endif
7353+
7354 /* This yields a mask that user programs can use to figure out what
7355 instruction set this CPU supports. This could be done in user space,
7356 but it's not easy, and we've already done it here. */
7357diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
7358index 3a08eae..08fef28 100644
7359--- a/arch/parisc/include/asm/pgalloc.h
7360+++ b/arch/parisc/include/asm/pgalloc.h
7361@@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7362 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
7363 }
7364
7365+static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7366+{
7367+ pgd_populate(mm, pgd, pmd);
7368+}
7369+
7370 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
7371 {
7372 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
7373@@ -72,7 +77,7 @@ static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
7374
7375 static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
7376 {
7377- if(pmd_flag(*pmd) & PxD_FLAG_ATTACHED)
7378+ if (pmd_flag(*pmd) & PxD_FLAG_ATTACHED) {
7379 /*
7380 * This is the permanent pmd attached to the pgd;
7381 * cannot free it.
7382@@ -81,6 +86,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
7383 */
7384 mm_inc_nr_pmds(mm);
7385 return;
7386+ }
7387 free_pages((unsigned long)pmd, PMD_ORDER);
7388 }
7389
7390@@ -96,6 +102,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
7391 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
7392 #define pmd_free(mm, x) do { } while (0)
7393 #define pgd_populate(mm, pmd, pte) BUG()
7394+#define pgd_populate_kernel(mm, pmd, pte) BUG()
7395
7396 #endif
7397
7398diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
7399index 0a18375..d613939 100644
7400--- a/arch/parisc/include/asm/pgtable.h
7401+++ b/arch/parisc/include/asm/pgtable.h
7402@@ -213,6 +213,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
7403 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
7404 #define PAGE_COPY PAGE_EXECREAD
7405 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
7406+
7407+#ifdef CONFIG_PAX_PAGEEXEC
7408+# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
7409+# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7410+# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7411+#else
7412+# define PAGE_SHARED_NOEXEC PAGE_SHARED
7413+# define PAGE_COPY_NOEXEC PAGE_COPY
7414+# define PAGE_READONLY_NOEXEC PAGE_READONLY
7415+#endif
7416+
7417 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
7418 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
7419 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
7420diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
7421index 0abdd4c..1af92f0 100644
7422--- a/arch/parisc/include/asm/uaccess.h
7423+++ b/arch/parisc/include/asm/uaccess.h
7424@@ -243,10 +243,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
7425 const void __user *from,
7426 unsigned long n)
7427 {
7428- int sz = __compiletime_object_size(to);
7429+ size_t sz = __compiletime_object_size(to);
7430 int ret = -EFAULT;
7431
7432- if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
7433+ if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
7434 ret = __copy_from_user(to, from, n);
7435 else
7436 copy_from_user_overflow();
7437diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
7438index 3c63a82..b1d6ee9 100644
7439--- a/arch/parisc/kernel/module.c
7440+++ b/arch/parisc/kernel/module.c
7441@@ -98,16 +98,38 @@
7442
7443 /* three functions to determine where in the module core
7444 * or init pieces the location is */
7445+static inline int in_init_rx(struct module *me, void *loc)
7446+{
7447+ return (loc >= me->module_init_rx &&
7448+ loc < (me->module_init_rx + me->init_size_rx));
7449+}
7450+
7451+static inline int in_init_rw(struct module *me, void *loc)
7452+{
7453+ return (loc >= me->module_init_rw &&
7454+ loc < (me->module_init_rw + me->init_size_rw));
7455+}
7456+
7457 static inline int in_init(struct module *me, void *loc)
7458 {
7459- return (loc >= me->module_init &&
7460- loc <= (me->module_init + me->init_size));
7461+ return in_init_rx(me, loc) || in_init_rw(me, loc);
7462+}
7463+
7464+static inline int in_core_rx(struct module *me, void *loc)
7465+{
7466+ return (loc >= me->module_core_rx &&
7467+ loc < (me->module_core_rx + me->core_size_rx));
7468+}
7469+
7470+static inline int in_core_rw(struct module *me, void *loc)
7471+{
7472+ return (loc >= me->module_core_rw &&
7473+ loc < (me->module_core_rw + me->core_size_rw));
7474 }
7475
7476 static inline int in_core(struct module *me, void *loc)
7477 {
7478- return (loc >= me->module_core &&
7479- loc <= (me->module_core + me->core_size));
7480+ return in_core_rx(me, loc) || in_core_rw(me, loc);
7481 }
7482
7483 static inline int in_local(struct module *me, void *loc)
7484@@ -367,13 +389,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
7485 }
7486
7487 /* align things a bit */
7488- me->core_size = ALIGN(me->core_size, 16);
7489- me->arch.got_offset = me->core_size;
7490- me->core_size += gots * sizeof(struct got_entry);
7491+ me->core_size_rw = ALIGN(me->core_size_rw, 16);
7492+ me->arch.got_offset = me->core_size_rw;
7493+ me->core_size_rw += gots * sizeof(struct got_entry);
7494
7495- me->core_size = ALIGN(me->core_size, 16);
7496- me->arch.fdesc_offset = me->core_size;
7497- me->core_size += fdescs * sizeof(Elf_Fdesc);
7498+ me->core_size_rw = ALIGN(me->core_size_rw, 16);
7499+ me->arch.fdesc_offset = me->core_size_rw;
7500+ me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
7501
7502 me->arch.got_max = gots;
7503 me->arch.fdesc_max = fdescs;
7504@@ -391,7 +413,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7505
7506 BUG_ON(value == 0);
7507
7508- got = me->module_core + me->arch.got_offset;
7509+ got = me->module_core_rw + me->arch.got_offset;
7510 for (i = 0; got[i].addr; i++)
7511 if (got[i].addr == value)
7512 goto out;
7513@@ -409,7 +431,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7514 #ifdef CONFIG_64BIT
7515 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7516 {
7517- Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
7518+ Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
7519
7520 if (!value) {
7521 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
7522@@ -427,7 +449,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7523
7524 /* Create new one */
7525 fdesc->addr = value;
7526- fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7527+ fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7528 return (Elf_Addr)fdesc;
7529 }
7530 #endif /* CONFIG_64BIT */
7531@@ -839,7 +861,7 @@ register_unwind_table(struct module *me,
7532
7533 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
7534 end = table + sechdrs[me->arch.unwind_section].sh_size;
7535- gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7536+ gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7537
7538 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
7539 me->arch.unwind_section, table, end, gp);
7540diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
7541index 5aba01a..47cdd5a 100644
7542--- a/arch/parisc/kernel/sys_parisc.c
7543+++ b/arch/parisc/kernel/sys_parisc.c
7544@@ -92,6 +92,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7545 unsigned long task_size = TASK_SIZE;
7546 int do_color_align, last_mmap;
7547 struct vm_unmapped_area_info info;
7548+ unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7549
7550 if (len > task_size)
7551 return -ENOMEM;
7552@@ -109,6 +110,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7553 goto found_addr;
7554 }
7555
7556+#ifdef CONFIG_PAX_RANDMMAP
7557+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7558+#endif
7559+
7560 if (addr) {
7561 if (do_color_align && last_mmap)
7562 addr = COLOR_ALIGN(addr, last_mmap, pgoff);
7563@@ -127,6 +132,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7564 info.high_limit = mmap_upper_limit();
7565 info.align_mask = last_mmap ? (PAGE_MASK & (SHM_COLOUR - 1)) : 0;
7566 info.align_offset = shared_align_offset(last_mmap, pgoff);
7567+ info.threadstack_offset = offset;
7568 addr = vm_unmapped_area(&info);
7569
7570 found_addr:
7571@@ -146,6 +152,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7572 unsigned long addr = addr0;
7573 int do_color_align, last_mmap;
7574 struct vm_unmapped_area_info info;
7575+ unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7576
7577 #ifdef CONFIG_64BIT
7578 /* This should only ever run for 32-bit processes. */
7579@@ -170,6 +177,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7580 }
7581
7582 /* requesting a specific address */
7583+#ifdef CONFIG_PAX_RANDMMAP
7584+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7585+#endif
7586+
7587 if (addr) {
7588 if (do_color_align && last_mmap)
7589 addr = COLOR_ALIGN(addr, last_mmap, pgoff);
7590@@ -187,6 +198,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7591 info.high_limit = mm->mmap_base;
7592 info.align_mask = last_mmap ? (PAGE_MASK & (SHM_COLOUR - 1)) : 0;
7593 info.align_offset = shared_align_offset(last_mmap, pgoff);
7594+ info.threadstack_offset = offset;
7595 addr = vm_unmapped_area(&info);
7596 if (!(addr & ~PAGE_MASK))
7597 goto found_addr;
7598@@ -252,6 +264,13 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7599 mm->mmap_legacy_base = mmap_legacy_base();
7600 mm->mmap_base = mmap_upper_limit();
7601
7602+#ifdef CONFIG_PAX_RANDMMAP
7603+ if (mm->pax_flags & MF_PAX_RANDMMAP) {
7604+ mm->mmap_legacy_base += mm->delta_mmap;
7605+ mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7606+ }
7607+#endif
7608+
7609 if (mmap_is_legacy()) {
7610 mm->mmap_base = mm->mmap_legacy_base;
7611 mm->get_unmapped_area = arch_get_unmapped_area;
7612diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
7613index 47ee620..1107387 100644
7614--- a/arch/parisc/kernel/traps.c
7615+++ b/arch/parisc/kernel/traps.c
7616@@ -726,9 +726,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
7617
7618 down_read(&current->mm->mmap_sem);
7619 vma = find_vma(current->mm,regs->iaoq[0]);
7620- if (vma && (regs->iaoq[0] >= vma->vm_start)
7621- && (vma->vm_flags & VM_EXEC)) {
7622-
7623+ if (vma && (regs->iaoq[0] >= vma->vm_start)) {
7624 fault_address = regs->iaoq[0];
7625 fault_space = regs->iasq[0];
7626
7627diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
7628index e5120e6..8ddb5cc 100644
7629--- a/arch/parisc/mm/fault.c
7630+++ b/arch/parisc/mm/fault.c
7631@@ -15,6 +15,7 @@
7632 #include <linux/sched.h>
7633 #include <linux/interrupt.h>
7634 #include <linux/module.h>
7635+#include <linux/unistd.h>
7636
7637 #include <asm/uaccess.h>
7638 #include <asm/traps.h>
7639@@ -50,7 +51,7 @@ int show_unhandled_signals = 1;
7640 static unsigned long
7641 parisc_acctyp(unsigned long code, unsigned int inst)
7642 {
7643- if (code == 6 || code == 16)
7644+ if (code == 6 || code == 7 || code == 16)
7645 return VM_EXEC;
7646
7647 switch (inst & 0xf0000000) {
7648@@ -136,6 +137,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
7649 }
7650 #endif
7651
7652+#ifdef CONFIG_PAX_PAGEEXEC
7653+/*
7654+ * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
7655+ *
7656+ * returns 1 when task should be killed
7657+ * 2 when rt_sigreturn trampoline was detected
7658+ * 3 when unpatched PLT trampoline was detected
7659+ */
7660+static int pax_handle_fetch_fault(struct pt_regs *regs)
7661+{
7662+
7663+#ifdef CONFIG_PAX_EMUPLT
7664+ int err;
7665+
7666+ do { /* PaX: unpatched PLT emulation */
7667+ unsigned int bl, depwi;
7668+
7669+ err = get_user(bl, (unsigned int *)instruction_pointer(regs));
7670+ err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
7671+
7672+ if (err)
7673+ break;
7674+
7675+ if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
7676+ unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
7677+
7678+ err = get_user(ldw, (unsigned int *)addr);
7679+ err |= get_user(bv, (unsigned int *)(addr+4));
7680+ err |= get_user(ldw2, (unsigned int *)(addr+8));
7681+
7682+ if (err)
7683+ break;
7684+
7685+ if (ldw == 0x0E801096U &&
7686+ bv == 0xEAC0C000U &&
7687+ ldw2 == 0x0E881095U)
7688+ {
7689+ unsigned int resolver, map;
7690+
7691+ err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
7692+ err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
7693+ if (err)
7694+ break;
7695+
7696+ regs->gr[20] = instruction_pointer(regs)+8;
7697+ regs->gr[21] = map;
7698+ regs->gr[22] = resolver;
7699+ regs->iaoq[0] = resolver | 3UL;
7700+ regs->iaoq[1] = regs->iaoq[0] + 4;
7701+ return 3;
7702+ }
7703+ }
7704+ } while (0);
7705+#endif
7706+
7707+#ifdef CONFIG_PAX_EMUTRAMP
7708+
7709+#ifndef CONFIG_PAX_EMUSIGRT
7710+ if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
7711+ return 1;
7712+#endif
7713+
7714+ do { /* PaX: rt_sigreturn emulation */
7715+ unsigned int ldi1, ldi2, bel, nop;
7716+
7717+ err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
7718+ err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
7719+ err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
7720+ err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
7721+
7722+ if (err)
7723+ break;
7724+
7725+ if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
7726+ ldi2 == 0x3414015AU &&
7727+ bel == 0xE4008200U &&
7728+ nop == 0x08000240U)
7729+ {
7730+ regs->gr[25] = (ldi1 & 2) >> 1;
7731+ regs->gr[20] = __NR_rt_sigreturn;
7732+ regs->gr[31] = regs->iaoq[1] + 16;
7733+ regs->sr[0] = regs->iasq[1];
7734+ regs->iaoq[0] = 0x100UL;
7735+ regs->iaoq[1] = regs->iaoq[0] + 4;
7736+ regs->iasq[0] = regs->sr[2];
7737+ regs->iasq[1] = regs->sr[2];
7738+ return 2;
7739+ }
7740+ } while (0);
7741+#endif
7742+
7743+ return 1;
7744+}
7745+
7746+void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7747+{
7748+ unsigned long i;
7749+
7750+ printk(KERN_ERR "PAX: bytes at PC: ");
7751+ for (i = 0; i < 5; i++) {
7752+ unsigned int c;
7753+ if (get_user(c, (unsigned int *)pc+i))
7754+ printk(KERN_CONT "???????? ");
7755+ else
7756+ printk(KERN_CONT "%08x ", c);
7757+ }
7758+ printk("\n");
7759+}
7760+#endif
7761+
7762 int fixup_exception(struct pt_regs *regs)
7763 {
7764 const struct exception_table_entry *fix;
7765@@ -234,8 +345,33 @@ retry:
7766
7767 good_area:
7768
7769- if ((vma->vm_flags & acc_type) != acc_type)
7770+ if ((vma->vm_flags & acc_type) != acc_type) {
7771+
7772+#ifdef CONFIG_PAX_PAGEEXEC
7773+ if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
7774+ (address & ~3UL) == instruction_pointer(regs))
7775+ {
7776+ up_read(&mm->mmap_sem);
7777+ switch (pax_handle_fetch_fault(regs)) {
7778+
7779+#ifdef CONFIG_PAX_EMUPLT
7780+ case 3:
7781+ return;
7782+#endif
7783+
7784+#ifdef CONFIG_PAX_EMUTRAMP
7785+ case 2:
7786+ return;
7787+#endif
7788+
7789+ }
7790+ pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
7791+ do_group_exit(SIGKILL);
7792+ }
7793+#endif
7794+
7795 goto bad_area;
7796+ }
7797
7798 /*
7799 * If for any reason at all we couldn't handle the fault, make
7800diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
7801index 190cc48..48439ce 100644
7802--- a/arch/powerpc/Kconfig
7803+++ b/arch/powerpc/Kconfig
7804@@ -413,6 +413,7 @@ config PPC64_SUPPORTS_MEMORY_FAILURE
7805 config KEXEC
7806 bool "kexec system call"
7807 depends on (PPC_BOOK3S || FSL_BOOKE || (44x && !SMP))
7808+ depends on !GRKERNSEC_KMEM
7809 help
7810 kexec is a system call that implements the ability to shutdown your
7811 current kernel, and to start another kernel. It is like a reboot
7812diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
7813index 512d278..d31fadd 100644
7814--- a/arch/powerpc/include/asm/atomic.h
7815+++ b/arch/powerpc/include/asm/atomic.h
7816@@ -12,6 +12,11 @@
7817
7818 #define ATOMIC_INIT(i) { (i) }
7819
7820+#define _ASM_EXTABLE(from, to) \
7821+" .section __ex_table,\"a\"\n" \
7822+ PPC_LONG" " #from ", " #to"\n" \
7823+" .previous\n"
7824+
7825 static __inline__ int atomic_read(const atomic_t *v)
7826 {
7827 int t;
7828@@ -21,39 +26,80 @@ static __inline__ int atomic_read(const atomic_t *v)
7829 return t;
7830 }
7831
7832+static __inline__ int atomic_read_unchecked(const atomic_unchecked_t *v)
7833+{
7834+ int t;
7835+
7836+ __asm__ __volatile__("lwz%U1%X1 %0,%1" : "=r"(t) : "m"(v->counter));
7837+
7838+ return t;
7839+}
7840+
7841 static __inline__ void atomic_set(atomic_t *v, int i)
7842 {
7843 __asm__ __volatile__("stw%U0%X0 %1,%0" : "=m"(v->counter) : "r"(i));
7844 }
7845
7846-#define ATOMIC_OP(op, asm_op) \
7847-static __inline__ void atomic_##op(int a, atomic_t *v) \
7848+static __inline__ void atomic_set_unchecked(atomic_unchecked_t *v, int i)
7849+{
7850+ __asm__ __volatile__("stw%U0%X0 %1,%0" : "=m"(v->counter) : "r"(i));
7851+}
7852+
7853+#ifdef CONFIG_PAX_REFCOUNT
7854+#define __REFCOUNT_OP(op) op##o.
7855+#define __OVERFLOW_PRE \
7856+ " mcrxr cr0\n"
7857+#define __OVERFLOW_POST \
7858+ " bf 4*cr0+so, 3f\n" \
7859+ "2: .long 0x00c00b00\n" \
7860+ "3:\n"
7861+#define __OVERFLOW_EXTABLE \
7862+ "\n4:\n"
7863+ _ASM_EXTABLE(2b, 4b)
7864+#else
7865+#define __REFCOUNT_OP(op) op
7866+#define __OVERFLOW_PRE
7867+#define __OVERFLOW_POST
7868+#define __OVERFLOW_EXTABLE
7869+#endif
7870+
7871+#define __ATOMIC_OP(op, suffix, pre_op, asm_op, post_op, extable) \
7872+static inline void atomic_##op##suffix(int a, atomic##suffix##_t *v) \
7873 { \
7874 int t; \
7875 \
7876 __asm__ __volatile__( \
7877-"1: lwarx %0,0,%3 # atomic_" #op "\n" \
7878+"1: lwarx %0,0,%3 # atomic_" #op #suffix "\n" \
7879+ pre_op \
7880 #asm_op " %0,%2,%0\n" \
7881+ post_op \
7882 PPC405_ERR77(0,%3) \
7883 " stwcx. %0,0,%3 \n" \
7884 " bne- 1b\n" \
7885+ extable \
7886 : "=&r" (t), "+m" (v->counter) \
7887 : "r" (a), "r" (&v->counter) \
7888 : "cc"); \
7889 } \
7890
7891-#define ATOMIC_OP_RETURN(op, asm_op) \
7892-static __inline__ int atomic_##op##_return(int a, atomic_t *v) \
7893+#define ATOMIC_OP(op, asm_op) __ATOMIC_OP(op, , , asm_op, , ) \
7894+ __ATOMIC_OP(op, _unchecked, __OVERFLOW_PRE, __REFCOUNT_OP(asm_op), __OVERFLOW_POST, __OVERFLOW_EXTABLE)
7895+
7896+#define __ATOMIC_OP_RETURN(op, suffix, pre_op, asm_op, post_op, extable)\
7897+static inline int atomic_##op##_return##suffix(int a, atomic##suffix##_t *v)\
7898 { \
7899 int t; \
7900 \
7901 __asm__ __volatile__( \
7902 PPC_ATOMIC_ENTRY_BARRIER \
7903-"1: lwarx %0,0,%2 # atomic_" #op "_return\n" \
7904+"1: lwarx %0,0,%2 # atomic_" #op "_return" #suffix "\n" \
7905+ pre_op \
7906 #asm_op " %0,%1,%0\n" \
7907+ post_op \
7908 PPC405_ERR77(0,%2) \
7909 " stwcx. %0,0,%2 \n" \
7910 " bne- 1b\n" \
7911+ extable \
7912 PPC_ATOMIC_EXIT_BARRIER \
7913 : "=&r" (t) \
7914 : "r" (a), "r" (&v->counter) \
7915@@ -62,6 +108,9 @@ static __inline__ int atomic_##op##_return(int a, atomic_t *v) \
7916 return t; \
7917 }
7918
7919+#define ATOMIC_OP_RETURN(op, asm_op) __ATOMIC_OP_RETURN(op, , , asm_op, , )\
7920+ __ATOMIC_OP_RETURN(op, _unchecked, __OVERFLOW_PRE, __REFCOUNT_OP(asm_op), __OVERFLOW_POST, __OVERFLOW_EXTABLE)
7921+
7922 #define ATOMIC_OPS(op, asm_op) ATOMIC_OP(op, asm_op) ATOMIC_OP_RETURN(op, asm_op)
7923
7924 ATOMIC_OPS(add, add)
7925@@ -69,42 +118,29 @@ ATOMIC_OPS(sub, subf)
7926
7927 #undef ATOMIC_OPS
7928 #undef ATOMIC_OP_RETURN
7929+#undef __ATOMIC_OP_RETURN
7930 #undef ATOMIC_OP
7931+#undef __ATOMIC_OP
7932
7933 #define atomic_add_negative(a, v) (atomic_add_return((a), (v)) < 0)
7934
7935-static __inline__ void atomic_inc(atomic_t *v)
7936-{
7937- int t;
7938+/*
7939+ * atomic_inc - increment atomic variable
7940+ * @v: pointer of type atomic_t
7941+ *
7942+ * Automatically increments @v by 1
7943+ */
7944+#define atomic_inc(v) atomic_add(1, (v))
7945+#define atomic_inc_return(v) atomic_add_return(1, (v))
7946
7947- __asm__ __volatile__(
7948-"1: lwarx %0,0,%2 # atomic_inc\n\
7949- addic %0,%0,1\n"
7950- PPC405_ERR77(0,%2)
7951-" stwcx. %0,0,%2 \n\
7952- bne- 1b"
7953- : "=&r" (t), "+m" (v->counter)
7954- : "r" (&v->counter)
7955- : "cc", "xer");
7956+static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
7957+{
7958+ atomic_add_unchecked(1, v);
7959 }
7960
7961-static __inline__ int atomic_inc_return(atomic_t *v)
7962+static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
7963 {
7964- int t;
7965-
7966- __asm__ __volatile__(
7967- PPC_ATOMIC_ENTRY_BARRIER
7968-"1: lwarx %0,0,%1 # atomic_inc_return\n\
7969- addic %0,%0,1\n"
7970- PPC405_ERR77(0,%1)
7971-" stwcx. %0,0,%1 \n\
7972- bne- 1b"
7973- PPC_ATOMIC_EXIT_BARRIER
7974- : "=&r" (t)
7975- : "r" (&v->counter)
7976- : "cc", "xer", "memory");
7977-
7978- return t;
7979+ return atomic_add_return_unchecked(1, v);
7980 }
7981
7982 /*
7983@@ -117,43 +153,38 @@ static __inline__ int atomic_inc_return(atomic_t *v)
7984 */
7985 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
7986
7987-static __inline__ void atomic_dec(atomic_t *v)
7988+static __inline__ int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
7989 {
7990- int t;
7991-
7992- __asm__ __volatile__(
7993-"1: lwarx %0,0,%2 # atomic_dec\n\
7994- addic %0,%0,-1\n"
7995- PPC405_ERR77(0,%2)\
7996-" stwcx. %0,0,%2\n\
7997- bne- 1b"
7998- : "=&r" (t), "+m" (v->counter)
7999- : "r" (&v->counter)
8000- : "cc", "xer");
8001+ return atomic_add_return_unchecked(1, v) == 0;
8002 }
8003
8004-static __inline__ int atomic_dec_return(atomic_t *v)
8005+/*
8006+ * atomic_dec - decrement atomic variable
8007+ * @v: pointer of type atomic_t
8008+ *
8009+ * Atomically decrements @v by 1
8010+ */
8011+#define atomic_dec(v) atomic_sub(1, (v))
8012+#define atomic_dec_return(v) atomic_sub_return(1, (v))
8013+
8014+static __inline__ void atomic_dec_unchecked(atomic_unchecked_t *v)
8015 {
8016- int t;
8017-
8018- __asm__ __volatile__(
8019- PPC_ATOMIC_ENTRY_BARRIER
8020-"1: lwarx %0,0,%1 # atomic_dec_return\n\
8021- addic %0,%0,-1\n"
8022- PPC405_ERR77(0,%1)
8023-" stwcx. %0,0,%1\n\
8024- bne- 1b"
8025- PPC_ATOMIC_EXIT_BARRIER
8026- : "=&r" (t)
8027- : "r" (&v->counter)
8028- : "cc", "xer", "memory");
8029-
8030- return t;
8031+ atomic_sub_unchecked(1, v);
8032 }
8033
8034 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
8035 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
8036
8037+static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
8038+{
8039+ return cmpxchg(&(v->counter), old, new);
8040+}
8041+
8042+static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
8043+{
8044+ return xchg(&(v->counter), new);
8045+}
8046+
8047 /**
8048 * __atomic_add_unless - add unless the number is a given value
8049 * @v: pointer of type atomic_t
8050@@ -171,11 +202,27 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
8051 PPC_ATOMIC_ENTRY_BARRIER
8052 "1: lwarx %0,0,%1 # __atomic_add_unless\n\
8053 cmpw 0,%0,%3 \n\
8054- beq- 2f \n\
8055- add %0,%2,%0 \n"
8056+ beq- 2f \n"
8057+
8058+#ifdef CONFIG_PAX_REFCOUNT
8059+" mcrxr cr0\n"
8060+" addo. %0,%2,%0\n"
8061+" bf 4*cr0+so, 4f\n"
8062+"3:.long " "0x00c00b00""\n"
8063+"4:\n"
8064+#else
8065+ "add %0,%2,%0 \n"
8066+#endif
8067+
8068 PPC405_ERR77(0,%2)
8069 " stwcx. %0,0,%1 \n\
8070 bne- 1b \n"
8071+"5:"
8072+
8073+#ifdef CONFIG_PAX_REFCOUNT
8074+ _ASM_EXTABLE(3b, 5b)
8075+#endif
8076+
8077 PPC_ATOMIC_EXIT_BARRIER
8078 " subf %0,%2,%0 \n\
8079 2:"
8080@@ -248,6 +295,11 @@ static __inline__ int atomic_dec_if_positive(atomic_t *v)
8081 }
8082 #define atomic_dec_if_positive atomic_dec_if_positive
8083
8084+#define smp_mb__before_atomic_dec() smp_mb()
8085+#define smp_mb__after_atomic_dec() smp_mb()
8086+#define smp_mb__before_atomic_inc() smp_mb()
8087+#define smp_mb__after_atomic_inc() smp_mb()
8088+
8089 #ifdef __powerpc64__
8090
8091 #define ATOMIC64_INIT(i) { (i) }
8092@@ -261,37 +313,60 @@ static __inline__ long atomic64_read(const atomic64_t *v)
8093 return t;
8094 }
8095
8096+static __inline__ long atomic64_read_unchecked(const atomic64_unchecked_t *v)
8097+{
8098+ long t;
8099+
8100+ __asm__ __volatile__("ld%U1%X1 %0,%1" : "=r"(t) : "m"(v->counter));
8101+
8102+ return t;
8103+}
8104+
8105 static __inline__ void atomic64_set(atomic64_t *v, long i)
8106 {
8107 __asm__ __volatile__("std%U0%X0 %1,%0" : "=m"(v->counter) : "r"(i));
8108 }
8109
8110-#define ATOMIC64_OP(op, asm_op) \
8111-static __inline__ void atomic64_##op(long a, atomic64_t *v) \
8112+static __inline__ void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
8113+{
8114+ __asm__ __volatile__("std%U0%X0 %1,%0" : "=m"(v->counter) : "r"(i));
8115+}
8116+
8117+#define __ATOMIC64_OP(op, suffix, pre_op, asm_op, post_op, extable) \
8118+static inline void atomic64_##op##suffix(long a, atomic64##suffix##_t *v)\
8119 { \
8120 long t; \
8121 \
8122 __asm__ __volatile__( \
8123 "1: ldarx %0,0,%3 # atomic64_" #op "\n" \
8124+ pre_op \
8125 #asm_op " %0,%2,%0\n" \
8126+ post_op \
8127 " stdcx. %0,0,%3 \n" \
8128 " bne- 1b\n" \
8129+ extable \
8130 : "=&r" (t), "+m" (v->counter) \
8131 : "r" (a), "r" (&v->counter) \
8132 : "cc"); \
8133 }
8134
8135-#define ATOMIC64_OP_RETURN(op, asm_op) \
8136-static __inline__ long atomic64_##op##_return(long a, atomic64_t *v) \
8137+#define ATOMIC64_OP(op, asm_op) __ATOMIC64_OP(op, , , asm_op, , ) \
8138+ __ATOMIC64_OP(op, _unchecked, __OVERFLOW_PRE, __REFCOUNT_OP(asm_op), __OVERFLOW_POST, __OVERFLOW_EXTABLE)
8139+
8140+#define __ATOMIC64_OP_RETURN(op, suffix, pre_op, asm_op, post_op, extable)\
8141+static inline long atomic64_##op##_return##suffix(long a, atomic64##suffix##_t *v)\
8142 { \
8143 long t; \
8144 \
8145 __asm__ __volatile__( \
8146 PPC_ATOMIC_ENTRY_BARRIER \
8147 "1: ldarx %0,0,%2 # atomic64_" #op "_return\n" \
8148+ pre_op \
8149 #asm_op " %0,%1,%0\n" \
8150+ post_op \
8151 " stdcx. %0,0,%2 \n" \
8152 " bne- 1b\n" \
8153+ extable \
8154 PPC_ATOMIC_EXIT_BARRIER \
8155 : "=&r" (t) \
8156 : "r" (a), "r" (&v->counter) \
8157@@ -300,6 +375,9 @@ static __inline__ long atomic64_##op##_return(long a, atomic64_t *v) \
8158 return t; \
8159 }
8160
8161+#define ATOMIC64_OP_RETURN(op, asm_op) __ATOMIC64_OP_RETURN(op, , , asm_op, , )\
8162+ __ATOMIC64_OP_RETURN(op, _unchecked, __OVERFLOW_PRE, __REFCOUNT_OP(asm_op), __OVERFLOW_POST, __OVERFLOW_EXTABLE)
8163+
8164 #define ATOMIC64_OPS(op, asm_op) ATOMIC64_OP(op, asm_op) ATOMIC64_OP_RETURN(op, asm_op)
8165
8166 ATOMIC64_OPS(add, add)
8167@@ -307,40 +385,33 @@ ATOMIC64_OPS(sub, subf)
8168
8169 #undef ATOMIC64_OPS
8170 #undef ATOMIC64_OP_RETURN
8171+#undef __ATOMIC64_OP_RETURN
8172 #undef ATOMIC64_OP
8173+#undef __ATOMIC64_OP
8174+#undef __OVERFLOW_EXTABLE
8175+#undef __OVERFLOW_POST
8176+#undef __OVERFLOW_PRE
8177+#undef __REFCOUNT_OP
8178
8179 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
8180
8181-static __inline__ void atomic64_inc(atomic64_t *v)
8182-{
8183- long t;
8184+/*
8185+ * atomic64_inc - increment atomic variable
8186+ * @v: pointer of type atomic64_t
8187+ *
8188+ * Automatically increments @v by 1
8189+ */
8190+#define atomic64_inc(v) atomic64_add(1, (v))
8191+#define atomic64_inc_return(v) atomic64_add_return(1, (v))
8192
8193- __asm__ __volatile__(
8194-"1: ldarx %0,0,%2 # atomic64_inc\n\
8195- addic %0,%0,1\n\
8196- stdcx. %0,0,%2 \n\
8197- bne- 1b"
8198- : "=&r" (t), "+m" (v->counter)
8199- : "r" (&v->counter)
8200- : "cc", "xer");
8201+static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
8202+{
8203+ atomic64_add_unchecked(1, v);
8204 }
8205
8206-static __inline__ long atomic64_inc_return(atomic64_t *v)
8207+static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
8208 {
8209- long t;
8210-
8211- __asm__ __volatile__(
8212- PPC_ATOMIC_ENTRY_BARRIER
8213-"1: ldarx %0,0,%1 # atomic64_inc_return\n\
8214- addic %0,%0,1\n\
8215- stdcx. %0,0,%1 \n\
8216- bne- 1b"
8217- PPC_ATOMIC_EXIT_BARRIER
8218- : "=&r" (t)
8219- : "r" (&v->counter)
8220- : "cc", "xer", "memory");
8221-
8222- return t;
8223+ return atomic64_add_return_unchecked(1, v);
8224 }
8225
8226 /*
8227@@ -353,36 +424,18 @@ static __inline__ long atomic64_inc_return(atomic64_t *v)
8228 */
8229 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
8230
8231-static __inline__ void atomic64_dec(atomic64_t *v)
8232+/*
8233+ * atomic64_dec - decrement atomic variable
8234+ * @v: pointer of type atomic64_t
8235+ *
8236+ * Atomically decrements @v by 1
8237+ */
8238+#define atomic64_dec(v) atomic64_sub(1, (v))
8239+#define atomic64_dec_return(v) atomic64_sub_return(1, (v))
8240+
8241+static __inline__ void atomic64_dec_unchecked(atomic64_unchecked_t *v)
8242 {
8243- long t;
8244-
8245- __asm__ __volatile__(
8246-"1: ldarx %0,0,%2 # atomic64_dec\n\
8247- addic %0,%0,-1\n\
8248- stdcx. %0,0,%2\n\
8249- bne- 1b"
8250- : "=&r" (t), "+m" (v->counter)
8251- : "r" (&v->counter)
8252- : "cc", "xer");
8253-}
8254-
8255-static __inline__ long atomic64_dec_return(atomic64_t *v)
8256-{
8257- long t;
8258-
8259- __asm__ __volatile__(
8260- PPC_ATOMIC_ENTRY_BARRIER
8261-"1: ldarx %0,0,%1 # atomic64_dec_return\n\
8262- addic %0,%0,-1\n\
8263- stdcx. %0,0,%1\n\
8264- bne- 1b"
8265- PPC_ATOMIC_EXIT_BARRIER
8266- : "=&r" (t)
8267- : "r" (&v->counter)
8268- : "cc", "xer", "memory");
8269-
8270- return t;
8271+ atomic64_sub_unchecked(1, v);
8272 }
8273
8274 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
8275@@ -415,6 +468,16 @@ static __inline__ long atomic64_dec_if_positive(atomic64_t *v)
8276 #define atomic64_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
8277 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
8278
8279+static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
8280+{
8281+ return cmpxchg(&(v->counter), old, new);
8282+}
8283+
8284+static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
8285+{
8286+ return xchg(&(v->counter), new);
8287+}
8288+
8289 /**
8290 * atomic64_add_unless - add unless the number is a given value
8291 * @v: pointer of type atomic64_t
8292@@ -430,13 +493,29 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
8293
8294 __asm__ __volatile__ (
8295 PPC_ATOMIC_ENTRY_BARRIER
8296-"1: ldarx %0,0,%1 # __atomic_add_unless\n\
8297+"1: ldarx %0,0,%1 # atomic64_add_unless\n\
8298 cmpd 0,%0,%3 \n\
8299- beq- 2f \n\
8300- add %0,%2,%0 \n"
8301+ beq- 2f \n"
8302+
8303+#ifdef CONFIG_PAX_REFCOUNT
8304+" mcrxr cr0\n"
8305+" addo. %0,%2,%0\n"
8306+" bf 4*cr0+so, 4f\n"
8307+"3:.long " "0x00c00b00""\n"
8308+"4:\n"
8309+#else
8310+ "add %0,%2,%0 \n"
8311+#endif
8312+
8313 " stdcx. %0,0,%1 \n\
8314 bne- 1b \n"
8315 PPC_ATOMIC_EXIT_BARRIER
8316+"5:"
8317+
8318+#ifdef CONFIG_PAX_REFCOUNT
8319+ _ASM_EXTABLE(3b, 5b)
8320+#endif
8321+
8322 " subf %0,%2,%0 \n\
8323 2:"
8324 : "=&r" (t)
8325diff --git a/arch/powerpc/include/asm/barrier.h b/arch/powerpc/include/asm/barrier.h
8326index a3bf5be..e03ba81 100644
8327--- a/arch/powerpc/include/asm/barrier.h
8328+++ b/arch/powerpc/include/asm/barrier.h
8329@@ -76,7 +76,7 @@
8330 do { \
8331 compiletime_assert_atomic_type(*p); \
8332 smp_lwsync(); \
8333- ACCESS_ONCE(*p) = (v); \
8334+ ACCESS_ONCE_RW(*p) = (v); \
8335 } while (0)
8336
8337 #define smp_load_acquire(p) \
8338diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
8339index 0dc42c5..b80a3a1 100644
8340--- a/arch/powerpc/include/asm/cache.h
8341+++ b/arch/powerpc/include/asm/cache.h
8342@@ -4,6 +4,7 @@
8343 #ifdef __KERNEL__
8344
8345 #include <asm/reg.h>
8346+#include <linux/const.h>
8347
8348 /* bytes per L1 cache line */
8349 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
8350@@ -23,7 +24,7 @@
8351 #define L1_CACHE_SHIFT 7
8352 #endif
8353
8354-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8355+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8356
8357 #define SMP_CACHE_BYTES L1_CACHE_BYTES
8358
8359diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
8360index ee46ffe..b36c98c 100644
8361--- a/arch/powerpc/include/asm/elf.h
8362+++ b/arch/powerpc/include/asm/elf.h
8363@@ -30,6 +30,18 @@
8364
8365 #define ELF_ET_DYN_BASE 0x20000000
8366
8367+#ifdef CONFIG_PAX_ASLR
8368+#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
8369+
8370+#ifdef __powerpc64__
8371+#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
8372+#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
8373+#else
8374+#define PAX_DELTA_MMAP_LEN 15
8375+#define PAX_DELTA_STACK_LEN 15
8376+#endif
8377+#endif
8378+
8379 #define ELF_CORE_EFLAGS (is_elf2_task() ? 2 : 0)
8380
8381 /*
8382diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
8383index 8196e9c..d83a9f3 100644
8384--- a/arch/powerpc/include/asm/exec.h
8385+++ b/arch/powerpc/include/asm/exec.h
8386@@ -4,6 +4,6 @@
8387 #ifndef _ASM_POWERPC_EXEC_H
8388 #define _ASM_POWERPC_EXEC_H
8389
8390-extern unsigned long arch_align_stack(unsigned long sp);
8391+#define arch_align_stack(x) ((x) & ~0xfUL)
8392
8393 #endif /* _ASM_POWERPC_EXEC_H */
8394diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
8395index 5acabbd..7ea14fa 100644
8396--- a/arch/powerpc/include/asm/kmap_types.h
8397+++ b/arch/powerpc/include/asm/kmap_types.h
8398@@ -10,7 +10,7 @@
8399 * 2 of the License, or (at your option) any later version.
8400 */
8401
8402-#define KM_TYPE_NR 16
8403+#define KM_TYPE_NR 17
8404
8405 #endif /* __KERNEL__ */
8406 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
8407diff --git a/arch/powerpc/include/asm/local.h b/arch/powerpc/include/asm/local.h
8408index b8da913..c02b593 100644
8409--- a/arch/powerpc/include/asm/local.h
8410+++ b/arch/powerpc/include/asm/local.h
8411@@ -9,21 +9,65 @@ typedef struct
8412 atomic_long_t a;
8413 } local_t;
8414
8415+typedef struct
8416+{
8417+ atomic_long_unchecked_t a;
8418+} local_unchecked_t;
8419+
8420 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
8421
8422 #define local_read(l) atomic_long_read(&(l)->a)
8423+#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
8424 #define local_set(l,i) atomic_long_set(&(l)->a, (i))
8425+#define local_set_unchecked(l,i) atomic_long_set_unchecked(&(l)->a, (i))
8426
8427 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
8428+#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
8429 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
8430+#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
8431 #define local_inc(l) atomic_long_inc(&(l)->a)
8432+#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
8433 #define local_dec(l) atomic_long_dec(&(l)->a)
8434+#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
8435
8436 static __inline__ long local_add_return(long a, local_t *l)
8437 {
8438 long t;
8439
8440 __asm__ __volatile__(
8441+"1:" PPC_LLARX(%0,0,%2,0) " # local_add_return\n"
8442+
8443+#ifdef CONFIG_PAX_REFCOUNT
8444+" mcrxr cr0\n"
8445+" addo. %0,%1,%0\n"
8446+" bf 4*cr0+so, 3f\n"
8447+"2:.long " "0x00c00b00""\n"
8448+#else
8449+" add %0,%1,%0\n"
8450+#endif
8451+
8452+"3:\n"
8453+ PPC405_ERR77(0,%2)
8454+ PPC_STLCX "%0,0,%2 \n\
8455+ bne- 1b"
8456+
8457+#ifdef CONFIG_PAX_REFCOUNT
8458+"\n4:\n"
8459+ _ASM_EXTABLE(2b, 4b)
8460+#endif
8461+
8462+ : "=&r" (t)
8463+ : "r" (a), "r" (&(l->a.counter))
8464+ : "cc", "memory");
8465+
8466+ return t;
8467+}
8468+
8469+static __inline__ long local_add_return_unchecked(long a, local_unchecked_t *l)
8470+{
8471+ long t;
8472+
8473+ __asm__ __volatile__(
8474 "1:" PPC_LLARX(%0,0,%2,0) " # local_add_return\n\
8475 add %0,%1,%0\n"
8476 PPC405_ERR77(0,%2)
8477@@ -101,6 +145,8 @@ static __inline__ long local_dec_return(local_t *l)
8478
8479 #define local_cmpxchg(l, o, n) \
8480 (cmpxchg_local(&((l)->a.counter), (o), (n)))
8481+#define local_cmpxchg_unchecked(l, o, n) \
8482+ (cmpxchg_local(&((l)->a.counter), (o), (n)))
8483 #define local_xchg(l, n) (xchg_local(&((l)->a.counter), (n)))
8484
8485 /**
8486diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
8487index 8565c25..2865190 100644
8488--- a/arch/powerpc/include/asm/mman.h
8489+++ b/arch/powerpc/include/asm/mman.h
8490@@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
8491 }
8492 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
8493
8494-static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
8495+static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
8496 {
8497 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
8498 }
8499diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
8500index 69c0598..2c56964 100644
8501--- a/arch/powerpc/include/asm/page.h
8502+++ b/arch/powerpc/include/asm/page.h
8503@@ -227,8 +227,9 @@ extern long long virt_phys_offset;
8504 * and needs to be executable. This means the whole heap ends
8505 * up being executable.
8506 */
8507-#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
8508- VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
8509+#define VM_DATA_DEFAULT_FLAGS32 \
8510+ (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
8511+ VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
8512
8513 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
8514 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
8515@@ -256,6 +257,9 @@ extern long long virt_phys_offset;
8516 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
8517 #endif
8518
8519+#define ktla_ktva(addr) (addr)
8520+#define ktva_ktla(addr) (addr)
8521+
8522 #ifndef CONFIG_PPC_BOOK3S_64
8523 /*
8524 * Use the top bit of the higher-level page table entries to indicate whether
8525diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
8526index d908a46..3753f71 100644
8527--- a/arch/powerpc/include/asm/page_64.h
8528+++ b/arch/powerpc/include/asm/page_64.h
8529@@ -172,15 +172,18 @@ do { \
8530 * stack by default, so in the absence of a PT_GNU_STACK program header
8531 * we turn execute permission off.
8532 */
8533-#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
8534- VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
8535+#define VM_STACK_DEFAULT_FLAGS32 \
8536+ (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
8537+ VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
8538
8539 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
8540 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
8541
8542+#ifndef CONFIG_PAX_PAGEEXEC
8543 #define VM_STACK_DEFAULT_FLAGS \
8544 (is_32bit_task() ? \
8545 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
8546+#endif
8547
8548 #include <asm-generic/getorder.h>
8549
8550diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
8551index 4b0be20..c15a27d 100644
8552--- a/arch/powerpc/include/asm/pgalloc-64.h
8553+++ b/arch/powerpc/include/asm/pgalloc-64.h
8554@@ -54,6 +54,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
8555 #ifndef CONFIG_PPC_64K_PAGES
8556
8557 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
8558+#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
8559
8560 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
8561 {
8562@@ -71,6 +72,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
8563 pud_set(pud, (unsigned long)pmd);
8564 }
8565
8566+static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
8567+{
8568+ pud_populate(mm, pud, pmd);
8569+}
8570+
8571 #define pmd_populate(mm, pmd, pte_page) \
8572 pmd_populate_kernel(mm, pmd, page_address(pte_page))
8573 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
8574@@ -173,6 +179,7 @@ extern void __tlb_remove_table(void *_table);
8575 #endif
8576
8577 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
8578+#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
8579
8580 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
8581 pte_t *pte)
8582diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
8583index 11a3863..108f194 100644
8584--- a/arch/powerpc/include/asm/pgtable.h
8585+++ b/arch/powerpc/include/asm/pgtable.h
8586@@ -2,6 +2,7 @@
8587 #define _ASM_POWERPC_PGTABLE_H
8588 #ifdef __KERNEL__
8589
8590+#include <linux/const.h>
8591 #ifndef __ASSEMBLY__
8592 #include <linux/mmdebug.h>
8593 #include <linux/mmzone.h>
8594diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
8595index 62cfb0c..50c6402 100644
8596--- a/arch/powerpc/include/asm/pte-hash32.h
8597+++ b/arch/powerpc/include/asm/pte-hash32.h
8598@@ -20,6 +20,7 @@
8599 #define _PAGE_HASHPTE 0x002 /* hash_page has made an HPTE for this pte */
8600 #define _PAGE_USER 0x004 /* usermode access allowed */
8601 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
8602+#define _PAGE_EXEC _PAGE_GUARDED
8603 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
8604 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
8605 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
8606diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
8607index af56b5c..f86f3f6 100644
8608--- a/arch/powerpc/include/asm/reg.h
8609+++ b/arch/powerpc/include/asm/reg.h
8610@@ -253,6 +253,7 @@
8611 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
8612 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
8613 #define DSISR_NOHPTE 0x40000000 /* no translation found */
8614+#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
8615 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
8616 #define DSISR_ISSTORE 0x02000000 /* access was a store */
8617 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
8618diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
8619index 825663c..f9e9134 100644
8620--- a/arch/powerpc/include/asm/smp.h
8621+++ b/arch/powerpc/include/asm/smp.h
8622@@ -51,7 +51,7 @@ struct smp_ops_t {
8623 int (*cpu_disable)(void);
8624 void (*cpu_die)(unsigned int nr);
8625 int (*cpu_bootable)(unsigned int nr);
8626-};
8627+} __no_const;
8628
8629 extern void smp_send_debugger_break(void);
8630 extern void start_secondary_resume(void);
8631diff --git a/arch/powerpc/include/asm/spinlock.h b/arch/powerpc/include/asm/spinlock.h
8632index 4dbe072..b803275 100644
8633--- a/arch/powerpc/include/asm/spinlock.h
8634+++ b/arch/powerpc/include/asm/spinlock.h
8635@@ -204,13 +204,29 @@ static inline long __arch_read_trylock(arch_rwlock_t *rw)
8636 __asm__ __volatile__(
8637 "1: " PPC_LWARX(%0,0,%1,1) "\n"
8638 __DO_SIGN_EXTEND
8639-" addic. %0,%0,1\n\
8640- ble- 2f\n"
8641+
8642+#ifdef CONFIG_PAX_REFCOUNT
8643+" mcrxr cr0\n"
8644+" addico. %0,%0,1\n"
8645+" bf 4*cr0+so, 3f\n"
8646+"2:.long " "0x00c00b00""\n"
8647+#else
8648+" addic. %0,%0,1\n"
8649+#endif
8650+
8651+"3:\n"
8652+ "ble- 4f\n"
8653 PPC405_ERR77(0,%1)
8654 " stwcx. %0,0,%1\n\
8655 bne- 1b\n"
8656 PPC_ACQUIRE_BARRIER
8657-"2:" : "=&r" (tmp)
8658+"4:"
8659+
8660+#ifdef CONFIG_PAX_REFCOUNT
8661+ _ASM_EXTABLE(2b,4b)
8662+#endif
8663+
8664+ : "=&r" (tmp)
8665 : "r" (&rw->lock)
8666 : "cr0", "xer", "memory");
8667
8668@@ -286,11 +302,27 @@ static inline void arch_read_unlock(arch_rwlock_t *rw)
8669 __asm__ __volatile__(
8670 "# read_unlock\n\t"
8671 PPC_RELEASE_BARRIER
8672-"1: lwarx %0,0,%1\n\
8673- addic %0,%0,-1\n"
8674+"1: lwarx %0,0,%1\n"
8675+
8676+#ifdef CONFIG_PAX_REFCOUNT
8677+" mcrxr cr0\n"
8678+" addico. %0,%0,-1\n"
8679+" bf 4*cr0+so, 3f\n"
8680+"2:.long " "0x00c00b00""\n"
8681+#else
8682+" addic. %0,%0,-1\n"
8683+#endif
8684+
8685+"3:\n"
8686 PPC405_ERR77(0,%1)
8687 " stwcx. %0,0,%1\n\
8688 bne- 1b"
8689+
8690+#ifdef CONFIG_PAX_REFCOUNT
8691+"\n4:\n"
8692+ _ASM_EXTABLE(2b, 4b)
8693+#endif
8694+
8695 : "=&r"(tmp)
8696 : "r"(&rw->lock)
8697 : "cr0", "xer", "memory");
8698diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
8699index 7efee4a..48d47cc 100644
8700--- a/arch/powerpc/include/asm/thread_info.h
8701+++ b/arch/powerpc/include/asm/thread_info.h
8702@@ -101,6 +101,8 @@ static inline struct thread_info *current_thread_info(void)
8703 #if defined(CONFIG_PPC64)
8704 #define TIF_ELF2ABI 18 /* function descriptors must die! */
8705 #endif
8706+/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
8707+#define TIF_GRSEC_SETXID 6 /* update credentials on syscall entry/exit */
8708
8709 /* as above, but as bit values */
8710 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
8711@@ -119,9 +121,10 @@ static inline struct thread_info *current_thread_info(void)
8712 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
8713 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
8714 #define _TIF_NOHZ (1<<TIF_NOHZ)
8715+#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
8716 #define _TIF_SYSCALL_DOTRACE (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
8717 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
8718- _TIF_NOHZ)
8719+ _TIF_NOHZ | _TIF_GRSEC_SETXID)
8720
8721 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
8722 _TIF_NOTIFY_RESUME | _TIF_UPROBE | \
8723diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
8724index a0c071d..49cdc7f 100644
8725--- a/arch/powerpc/include/asm/uaccess.h
8726+++ b/arch/powerpc/include/asm/uaccess.h
8727@@ -58,6 +58,7 @@
8728
8729 #endif
8730
8731+#define access_ok_noprefault(type, addr, size) access_ok((type), (addr), (size))
8732 #define access_ok(type, addr, size) \
8733 (__chk_user_ptr(addr), \
8734 __access_ok((__force unsigned long)(addr), (size), get_fs()))
8735@@ -318,52 +319,6 @@ do { \
8736 extern unsigned long __copy_tofrom_user(void __user *to,
8737 const void __user *from, unsigned long size);
8738
8739-#ifndef __powerpc64__
8740-
8741-static inline unsigned long copy_from_user(void *to,
8742- const void __user *from, unsigned long n)
8743-{
8744- unsigned long over;
8745-
8746- if (access_ok(VERIFY_READ, from, n))
8747- return __copy_tofrom_user((__force void __user *)to, from, n);
8748- if ((unsigned long)from < TASK_SIZE) {
8749- over = (unsigned long)from + n - TASK_SIZE;
8750- return __copy_tofrom_user((__force void __user *)to, from,
8751- n - over) + over;
8752- }
8753- return n;
8754-}
8755-
8756-static inline unsigned long copy_to_user(void __user *to,
8757- const void *from, unsigned long n)
8758-{
8759- unsigned long over;
8760-
8761- if (access_ok(VERIFY_WRITE, to, n))
8762- return __copy_tofrom_user(to, (__force void __user *)from, n);
8763- if ((unsigned long)to < TASK_SIZE) {
8764- over = (unsigned long)to + n - TASK_SIZE;
8765- return __copy_tofrom_user(to, (__force void __user *)from,
8766- n - over) + over;
8767- }
8768- return n;
8769-}
8770-
8771-#else /* __powerpc64__ */
8772-
8773-#define __copy_in_user(to, from, size) \
8774- __copy_tofrom_user((to), (from), (size))
8775-
8776-extern unsigned long copy_from_user(void *to, const void __user *from,
8777- unsigned long n);
8778-extern unsigned long copy_to_user(void __user *to, const void *from,
8779- unsigned long n);
8780-extern unsigned long copy_in_user(void __user *to, const void __user *from,
8781- unsigned long n);
8782-
8783-#endif /* __powerpc64__ */
8784-
8785 static inline unsigned long __copy_from_user_inatomic(void *to,
8786 const void __user *from, unsigned long n)
8787 {
8788@@ -387,6 +342,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
8789 if (ret == 0)
8790 return 0;
8791 }
8792+
8793+ if (!__builtin_constant_p(n))
8794+ check_object_size(to, n, false);
8795+
8796 return __copy_tofrom_user((__force void __user *)to, from, n);
8797 }
8798
8799@@ -413,6 +372,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
8800 if (ret == 0)
8801 return 0;
8802 }
8803+
8804+ if (!__builtin_constant_p(n))
8805+ check_object_size(from, n, true);
8806+
8807 return __copy_tofrom_user(to, (__force const void __user *)from, n);
8808 }
8809
8810@@ -430,6 +393,92 @@ static inline unsigned long __copy_to_user(void __user *to,
8811 return __copy_to_user_inatomic(to, from, size);
8812 }
8813
8814+#ifndef __powerpc64__
8815+
8816+static inline unsigned long __must_check copy_from_user(void *to,
8817+ const void __user *from, unsigned long n)
8818+{
8819+ unsigned long over;
8820+
8821+ if ((long)n < 0)
8822+ return n;
8823+
8824+ if (access_ok(VERIFY_READ, from, n)) {
8825+ if (!__builtin_constant_p(n))
8826+ check_object_size(to, n, false);
8827+ return __copy_tofrom_user((__force void __user *)to, from, n);
8828+ }
8829+ if ((unsigned long)from < TASK_SIZE) {
8830+ over = (unsigned long)from + n - TASK_SIZE;
8831+ if (!__builtin_constant_p(n - over))
8832+ check_object_size(to, n - over, false);
8833+ return __copy_tofrom_user((__force void __user *)to, from,
8834+ n - over) + over;
8835+ }
8836+ return n;
8837+}
8838+
8839+static inline unsigned long __must_check copy_to_user(void __user *to,
8840+ const void *from, unsigned long n)
8841+{
8842+ unsigned long over;
8843+
8844+ if ((long)n < 0)
8845+ return n;
8846+
8847+ if (access_ok(VERIFY_WRITE, to, n)) {
8848+ if (!__builtin_constant_p(n))
8849+ check_object_size(from, n, true);
8850+ return __copy_tofrom_user(to, (__force void __user *)from, n);
8851+ }
8852+ if ((unsigned long)to < TASK_SIZE) {
8853+ over = (unsigned long)to + n - TASK_SIZE;
8854+ if (!__builtin_constant_p(n))
8855+ check_object_size(from, n - over, true);
8856+ return __copy_tofrom_user(to, (__force void __user *)from,
8857+ n - over) + over;
8858+ }
8859+ return n;
8860+}
8861+
8862+#else /* __powerpc64__ */
8863+
8864+#define __copy_in_user(to, from, size) \
8865+ __copy_tofrom_user((to), (from), (size))
8866+
8867+static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
8868+{
8869+ if ((long)n < 0 || n > INT_MAX)
8870+ return n;
8871+
8872+ if (!__builtin_constant_p(n))
8873+ check_object_size(to, n, false);
8874+
8875+ if (likely(access_ok(VERIFY_READ, from, n)))
8876+ n = __copy_from_user(to, from, n);
8877+ else
8878+ memset(to, 0, n);
8879+ return n;
8880+}
8881+
8882+static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
8883+{
8884+ if ((long)n < 0 || n > INT_MAX)
8885+ return n;
8886+
8887+ if (likely(access_ok(VERIFY_WRITE, to, n))) {
8888+ if (!__builtin_constant_p(n))
8889+ check_object_size(from, n, true);
8890+ n = __copy_to_user(to, from, n);
8891+ }
8892+ return n;
8893+}
8894+
8895+extern unsigned long copy_in_user(void __user *to, const void __user *from,
8896+ unsigned long n);
8897+
8898+#endif /* __powerpc64__ */
8899+
8900 extern unsigned long __clear_user(void __user *addr, unsigned long size);
8901
8902 static inline unsigned long clear_user(void __user *addr, unsigned long size)
8903diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
8904index c1ebbda..fd8a98d 100644
8905--- a/arch/powerpc/kernel/Makefile
8906+++ b/arch/powerpc/kernel/Makefile
8907@@ -15,6 +15,11 @@ CFLAGS_prom_init.o += -fPIC
8908 CFLAGS_btext.o += -fPIC
8909 endif
8910
8911+CFLAGS_REMOVE_cputable.o = $(LATENT_ENTROPY_PLUGIN_CFLAGS)
8912+CFLAGS_REMOVE_prom_init.o = $(LATENT_ENTROPY_PLUGIN_CFLAGS)
8913+CFLAGS_REMOVE_btext.o = $(LATENT_ENTROPY_PLUGIN_CFLAGS)
8914+CFLAGS_REMOVE_prom.o = $(LATENT_ENTROPY_PLUGIN_CFLAGS)
8915+
8916 ifdef CONFIG_FUNCTION_TRACER
8917 # Do not trace early boot code
8918 CFLAGS_REMOVE_cputable.o = -pg -mno-sched-epilog
8919@@ -27,6 +32,8 @@ CFLAGS_REMOVE_ftrace.o = -pg -mno-sched-epilog
8920 CFLAGS_REMOVE_time.o = -pg -mno-sched-epilog
8921 endif
8922
8923+CFLAGS_REMOVE_prom_init.o += $(LATENT_ENTROPY_PLUGIN_CFLAGS)
8924+
8925 obj-y := cputable.o ptrace.o syscalls.o \
8926 irq.o align.o signal_32.o pmc.o vdso.o \
8927 process.o systbl.o idle.o \
8928diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
8929index 3e68d1c..72a5ee6 100644
8930--- a/arch/powerpc/kernel/exceptions-64e.S
8931+++ b/arch/powerpc/kernel/exceptions-64e.S
8932@@ -1010,6 +1010,7 @@ storage_fault_common:
8933 std r14,_DAR(r1)
8934 std r15,_DSISR(r1)
8935 addi r3,r1,STACK_FRAME_OVERHEAD
8936+ bl save_nvgprs
8937 mr r4,r14
8938 mr r5,r15
8939 ld r14,PACA_EXGEN+EX_R14(r13)
8940@@ -1018,8 +1019,7 @@ storage_fault_common:
8941 cmpdi r3,0
8942 bne- 1f
8943 b ret_from_except_lite
8944-1: bl save_nvgprs
8945- mr r5,r3
8946+1: mr r5,r3
8947 addi r3,r1,STACK_FRAME_OVERHEAD
8948 ld r4,_DAR(r1)
8949 bl bad_page_fault
8950diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
8951index 9519e6b..13f6c38 100644
8952--- a/arch/powerpc/kernel/exceptions-64s.S
8953+++ b/arch/powerpc/kernel/exceptions-64s.S
8954@@ -1599,10 +1599,10 @@ handle_page_fault:
8955 11: ld r4,_DAR(r1)
8956 ld r5,_DSISR(r1)
8957 addi r3,r1,STACK_FRAME_OVERHEAD
8958+ bl save_nvgprs
8959 bl do_page_fault
8960 cmpdi r3,0
8961 beq+ 12f
8962- bl save_nvgprs
8963 mr r5,r3
8964 addi r3,r1,STACK_FRAME_OVERHEAD
8965 lwz r4,_DAR(r1)
8966diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
8967index 4509603..cdb491f 100644
8968--- a/arch/powerpc/kernel/irq.c
8969+++ b/arch/powerpc/kernel/irq.c
8970@@ -460,6 +460,8 @@ void migrate_irqs(void)
8971 }
8972 #endif
8973
8974+extern void gr_handle_kernel_exploit(void);
8975+
8976 static inline void check_stack_overflow(void)
8977 {
8978 #ifdef CONFIG_DEBUG_STACKOVERFLOW
8979@@ -472,6 +474,7 @@ static inline void check_stack_overflow(void)
8980 pr_err("do_IRQ: stack overflow: %ld\n",
8981 sp - sizeof(struct thread_info));
8982 dump_stack();
8983+ gr_handle_kernel_exploit();
8984 }
8985 #endif
8986 }
8987diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
8988index c94d2e0..992a9ce 100644
8989--- a/arch/powerpc/kernel/module_32.c
8990+++ b/arch/powerpc/kernel/module_32.c
8991@@ -158,7 +158,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
8992 me->arch.core_plt_section = i;
8993 }
8994 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
8995- pr_err("Module doesn't contain .plt or .init.plt sections.\n");
8996+ pr_err("Module $s doesn't contain .plt or .init.plt sections.\n", me->name);
8997 return -ENOEXEC;
8998 }
8999
9000@@ -188,11 +188,16 @@ static uint32_t do_plt_call(void *location,
9001
9002 pr_debug("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
9003 /* Init, or core PLT? */
9004- if (location >= mod->module_core
9005- && location < mod->module_core + mod->core_size)
9006+ if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
9007+ (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
9008 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
9009- else
9010+ else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
9011+ (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
9012 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
9013+ else {
9014+ printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
9015+ return ~0UL;
9016+ }
9017
9018 /* Find this entry, or if that fails, the next avail. entry */
9019 while (entry->jump[0]) {
9020@@ -296,7 +301,7 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
9021 }
9022 #ifdef CONFIG_DYNAMIC_FTRACE
9023 module->arch.tramp =
9024- do_plt_call(module->module_core,
9025+ do_plt_call(module->module_core_rx,
9026 (unsigned long)ftrace_caller,
9027 sechdrs, module);
9028 #endif
9029diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
9030index febb50d..bb10020 100644
9031--- a/arch/powerpc/kernel/process.c
9032+++ b/arch/powerpc/kernel/process.c
9033@@ -1036,8 +1036,8 @@ void show_regs(struct pt_regs * regs)
9034 * Lookup NIP late so we have the best change of getting the
9035 * above info out without failing
9036 */
9037- printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
9038- printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
9039+ printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
9040+ printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
9041 #endif
9042 show_stack(current, (unsigned long *) regs->gpr[1]);
9043 if (!user_mode(regs))
9044@@ -1554,10 +1554,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
9045 newsp = stack[0];
9046 ip = stack[STACK_FRAME_LR_SAVE];
9047 if (!firstframe || ip != lr) {
9048- printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
9049+ printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
9050 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
9051 if ((ip == rth) && curr_frame >= 0) {
9052- printk(" (%pS)",
9053+ printk(" (%pA)",
9054 (void *)current->ret_stack[curr_frame].ret);
9055 curr_frame--;
9056 }
9057@@ -1577,7 +1577,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
9058 struct pt_regs *regs = (struct pt_regs *)
9059 (sp + STACK_FRAME_OVERHEAD);
9060 lr = regs->link;
9061- printk("--- interrupt: %lx at %pS\n LR = %pS\n",
9062+ printk("--- interrupt: %lx at %pA\n LR = %pA\n",
9063 regs->trap, (void *)regs->nip, (void *)lr);
9064 firstframe = 1;
9065 }
9066@@ -1613,49 +1613,3 @@ void notrace __ppc64_runlatch_off(void)
9067 mtspr(SPRN_CTRLT, ctrl);
9068 }
9069 #endif /* CONFIG_PPC64 */
9070-
9071-unsigned long arch_align_stack(unsigned long sp)
9072-{
9073- if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
9074- sp -= get_random_int() & ~PAGE_MASK;
9075- return sp & ~0xf;
9076-}
9077-
9078-static inline unsigned long brk_rnd(void)
9079-{
9080- unsigned long rnd = 0;
9081-
9082- /* 8MB for 32bit, 1GB for 64bit */
9083- if (is_32bit_task())
9084- rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
9085- else
9086- rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
9087-
9088- return rnd << PAGE_SHIFT;
9089-}
9090-
9091-unsigned long arch_randomize_brk(struct mm_struct *mm)
9092-{
9093- unsigned long base = mm->brk;
9094- unsigned long ret;
9095-
9096-#ifdef CONFIG_PPC_STD_MMU_64
9097- /*
9098- * If we are using 1TB segments and we are allowed to randomise
9099- * the heap, we can put it above 1TB so it is backed by a 1TB
9100- * segment. Otherwise the heap will be in the bottom 1TB
9101- * which always uses 256MB segments and this may result in a
9102- * performance penalty.
9103- */
9104- if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
9105- base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
9106-#endif
9107-
9108- ret = PAGE_ALIGN(base + brk_rnd());
9109-
9110- if (ret < mm->brk)
9111- return mm->brk;
9112-
9113- return ret;
9114-}
9115-
9116diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
9117index f21897b..28c0428 100644
9118--- a/arch/powerpc/kernel/ptrace.c
9119+++ b/arch/powerpc/kernel/ptrace.c
9120@@ -1762,6 +1762,10 @@ long arch_ptrace(struct task_struct *child, long request,
9121 return ret;
9122 }
9123
9124+#ifdef CONFIG_GRKERNSEC_SETXID
9125+extern void gr_delayed_cred_worker(void);
9126+#endif
9127+
9128 /*
9129 * We must return the syscall number to actually look up in the table.
9130 * This can be -1L to skip running any syscall at all.
9131@@ -1774,6 +1778,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
9132
9133 secure_computing_strict(regs->gpr[0]);
9134
9135+#ifdef CONFIG_GRKERNSEC_SETXID
9136+ if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9137+ gr_delayed_cred_worker();
9138+#endif
9139+
9140 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
9141 tracehook_report_syscall_entry(regs))
9142 /*
9143@@ -1805,6 +1814,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
9144 {
9145 int step;
9146
9147+#ifdef CONFIG_GRKERNSEC_SETXID
9148+ if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9149+ gr_delayed_cred_worker();
9150+#endif
9151+
9152 audit_syscall_exit(regs);
9153
9154 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
9155diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
9156index d3a831a..3a33123 100644
9157--- a/arch/powerpc/kernel/signal_32.c
9158+++ b/arch/powerpc/kernel/signal_32.c
9159@@ -1011,7 +1011,7 @@ int handle_rt_signal32(struct ksignal *ksig, sigset_t *oldset,
9160 /* Save user registers on the stack */
9161 frame = &rt_sf->uc.uc_mcontext;
9162 addr = frame;
9163- if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
9164+ if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
9165 sigret = 0;
9166 tramp = current->mm->context.vdso_base + vdso32_rt_sigtramp;
9167 } else {
9168diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
9169index c7c24d2..1bf7039 100644
9170--- a/arch/powerpc/kernel/signal_64.c
9171+++ b/arch/powerpc/kernel/signal_64.c
9172@@ -754,7 +754,7 @@ int handle_rt_signal64(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs
9173 current->thread.fp_state.fpscr = 0;
9174
9175 /* Set up to return from userspace. */
9176- if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
9177+ if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
9178 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
9179 } else {
9180 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
9181diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
9182index 19e4744..28a8d7b 100644
9183--- a/arch/powerpc/kernel/traps.c
9184+++ b/arch/powerpc/kernel/traps.c
9185@@ -36,6 +36,7 @@
9186 #include <linux/debugfs.h>
9187 #include <linux/ratelimit.h>
9188 #include <linux/context_tracking.h>
9189+#include <linux/uaccess.h>
9190
9191 #include <asm/emulated_ops.h>
9192 #include <asm/pgtable.h>
9193@@ -142,6 +143,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
9194 return flags;
9195 }
9196
9197+extern void gr_handle_kernel_exploit(void);
9198+
9199 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
9200 int signr)
9201 {
9202@@ -191,6 +194,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
9203 panic("Fatal exception in interrupt");
9204 if (panic_on_oops)
9205 panic("Fatal exception");
9206+
9207+ gr_handle_kernel_exploit();
9208+
9209 do_exit(signr);
9210 }
9211
9212@@ -1137,6 +1143,26 @@ void __kprobes program_check_exception(struct pt_regs *regs)
9213 enum ctx_state prev_state = exception_enter();
9214 unsigned int reason = get_reason(regs);
9215
9216+#ifdef CONFIG_PAX_REFCOUNT
9217+ unsigned int bkpt;
9218+ const struct exception_table_entry *entry;
9219+
9220+ if (reason & REASON_ILLEGAL) {
9221+ /* Check if PaX bad instruction */
9222+ if (!probe_kernel_address(regs->nip, bkpt) && bkpt == 0xc00b00) {
9223+ current->thread.trap_nr = 0;
9224+ pax_report_refcount_overflow(regs);
9225+ /* fixup_exception() for PowerPC does not exist, simulate its job */
9226+ if ((entry = search_exception_tables(regs->nip)) != NULL) {
9227+ regs->nip = entry->fixup;
9228+ return;
9229+ }
9230+ /* fixup_exception() could not handle */
9231+ goto bail;
9232+ }
9233+ }
9234+#endif
9235+
9236 /* We can now get here via a FP Unavailable exception if the core
9237 * has no FPU, in that case the reason flags will be 0 */
9238
9239diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
9240index 305eb0d..accc5b40 100644
9241--- a/arch/powerpc/kernel/vdso.c
9242+++ b/arch/powerpc/kernel/vdso.c
9243@@ -34,6 +34,7 @@
9244 #include <asm/vdso.h>
9245 #include <asm/vdso_datapage.h>
9246 #include <asm/setup.h>
9247+#include <asm/mman.h>
9248
9249 #undef DEBUG
9250
9251@@ -220,7 +221,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
9252 vdso_base = VDSO32_MBASE;
9253 #endif
9254
9255- current->mm->context.vdso_base = 0;
9256+ current->mm->context.vdso_base = ~0UL;
9257
9258 /* vDSO has a problem and was disabled, just don't "enable" it for the
9259 * process
9260@@ -240,7 +241,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
9261 vdso_base = get_unmapped_area(NULL, vdso_base,
9262 (vdso_pages << PAGE_SHIFT) +
9263 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
9264- 0, 0);
9265+ 0, MAP_PRIVATE | MAP_EXECUTABLE);
9266 if (IS_ERR_VALUE(vdso_base)) {
9267 rc = vdso_base;
9268 goto fail_mmapsem;
9269diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
9270index ac3ddf1..9a54c76 100644
9271--- a/arch/powerpc/kvm/powerpc.c
9272+++ b/arch/powerpc/kvm/powerpc.c
9273@@ -1403,7 +1403,7 @@ void kvmppc_init_lpid(unsigned long nr_lpids_param)
9274 }
9275 EXPORT_SYMBOL_GPL(kvmppc_init_lpid);
9276
9277-int kvm_arch_init(void *opaque)
9278+int kvm_arch_init(const void *opaque)
9279 {
9280 return 0;
9281 }
9282diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
9283index 5eea6f3..5d10396 100644
9284--- a/arch/powerpc/lib/usercopy_64.c
9285+++ b/arch/powerpc/lib/usercopy_64.c
9286@@ -9,22 +9,6 @@
9287 #include <linux/module.h>
9288 #include <asm/uaccess.h>
9289
9290-unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
9291-{
9292- if (likely(access_ok(VERIFY_READ, from, n)))
9293- n = __copy_from_user(to, from, n);
9294- else
9295- memset(to, 0, n);
9296- return n;
9297-}
9298-
9299-unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
9300-{
9301- if (likely(access_ok(VERIFY_WRITE, to, n)))
9302- n = __copy_to_user(to, from, n);
9303- return n;
9304-}
9305-
9306 unsigned long copy_in_user(void __user *to, const void __user *from,
9307 unsigned long n)
9308 {
9309@@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
9310 return n;
9311 }
9312
9313-EXPORT_SYMBOL(copy_from_user);
9314-EXPORT_SYMBOL(copy_to_user);
9315 EXPORT_SYMBOL(copy_in_user);
9316
9317diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
9318index b396868..3eb6b9f 100644
9319--- a/arch/powerpc/mm/fault.c
9320+++ b/arch/powerpc/mm/fault.c
9321@@ -33,6 +33,10 @@
9322 #include <linux/ratelimit.h>
9323 #include <linux/context_tracking.h>
9324 #include <linux/hugetlb.h>
9325+#include <linux/slab.h>
9326+#include <linux/pagemap.h>
9327+#include <linux/compiler.h>
9328+#include <linux/unistd.h>
9329
9330 #include <asm/firmware.h>
9331 #include <asm/page.h>
9332@@ -68,6 +72,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
9333 }
9334 #endif
9335
9336+#ifdef CONFIG_PAX_PAGEEXEC
9337+/*
9338+ * PaX: decide what to do with offenders (regs->nip = fault address)
9339+ *
9340+ * returns 1 when task should be killed
9341+ */
9342+static int pax_handle_fetch_fault(struct pt_regs *regs)
9343+{
9344+ return 1;
9345+}
9346+
9347+void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9348+{
9349+ unsigned long i;
9350+
9351+ printk(KERN_ERR "PAX: bytes at PC: ");
9352+ for (i = 0; i < 5; i++) {
9353+ unsigned int c;
9354+ if (get_user(c, (unsigned int __user *)pc+i))
9355+ printk(KERN_CONT "???????? ");
9356+ else
9357+ printk(KERN_CONT "%08x ", c);
9358+ }
9359+ printk("\n");
9360+}
9361+#endif
9362+
9363 /*
9364 * Check whether the instruction at regs->nip is a store using
9365 * an update addressing form which will update r1.
9366@@ -227,7 +258,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
9367 * indicate errors in DSISR but can validly be set in SRR1.
9368 */
9369 if (trap == 0x400)
9370- error_code &= 0x48200000;
9371+ error_code &= 0x58200000;
9372 else
9373 is_write = error_code & DSISR_ISSTORE;
9374 #else
9375@@ -383,12 +414,16 @@ good_area:
9376 * "undefined". Of those that can be set, this is the only
9377 * one which seems bad.
9378 */
9379- if (error_code & 0x10000000)
9380+ if (error_code & DSISR_GUARDED)
9381 /* Guarded storage error. */
9382 goto bad_area;
9383 #endif /* CONFIG_8xx */
9384
9385 if (is_exec) {
9386+#ifdef CONFIG_PPC_STD_MMU
9387+ if (error_code & DSISR_GUARDED)
9388+ goto bad_area;
9389+#endif
9390 /*
9391 * Allow execution from readable areas if the MMU does not
9392 * provide separate controls over reading and executing.
9393@@ -483,6 +518,23 @@ bad_area:
9394 bad_area_nosemaphore:
9395 /* User mode accesses cause a SIGSEGV */
9396 if (user_mode(regs)) {
9397+
9398+#ifdef CONFIG_PAX_PAGEEXEC
9399+ if (mm->pax_flags & MF_PAX_PAGEEXEC) {
9400+#ifdef CONFIG_PPC_STD_MMU
9401+ if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
9402+#else
9403+ if (is_exec && regs->nip == address) {
9404+#endif
9405+ switch (pax_handle_fetch_fault(regs)) {
9406+ }
9407+
9408+ pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
9409+ do_group_exit(SIGKILL);
9410+ }
9411+ }
9412+#endif
9413+
9414 _exception(SIGSEGV, regs, code, address);
9415 goto bail;
9416 }
9417diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c
9418index 0f0502e..bc3e7a3 100644
9419--- a/arch/powerpc/mm/mmap.c
9420+++ b/arch/powerpc/mm/mmap.c
9421@@ -86,6 +86,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9422 {
9423 unsigned long random_factor = 0UL;
9424
9425+#ifdef CONFIG_PAX_RANDMMAP
9426+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9427+#endif
9428+
9429 if (current->flags & PF_RANDOMIZE)
9430 random_factor = arch_mmap_rnd();
9431
9432@@ -95,9 +99,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9433 */
9434 if (mmap_is_legacy()) {
9435 mm->mmap_base = TASK_UNMAPPED_BASE;
9436+
9437+#ifdef CONFIG_PAX_RANDMMAP
9438+ if (mm->pax_flags & MF_PAX_RANDMMAP)
9439+ mm->mmap_base += mm->delta_mmap;
9440+#endif
9441+
9442 mm->get_unmapped_area = arch_get_unmapped_area;
9443 } else {
9444 mm->mmap_base = mmap_base(random_factor);
9445+
9446+#ifdef CONFIG_PAX_RANDMMAP
9447+ if (mm->pax_flags & MF_PAX_RANDMMAP)
9448+ mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
9449+#endif
9450+
9451 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
9452 }
9453 }
9454diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
9455index 0f432a7..abfe841 100644
9456--- a/arch/powerpc/mm/slice.c
9457+++ b/arch/powerpc/mm/slice.c
9458@@ -105,7 +105,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
9459 if ((mm->task_size - len) < addr)
9460 return 0;
9461 vma = find_vma(mm, addr);
9462- return (!vma || (addr + len) <= vma->vm_start);
9463+ return check_heap_stack_gap(vma, addr, len, 0);
9464 }
9465
9466 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
9467@@ -277,6 +277,12 @@ static unsigned long slice_find_area_bottomup(struct mm_struct *mm,
9468 info.align_offset = 0;
9469
9470 addr = TASK_UNMAPPED_BASE;
9471+
9472+#ifdef CONFIG_PAX_RANDMMAP
9473+ if (mm->pax_flags & MF_PAX_RANDMMAP)
9474+ addr += mm->delta_mmap;
9475+#endif
9476+
9477 while (addr < TASK_SIZE) {
9478 info.low_limit = addr;
9479 if (!slice_scan_available(addr, available, 1, &addr))
9480@@ -410,6 +416,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
9481 if (fixed && addr > (mm->task_size - len))
9482 return -ENOMEM;
9483
9484+#ifdef CONFIG_PAX_RANDMMAP
9485+ if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
9486+ addr = 0;
9487+#endif
9488+
9489 /* If hint, make sure it matches our alignment restrictions */
9490 if (!fixed && addr) {
9491 addr = _ALIGN_UP(addr, 1ul << pshift);
9492diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
9493index d966bbe..372124a 100644
9494--- a/arch/powerpc/platforms/cell/spufs/file.c
9495+++ b/arch/powerpc/platforms/cell/spufs/file.c
9496@@ -280,9 +280,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9497 return VM_FAULT_NOPAGE;
9498 }
9499
9500-static int spufs_mem_mmap_access(struct vm_area_struct *vma,
9501+static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
9502 unsigned long address,
9503- void *buf, int len, int write)
9504+ void *buf, size_t len, int write)
9505 {
9506 struct spu_context *ctx = vma->vm_file->private_data;
9507 unsigned long offset = address - vma->vm_start;
9508diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
9509index adbe380..adb7516 100644
9510--- a/arch/s390/include/asm/atomic.h
9511+++ b/arch/s390/include/asm/atomic.h
9512@@ -317,4 +317,14 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
9513 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
9514 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
9515
9516+#define atomic64_read_unchecked(v) atomic64_read(v)
9517+#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
9518+#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
9519+#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
9520+#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
9521+#define atomic64_inc_unchecked(v) atomic64_inc(v)
9522+#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
9523+#define atomic64_dec_unchecked(v) atomic64_dec(v)
9524+#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
9525+
9526 #endif /* __ARCH_S390_ATOMIC__ */
9527diff --git a/arch/s390/include/asm/barrier.h b/arch/s390/include/asm/barrier.h
9528index 8d72471..5322500 100644
9529--- a/arch/s390/include/asm/barrier.h
9530+++ b/arch/s390/include/asm/barrier.h
9531@@ -42,7 +42,7 @@
9532 do { \
9533 compiletime_assert_atomic_type(*p); \
9534 barrier(); \
9535- ACCESS_ONCE(*p) = (v); \
9536+ ACCESS_ONCE_RW(*p) = (v); \
9537 } while (0)
9538
9539 #define smp_load_acquire(p) \
9540diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
9541index 4d7ccac..d03d0ad 100644
9542--- a/arch/s390/include/asm/cache.h
9543+++ b/arch/s390/include/asm/cache.h
9544@@ -9,8 +9,10 @@
9545 #ifndef __ARCH_S390_CACHE_H
9546 #define __ARCH_S390_CACHE_H
9547
9548-#define L1_CACHE_BYTES 256
9549+#include <linux/const.h>
9550+
9551 #define L1_CACHE_SHIFT 8
9552+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
9553 #define NET_SKB_PAD 32
9554
9555 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
9556diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
9557index 3ad48f2..64cc6f3 100644
9558--- a/arch/s390/include/asm/elf.h
9559+++ b/arch/s390/include/asm/elf.h
9560@@ -163,6 +163,13 @@ extern unsigned int vdso_enabled;
9561 (STACK_TOP / 3 * 2) : \
9562 (STACK_TOP / 3 * 2) & ~((1UL << 32) - 1))
9563
9564+#ifdef CONFIG_PAX_ASLR
9565+#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
9566+
9567+#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
9568+#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
9569+#endif
9570+
9571 /* This yields a mask that user programs can use to figure out what
9572 instruction set this CPU supports. */
9573
9574diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
9575index c4a93d6..4d2a9b4 100644
9576--- a/arch/s390/include/asm/exec.h
9577+++ b/arch/s390/include/asm/exec.h
9578@@ -7,6 +7,6 @@
9579 #ifndef __ASM_EXEC_H
9580 #define __ASM_EXEC_H
9581
9582-extern unsigned long arch_align_stack(unsigned long sp);
9583+#define arch_align_stack(x) ((x) & ~0xfUL)
9584
9585 #endif /* __ASM_EXEC_H */
9586diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
9587index d64a7a6..0830329 100644
9588--- a/arch/s390/include/asm/uaccess.h
9589+++ b/arch/s390/include/asm/uaccess.h
9590@@ -59,6 +59,7 @@ static inline int __range_ok(unsigned long addr, unsigned long size)
9591 __range_ok((unsigned long)(addr), (size)); \
9592 })
9593
9594+#define access_ok_noprefault(type, addr, size) access_ok((type), (addr), (size))
9595 #define access_ok(type, addr, size) __access_ok(addr, size)
9596
9597 /*
9598@@ -275,6 +276,10 @@ static inline unsigned long __must_check
9599 copy_to_user(void __user *to, const void *from, unsigned long n)
9600 {
9601 might_fault();
9602+
9603+ if ((long)n < 0)
9604+ return n;
9605+
9606 return __copy_to_user(to, from, n);
9607 }
9608
9609@@ -303,10 +308,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
9610 static inline unsigned long __must_check
9611 copy_from_user(void *to, const void __user *from, unsigned long n)
9612 {
9613- unsigned int sz = __compiletime_object_size(to);
9614+ size_t sz = __compiletime_object_size(to);
9615
9616 might_fault();
9617- if (unlikely(sz != -1 && sz < n)) {
9618+
9619+ if ((long)n < 0)
9620+ return n;
9621+
9622+ if (unlikely(sz != (size_t)-1 && sz < n)) {
9623 copy_from_user_overflow();
9624 return n;
9625 }
9626diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
9627index 0c1a679..e1df357 100644
9628--- a/arch/s390/kernel/module.c
9629+++ b/arch/s390/kernel/module.c
9630@@ -159,11 +159,11 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
9631
9632 /* Increase core size by size of got & plt and set start
9633 offsets for got and plt. */
9634- me->core_size = ALIGN(me->core_size, 4);
9635- me->arch.got_offset = me->core_size;
9636- me->core_size += me->arch.got_size;
9637- me->arch.plt_offset = me->core_size;
9638- me->core_size += me->arch.plt_size;
9639+ me->core_size_rw = ALIGN(me->core_size_rw, 4);
9640+ me->arch.got_offset = me->core_size_rw;
9641+ me->core_size_rw += me->arch.got_size;
9642+ me->arch.plt_offset = me->core_size_rx;
9643+ me->core_size_rx += me->arch.plt_size;
9644 return 0;
9645 }
9646
9647@@ -279,7 +279,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
9648 if (info->got_initialized == 0) {
9649 Elf_Addr *gotent;
9650
9651- gotent = me->module_core + me->arch.got_offset +
9652+ gotent = me->module_core_rw + me->arch.got_offset +
9653 info->got_offset;
9654 *gotent = val;
9655 info->got_initialized = 1;
9656@@ -302,7 +302,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
9657 rc = apply_rela_bits(loc, val, 0, 64, 0);
9658 else if (r_type == R_390_GOTENT ||
9659 r_type == R_390_GOTPLTENT) {
9660- val += (Elf_Addr) me->module_core - loc;
9661+ val += (Elf_Addr) me->module_core_rw - loc;
9662 rc = apply_rela_bits(loc, val, 1, 32, 1);
9663 }
9664 break;
9665@@ -315,7 +315,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
9666 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
9667 if (info->plt_initialized == 0) {
9668 unsigned int *ip;
9669- ip = me->module_core + me->arch.plt_offset +
9670+ ip = me->module_core_rx + me->arch.plt_offset +
9671 info->plt_offset;
9672 ip[0] = 0x0d10e310; /* basr 1,0; lg 1,10(1); br 1 */
9673 ip[1] = 0x100a0004;
9674@@ -334,7 +334,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
9675 val - loc + 0xffffUL < 0x1ffffeUL) ||
9676 (r_type == R_390_PLT32DBL &&
9677 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
9678- val = (Elf_Addr) me->module_core +
9679+ val = (Elf_Addr) me->module_core_rx +
9680 me->arch.plt_offset +
9681 info->plt_offset;
9682 val += rela->r_addend - loc;
9683@@ -356,7 +356,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
9684 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
9685 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
9686 val = val + rela->r_addend -
9687- ((Elf_Addr) me->module_core + me->arch.got_offset);
9688+ ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
9689 if (r_type == R_390_GOTOFF16)
9690 rc = apply_rela_bits(loc, val, 0, 16, 0);
9691 else if (r_type == R_390_GOTOFF32)
9692@@ -366,7 +366,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
9693 break;
9694 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
9695 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
9696- val = (Elf_Addr) me->module_core + me->arch.got_offset +
9697+ val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
9698 rela->r_addend - loc;
9699 if (r_type == R_390_GOTPC)
9700 rc = apply_rela_bits(loc, val, 1, 32, 0);
9701diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
9702index dc5edc2..7d34ae3 100644
9703--- a/arch/s390/kernel/process.c
9704+++ b/arch/s390/kernel/process.c
9705@@ -200,27 +200,3 @@ unsigned long get_wchan(struct task_struct *p)
9706 }
9707 return 0;
9708 }
9709-
9710-unsigned long arch_align_stack(unsigned long sp)
9711-{
9712- if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
9713- sp -= get_random_int() & ~PAGE_MASK;
9714- return sp & ~0xf;
9715-}
9716-
9717-static inline unsigned long brk_rnd(void)
9718-{
9719- /* 8MB for 32bit, 1GB for 64bit */
9720- if (is_32bit_task())
9721- return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
9722- else
9723- return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
9724-}
9725-
9726-unsigned long arch_randomize_brk(struct mm_struct *mm)
9727-{
9728- unsigned long ret;
9729-
9730- ret = PAGE_ALIGN(mm->brk + brk_rnd());
9731- return (ret > mm->brk) ? ret : mm->brk;
9732-}
9733diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
9734index 6e552af..3e608a1 100644
9735--- a/arch/s390/mm/mmap.c
9736+++ b/arch/s390/mm/mmap.c
9737@@ -239,6 +239,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9738 {
9739 unsigned long random_factor = 0UL;
9740
9741+#ifdef CONFIG_PAX_RANDMMAP
9742+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9743+#endif
9744+
9745 if (current->flags & PF_RANDOMIZE)
9746 random_factor = arch_mmap_rnd();
9747
9748@@ -248,9 +252,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9749 */
9750 if (mmap_is_legacy()) {
9751 mm->mmap_base = mmap_base_legacy(random_factor);
9752+
9753+#ifdef CONFIG_PAX_RANDMMAP
9754+ if (mm->pax_flags & MF_PAX_RANDMMAP)
9755+ mm->mmap_base += mm->delta_mmap;
9756+#endif
9757+
9758 mm->get_unmapped_area = s390_get_unmapped_area;
9759 } else {
9760 mm->mmap_base = mmap_base(random_factor);
9761+
9762+#ifdef CONFIG_PAX_RANDMMAP
9763+ if (mm->pax_flags & MF_PAX_RANDMMAP)
9764+ mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
9765+#endif
9766+
9767 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
9768 }
9769 }
9770diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
9771index ae3d59f..f65f075 100644
9772--- a/arch/score/include/asm/cache.h
9773+++ b/arch/score/include/asm/cache.h
9774@@ -1,7 +1,9 @@
9775 #ifndef _ASM_SCORE_CACHE_H
9776 #define _ASM_SCORE_CACHE_H
9777
9778+#include <linux/const.h>
9779+
9780 #define L1_CACHE_SHIFT 4
9781-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
9782+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
9783
9784 #endif /* _ASM_SCORE_CACHE_H */
9785diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
9786index f9f3cd5..58ff438 100644
9787--- a/arch/score/include/asm/exec.h
9788+++ b/arch/score/include/asm/exec.h
9789@@ -1,6 +1,6 @@
9790 #ifndef _ASM_SCORE_EXEC_H
9791 #define _ASM_SCORE_EXEC_H
9792
9793-extern unsigned long arch_align_stack(unsigned long sp);
9794+#define arch_align_stack(x) (x)
9795
9796 #endif /* _ASM_SCORE_EXEC_H */
9797diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
9798index a1519ad3..e8ac1ff 100644
9799--- a/arch/score/kernel/process.c
9800+++ b/arch/score/kernel/process.c
9801@@ -116,8 +116,3 @@ unsigned long get_wchan(struct task_struct *task)
9802
9803 return task_pt_regs(task)->cp0_epc;
9804 }
9805-
9806-unsigned long arch_align_stack(unsigned long sp)
9807-{
9808- return sp;
9809-}
9810diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
9811index ef9e555..331bd29 100644
9812--- a/arch/sh/include/asm/cache.h
9813+++ b/arch/sh/include/asm/cache.h
9814@@ -9,10 +9,11 @@
9815 #define __ASM_SH_CACHE_H
9816 #ifdef __KERNEL__
9817
9818+#include <linux/const.h>
9819 #include <linux/init.h>
9820 #include <cpu/cache.h>
9821
9822-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
9823+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
9824
9825 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
9826
9827diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
9828index 6777177..cb5e44f 100644
9829--- a/arch/sh/mm/mmap.c
9830+++ b/arch/sh/mm/mmap.c
9831@@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
9832 struct mm_struct *mm = current->mm;
9833 struct vm_area_struct *vma;
9834 int do_colour_align;
9835+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9836 struct vm_unmapped_area_info info;
9837
9838 if (flags & MAP_FIXED) {
9839@@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
9840 if (filp || (flags & MAP_SHARED))
9841 do_colour_align = 1;
9842
9843+#ifdef CONFIG_PAX_RANDMMAP
9844+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9845+#endif
9846+
9847 if (addr) {
9848 if (do_colour_align)
9849 addr = COLOUR_ALIGN(addr, pgoff);
9850@@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
9851 addr = PAGE_ALIGN(addr);
9852
9853 vma = find_vma(mm, addr);
9854- if (TASK_SIZE - len >= addr &&
9855- (!vma || addr + len <= vma->vm_start))
9856+ if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9857 return addr;
9858 }
9859
9860 info.flags = 0;
9861 info.length = len;
9862- info.low_limit = TASK_UNMAPPED_BASE;
9863+ info.low_limit = mm->mmap_base;
9864 info.high_limit = TASK_SIZE;
9865 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
9866 info.align_offset = pgoff << PAGE_SHIFT;
9867@@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9868 struct mm_struct *mm = current->mm;
9869 unsigned long addr = addr0;
9870 int do_colour_align;
9871+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9872 struct vm_unmapped_area_info info;
9873
9874 if (flags & MAP_FIXED) {
9875@@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9876 if (filp || (flags & MAP_SHARED))
9877 do_colour_align = 1;
9878
9879+#ifdef CONFIG_PAX_RANDMMAP
9880+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9881+#endif
9882+
9883 /* requesting a specific address */
9884 if (addr) {
9885 if (do_colour_align)
9886@@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9887 addr = PAGE_ALIGN(addr);
9888
9889 vma = find_vma(mm, addr);
9890- if (TASK_SIZE - len >= addr &&
9891- (!vma || addr + len <= vma->vm_start))
9892+ if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9893 return addr;
9894 }
9895
9896@@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9897 VM_BUG_ON(addr != -ENOMEM);
9898 info.flags = 0;
9899 info.low_limit = TASK_UNMAPPED_BASE;
9900+
9901+#ifdef CONFIG_PAX_RANDMMAP
9902+ if (mm->pax_flags & MF_PAX_RANDMMAP)
9903+ info.low_limit += mm->delta_mmap;
9904+#endif
9905+
9906 info.high_limit = TASK_SIZE;
9907 addr = vm_unmapped_area(&info);
9908 }
9909diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
9910index 4082749..fd97781 100644
9911--- a/arch/sparc/include/asm/atomic_64.h
9912+++ b/arch/sparc/include/asm/atomic_64.h
9913@@ -15,18 +15,38 @@
9914 #define ATOMIC64_INIT(i) { (i) }
9915
9916 #define atomic_read(v) ACCESS_ONCE((v)->counter)
9917+static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
9918+{
9919+ return ACCESS_ONCE(v->counter);
9920+}
9921 #define atomic64_read(v) ACCESS_ONCE((v)->counter)
9922+static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
9923+{
9924+ return ACCESS_ONCE(v->counter);
9925+}
9926
9927 #define atomic_set(v, i) (((v)->counter) = i)
9928+static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
9929+{
9930+ v->counter = i;
9931+}
9932 #define atomic64_set(v, i) (((v)->counter) = i)
9933+static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
9934+{
9935+ v->counter = i;
9936+}
9937
9938-#define ATOMIC_OP(op) \
9939-void atomic_##op(int, atomic_t *); \
9940-void atomic64_##op(long, atomic64_t *);
9941+#define __ATOMIC_OP(op, suffix) \
9942+void atomic_##op##suffix(int, atomic##suffix##_t *); \
9943+void atomic64_##op##suffix(long, atomic64##suffix##_t *);
9944
9945-#define ATOMIC_OP_RETURN(op) \
9946-int atomic_##op##_return(int, atomic_t *); \
9947-long atomic64_##op##_return(long, atomic64_t *);
9948+#define ATOMIC_OP(op) __ATOMIC_OP(op, ) __ATOMIC_OP(op, _unchecked)
9949+
9950+#define __ATOMIC_OP_RETURN(op, suffix) \
9951+int atomic_##op##_return##suffix(int, atomic##suffix##_t *); \
9952+long atomic64_##op##_return##suffix(long, atomic64##suffix##_t *);
9953+
9954+#define ATOMIC_OP_RETURN(op) __ATOMIC_OP_RETURN(op, ) __ATOMIC_OP_RETURN(op, _unchecked)
9955
9956 #define ATOMIC_OPS(op) ATOMIC_OP(op) ATOMIC_OP_RETURN(op)
9957
9958@@ -35,13 +55,23 @@ ATOMIC_OPS(sub)
9959
9960 #undef ATOMIC_OPS
9961 #undef ATOMIC_OP_RETURN
9962+#undef __ATOMIC_OP_RETURN
9963 #undef ATOMIC_OP
9964+#undef __ATOMIC_OP
9965
9966 #define atomic_dec_return(v) atomic_sub_return(1, v)
9967 #define atomic64_dec_return(v) atomic64_sub_return(1, v)
9968
9969 #define atomic_inc_return(v) atomic_add_return(1, v)
9970+static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
9971+{
9972+ return atomic_add_return_unchecked(1, v);
9973+}
9974 #define atomic64_inc_return(v) atomic64_add_return(1, v)
9975+static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
9976+{
9977+ return atomic64_add_return_unchecked(1, v);
9978+}
9979
9980 /*
9981 * atomic_inc_and_test - increment and test
9982@@ -52,6 +82,10 @@ ATOMIC_OPS(sub)
9983 * other cases.
9984 */
9985 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
9986+static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
9987+{
9988+ return atomic_inc_return_unchecked(v) == 0;
9989+}
9990 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
9991
9992 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
9993@@ -61,25 +95,60 @@ ATOMIC_OPS(sub)
9994 #define atomic64_dec_and_test(v) (atomic64_sub_return(1, v) == 0)
9995
9996 #define atomic_inc(v) atomic_add(1, v)
9997+static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
9998+{
9999+ atomic_add_unchecked(1, v);
10000+}
10001 #define atomic64_inc(v) atomic64_add(1, v)
10002+static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
10003+{
10004+ atomic64_add_unchecked(1, v);
10005+}
10006
10007 #define atomic_dec(v) atomic_sub(1, v)
10008+static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
10009+{
10010+ atomic_sub_unchecked(1, v);
10011+}
10012 #define atomic64_dec(v) atomic64_sub(1, v)
10013+static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
10014+{
10015+ atomic64_sub_unchecked(1, v);
10016+}
10017
10018 #define atomic_add_negative(i, v) (atomic_add_return(i, v) < 0)
10019 #define atomic64_add_negative(i, v) (atomic64_add_return(i, v) < 0)
10020
10021 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
10022+static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
10023+{
10024+ return cmpxchg(&v->counter, old, new);
10025+}
10026 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
10027+static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
10028+{
10029+ return xchg(&v->counter, new);
10030+}
10031
10032 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
10033 {
10034- int c, old;
10035+ int c, old, new;
10036 c = atomic_read(v);
10037 for (;;) {
10038- if (unlikely(c == (u)))
10039+ if (unlikely(c == u))
10040 break;
10041- old = atomic_cmpxchg((v), c, c + (a));
10042+
10043+ asm volatile("addcc %2, %0, %0\n"
10044+
10045+#ifdef CONFIG_PAX_REFCOUNT
10046+ "tvs %%icc, 6\n"
10047+#endif
10048+
10049+ : "=r" (new)
10050+ : "0" (c), "ir" (a)
10051+ : "cc");
10052+
10053+ old = atomic_cmpxchg(v, c, new);
10054 if (likely(old == c))
10055 break;
10056 c = old;
10057@@ -90,20 +159,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
10058 #define atomic64_cmpxchg(v, o, n) \
10059 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
10060 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
10061+static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
10062+{
10063+ return xchg(&v->counter, new);
10064+}
10065
10066 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
10067 {
10068- long c, old;
10069+ long c, old, new;
10070 c = atomic64_read(v);
10071 for (;;) {
10072- if (unlikely(c == (u)))
10073+ if (unlikely(c == u))
10074 break;
10075- old = atomic64_cmpxchg((v), c, c + (a));
10076+
10077+ asm volatile("addcc %2, %0, %0\n"
10078+
10079+#ifdef CONFIG_PAX_REFCOUNT
10080+ "tvs %%xcc, 6\n"
10081+#endif
10082+
10083+ : "=r" (new)
10084+ : "0" (c), "ir" (a)
10085+ : "cc");
10086+
10087+ old = atomic64_cmpxchg(v, c, new);
10088 if (likely(old == c))
10089 break;
10090 c = old;
10091 }
10092- return c != (u);
10093+ return c != u;
10094 }
10095
10096 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
10097diff --git a/arch/sparc/include/asm/barrier_64.h b/arch/sparc/include/asm/barrier_64.h
10098index 7664894..45a974b 100644
10099--- a/arch/sparc/include/asm/barrier_64.h
10100+++ b/arch/sparc/include/asm/barrier_64.h
10101@@ -60,7 +60,7 @@ do { __asm__ __volatile__("ba,pt %%xcc, 1f\n\t" \
10102 do { \
10103 compiletime_assert_atomic_type(*p); \
10104 barrier(); \
10105- ACCESS_ONCE(*p) = (v); \
10106+ ACCESS_ONCE_RW(*p) = (v); \
10107 } while (0)
10108
10109 #define smp_load_acquire(p) \
10110diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
10111index 5bb6991..5c2132e 100644
10112--- a/arch/sparc/include/asm/cache.h
10113+++ b/arch/sparc/include/asm/cache.h
10114@@ -7,10 +7,12 @@
10115 #ifndef _SPARC_CACHE_H
10116 #define _SPARC_CACHE_H
10117
10118+#include <linux/const.h>
10119+
10120 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
10121
10122 #define L1_CACHE_SHIFT 5
10123-#define L1_CACHE_BYTES 32
10124+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10125
10126 #ifdef CONFIG_SPARC32
10127 #define SMP_CACHE_BYTES_SHIFT 5
10128diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
10129index a24e41f..47677ff 100644
10130--- a/arch/sparc/include/asm/elf_32.h
10131+++ b/arch/sparc/include/asm/elf_32.h
10132@@ -114,6 +114,13 @@ typedef struct {
10133
10134 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
10135
10136+#ifdef CONFIG_PAX_ASLR
10137+#define PAX_ELF_ET_DYN_BASE 0x10000UL
10138+
10139+#define PAX_DELTA_MMAP_LEN 16
10140+#define PAX_DELTA_STACK_LEN 16
10141+#endif
10142+
10143 /* This yields a mask that user programs can use to figure out what
10144 instruction set this cpu supports. This can NOT be done in userspace
10145 on Sparc. */
10146diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
10147index 370ca1e..d4f4a98 100644
10148--- a/arch/sparc/include/asm/elf_64.h
10149+++ b/arch/sparc/include/asm/elf_64.h
10150@@ -189,6 +189,13 @@ typedef struct {
10151 #define ELF_ET_DYN_BASE 0x0000010000000000UL
10152 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
10153
10154+#ifdef CONFIG_PAX_ASLR
10155+#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
10156+
10157+#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
10158+#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
10159+#endif
10160+
10161 extern unsigned long sparc64_elf_hwcap;
10162 #define ELF_HWCAP sparc64_elf_hwcap
10163
10164diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
10165index a3890da..f6a408e 100644
10166--- a/arch/sparc/include/asm/pgalloc_32.h
10167+++ b/arch/sparc/include/asm/pgalloc_32.h
10168@@ -35,6 +35,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
10169 }
10170
10171 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
10172+#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
10173
10174 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
10175 unsigned long address)
10176diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
10177index 5e31871..13469c6 100644
10178--- a/arch/sparc/include/asm/pgalloc_64.h
10179+++ b/arch/sparc/include/asm/pgalloc_64.h
10180@@ -21,6 +21,7 @@ static inline void __pgd_populate(pgd_t *pgd, pud_t *pud)
10181 }
10182
10183 #define pgd_populate(MM, PGD, PUD) __pgd_populate(PGD, PUD)
10184+#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
10185
10186 static inline pgd_t *pgd_alloc(struct mm_struct *mm)
10187 {
10188@@ -38,6 +39,7 @@ static inline void __pud_populate(pud_t *pud, pmd_t *pmd)
10189 }
10190
10191 #define pud_populate(MM, PUD, PMD) __pud_populate(PUD, PMD)
10192+#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
10193
10194 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
10195 {
10196diff --git a/arch/sparc/include/asm/pgtable.h b/arch/sparc/include/asm/pgtable.h
10197index 59ba6f6..4518128 100644
10198--- a/arch/sparc/include/asm/pgtable.h
10199+++ b/arch/sparc/include/asm/pgtable.h
10200@@ -5,4 +5,8 @@
10201 #else
10202 #include <asm/pgtable_32.h>
10203 #endif
10204+
10205+#define ktla_ktva(addr) (addr)
10206+#define ktva_ktla(addr) (addr)
10207+
10208 #endif
10209diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
10210index f06b36a..bca3189 100644
10211--- a/arch/sparc/include/asm/pgtable_32.h
10212+++ b/arch/sparc/include/asm/pgtable_32.h
10213@@ -51,6 +51,9 @@ unsigned long __init bootmem_init(unsigned long *pages_avail);
10214 #define PAGE_SHARED SRMMU_PAGE_SHARED
10215 #define PAGE_COPY SRMMU_PAGE_COPY
10216 #define PAGE_READONLY SRMMU_PAGE_RDONLY
10217+#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
10218+#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
10219+#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
10220 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
10221
10222 /* Top-level page directory - dummy used by init-mm.
10223@@ -63,18 +66,18 @@ extern unsigned long ptr_in_current_pgd;
10224
10225 /* xwr */
10226 #define __P000 PAGE_NONE
10227-#define __P001 PAGE_READONLY
10228-#define __P010 PAGE_COPY
10229-#define __P011 PAGE_COPY
10230+#define __P001 PAGE_READONLY_NOEXEC
10231+#define __P010 PAGE_COPY_NOEXEC
10232+#define __P011 PAGE_COPY_NOEXEC
10233 #define __P100 PAGE_READONLY
10234 #define __P101 PAGE_READONLY
10235 #define __P110 PAGE_COPY
10236 #define __P111 PAGE_COPY
10237
10238 #define __S000 PAGE_NONE
10239-#define __S001 PAGE_READONLY
10240-#define __S010 PAGE_SHARED
10241-#define __S011 PAGE_SHARED
10242+#define __S001 PAGE_READONLY_NOEXEC
10243+#define __S010 PAGE_SHARED_NOEXEC
10244+#define __S011 PAGE_SHARED_NOEXEC
10245 #define __S100 PAGE_READONLY
10246 #define __S101 PAGE_READONLY
10247 #define __S110 PAGE_SHARED
10248diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
10249index ae51a11..eadfd03 100644
10250--- a/arch/sparc/include/asm/pgtsrmmu.h
10251+++ b/arch/sparc/include/asm/pgtsrmmu.h
10252@@ -111,6 +111,11 @@
10253 SRMMU_EXEC | SRMMU_REF)
10254 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
10255 SRMMU_EXEC | SRMMU_REF)
10256+
10257+#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
10258+#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
10259+#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
10260+
10261 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
10262 SRMMU_DIRTY | SRMMU_REF)
10263
10264diff --git a/arch/sparc/include/asm/setup.h b/arch/sparc/include/asm/setup.h
10265index 29d64b1..4272fe8 100644
10266--- a/arch/sparc/include/asm/setup.h
10267+++ b/arch/sparc/include/asm/setup.h
10268@@ -55,8 +55,8 @@ int handle_ldf_stq(u32 insn, struct pt_regs *regs);
10269 void handle_ld_nf(u32 insn, struct pt_regs *regs);
10270
10271 /* init_64.c */
10272-extern atomic_t dcpage_flushes;
10273-extern atomic_t dcpage_flushes_xcall;
10274+extern atomic_unchecked_t dcpage_flushes;
10275+extern atomic_unchecked_t dcpage_flushes_xcall;
10276
10277 extern int sysctl_tsb_ratio;
10278 #endif
10279diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
10280index 9689176..63c18ea 100644
10281--- a/arch/sparc/include/asm/spinlock_64.h
10282+++ b/arch/sparc/include/asm/spinlock_64.h
10283@@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
10284
10285 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
10286
10287-static void inline arch_read_lock(arch_rwlock_t *lock)
10288+static inline void arch_read_lock(arch_rwlock_t *lock)
10289 {
10290 unsigned long tmp1, tmp2;
10291
10292 __asm__ __volatile__ (
10293 "1: ldsw [%2], %0\n"
10294 " brlz,pn %0, 2f\n"
10295-"4: add %0, 1, %1\n"
10296+"4: addcc %0, 1, %1\n"
10297+
10298+#ifdef CONFIG_PAX_REFCOUNT
10299+" tvs %%icc, 6\n"
10300+#endif
10301+
10302 " cas [%2], %0, %1\n"
10303 " cmp %0, %1\n"
10304 " bne,pn %%icc, 1b\n"
10305@@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
10306 " .previous"
10307 : "=&r" (tmp1), "=&r" (tmp2)
10308 : "r" (lock)
10309- : "memory");
10310+ : "memory", "cc");
10311 }
10312
10313-static int inline arch_read_trylock(arch_rwlock_t *lock)
10314+static inline int arch_read_trylock(arch_rwlock_t *lock)
10315 {
10316 int tmp1, tmp2;
10317
10318@@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
10319 "1: ldsw [%2], %0\n"
10320 " brlz,a,pn %0, 2f\n"
10321 " mov 0, %0\n"
10322-" add %0, 1, %1\n"
10323+" addcc %0, 1, %1\n"
10324+
10325+#ifdef CONFIG_PAX_REFCOUNT
10326+" tvs %%icc, 6\n"
10327+#endif
10328+
10329 " cas [%2], %0, %1\n"
10330 " cmp %0, %1\n"
10331 " bne,pn %%icc, 1b\n"
10332@@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
10333 return tmp1;
10334 }
10335
10336-static void inline arch_read_unlock(arch_rwlock_t *lock)
10337+static inline void arch_read_unlock(arch_rwlock_t *lock)
10338 {
10339 unsigned long tmp1, tmp2;
10340
10341 __asm__ __volatile__(
10342 "1: lduw [%2], %0\n"
10343-" sub %0, 1, %1\n"
10344+" subcc %0, 1, %1\n"
10345+
10346+#ifdef CONFIG_PAX_REFCOUNT
10347+" tvs %%icc, 6\n"
10348+#endif
10349+
10350 " cas [%2], %0, %1\n"
10351 " cmp %0, %1\n"
10352 " bne,pn %%xcc, 1b\n"
10353@@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
10354 : "memory");
10355 }
10356
10357-static void inline arch_write_lock(arch_rwlock_t *lock)
10358+static inline void arch_write_lock(arch_rwlock_t *lock)
10359 {
10360 unsigned long mask, tmp1, tmp2;
10361
10362@@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
10363 : "memory");
10364 }
10365
10366-static void inline arch_write_unlock(arch_rwlock_t *lock)
10367+static inline void arch_write_unlock(arch_rwlock_t *lock)
10368 {
10369 __asm__ __volatile__(
10370 " stw %%g0, [%0]"
10371@@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
10372 : "memory");
10373 }
10374
10375-static int inline arch_write_trylock(arch_rwlock_t *lock)
10376+static inline int arch_write_trylock(arch_rwlock_t *lock)
10377 {
10378 unsigned long mask, tmp1, tmp2, result;
10379
10380diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
10381index 229475f..2fca9163 100644
10382--- a/arch/sparc/include/asm/thread_info_32.h
10383+++ b/arch/sparc/include/asm/thread_info_32.h
10384@@ -48,6 +48,7 @@ struct thread_info {
10385 struct reg_window32 reg_window[NSWINS]; /* align for ldd! */
10386 unsigned long rwbuf_stkptrs[NSWINS];
10387 unsigned long w_saved;
10388+ unsigned long lowest_stack;
10389 };
10390
10391 /*
10392diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
10393index bde5982..9cbb56d 100644
10394--- a/arch/sparc/include/asm/thread_info_64.h
10395+++ b/arch/sparc/include/asm/thread_info_64.h
10396@@ -59,6 +59,8 @@ struct thread_info {
10397 struct pt_regs *kern_una_regs;
10398 unsigned int kern_una_insn;
10399
10400+ unsigned long lowest_stack;
10401+
10402 unsigned long fpregs[(7 * 256) / sizeof(unsigned long)]
10403 __attribute__ ((aligned(64)));
10404 };
10405@@ -180,12 +182,13 @@ register struct thread_info *current_thread_info_reg asm("g6");
10406 #define TIF_NEED_RESCHED 3 /* rescheduling necessary */
10407 /* flag bit 4 is available */
10408 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
10409-/* flag bit 6 is available */
10410+#define TIF_GRSEC_SETXID 6 /* update credentials on syscall entry/exit */
10411 #define TIF_32BIT 7 /* 32-bit binary */
10412 #define TIF_NOHZ 8 /* in adaptive nohz mode */
10413 #define TIF_SECCOMP 9 /* secure computing */
10414 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
10415 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
10416+
10417 /* NOTE: Thread flags >= 12 should be ones we have no interest
10418 * in using in assembly, else we can't use the mask as
10419 * an immediate value in instructions such as andcc.
10420@@ -205,12 +208,17 @@ register struct thread_info *current_thread_info_reg asm("g6");
10421 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
10422 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
10423 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
10424+#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
10425
10426 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
10427 _TIF_DO_NOTIFY_RESUME_MASK | \
10428 _TIF_NEED_RESCHED)
10429 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
10430
10431+#define _TIF_WORK_SYSCALL \
10432+ (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
10433+ _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
10434+
10435 #define is_32bit_task() (test_thread_flag(TIF_32BIT))
10436
10437 /*
10438diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
10439index bd56c28..4b63d83 100644
10440--- a/arch/sparc/include/asm/uaccess.h
10441+++ b/arch/sparc/include/asm/uaccess.h
10442@@ -1,5 +1,6 @@
10443 #ifndef ___ASM_SPARC_UACCESS_H
10444 #define ___ASM_SPARC_UACCESS_H
10445+
10446 #if defined(__sparc__) && defined(__arch64__)
10447 #include <asm/uaccess_64.h>
10448 #else
10449diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
10450index 64ee103..388aef0 100644
10451--- a/arch/sparc/include/asm/uaccess_32.h
10452+++ b/arch/sparc/include/asm/uaccess_32.h
10453@@ -47,6 +47,7 @@
10454 #define __user_ok(addr, size) ({ (void)(size); (addr) < STACK_TOP; })
10455 #define __kernel_ok (segment_eq(get_fs(), KERNEL_DS))
10456 #define __access_ok(addr, size) (__user_ok((addr) & get_fs().seg, (size)))
10457+#define access_ok_noprefault(type, addr, size) access_ok((type), (addr), (size))
10458 #define access_ok(type, addr, size) \
10459 ({ (void)(type); __access_ok((unsigned long)(addr), size); })
10460
10461@@ -313,27 +314,46 @@ unsigned long __copy_user(void __user *to, const void __user *from, unsigned lon
10462
10463 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
10464 {
10465- if (n && __access_ok((unsigned long) to, n))
10466+ if ((long)n < 0)
10467+ return n;
10468+
10469+ if (n && __access_ok((unsigned long) to, n)) {
10470+ if (!__builtin_constant_p(n))
10471+ check_object_size(from, n, true);
10472 return __copy_user(to, (__force void __user *) from, n);
10473- else
10474+ } else
10475 return n;
10476 }
10477
10478 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
10479 {
10480+ if ((long)n < 0)
10481+ return n;
10482+
10483+ if (!__builtin_constant_p(n))
10484+ check_object_size(from, n, true);
10485+
10486 return __copy_user(to, (__force void __user *) from, n);
10487 }
10488
10489 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
10490 {
10491- if (n && __access_ok((unsigned long) from, n))
10492+ if ((long)n < 0)
10493+ return n;
10494+
10495+ if (n && __access_ok((unsigned long) from, n)) {
10496+ if (!__builtin_constant_p(n))
10497+ check_object_size(to, n, false);
10498 return __copy_user((__force void __user *) to, from, n);
10499- else
10500+ } else
10501 return n;
10502 }
10503
10504 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
10505 {
10506+ if ((long)n < 0)
10507+ return n;
10508+
10509 return __copy_user((__force void __user *) to, from, n);
10510 }
10511
10512diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
10513index a35194b..47dabc0d 100644
10514--- a/arch/sparc/include/asm/uaccess_64.h
10515+++ b/arch/sparc/include/asm/uaccess_64.h
10516@@ -10,6 +10,7 @@
10517 #include <linux/compiler.h>
10518 #include <linux/string.h>
10519 #include <linux/thread_info.h>
10520+#include <linux/kernel.h>
10521 #include <asm/asi.h>
10522 #include <asm/spitfire.h>
10523 #include <asm-generic/uaccess-unaligned.h>
10524@@ -54,6 +55,11 @@ static inline int __access_ok(const void __user * addr, unsigned long size)
10525 return 1;
10526 }
10527
10528+static inline int access_ok_noprefault(int type, const void __user * addr, unsigned long size)
10529+{
10530+ return 1;
10531+}
10532+
10533 static inline int access_ok(int type, const void __user * addr, unsigned long size)
10534 {
10535 return 1;
10536@@ -228,8 +234,15 @@ unsigned long copy_from_user_fixup(void *to, const void __user *from,
10537 static inline unsigned long __must_check
10538 copy_from_user(void *to, const void __user *from, unsigned long size)
10539 {
10540- unsigned long ret = ___copy_from_user(to, from, size);
10541+ unsigned long ret;
10542
10543+ if ((long)size < 0 || size > INT_MAX)
10544+ return size;
10545+
10546+ if (!__builtin_constant_p(size))
10547+ check_object_size(to, size, false);
10548+
10549+ ret = ___copy_from_user(to, from, size);
10550 if (unlikely(ret))
10551 ret = copy_from_user_fixup(to, from, size);
10552
10553@@ -245,8 +258,15 @@ unsigned long copy_to_user_fixup(void __user *to, const void *from,
10554 static inline unsigned long __must_check
10555 copy_to_user(void __user *to, const void *from, unsigned long size)
10556 {
10557- unsigned long ret = ___copy_to_user(to, from, size);
10558+ unsigned long ret;
10559
10560+ if ((long)size < 0 || size > INT_MAX)
10561+ return size;
10562+
10563+ if (!__builtin_constant_p(size))
10564+ check_object_size(from, size, true);
10565+
10566+ ret = ___copy_to_user(to, from, size);
10567 if (unlikely(ret))
10568 ret = copy_to_user_fixup(to, from, size);
10569 return ret;
10570diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
10571index 7cf9c6e..6206648 100644
10572--- a/arch/sparc/kernel/Makefile
10573+++ b/arch/sparc/kernel/Makefile
10574@@ -4,7 +4,7 @@
10575 #
10576
10577 asflags-y := -ansi
10578-ccflags-y := -Werror
10579+#ccflags-y := -Werror
10580
10581 extra-y := head_$(BITS).o
10582
10583diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
10584index 50e7b62..79fae35 100644
10585--- a/arch/sparc/kernel/process_32.c
10586+++ b/arch/sparc/kernel/process_32.c
10587@@ -123,14 +123,14 @@ void show_regs(struct pt_regs *r)
10588
10589 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
10590 r->psr, r->pc, r->npc, r->y, print_tainted());
10591- printk("PC: <%pS>\n", (void *) r->pc);
10592+ printk("PC: <%pA>\n", (void *) r->pc);
10593 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
10594 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
10595 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
10596 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
10597 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
10598 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
10599- printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
10600+ printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
10601
10602 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
10603 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
10604@@ -167,7 +167,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
10605 rw = (struct reg_window32 *) fp;
10606 pc = rw->ins[7];
10607 printk("[%08lx : ", pc);
10608- printk("%pS ] ", (void *) pc);
10609+ printk("%pA ] ", (void *) pc);
10610 fp = rw->ins[6];
10611 } while (++count < 16);
10612 printk("\n");
10613diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
10614index 46a5964..a35c62c 100644
10615--- a/arch/sparc/kernel/process_64.c
10616+++ b/arch/sparc/kernel/process_64.c
10617@@ -161,7 +161,7 @@ static void show_regwindow(struct pt_regs *regs)
10618 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
10619 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
10620 if (regs->tstate & TSTATE_PRIV)
10621- printk("I7: <%pS>\n", (void *) rwk->ins[7]);
10622+ printk("I7: <%pA>\n", (void *) rwk->ins[7]);
10623 }
10624
10625 void show_regs(struct pt_regs *regs)
10626@@ -170,7 +170,7 @@ void show_regs(struct pt_regs *regs)
10627
10628 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
10629 regs->tpc, regs->tnpc, regs->y, print_tainted());
10630- printk("TPC: <%pS>\n", (void *) regs->tpc);
10631+ printk("TPC: <%pA>\n", (void *) regs->tpc);
10632 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
10633 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
10634 regs->u_regs[3]);
10635@@ -183,7 +183,7 @@ void show_regs(struct pt_regs *regs)
10636 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
10637 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
10638 regs->u_regs[15]);
10639- printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
10640+ printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
10641 show_regwindow(regs);
10642 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
10643 }
10644@@ -278,7 +278,7 @@ void arch_trigger_all_cpu_backtrace(bool include_self)
10645 ((tp && tp->task) ? tp->task->pid : -1));
10646
10647 if (gp->tstate & TSTATE_PRIV) {
10648- printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
10649+ printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
10650 (void *) gp->tpc,
10651 (void *) gp->o7,
10652 (void *) gp->i7,
10653diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
10654index 79cc0d1..ec62734 100644
10655--- a/arch/sparc/kernel/prom_common.c
10656+++ b/arch/sparc/kernel/prom_common.c
10657@@ -144,7 +144,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
10658
10659 unsigned int prom_early_allocated __initdata;
10660
10661-static struct of_pdt_ops prom_sparc_ops __initdata = {
10662+static struct of_pdt_ops prom_sparc_ops __initconst = {
10663 .nextprop = prom_common_nextprop,
10664 .getproplen = prom_getproplen,
10665 .getproperty = prom_getproperty,
10666diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
10667index 9ddc492..27a5619 100644
10668--- a/arch/sparc/kernel/ptrace_64.c
10669+++ b/arch/sparc/kernel/ptrace_64.c
10670@@ -1060,6 +1060,10 @@ long arch_ptrace(struct task_struct *child, long request,
10671 return ret;
10672 }
10673
10674+#ifdef CONFIG_GRKERNSEC_SETXID
10675+extern void gr_delayed_cred_worker(void);
10676+#endif
10677+
10678 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
10679 {
10680 int ret = 0;
10681@@ -1070,6 +1074,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
10682 if (test_thread_flag(TIF_NOHZ))
10683 user_exit();
10684
10685+#ifdef CONFIG_GRKERNSEC_SETXID
10686+ if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
10687+ gr_delayed_cred_worker();
10688+#endif
10689+
10690 if (test_thread_flag(TIF_SYSCALL_TRACE))
10691 ret = tracehook_report_syscall_entry(regs);
10692
10693@@ -1088,6 +1097,11 @@ asmlinkage void syscall_trace_leave(struct pt_regs *regs)
10694 if (test_thread_flag(TIF_NOHZ))
10695 user_exit();
10696
10697+#ifdef CONFIG_GRKERNSEC_SETXID
10698+ if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
10699+ gr_delayed_cred_worker();
10700+#endif
10701+
10702 audit_syscall_exit(regs);
10703
10704 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
10705diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
10706index 19cd08d..ff21e99 100644
10707--- a/arch/sparc/kernel/smp_64.c
10708+++ b/arch/sparc/kernel/smp_64.c
10709@@ -891,7 +891,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
10710 return;
10711
10712 #ifdef CONFIG_DEBUG_DCFLUSH
10713- atomic_inc(&dcpage_flushes);
10714+ atomic_inc_unchecked(&dcpage_flushes);
10715 #endif
10716
10717 this_cpu = get_cpu();
10718@@ -915,7 +915,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
10719 xcall_deliver(data0, __pa(pg_addr),
10720 (u64) pg_addr, cpumask_of(cpu));
10721 #ifdef CONFIG_DEBUG_DCFLUSH
10722- atomic_inc(&dcpage_flushes_xcall);
10723+ atomic_inc_unchecked(&dcpage_flushes_xcall);
10724 #endif
10725 }
10726 }
10727@@ -934,7 +934,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
10728 preempt_disable();
10729
10730 #ifdef CONFIG_DEBUG_DCFLUSH
10731- atomic_inc(&dcpage_flushes);
10732+ atomic_inc_unchecked(&dcpage_flushes);
10733 #endif
10734 data0 = 0;
10735 pg_addr = page_address(page);
10736@@ -951,7 +951,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
10737 xcall_deliver(data0, __pa(pg_addr),
10738 (u64) pg_addr, cpu_online_mask);
10739 #ifdef CONFIG_DEBUG_DCFLUSH
10740- atomic_inc(&dcpage_flushes_xcall);
10741+ atomic_inc_unchecked(&dcpage_flushes_xcall);
10742 #endif
10743 }
10744 __local_flush_dcache_page(page);
10745diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
10746index 646988d..b88905f 100644
10747--- a/arch/sparc/kernel/sys_sparc_32.c
10748+++ b/arch/sparc/kernel/sys_sparc_32.c
10749@@ -54,7 +54,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
10750 if (len > TASK_SIZE - PAGE_SIZE)
10751 return -ENOMEM;
10752 if (!addr)
10753- addr = TASK_UNMAPPED_BASE;
10754+ addr = current->mm->mmap_base;
10755
10756 info.flags = 0;
10757 info.length = len;
10758diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
10759index 30e7ddb..266a3b0 100644
10760--- a/arch/sparc/kernel/sys_sparc_64.c
10761+++ b/arch/sparc/kernel/sys_sparc_64.c
10762@@ -89,13 +89,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
10763 struct vm_area_struct * vma;
10764 unsigned long task_size = TASK_SIZE;
10765 int do_color_align;
10766+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
10767 struct vm_unmapped_area_info info;
10768
10769 if (flags & MAP_FIXED) {
10770 /* We do not accept a shared mapping if it would violate
10771 * cache aliasing constraints.
10772 */
10773- if ((flags & MAP_SHARED) &&
10774+ if ((filp || (flags & MAP_SHARED)) &&
10775 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
10776 return -EINVAL;
10777 return addr;
10778@@ -110,6 +111,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
10779 if (filp || (flags & MAP_SHARED))
10780 do_color_align = 1;
10781
10782+#ifdef CONFIG_PAX_RANDMMAP
10783+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
10784+#endif
10785+
10786 if (addr) {
10787 if (do_color_align)
10788 addr = COLOR_ALIGN(addr, pgoff);
10789@@ -117,22 +122,28 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
10790 addr = PAGE_ALIGN(addr);
10791
10792 vma = find_vma(mm, addr);
10793- if (task_size - len >= addr &&
10794- (!vma || addr + len <= vma->vm_start))
10795+ if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
10796 return addr;
10797 }
10798
10799 info.flags = 0;
10800 info.length = len;
10801- info.low_limit = TASK_UNMAPPED_BASE;
10802+ info.low_limit = mm->mmap_base;
10803 info.high_limit = min(task_size, VA_EXCLUDE_START);
10804 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
10805 info.align_offset = pgoff << PAGE_SHIFT;
10806+ info.threadstack_offset = offset;
10807 addr = vm_unmapped_area(&info);
10808
10809 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
10810 VM_BUG_ON(addr != -ENOMEM);
10811 info.low_limit = VA_EXCLUDE_END;
10812+
10813+#ifdef CONFIG_PAX_RANDMMAP
10814+ if (mm->pax_flags & MF_PAX_RANDMMAP)
10815+ info.low_limit += mm->delta_mmap;
10816+#endif
10817+
10818 info.high_limit = task_size;
10819 addr = vm_unmapped_area(&info);
10820 }
10821@@ -150,6 +161,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10822 unsigned long task_size = STACK_TOP32;
10823 unsigned long addr = addr0;
10824 int do_color_align;
10825+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
10826 struct vm_unmapped_area_info info;
10827
10828 /* This should only ever run for 32-bit processes. */
10829@@ -159,7 +171,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10830 /* We do not accept a shared mapping if it would violate
10831 * cache aliasing constraints.
10832 */
10833- if ((flags & MAP_SHARED) &&
10834+ if ((filp || (flags & MAP_SHARED)) &&
10835 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
10836 return -EINVAL;
10837 return addr;
10838@@ -172,6 +184,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10839 if (filp || (flags & MAP_SHARED))
10840 do_color_align = 1;
10841
10842+#ifdef CONFIG_PAX_RANDMMAP
10843+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
10844+#endif
10845+
10846 /* requesting a specific address */
10847 if (addr) {
10848 if (do_color_align)
10849@@ -180,8 +196,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10850 addr = PAGE_ALIGN(addr);
10851
10852 vma = find_vma(mm, addr);
10853- if (task_size - len >= addr &&
10854- (!vma || addr + len <= vma->vm_start))
10855+ if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
10856 return addr;
10857 }
10858
10859@@ -191,6 +206,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10860 info.high_limit = mm->mmap_base;
10861 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
10862 info.align_offset = pgoff << PAGE_SHIFT;
10863+ info.threadstack_offset = offset;
10864 addr = vm_unmapped_area(&info);
10865
10866 /*
10867@@ -203,6 +219,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10868 VM_BUG_ON(addr != -ENOMEM);
10869 info.flags = 0;
10870 info.low_limit = TASK_UNMAPPED_BASE;
10871+
10872+#ifdef CONFIG_PAX_RANDMMAP
10873+ if (mm->pax_flags & MF_PAX_RANDMMAP)
10874+ info.low_limit += mm->delta_mmap;
10875+#endif
10876+
10877 info.high_limit = STACK_TOP32;
10878 addr = vm_unmapped_area(&info);
10879 }
10880@@ -259,10 +281,14 @@ unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, u
10881 EXPORT_SYMBOL(get_fb_unmapped_area);
10882
10883 /* Essentially the same as PowerPC. */
10884-static unsigned long mmap_rnd(void)
10885+static unsigned long mmap_rnd(struct mm_struct *mm)
10886 {
10887 unsigned long rnd = 0UL;
10888
10889+#ifdef CONFIG_PAX_RANDMMAP
10890+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
10891+#endif
10892+
10893 if (current->flags & PF_RANDOMIZE) {
10894 unsigned long val = get_random_int();
10895 if (test_thread_flag(TIF_32BIT))
10896@@ -275,7 +301,7 @@ static unsigned long mmap_rnd(void)
10897
10898 void arch_pick_mmap_layout(struct mm_struct *mm)
10899 {
10900- unsigned long random_factor = mmap_rnd();
10901+ unsigned long random_factor = mmap_rnd(mm);
10902 unsigned long gap;
10903
10904 /*
10905@@ -288,6 +314,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
10906 gap == RLIM_INFINITY ||
10907 sysctl_legacy_va_layout) {
10908 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
10909+
10910+#ifdef CONFIG_PAX_RANDMMAP
10911+ if (mm->pax_flags & MF_PAX_RANDMMAP)
10912+ mm->mmap_base += mm->delta_mmap;
10913+#endif
10914+
10915 mm->get_unmapped_area = arch_get_unmapped_area;
10916 } else {
10917 /* We know it's 32-bit */
10918@@ -299,6 +331,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
10919 gap = (task_size / 6 * 5);
10920
10921 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
10922+
10923+#ifdef CONFIG_PAX_RANDMMAP
10924+ if (mm->pax_flags & MF_PAX_RANDMMAP)
10925+ mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
10926+#endif
10927+
10928 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
10929 }
10930 }
10931diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
10932index bb00089..e0ea580 100644
10933--- a/arch/sparc/kernel/syscalls.S
10934+++ b/arch/sparc/kernel/syscalls.S
10935@@ -62,7 +62,7 @@ sys32_rt_sigreturn:
10936 #endif
10937 .align 32
10938 1: ldx [%g6 + TI_FLAGS], %l5
10939- andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT|_TIF_NOHZ), %g0
10940+ andcc %l5, _TIF_WORK_SYSCALL, %g0
10941 be,pt %icc, rtrap
10942 nop
10943 call syscall_trace_leave
10944@@ -194,7 +194,7 @@ linux_sparc_syscall32:
10945
10946 srl %i3, 0, %o3 ! IEU0
10947 srl %i2, 0, %o2 ! IEU0 Group
10948- andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT|_TIF_NOHZ), %g0
10949+ andcc %l0, _TIF_WORK_SYSCALL, %g0
10950 bne,pn %icc, linux_syscall_trace32 ! CTI
10951 mov %i0, %l5 ! IEU1
10952 5: call %l7 ! CTI Group brk forced
10953@@ -218,7 +218,7 @@ linux_sparc_syscall:
10954
10955 mov %i3, %o3 ! IEU1
10956 mov %i4, %o4 ! IEU0 Group
10957- andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT|_TIF_NOHZ), %g0
10958+ andcc %l0, _TIF_WORK_SYSCALL, %g0
10959 bne,pn %icc, linux_syscall_trace ! CTI Group
10960 mov %i0, %l5 ! IEU0
10961 2: call %l7 ! CTI Group brk forced
10962@@ -233,7 +233,7 @@ ret_sys_call:
10963
10964 cmp %o0, -ERESTART_RESTARTBLOCK
10965 bgeu,pn %xcc, 1f
10966- andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT|_TIF_NOHZ), %g0
10967+ andcc %l0, _TIF_WORK_SYSCALL, %g0
10968 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
10969
10970 2:
10971diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
10972index 4f21df7..0a374da 100644
10973--- a/arch/sparc/kernel/traps_32.c
10974+++ b/arch/sparc/kernel/traps_32.c
10975@@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
10976 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
10977 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
10978
10979+extern void gr_handle_kernel_exploit(void);
10980+
10981 void __noreturn die_if_kernel(char *str, struct pt_regs *regs)
10982 {
10983 static int die_counter;
10984@@ -76,15 +78,17 @@ void __noreturn die_if_kernel(char *str, struct pt_regs *regs)
10985 count++ < 30 &&
10986 (((unsigned long) rw) >= PAGE_OFFSET) &&
10987 !(((unsigned long) rw) & 0x7)) {
10988- printk("Caller[%08lx]: %pS\n", rw->ins[7],
10989+ printk("Caller[%08lx]: %pA\n", rw->ins[7],
10990 (void *) rw->ins[7]);
10991 rw = (struct reg_window32 *)rw->ins[6];
10992 }
10993 }
10994 printk("Instruction DUMP:");
10995 instruction_dump ((unsigned long *) regs->pc);
10996- if(regs->psr & PSR_PS)
10997+ if(regs->psr & PSR_PS) {
10998+ gr_handle_kernel_exploit();
10999 do_exit(SIGKILL);
11000+ }
11001 do_exit(SIGSEGV);
11002 }
11003
11004diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
11005index d21cd62..00a4a17 100644
11006--- a/arch/sparc/kernel/traps_64.c
11007+++ b/arch/sparc/kernel/traps_64.c
11008@@ -79,7 +79,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
11009 i + 1,
11010 p->trapstack[i].tstate, p->trapstack[i].tpc,
11011 p->trapstack[i].tnpc, p->trapstack[i].tt);
11012- printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
11013+ printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
11014 }
11015 }
11016
11017@@ -99,6 +99,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
11018
11019 lvl -= 0x100;
11020 if (regs->tstate & TSTATE_PRIV) {
11021+
11022+#ifdef CONFIG_PAX_REFCOUNT
11023+ if (lvl == 6)
11024+ pax_report_refcount_overflow(regs);
11025+#endif
11026+
11027 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
11028 die_if_kernel(buffer, regs);
11029 }
11030@@ -117,11 +123,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
11031 void bad_trap_tl1(struct pt_regs *regs, long lvl)
11032 {
11033 char buffer[32];
11034-
11035+
11036 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
11037 0, lvl, SIGTRAP) == NOTIFY_STOP)
11038 return;
11039
11040+#ifdef CONFIG_PAX_REFCOUNT
11041+ if (lvl == 6)
11042+ pax_report_refcount_overflow(regs);
11043+#endif
11044+
11045 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
11046
11047 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
11048@@ -1151,7 +1162,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
11049 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
11050 printk("%s" "ERROR(%d): ",
11051 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
11052- printk("TPC<%pS>\n", (void *) regs->tpc);
11053+ printk("TPC<%pA>\n", (void *) regs->tpc);
11054 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
11055 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
11056 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
11057@@ -1758,7 +1769,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
11058 smp_processor_id(),
11059 (type & 0x1) ? 'I' : 'D',
11060 regs->tpc);
11061- printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
11062+ printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
11063 panic("Irrecoverable Cheetah+ parity error.");
11064 }
11065
11066@@ -1766,7 +1777,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
11067 smp_processor_id(),
11068 (type & 0x1) ? 'I' : 'D',
11069 regs->tpc);
11070- printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
11071+ printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
11072 }
11073
11074 struct sun4v_error_entry {
11075@@ -1839,8 +1850,8 @@ struct sun4v_error_entry {
11076 /*0x38*/u64 reserved_5;
11077 };
11078
11079-static atomic_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
11080-static atomic_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
11081+static atomic_unchecked_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
11082+static atomic_unchecked_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
11083
11084 static const char *sun4v_err_type_to_str(u8 type)
11085 {
11086@@ -1932,7 +1943,7 @@ static void sun4v_report_real_raddr(const char *pfx, struct pt_regs *regs)
11087 }
11088
11089 static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
11090- int cpu, const char *pfx, atomic_t *ocnt)
11091+ int cpu, const char *pfx, atomic_unchecked_t *ocnt)
11092 {
11093 u64 *raw_ptr = (u64 *) ent;
11094 u32 attrs;
11095@@ -1990,8 +2001,8 @@ static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
11096
11097 show_regs(regs);
11098
11099- if ((cnt = atomic_read(ocnt)) != 0) {
11100- atomic_set(ocnt, 0);
11101+ if ((cnt = atomic_read_unchecked(ocnt)) != 0) {
11102+ atomic_set_unchecked(ocnt, 0);
11103 wmb();
11104 printk("%s: Queue overflowed %d times.\n",
11105 pfx, cnt);
11106@@ -2048,7 +2059,7 @@ out:
11107 */
11108 void sun4v_resum_overflow(struct pt_regs *regs)
11109 {
11110- atomic_inc(&sun4v_resum_oflow_cnt);
11111+ atomic_inc_unchecked(&sun4v_resum_oflow_cnt);
11112 }
11113
11114 /* We run with %pil set to PIL_NORMAL_MAX and PSTATE_IE enabled in %pstate.
11115@@ -2101,7 +2112,7 @@ void sun4v_nonresum_overflow(struct pt_regs *regs)
11116 /* XXX Actually even this can make not that much sense. Perhaps
11117 * XXX we should just pull the plug and panic directly from here?
11118 */
11119- atomic_inc(&sun4v_nonresum_oflow_cnt);
11120+ atomic_inc_unchecked(&sun4v_nonresum_oflow_cnt);
11121 }
11122
11123 static void sun4v_tlb_error(struct pt_regs *regs)
11124@@ -2120,9 +2131,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
11125
11126 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
11127 regs->tpc, tl);
11128- printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
11129+ printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
11130 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
11131- printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
11132+ printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
11133 (void *) regs->u_regs[UREG_I7]);
11134 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
11135 "pte[%lx] error[%lx]\n",
11136@@ -2143,9 +2154,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
11137
11138 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
11139 regs->tpc, tl);
11140- printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
11141+ printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
11142 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
11143- printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
11144+ printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
11145 (void *) regs->u_regs[UREG_I7]);
11146 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
11147 "pte[%lx] error[%lx]\n",
11148@@ -2362,13 +2373,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
11149 fp = (unsigned long)sf->fp + STACK_BIAS;
11150 }
11151
11152- printk(" [%016lx] %pS\n", pc, (void *) pc);
11153+ printk(" [%016lx] %pA\n", pc, (void *) pc);
11154 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
11155 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
11156 int index = tsk->curr_ret_stack;
11157 if (tsk->ret_stack && index >= graph) {
11158 pc = tsk->ret_stack[index - graph].ret;
11159- printk(" [%016lx] %pS\n", pc, (void *) pc);
11160+ printk(" [%016lx] %pA\n", pc, (void *) pc);
11161 graph++;
11162 }
11163 }
11164@@ -2386,6 +2397,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
11165 return (struct reg_window *) (fp + STACK_BIAS);
11166 }
11167
11168+extern void gr_handle_kernel_exploit(void);
11169+
11170 void __noreturn die_if_kernel(char *str, struct pt_regs *regs)
11171 {
11172 static int die_counter;
11173@@ -2414,7 +2427,7 @@ void __noreturn die_if_kernel(char *str, struct pt_regs *regs)
11174 while (rw &&
11175 count++ < 30 &&
11176 kstack_valid(tp, (unsigned long) rw)) {
11177- printk("Caller[%016lx]: %pS\n", rw->ins[7],
11178+ printk("Caller[%016lx]: %pA\n", rw->ins[7],
11179 (void *) rw->ins[7]);
11180
11181 rw = kernel_stack_up(rw);
11182@@ -2429,8 +2442,10 @@ void __noreturn die_if_kernel(char *str, struct pt_regs *regs)
11183 }
11184 if (panic_on_oops)
11185 panic("Fatal exception");
11186- if (regs->tstate & TSTATE_PRIV)
11187+ if (regs->tstate & TSTATE_PRIV) {
11188+ gr_handle_kernel_exploit();
11189 do_exit(SIGKILL);
11190+ }
11191 do_exit(SIGSEGV);
11192 }
11193 EXPORT_SYMBOL(die_if_kernel);
11194diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
11195index 62098a8..547ab2c 100644
11196--- a/arch/sparc/kernel/unaligned_64.c
11197+++ b/arch/sparc/kernel/unaligned_64.c
11198@@ -297,7 +297,7 @@ static void log_unaligned(struct pt_regs *regs)
11199 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
11200
11201 if (__ratelimit(&ratelimit)) {
11202- printk("Kernel unaligned access at TPC[%lx] %pS\n",
11203+ printk("Kernel unaligned access at TPC[%lx] %pA\n",
11204 regs->tpc, (void *) regs->tpc);
11205 }
11206 }
11207diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
11208index 3269b02..64f5231 100644
11209--- a/arch/sparc/lib/Makefile
11210+++ b/arch/sparc/lib/Makefile
11211@@ -2,7 +2,7 @@
11212 #
11213
11214 asflags-y := -ansi -DST_DIV0=0x02
11215-ccflags-y := -Werror
11216+#ccflags-y := -Werror
11217
11218 lib-$(CONFIG_SPARC32) += ashrdi3.o
11219 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
11220diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
11221index 05dac43..76f8ed4 100644
11222--- a/arch/sparc/lib/atomic_64.S
11223+++ b/arch/sparc/lib/atomic_64.S
11224@@ -15,11 +15,22 @@
11225 * a value and does the barriers.
11226 */
11227
11228-#define ATOMIC_OP(op) \
11229-ENTRY(atomic_##op) /* %o0 = increment, %o1 = atomic_ptr */ \
11230+#ifdef CONFIG_PAX_REFCOUNT
11231+#define __REFCOUNT_OP(op) op##cc
11232+#define __OVERFLOW_IOP tvs %icc, 6;
11233+#define __OVERFLOW_XOP tvs %xcc, 6;
11234+#else
11235+#define __REFCOUNT_OP(op) op
11236+#define __OVERFLOW_IOP
11237+#define __OVERFLOW_XOP
11238+#endif
11239+
11240+#define __ATOMIC_OP(op, suffix, asm_op, post_op) \
11241+ENTRY(atomic_##op##suffix) /* %o0 = increment, %o1 = atomic_ptr */ \
11242 BACKOFF_SETUP(%o2); \
11243 1: lduw [%o1], %g1; \
11244- op %g1, %o0, %g7; \
11245+ asm_op %g1, %o0, %g7; \
11246+ post_op \
11247 cas [%o1], %g1, %g7; \
11248 cmp %g1, %g7; \
11249 bne,pn %icc, BACKOFF_LABEL(2f, 1b); \
11250@@ -29,11 +40,15 @@ ENTRY(atomic_##op) /* %o0 = increment, %o1 = atomic_ptr */ \
11251 2: BACKOFF_SPIN(%o2, %o3, 1b); \
11252 ENDPROC(atomic_##op); \
11253
11254-#define ATOMIC_OP_RETURN(op) \
11255-ENTRY(atomic_##op##_return) /* %o0 = increment, %o1 = atomic_ptr */ \
11256+#define ATOMIC_OP(op) __ATOMIC_OP(op, , op, ) \
11257+ __ATOMIC_OP(op, _unchecked, __REFCOUNT_OP(op), __OVERFLOW_IOP)
11258+
11259+#define __ATOMIC_OP_RETURN(op, suffix, asm_op, post_op) \
11260+ENTRY(atomic_##op##_return##suffix) /* %o0 = increment, %o1 = atomic_ptr */\
11261 BACKOFF_SETUP(%o2); \
11262 1: lduw [%o1], %g1; \
11263- op %g1, %o0, %g7; \
11264+ asm_op %g1, %o0, %g7; \
11265+ post_op \
11266 cas [%o1], %g1, %g7; \
11267 cmp %g1, %g7; \
11268 bne,pn %icc, BACKOFF_LABEL(2f, 1b); \
11269@@ -43,6 +58,9 @@ ENTRY(atomic_##op##_return) /* %o0 = increment, %o1 = atomic_ptr */ \
11270 2: BACKOFF_SPIN(%o2, %o3, 1b); \
11271 ENDPROC(atomic_##op##_return);
11272
11273+#define ATOMIC_OP_RETURN(op) __ATOMIC_OP_RETURN(op, , op, ) \
11274+ __ATOMIC_OP_RETURN(op, _unchecked, __REFCOUNT_OP(op), __OVERFLOW_IOP)
11275+
11276 #define ATOMIC_OPS(op) ATOMIC_OP(op) ATOMIC_OP_RETURN(op)
11277
11278 ATOMIC_OPS(add)
11279@@ -50,13 +68,16 @@ ATOMIC_OPS(sub)
11280
11281 #undef ATOMIC_OPS
11282 #undef ATOMIC_OP_RETURN
11283+#undef __ATOMIC_OP_RETURN
11284 #undef ATOMIC_OP
11285+#undef __ATOMIC_OP
11286
11287-#define ATOMIC64_OP(op) \
11288-ENTRY(atomic64_##op) /* %o0 = increment, %o1 = atomic_ptr */ \
11289+#define __ATOMIC64_OP(op, suffix, asm_op, post_op) \
11290+ENTRY(atomic64_##op##suffix) /* %o0 = increment, %o1 = atomic_ptr */ \
11291 BACKOFF_SETUP(%o2); \
11292 1: ldx [%o1], %g1; \
11293- op %g1, %o0, %g7; \
11294+ asm_op %g1, %o0, %g7; \
11295+ post_op \
11296 casx [%o1], %g1, %g7; \
11297 cmp %g1, %g7; \
11298 bne,pn %xcc, BACKOFF_LABEL(2f, 1b); \
11299@@ -66,11 +87,15 @@ ENTRY(atomic64_##op) /* %o0 = increment, %o1 = atomic_ptr */ \
11300 2: BACKOFF_SPIN(%o2, %o3, 1b); \
11301 ENDPROC(atomic64_##op); \
11302
11303-#define ATOMIC64_OP_RETURN(op) \
11304-ENTRY(atomic64_##op##_return) /* %o0 = increment, %o1 = atomic_ptr */ \
11305+#define ATOMIC64_OP(op) __ATOMIC64_OP(op, , op, ) \
11306+ __ATOMIC64_OP(op, _unchecked, __REFCOUNT_OP(op), __OVERFLOW_XOP)
11307+
11308+#define __ATOMIC64_OP_RETURN(op, suffix, asm_op, post_op) \
11309+ENTRY(atomic64_##op##_return##suffix) /* %o0 = increment, %o1 = atomic_ptr */\
11310 BACKOFF_SETUP(%o2); \
11311 1: ldx [%o1], %g1; \
11312- op %g1, %o0, %g7; \
11313+ asm_op %g1, %o0, %g7; \
11314+ post_op \
11315 casx [%o1], %g1, %g7; \
11316 cmp %g1, %g7; \
11317 bne,pn %xcc, BACKOFF_LABEL(2f, 1b); \
11318@@ -80,6 +105,9 @@ ENTRY(atomic64_##op##_return) /* %o0 = increment, %o1 = atomic_ptr */ \
11319 2: BACKOFF_SPIN(%o2, %o3, 1b); \
11320 ENDPROC(atomic64_##op##_return);
11321
11322+#define ATOMIC64_OP_RETURN(op) __ATOMIC64_OP_RETURN(op, , op, ) \
11323+i __ATOMIC64_OP_RETURN(op, _unchecked, __REFCOUNT_OP(op), __OVERFLOW_XOP)
11324+
11325 #define ATOMIC64_OPS(op) ATOMIC64_OP(op) ATOMIC64_OP_RETURN(op)
11326
11327 ATOMIC64_OPS(add)
11328@@ -87,7 +115,12 @@ ATOMIC64_OPS(sub)
11329
11330 #undef ATOMIC64_OPS
11331 #undef ATOMIC64_OP_RETURN
11332+#undef __ATOMIC64_OP_RETURN
11333 #undef ATOMIC64_OP
11334+#undef __ATOMIC64_OP
11335+#undef __OVERFLOW_XOP
11336+#undef __OVERFLOW_IOP
11337+#undef __REFCOUNT_OP
11338
11339 ENTRY(atomic64_dec_if_positive) /* %o0 = atomic_ptr */
11340 BACKOFF_SETUP(%o2)
11341diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
11342index 1d649a9..fbc5bfc 100644
11343--- a/arch/sparc/lib/ksyms.c
11344+++ b/arch/sparc/lib/ksyms.c
11345@@ -101,7 +101,9 @@ EXPORT_SYMBOL(__clear_user);
11346 /* Atomic counter implementation. */
11347 #define ATOMIC_OP(op) \
11348 EXPORT_SYMBOL(atomic_##op); \
11349-EXPORT_SYMBOL(atomic64_##op);
11350+EXPORT_SYMBOL(atomic_##op##_unchecked); \
11351+EXPORT_SYMBOL(atomic64_##op); \
11352+EXPORT_SYMBOL(atomic64_##op##_unchecked);
11353
11354 #define ATOMIC_OP_RETURN(op) \
11355 EXPORT_SYMBOL(atomic_##op##_return); \
11356@@ -110,6 +112,8 @@ EXPORT_SYMBOL(atomic64_##op##_return);
11357 #define ATOMIC_OPS(op) ATOMIC_OP(op) ATOMIC_OP_RETURN(op)
11358
11359 ATOMIC_OPS(add)
11360+EXPORT_SYMBOL(atomic_add_ret_unchecked);
11361+EXPORT_SYMBOL(atomic64_add_ret_unchecked);
11362 ATOMIC_OPS(sub)
11363
11364 #undef ATOMIC_OPS
11365diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
11366index 30c3ecc..736f015 100644
11367--- a/arch/sparc/mm/Makefile
11368+++ b/arch/sparc/mm/Makefile
11369@@ -2,7 +2,7 @@
11370 #
11371
11372 asflags-y := -ansi
11373-ccflags-y := -Werror
11374+#ccflags-y := -Werror
11375
11376 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
11377 obj-y += fault_$(BITS).o
11378diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
11379index 70d8171..274c6c0 100644
11380--- a/arch/sparc/mm/fault_32.c
11381+++ b/arch/sparc/mm/fault_32.c
11382@@ -21,6 +21,9 @@
11383 #include <linux/perf_event.h>
11384 #include <linux/interrupt.h>
11385 #include <linux/kdebug.h>
11386+#include <linux/slab.h>
11387+#include <linux/pagemap.h>
11388+#include <linux/compiler.h>
11389
11390 #include <asm/page.h>
11391 #include <asm/pgtable.h>
11392@@ -156,6 +159,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
11393 return safe_compute_effective_address(regs, insn);
11394 }
11395
11396+#ifdef CONFIG_PAX_PAGEEXEC
11397+#ifdef CONFIG_PAX_DLRESOLVE
11398+static void pax_emuplt_close(struct vm_area_struct *vma)
11399+{
11400+ vma->vm_mm->call_dl_resolve = 0UL;
11401+}
11402+
11403+static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
11404+{
11405+ unsigned int *kaddr;
11406+
11407+ vmf->page = alloc_page(GFP_HIGHUSER);
11408+ if (!vmf->page)
11409+ return VM_FAULT_OOM;
11410+
11411+ kaddr = kmap(vmf->page);
11412+ memset(kaddr, 0, PAGE_SIZE);
11413+ kaddr[0] = 0x9DE3BFA8U; /* save */
11414+ flush_dcache_page(vmf->page);
11415+ kunmap(vmf->page);
11416+ return VM_FAULT_MAJOR;
11417+}
11418+
11419+static const struct vm_operations_struct pax_vm_ops = {
11420+ .close = pax_emuplt_close,
11421+ .fault = pax_emuplt_fault
11422+};
11423+
11424+static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
11425+{
11426+ int ret;
11427+
11428+ INIT_LIST_HEAD(&vma->anon_vma_chain);
11429+ vma->vm_mm = current->mm;
11430+ vma->vm_start = addr;
11431+ vma->vm_end = addr + PAGE_SIZE;
11432+ vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
11433+ vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
11434+ vma->vm_ops = &pax_vm_ops;
11435+
11436+ ret = insert_vm_struct(current->mm, vma);
11437+ if (ret)
11438+ return ret;
11439+
11440+ ++current->mm->total_vm;
11441+ return 0;
11442+}
11443+#endif
11444+
11445+/*
11446+ * PaX: decide what to do with offenders (regs->pc = fault address)
11447+ *
11448+ * returns 1 when task should be killed
11449+ * 2 when patched PLT trampoline was detected
11450+ * 3 when unpatched PLT trampoline was detected
11451+ */
11452+static int pax_handle_fetch_fault(struct pt_regs *regs)
11453+{
11454+
11455+#ifdef CONFIG_PAX_EMUPLT
11456+ int err;
11457+
11458+ do { /* PaX: patched PLT emulation #1 */
11459+ unsigned int sethi1, sethi2, jmpl;
11460+
11461+ err = get_user(sethi1, (unsigned int *)regs->pc);
11462+ err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
11463+ err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
11464+
11465+ if (err)
11466+ break;
11467+
11468+ if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
11469+ (sethi2 & 0xFFC00000U) == 0x03000000U &&
11470+ (jmpl & 0xFFFFE000U) == 0x81C06000U)
11471+ {
11472+ unsigned int addr;
11473+
11474+ regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
11475+ addr = regs->u_regs[UREG_G1];
11476+ addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
11477+ regs->pc = addr;
11478+ regs->npc = addr+4;
11479+ return 2;
11480+ }
11481+ } while (0);
11482+
11483+ do { /* PaX: patched PLT emulation #2 */
11484+ unsigned int ba;
11485+
11486+ err = get_user(ba, (unsigned int *)regs->pc);
11487+
11488+ if (err)
11489+ break;
11490+
11491+ if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
11492+ unsigned int addr;
11493+
11494+ if ((ba & 0xFFC00000U) == 0x30800000U)
11495+ addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
11496+ else
11497+ addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
11498+ regs->pc = addr;
11499+ regs->npc = addr+4;
11500+ return 2;
11501+ }
11502+ } while (0);
11503+
11504+ do { /* PaX: patched PLT emulation #3 */
11505+ unsigned int sethi, bajmpl, nop;
11506+
11507+ err = get_user(sethi, (unsigned int *)regs->pc);
11508+ err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
11509+ err |= get_user(nop, (unsigned int *)(regs->pc+8));
11510+
11511+ if (err)
11512+ break;
11513+
11514+ if ((sethi & 0xFFC00000U) == 0x03000000U &&
11515+ ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
11516+ nop == 0x01000000U)
11517+ {
11518+ unsigned int addr;
11519+
11520+ addr = (sethi & 0x003FFFFFU) << 10;
11521+ regs->u_regs[UREG_G1] = addr;
11522+ if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
11523+ addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
11524+ else
11525+ addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
11526+ regs->pc = addr;
11527+ regs->npc = addr+4;
11528+ return 2;
11529+ }
11530+ } while (0);
11531+
11532+ do { /* PaX: unpatched PLT emulation step 1 */
11533+ unsigned int sethi, ba, nop;
11534+
11535+ err = get_user(sethi, (unsigned int *)regs->pc);
11536+ err |= get_user(ba, (unsigned int *)(regs->pc+4));
11537+ err |= get_user(nop, (unsigned int *)(regs->pc+8));
11538+
11539+ if (err)
11540+ break;
11541+
11542+ if ((sethi & 0xFFC00000U) == 0x03000000U &&
11543+ ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
11544+ nop == 0x01000000U)
11545+ {
11546+ unsigned int addr, save, call;
11547+
11548+ if ((ba & 0xFFC00000U) == 0x30800000U)
11549+ addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
11550+ else
11551+ addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
11552+
11553+ err = get_user(save, (unsigned int *)addr);
11554+ err |= get_user(call, (unsigned int *)(addr+4));
11555+ err |= get_user(nop, (unsigned int *)(addr+8));
11556+ if (err)
11557+ break;
11558+
11559+#ifdef CONFIG_PAX_DLRESOLVE
11560+ if (save == 0x9DE3BFA8U &&
11561+ (call & 0xC0000000U) == 0x40000000U &&
11562+ nop == 0x01000000U)
11563+ {
11564+ struct vm_area_struct *vma;
11565+ unsigned long call_dl_resolve;
11566+
11567+ down_read(&current->mm->mmap_sem);
11568+ call_dl_resolve = current->mm->call_dl_resolve;
11569+ up_read(&current->mm->mmap_sem);
11570+ if (likely(call_dl_resolve))
11571+ goto emulate;
11572+
11573+ vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
11574+
11575+ down_write(&current->mm->mmap_sem);
11576+ if (current->mm->call_dl_resolve) {
11577+ call_dl_resolve = current->mm->call_dl_resolve;
11578+ up_write(&current->mm->mmap_sem);
11579+ if (vma)
11580+ kmem_cache_free(vm_area_cachep, vma);
11581+ goto emulate;
11582+ }
11583+
11584+ call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
11585+ if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
11586+ up_write(&current->mm->mmap_sem);
11587+ if (vma)
11588+ kmem_cache_free(vm_area_cachep, vma);
11589+ return 1;
11590+ }
11591+
11592+ if (pax_insert_vma(vma, call_dl_resolve)) {
11593+ up_write(&current->mm->mmap_sem);
11594+ kmem_cache_free(vm_area_cachep, vma);
11595+ return 1;
11596+ }
11597+
11598+ current->mm->call_dl_resolve = call_dl_resolve;
11599+ up_write(&current->mm->mmap_sem);
11600+
11601+emulate:
11602+ regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11603+ regs->pc = call_dl_resolve;
11604+ regs->npc = addr+4;
11605+ return 3;
11606+ }
11607+#endif
11608+
11609+ /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
11610+ if ((save & 0xFFC00000U) == 0x05000000U &&
11611+ (call & 0xFFFFE000U) == 0x85C0A000U &&
11612+ nop == 0x01000000U)
11613+ {
11614+ regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11615+ regs->u_regs[UREG_G2] = addr + 4;
11616+ addr = (save & 0x003FFFFFU) << 10;
11617+ addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
11618+ regs->pc = addr;
11619+ regs->npc = addr+4;
11620+ return 3;
11621+ }
11622+ }
11623+ } while (0);
11624+
11625+ do { /* PaX: unpatched PLT emulation step 2 */
11626+ unsigned int save, call, nop;
11627+
11628+ err = get_user(save, (unsigned int *)(regs->pc-4));
11629+ err |= get_user(call, (unsigned int *)regs->pc);
11630+ err |= get_user(nop, (unsigned int *)(regs->pc+4));
11631+ if (err)
11632+ break;
11633+
11634+ if (save == 0x9DE3BFA8U &&
11635+ (call & 0xC0000000U) == 0x40000000U &&
11636+ nop == 0x01000000U)
11637+ {
11638+ unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
11639+
11640+ regs->u_regs[UREG_RETPC] = regs->pc;
11641+ regs->pc = dl_resolve;
11642+ regs->npc = dl_resolve+4;
11643+ return 3;
11644+ }
11645+ } while (0);
11646+#endif
11647+
11648+ return 1;
11649+}
11650+
11651+void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
11652+{
11653+ unsigned long i;
11654+
11655+ printk(KERN_ERR "PAX: bytes at PC: ");
11656+ for (i = 0; i < 8; i++) {
11657+ unsigned int c;
11658+ if (get_user(c, (unsigned int *)pc+i))
11659+ printk(KERN_CONT "???????? ");
11660+ else
11661+ printk(KERN_CONT "%08x ", c);
11662+ }
11663+ printk("\n");
11664+}
11665+#endif
11666+
11667 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
11668 int text_fault)
11669 {
11670@@ -226,6 +500,24 @@ good_area:
11671 if (!(vma->vm_flags & VM_WRITE))
11672 goto bad_area;
11673 } else {
11674+
11675+#ifdef CONFIG_PAX_PAGEEXEC
11676+ if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
11677+ up_read(&mm->mmap_sem);
11678+ switch (pax_handle_fetch_fault(regs)) {
11679+
11680+#ifdef CONFIG_PAX_EMUPLT
11681+ case 2:
11682+ case 3:
11683+ return;
11684+#endif
11685+
11686+ }
11687+ pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
11688+ do_group_exit(SIGKILL);
11689+ }
11690+#endif
11691+
11692 /* Allow reads even for write-only mappings */
11693 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
11694 goto bad_area;
11695diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
11696index 4798232..f76e3aa 100644
11697--- a/arch/sparc/mm/fault_64.c
11698+++ b/arch/sparc/mm/fault_64.c
11699@@ -22,6 +22,9 @@
11700 #include <linux/kdebug.h>
11701 #include <linux/percpu.h>
11702 #include <linux/context_tracking.h>
11703+#include <linux/slab.h>
11704+#include <linux/pagemap.h>
11705+#include <linux/compiler.h>
11706
11707 #include <asm/page.h>
11708 #include <asm/pgtable.h>
11709@@ -76,7 +79,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
11710 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
11711 regs->tpc);
11712 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
11713- printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
11714+ printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
11715 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
11716 dump_stack();
11717 unhandled_fault(regs->tpc, current, regs);
11718@@ -279,6 +282,466 @@ static void noinline __kprobes bogus_32bit_fault_tpc(struct pt_regs *regs)
11719 show_regs(regs);
11720 }
11721
11722+#ifdef CONFIG_PAX_PAGEEXEC
11723+#ifdef CONFIG_PAX_DLRESOLVE
11724+static void pax_emuplt_close(struct vm_area_struct *vma)
11725+{
11726+ vma->vm_mm->call_dl_resolve = 0UL;
11727+}
11728+
11729+static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
11730+{
11731+ unsigned int *kaddr;
11732+
11733+ vmf->page = alloc_page(GFP_HIGHUSER);
11734+ if (!vmf->page)
11735+ return VM_FAULT_OOM;
11736+
11737+ kaddr = kmap(vmf->page);
11738+ memset(kaddr, 0, PAGE_SIZE);
11739+ kaddr[0] = 0x9DE3BFA8U; /* save */
11740+ flush_dcache_page(vmf->page);
11741+ kunmap(vmf->page);
11742+ return VM_FAULT_MAJOR;
11743+}
11744+
11745+static const struct vm_operations_struct pax_vm_ops = {
11746+ .close = pax_emuplt_close,
11747+ .fault = pax_emuplt_fault
11748+};
11749+
11750+static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
11751+{
11752+ int ret;
11753+
11754+ INIT_LIST_HEAD(&vma->anon_vma_chain);
11755+ vma->vm_mm = current->mm;
11756+ vma->vm_start = addr;
11757+ vma->vm_end = addr + PAGE_SIZE;
11758+ vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
11759+ vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
11760+ vma->vm_ops = &pax_vm_ops;
11761+
11762+ ret = insert_vm_struct(current->mm, vma);
11763+ if (ret)
11764+ return ret;
11765+
11766+ ++current->mm->total_vm;
11767+ return 0;
11768+}
11769+#endif
11770+
11771+/*
11772+ * PaX: decide what to do with offenders (regs->tpc = fault address)
11773+ *
11774+ * returns 1 when task should be killed
11775+ * 2 when patched PLT trampoline was detected
11776+ * 3 when unpatched PLT trampoline was detected
11777+ */
11778+static int pax_handle_fetch_fault(struct pt_regs *regs)
11779+{
11780+
11781+#ifdef CONFIG_PAX_EMUPLT
11782+ int err;
11783+
11784+ do { /* PaX: patched PLT emulation #1 */
11785+ unsigned int sethi1, sethi2, jmpl;
11786+
11787+ err = get_user(sethi1, (unsigned int *)regs->tpc);
11788+ err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
11789+ err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
11790+
11791+ if (err)
11792+ break;
11793+
11794+ if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
11795+ (sethi2 & 0xFFC00000U) == 0x03000000U &&
11796+ (jmpl & 0xFFFFE000U) == 0x81C06000U)
11797+ {
11798+ unsigned long addr;
11799+
11800+ regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
11801+ addr = regs->u_regs[UREG_G1];
11802+ addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
11803+
11804+ if (test_thread_flag(TIF_32BIT))
11805+ addr &= 0xFFFFFFFFUL;
11806+
11807+ regs->tpc = addr;
11808+ regs->tnpc = addr+4;
11809+ return 2;
11810+ }
11811+ } while (0);
11812+
11813+ do { /* PaX: patched PLT emulation #2 */
11814+ unsigned int ba;
11815+
11816+ err = get_user(ba, (unsigned int *)regs->tpc);
11817+
11818+ if (err)
11819+ break;
11820+
11821+ if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
11822+ unsigned long addr;
11823+
11824+ if ((ba & 0xFFC00000U) == 0x30800000U)
11825+ addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
11826+ else
11827+ addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
11828+
11829+ if (test_thread_flag(TIF_32BIT))
11830+ addr &= 0xFFFFFFFFUL;
11831+
11832+ regs->tpc = addr;
11833+ regs->tnpc = addr+4;
11834+ return 2;
11835+ }
11836+ } while (0);
11837+
11838+ do { /* PaX: patched PLT emulation #3 */
11839+ unsigned int sethi, bajmpl, nop;
11840+
11841+ err = get_user(sethi, (unsigned int *)regs->tpc);
11842+ err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
11843+ err |= get_user(nop, (unsigned int *)(regs->tpc+8));
11844+
11845+ if (err)
11846+ break;
11847+
11848+ if ((sethi & 0xFFC00000U) == 0x03000000U &&
11849+ ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
11850+ nop == 0x01000000U)
11851+ {
11852+ unsigned long addr;
11853+
11854+ addr = (sethi & 0x003FFFFFU) << 10;
11855+ regs->u_regs[UREG_G1] = addr;
11856+ if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
11857+ addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
11858+ else
11859+ addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
11860+
11861+ if (test_thread_flag(TIF_32BIT))
11862+ addr &= 0xFFFFFFFFUL;
11863+
11864+ regs->tpc = addr;
11865+ regs->tnpc = addr+4;
11866+ return 2;
11867+ }
11868+ } while (0);
11869+
11870+ do { /* PaX: patched PLT emulation #4 */
11871+ unsigned int sethi, mov1, call, mov2;
11872+
11873+ err = get_user(sethi, (unsigned int *)regs->tpc);
11874+ err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
11875+ err |= get_user(call, (unsigned int *)(regs->tpc+8));
11876+ err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
11877+
11878+ if (err)
11879+ break;
11880+
11881+ if ((sethi & 0xFFC00000U) == 0x03000000U &&
11882+ mov1 == 0x8210000FU &&
11883+ (call & 0xC0000000U) == 0x40000000U &&
11884+ mov2 == 0x9E100001U)
11885+ {
11886+ unsigned long addr;
11887+
11888+ regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
11889+ addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
11890+
11891+ if (test_thread_flag(TIF_32BIT))
11892+ addr &= 0xFFFFFFFFUL;
11893+
11894+ regs->tpc = addr;
11895+ regs->tnpc = addr+4;
11896+ return 2;
11897+ }
11898+ } while (0);
11899+
11900+ do { /* PaX: patched PLT emulation #5 */
11901+ unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
11902+
11903+ err = get_user(sethi, (unsigned int *)regs->tpc);
11904+ err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
11905+ err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
11906+ err |= get_user(or1, (unsigned int *)(regs->tpc+12));
11907+ err |= get_user(or2, (unsigned int *)(regs->tpc+16));
11908+ err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
11909+ err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
11910+ err |= get_user(nop, (unsigned int *)(regs->tpc+28));
11911+
11912+ if (err)
11913+ break;
11914+
11915+ if ((sethi & 0xFFC00000U) == 0x03000000U &&
11916+ (sethi1 & 0xFFC00000U) == 0x03000000U &&
11917+ (sethi2 & 0xFFC00000U) == 0x0B000000U &&
11918+ (or1 & 0xFFFFE000U) == 0x82106000U &&
11919+ (or2 & 0xFFFFE000U) == 0x8A116000U &&
11920+ sllx == 0x83287020U &&
11921+ jmpl == 0x81C04005U &&
11922+ nop == 0x01000000U)
11923+ {
11924+ unsigned long addr;
11925+
11926+ regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
11927+ regs->u_regs[UREG_G1] <<= 32;
11928+ regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
11929+ addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
11930+ regs->tpc = addr;
11931+ regs->tnpc = addr+4;
11932+ return 2;
11933+ }
11934+ } while (0);
11935+
11936+ do { /* PaX: patched PLT emulation #6 */
11937+ unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
11938+
11939+ err = get_user(sethi, (unsigned int *)regs->tpc);
11940+ err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
11941+ err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
11942+ err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
11943+ err |= get_user(or, (unsigned int *)(regs->tpc+16));
11944+ err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
11945+ err |= get_user(nop, (unsigned int *)(regs->tpc+24));
11946+
11947+ if (err)
11948+ break;
11949+
11950+ if ((sethi & 0xFFC00000U) == 0x03000000U &&
11951+ (sethi1 & 0xFFC00000U) == 0x03000000U &&
11952+ (sethi2 & 0xFFC00000U) == 0x0B000000U &&
11953+ sllx == 0x83287020U &&
11954+ (or & 0xFFFFE000U) == 0x8A116000U &&
11955+ jmpl == 0x81C04005U &&
11956+ nop == 0x01000000U)
11957+ {
11958+ unsigned long addr;
11959+
11960+ regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
11961+ regs->u_regs[UREG_G1] <<= 32;
11962+ regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
11963+ addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
11964+ regs->tpc = addr;
11965+ regs->tnpc = addr+4;
11966+ return 2;
11967+ }
11968+ } while (0);
11969+
11970+ do { /* PaX: unpatched PLT emulation step 1 */
11971+ unsigned int sethi, ba, nop;
11972+
11973+ err = get_user(sethi, (unsigned int *)regs->tpc);
11974+ err |= get_user(ba, (unsigned int *)(regs->tpc+4));
11975+ err |= get_user(nop, (unsigned int *)(regs->tpc+8));
11976+
11977+ if (err)
11978+ break;
11979+
11980+ if ((sethi & 0xFFC00000U) == 0x03000000U &&
11981+ ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
11982+ nop == 0x01000000U)
11983+ {
11984+ unsigned long addr;
11985+ unsigned int save, call;
11986+ unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
11987+
11988+ if ((ba & 0xFFC00000U) == 0x30800000U)
11989+ addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
11990+ else
11991+ addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
11992+
11993+ if (test_thread_flag(TIF_32BIT))
11994+ addr &= 0xFFFFFFFFUL;
11995+
11996+ err = get_user(save, (unsigned int *)addr);
11997+ err |= get_user(call, (unsigned int *)(addr+4));
11998+ err |= get_user(nop, (unsigned int *)(addr+8));
11999+ if (err)
12000+ break;
12001+
12002+#ifdef CONFIG_PAX_DLRESOLVE
12003+ if (save == 0x9DE3BFA8U &&
12004+ (call & 0xC0000000U) == 0x40000000U &&
12005+ nop == 0x01000000U)
12006+ {
12007+ struct vm_area_struct *vma;
12008+ unsigned long call_dl_resolve;
12009+
12010+ down_read(&current->mm->mmap_sem);
12011+ call_dl_resolve = current->mm->call_dl_resolve;
12012+ up_read(&current->mm->mmap_sem);
12013+ if (likely(call_dl_resolve))
12014+ goto emulate;
12015+
12016+ vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
12017+
12018+ down_write(&current->mm->mmap_sem);
12019+ if (current->mm->call_dl_resolve) {
12020+ call_dl_resolve = current->mm->call_dl_resolve;
12021+ up_write(&current->mm->mmap_sem);
12022+ if (vma)
12023+ kmem_cache_free(vm_area_cachep, vma);
12024+ goto emulate;
12025+ }
12026+
12027+ call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
12028+ if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
12029+ up_write(&current->mm->mmap_sem);
12030+ if (vma)
12031+ kmem_cache_free(vm_area_cachep, vma);
12032+ return 1;
12033+ }
12034+
12035+ if (pax_insert_vma(vma, call_dl_resolve)) {
12036+ up_write(&current->mm->mmap_sem);
12037+ kmem_cache_free(vm_area_cachep, vma);
12038+ return 1;
12039+ }
12040+
12041+ current->mm->call_dl_resolve = call_dl_resolve;
12042+ up_write(&current->mm->mmap_sem);
12043+
12044+emulate:
12045+ regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
12046+ regs->tpc = call_dl_resolve;
12047+ regs->tnpc = addr+4;
12048+ return 3;
12049+ }
12050+#endif
12051+
12052+ /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
12053+ if ((save & 0xFFC00000U) == 0x05000000U &&
12054+ (call & 0xFFFFE000U) == 0x85C0A000U &&
12055+ nop == 0x01000000U)
12056+ {
12057+ regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
12058+ regs->u_regs[UREG_G2] = addr + 4;
12059+ addr = (save & 0x003FFFFFU) << 10;
12060+ addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
12061+
12062+ if (test_thread_flag(TIF_32BIT))
12063+ addr &= 0xFFFFFFFFUL;
12064+
12065+ regs->tpc = addr;
12066+ regs->tnpc = addr+4;
12067+ return 3;
12068+ }
12069+
12070+ /* PaX: 64-bit PLT stub */
12071+ err = get_user(sethi1, (unsigned int *)addr);
12072+ err |= get_user(sethi2, (unsigned int *)(addr+4));
12073+ err |= get_user(or1, (unsigned int *)(addr+8));
12074+ err |= get_user(or2, (unsigned int *)(addr+12));
12075+ err |= get_user(sllx, (unsigned int *)(addr+16));
12076+ err |= get_user(add, (unsigned int *)(addr+20));
12077+ err |= get_user(jmpl, (unsigned int *)(addr+24));
12078+ err |= get_user(nop, (unsigned int *)(addr+28));
12079+ if (err)
12080+ break;
12081+
12082+ if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
12083+ (sethi2 & 0xFFC00000U) == 0x0B000000U &&
12084+ (or1 & 0xFFFFE000U) == 0x88112000U &&
12085+ (or2 & 0xFFFFE000U) == 0x8A116000U &&
12086+ sllx == 0x89293020U &&
12087+ add == 0x8A010005U &&
12088+ jmpl == 0x89C14000U &&
12089+ nop == 0x01000000U)
12090+ {
12091+ regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
12092+ regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
12093+ regs->u_regs[UREG_G4] <<= 32;
12094+ regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
12095+ regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
12096+ regs->u_regs[UREG_G4] = addr + 24;
12097+ addr = regs->u_regs[UREG_G5];
12098+ regs->tpc = addr;
12099+ regs->tnpc = addr+4;
12100+ return 3;
12101+ }
12102+ }
12103+ } while (0);
12104+
12105+#ifdef CONFIG_PAX_DLRESOLVE
12106+ do { /* PaX: unpatched PLT emulation step 2 */
12107+ unsigned int save, call, nop;
12108+
12109+ err = get_user(save, (unsigned int *)(regs->tpc-4));
12110+ err |= get_user(call, (unsigned int *)regs->tpc);
12111+ err |= get_user(nop, (unsigned int *)(regs->tpc+4));
12112+ if (err)
12113+ break;
12114+
12115+ if (save == 0x9DE3BFA8U &&
12116+ (call & 0xC0000000U) == 0x40000000U &&
12117+ nop == 0x01000000U)
12118+ {
12119+ unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
12120+
12121+ if (test_thread_flag(TIF_32BIT))
12122+ dl_resolve &= 0xFFFFFFFFUL;
12123+
12124+ regs->u_regs[UREG_RETPC] = regs->tpc;
12125+ regs->tpc = dl_resolve;
12126+ regs->tnpc = dl_resolve+4;
12127+ return 3;
12128+ }
12129+ } while (0);
12130+#endif
12131+
12132+ do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
12133+ unsigned int sethi, ba, nop;
12134+
12135+ err = get_user(sethi, (unsigned int *)regs->tpc);
12136+ err |= get_user(ba, (unsigned int *)(regs->tpc+4));
12137+ err |= get_user(nop, (unsigned int *)(regs->tpc+8));
12138+
12139+ if (err)
12140+ break;
12141+
12142+ if ((sethi & 0xFFC00000U) == 0x03000000U &&
12143+ (ba & 0xFFF00000U) == 0x30600000U &&
12144+ nop == 0x01000000U)
12145+ {
12146+ unsigned long addr;
12147+
12148+ addr = (sethi & 0x003FFFFFU) << 10;
12149+ regs->u_regs[UREG_G1] = addr;
12150+ addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
12151+
12152+ if (test_thread_flag(TIF_32BIT))
12153+ addr &= 0xFFFFFFFFUL;
12154+
12155+ regs->tpc = addr;
12156+ regs->tnpc = addr+4;
12157+ return 2;
12158+ }
12159+ } while (0);
12160+
12161+#endif
12162+
12163+ return 1;
12164+}
12165+
12166+void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
12167+{
12168+ unsigned long i;
12169+
12170+ printk(KERN_ERR "PAX: bytes at PC: ");
12171+ for (i = 0; i < 8; i++) {
12172+ unsigned int c;
12173+ if (get_user(c, (unsigned int *)pc+i))
12174+ printk(KERN_CONT "???????? ");
12175+ else
12176+ printk(KERN_CONT "%08x ", c);
12177+ }
12178+ printk("\n");
12179+}
12180+#endif
12181+
12182 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
12183 {
12184 enum ctx_state prev_state = exception_enter();
12185@@ -353,6 +816,29 @@ retry:
12186 if (!vma)
12187 goto bad_area;
12188
12189+#ifdef CONFIG_PAX_PAGEEXEC
12190+ /* PaX: detect ITLB misses on non-exec pages */
12191+ if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
12192+ !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
12193+ {
12194+ if (address != regs->tpc)
12195+ goto good_area;
12196+
12197+ up_read(&mm->mmap_sem);
12198+ switch (pax_handle_fetch_fault(regs)) {
12199+
12200+#ifdef CONFIG_PAX_EMUPLT
12201+ case 2:
12202+ case 3:
12203+ return;
12204+#endif
12205+
12206+ }
12207+ pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
12208+ do_group_exit(SIGKILL);
12209+ }
12210+#endif
12211+
12212 /* Pure DTLB misses do not tell us whether the fault causing
12213 * load/store/atomic was a write or not, it only says that there
12214 * was no match. So in such a case we (carefully) read the
12215diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
12216index 4242eab..9ae6360 100644
12217--- a/arch/sparc/mm/hugetlbpage.c
12218+++ b/arch/sparc/mm/hugetlbpage.c
12219@@ -25,8 +25,10 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
12220 unsigned long addr,
12221 unsigned long len,
12222 unsigned long pgoff,
12223- unsigned long flags)
12224+ unsigned long flags,
12225+ unsigned long offset)
12226 {
12227+ struct mm_struct *mm = current->mm;
12228 unsigned long task_size = TASK_SIZE;
12229 struct vm_unmapped_area_info info;
12230
12231@@ -35,15 +37,22 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
12232
12233 info.flags = 0;
12234 info.length = len;
12235- info.low_limit = TASK_UNMAPPED_BASE;
12236+ info.low_limit = mm->mmap_base;
12237 info.high_limit = min(task_size, VA_EXCLUDE_START);
12238 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
12239 info.align_offset = 0;
12240+ info.threadstack_offset = offset;
12241 addr = vm_unmapped_area(&info);
12242
12243 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
12244 VM_BUG_ON(addr != -ENOMEM);
12245 info.low_limit = VA_EXCLUDE_END;
12246+
12247+#ifdef CONFIG_PAX_RANDMMAP
12248+ if (mm->pax_flags & MF_PAX_RANDMMAP)
12249+ info.low_limit += mm->delta_mmap;
12250+#endif
12251+
12252 info.high_limit = task_size;
12253 addr = vm_unmapped_area(&info);
12254 }
12255@@ -55,7 +64,8 @@ static unsigned long
12256 hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
12257 const unsigned long len,
12258 const unsigned long pgoff,
12259- const unsigned long flags)
12260+ const unsigned long flags,
12261+ const unsigned long offset)
12262 {
12263 struct mm_struct *mm = current->mm;
12264 unsigned long addr = addr0;
12265@@ -70,6 +80,7 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
12266 info.high_limit = mm->mmap_base;
12267 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
12268 info.align_offset = 0;
12269+ info.threadstack_offset = offset;
12270 addr = vm_unmapped_area(&info);
12271
12272 /*
12273@@ -82,6 +93,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
12274 VM_BUG_ON(addr != -ENOMEM);
12275 info.flags = 0;
12276 info.low_limit = TASK_UNMAPPED_BASE;
12277+
12278+#ifdef CONFIG_PAX_RANDMMAP
12279+ if (mm->pax_flags & MF_PAX_RANDMMAP)
12280+ info.low_limit += mm->delta_mmap;
12281+#endif
12282+
12283 info.high_limit = STACK_TOP32;
12284 addr = vm_unmapped_area(&info);
12285 }
12286@@ -96,6 +113,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
12287 struct mm_struct *mm = current->mm;
12288 struct vm_area_struct *vma;
12289 unsigned long task_size = TASK_SIZE;
12290+ unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
12291
12292 if (test_thread_flag(TIF_32BIT))
12293 task_size = STACK_TOP32;
12294@@ -111,19 +129,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
12295 return addr;
12296 }
12297
12298+#ifdef CONFIG_PAX_RANDMMAP
12299+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
12300+#endif
12301+
12302 if (addr) {
12303 addr = ALIGN(addr, HPAGE_SIZE);
12304 vma = find_vma(mm, addr);
12305- if (task_size - len >= addr &&
12306- (!vma || addr + len <= vma->vm_start))
12307+ if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
12308 return addr;
12309 }
12310 if (mm->get_unmapped_area == arch_get_unmapped_area)
12311 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
12312- pgoff, flags);
12313+ pgoff, flags, offset);
12314 else
12315 return hugetlb_get_unmapped_area_topdown(file, addr, len,
12316- pgoff, flags);
12317+ pgoff, flags, offset);
12318 }
12319
12320 pte_t *huge_pte_alloc(struct mm_struct *mm,
12321diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
12322index 559cb74..9e5f097 100644
12323--- a/arch/sparc/mm/init_64.c
12324+++ b/arch/sparc/mm/init_64.c
12325@@ -187,9 +187,9 @@ unsigned long sparc64_kern_sec_context __read_mostly;
12326 int num_kernel_image_mappings;
12327
12328 #ifdef CONFIG_DEBUG_DCFLUSH
12329-atomic_t dcpage_flushes = ATOMIC_INIT(0);
12330+atomic_unchecked_t dcpage_flushes = ATOMIC_INIT(0);
12331 #ifdef CONFIG_SMP
12332-atomic_t dcpage_flushes_xcall = ATOMIC_INIT(0);
12333+atomic_unchecked_t dcpage_flushes_xcall = ATOMIC_INIT(0);
12334 #endif
12335 #endif
12336
12337@@ -197,7 +197,7 @@ inline void flush_dcache_page_impl(struct page *page)
12338 {
12339 BUG_ON(tlb_type == hypervisor);
12340 #ifdef CONFIG_DEBUG_DCFLUSH
12341- atomic_inc(&dcpage_flushes);
12342+ atomic_inc_unchecked(&dcpage_flushes);
12343 #endif
12344
12345 #ifdef DCACHE_ALIASING_POSSIBLE
12346@@ -469,10 +469,10 @@ void mmu_info(struct seq_file *m)
12347
12348 #ifdef CONFIG_DEBUG_DCFLUSH
12349 seq_printf(m, "DCPageFlushes\t: %d\n",
12350- atomic_read(&dcpage_flushes));
12351+ atomic_read_unchecked(&dcpage_flushes));
12352 #ifdef CONFIG_SMP
12353 seq_printf(m, "DCPageFlushesXC\t: %d\n",
12354- atomic_read(&dcpage_flushes_xcall));
12355+ atomic_read_unchecked(&dcpage_flushes_xcall));
12356 #endif /* CONFIG_SMP */
12357 #endif /* CONFIG_DEBUG_DCFLUSH */
12358 }
12359diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig
12360index a07e31b..85c9003 100644
12361--- a/arch/tile/Kconfig
12362+++ b/arch/tile/Kconfig
12363@@ -198,6 +198,7 @@ source "kernel/Kconfig.hz"
12364
12365 config KEXEC
12366 bool "kexec system call"
12367+ depends on !GRKERNSEC_KMEM
12368 ---help---
12369 kexec is a system call that implements the ability to shutdown your
12370 current kernel, and to start another kernel. It is like a reboot
12371diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
12372index 7b11c5f..755a026 100644
12373--- a/arch/tile/include/asm/atomic_64.h
12374+++ b/arch/tile/include/asm/atomic_64.h
12375@@ -105,6 +105,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
12376
12377 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
12378
12379+#define atomic64_read_unchecked(v) atomic64_read(v)
12380+#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
12381+#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
12382+#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
12383+#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
12384+#define atomic64_inc_unchecked(v) atomic64_inc(v)
12385+#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
12386+#define atomic64_dec_unchecked(v) atomic64_dec(v)
12387+#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
12388+
12389 /* Define this to indicate that cmpxchg is an efficient operation. */
12390 #define __HAVE_ARCH_CMPXCHG
12391
12392diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
12393index 6160761..00cac88 100644
12394--- a/arch/tile/include/asm/cache.h
12395+++ b/arch/tile/include/asm/cache.h
12396@@ -15,11 +15,12 @@
12397 #ifndef _ASM_TILE_CACHE_H
12398 #define _ASM_TILE_CACHE_H
12399
12400+#include <linux/const.h>
12401 #include <arch/chip.h>
12402
12403 /* bytes per L1 data cache line */
12404 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
12405-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
12406+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
12407
12408 /* bytes per L2 cache line */
12409 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
12410diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
12411index f41cb53..31d3ab4 100644
12412--- a/arch/tile/include/asm/uaccess.h
12413+++ b/arch/tile/include/asm/uaccess.h
12414@@ -417,9 +417,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
12415 const void __user *from,
12416 unsigned long n)
12417 {
12418- int sz = __compiletime_object_size(to);
12419+ size_t sz = __compiletime_object_size(to);
12420
12421- if (likely(sz == -1 || sz >= n))
12422+ if (likely(sz == (size_t)-1 || sz >= n))
12423 n = _copy_from_user(to, from, n);
12424 else
12425 copy_from_user_overflow();
12426diff --git a/arch/tile/mm/hugetlbpage.c b/arch/tile/mm/hugetlbpage.c
12427index 8416240..a012fb7 100644
12428--- a/arch/tile/mm/hugetlbpage.c
12429+++ b/arch/tile/mm/hugetlbpage.c
12430@@ -179,6 +179,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
12431 info.high_limit = TASK_SIZE;
12432 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
12433 info.align_offset = 0;
12434+ info.threadstack_offset = 0;
12435 return vm_unmapped_area(&info);
12436 }
12437
12438@@ -196,6 +197,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
12439 info.high_limit = current->mm->mmap_base;
12440 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
12441 info.align_offset = 0;
12442+ info.threadstack_offset = 0;
12443 addr = vm_unmapped_area(&info);
12444
12445 /*
12446diff --git a/arch/um/Makefile b/arch/um/Makefile
12447index 17d4460..9d74338e3de4 100644
12448--- a/arch/um/Makefile
12449+++ b/arch/um/Makefile
12450@@ -72,6 +72,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
12451 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
12452 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
12453
12454+ifdef CONSTIFY_PLUGIN
12455+USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
12456+endif
12457+
12458 #This will adjust *FLAGS accordingly to the platform.
12459 include $(ARCH_DIR)/Makefile-os-$(OS)
12460
12461diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
12462index 19e1bdd..3665b77 100644
12463--- a/arch/um/include/asm/cache.h
12464+++ b/arch/um/include/asm/cache.h
12465@@ -1,6 +1,7 @@
12466 #ifndef __UM_CACHE_H
12467 #define __UM_CACHE_H
12468
12469+#include <linux/const.h>
12470
12471 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
12472 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
12473@@ -12,6 +13,6 @@
12474 # define L1_CACHE_SHIFT 5
12475 #endif
12476
12477-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
12478+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
12479
12480 #endif
12481diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
12482index 2e0a6b1..a64d0f5 100644
12483--- a/arch/um/include/asm/kmap_types.h
12484+++ b/arch/um/include/asm/kmap_types.h
12485@@ -8,6 +8,6 @@
12486
12487 /* No more #include "asm/arch/kmap_types.h" ! */
12488
12489-#define KM_TYPE_NR 14
12490+#define KM_TYPE_NR 15
12491
12492 #endif
12493diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
12494index 71c5d13..4c7b9f1 100644
12495--- a/arch/um/include/asm/page.h
12496+++ b/arch/um/include/asm/page.h
12497@@ -14,6 +14,9 @@
12498 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
12499 #define PAGE_MASK (~(PAGE_SIZE-1))
12500
12501+#define ktla_ktva(addr) (addr)
12502+#define ktva_ktla(addr) (addr)
12503+
12504 #ifndef __ASSEMBLY__
12505
12506 struct page;
12507diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
12508index 2b4274e..754fe06 100644
12509--- a/arch/um/include/asm/pgtable-3level.h
12510+++ b/arch/um/include/asm/pgtable-3level.h
12511@@ -58,6 +58,7 @@
12512 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
12513 #define pud_populate(mm, pud, pmd) \
12514 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
12515+#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
12516
12517 #ifdef CONFIG_64BIT
12518 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
12519diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
12520index 68b9119..f72353c 100644
12521--- a/arch/um/kernel/process.c
12522+++ b/arch/um/kernel/process.c
12523@@ -345,22 +345,6 @@ int singlestepping(void * t)
12524 return 2;
12525 }
12526
12527-/*
12528- * Only x86 and x86_64 have an arch_align_stack().
12529- * All other arches have "#define arch_align_stack(x) (x)"
12530- * in their asm/exec.h
12531- * As this is included in UML from asm-um/system-generic.h,
12532- * we can use it to behave as the subarch does.
12533- */
12534-#ifndef arch_align_stack
12535-unsigned long arch_align_stack(unsigned long sp)
12536-{
12537- if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
12538- sp -= get_random_int() % 8192;
12539- return sp & ~0xf;
12540-}
12541-#endif
12542-
12543 unsigned long get_wchan(struct task_struct *p)
12544 {
12545 unsigned long stack_page, sp, ip;
12546diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
12547index ad8f795..2c7eec6 100644
12548--- a/arch/unicore32/include/asm/cache.h
12549+++ b/arch/unicore32/include/asm/cache.h
12550@@ -12,8 +12,10 @@
12551 #ifndef __UNICORE_CACHE_H__
12552 #define __UNICORE_CACHE_H__
12553
12554-#define L1_CACHE_SHIFT (5)
12555-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
12556+#include <linux/const.h>
12557+
12558+#define L1_CACHE_SHIFT 5
12559+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
12560
12561 /*
12562 * Memory returned by kmalloc() may be used for DMA, so we must make
12563diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
12564index 226d569..d420edc 100644
12565--- a/arch/x86/Kconfig
12566+++ b/arch/x86/Kconfig
12567@@ -32,7 +32,7 @@ config X86
12568 select HAVE_AOUT if X86_32
12569 select HAVE_UNSTABLE_SCHED_CLOCK
12570 select ARCH_SUPPORTS_NUMA_BALANCING if X86_64
12571- select ARCH_SUPPORTS_INT128 if X86_64
12572+ select ARCH_SUPPORTS_INT128 if X86_64 && !PAX_SIZE_OVERFLOW
12573 select HAVE_IDE
12574 select HAVE_OPROFILE
12575 select HAVE_PCSPKR_PLATFORM
12576@@ -134,7 +134,7 @@ config X86
12577 select RTC_LIB
12578 select HAVE_DEBUG_STACKOVERFLOW
12579 select HAVE_IRQ_EXIT_ON_IRQ_STACK if X86_64
12580- select HAVE_CC_STACKPROTECTOR
12581+ select HAVE_CC_STACKPROTECTOR if X86_64 || !PAX_MEMORY_UDEREF
12582 select GENERIC_CPU_AUTOPROBE
12583 select HAVE_ARCH_AUDITSYSCALL
12584 select ARCH_SUPPORTS_ATOMIC_RMW
12585@@ -266,7 +266,7 @@ config X86_HT
12586
12587 config X86_32_LAZY_GS
12588 def_bool y
12589- depends on X86_32 && !CC_STACKPROTECTOR
12590+ depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
12591
12592 config ARCH_HWEIGHT_CFLAGS
12593 string
12594@@ -638,6 +638,7 @@ config SCHED_OMIT_FRAME_POINTER
12595
12596 menuconfig HYPERVISOR_GUEST
12597 bool "Linux guest support"
12598+ depends on !GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_VIRT_GUEST || (GRKERNSEC_CONFIG_VIRT_HOST && GRKERNSEC_CONFIG_VIRT_XEN)
12599 ---help---
12600 Say Y here to enable options for running Linux under various hyper-
12601 visors. This option enables basic hypervisor detection and platform
12602@@ -1005,6 +1006,7 @@ config VM86
12603
12604 config X86_16BIT
12605 bool "Enable support for 16-bit segments" if EXPERT
12606+ depends on !GRKERNSEC
12607 default y
12608 ---help---
12609 This option is required by programs like Wine to run 16-bit
12610@@ -1178,6 +1180,7 @@ choice
12611
12612 config NOHIGHMEM
12613 bool "off"
12614+ depends on !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
12615 ---help---
12616 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
12617 However, the address space of 32-bit x86 processors is only 4
12618@@ -1214,6 +1217,7 @@ config NOHIGHMEM
12619
12620 config HIGHMEM4G
12621 bool "4GB"
12622+ depends on !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
12623 ---help---
12624 Select this if you have a 32-bit processor and between 1 and 4
12625 gigabytes of physical RAM.
12626@@ -1266,7 +1270,7 @@ config PAGE_OFFSET
12627 hex
12628 default 0xB0000000 if VMSPLIT_3G_OPT
12629 default 0x80000000 if VMSPLIT_2G
12630- default 0x78000000 if VMSPLIT_2G_OPT
12631+ default 0x70000000 if VMSPLIT_2G_OPT
12632 default 0x40000000 if VMSPLIT_1G
12633 default 0xC0000000
12634 depends on X86_32
12635@@ -1717,6 +1721,7 @@ source kernel/Kconfig.hz
12636
12637 config KEXEC
12638 bool "kexec system call"
12639+ depends on !GRKERNSEC_KMEM
12640 ---help---
12641 kexec is a system call that implements the ability to shutdown your
12642 current kernel, and to start another kernel. It is like a reboot
12643@@ -1899,7 +1904,9 @@ config X86_NEED_RELOCS
12644
12645 config PHYSICAL_ALIGN
12646 hex "Alignment value to which kernel should be aligned"
12647- default "0x200000"
12648+ default "0x1000000"
12649+ range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
12650+ range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
12651 range 0x2000 0x1000000 if X86_32
12652 range 0x200000 0x1000000 if X86_64
12653 ---help---
12654@@ -1982,6 +1989,7 @@ config COMPAT_VDSO
12655 def_bool n
12656 prompt "Disable the 32-bit vDSO (needed for glibc 2.3.3)"
12657 depends on X86_32 || IA32_EMULATION
12658+ depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
12659 ---help---
12660 Certain buggy versions of glibc will crash if they are
12661 presented with a 32-bit vDSO that is not mapped at the address
12662@@ -2046,6 +2054,22 @@ config CMDLINE_OVERRIDE
12663 This is used to work around broken boot loaders. This should
12664 be set to 'N' under normal conditions.
12665
12666+config DEFAULT_MODIFY_LDT_SYSCALL
12667+ bool "Allow userspace to modify the LDT by default"
12668+ default y
12669+
12670+ ---help---
12671+ Modifying the LDT (Local Descriptor Table) may be needed to run a
12672+ 16-bit or segmented code such as Dosemu or Wine. This is done via
12673+ a system call which is not needed to run portable applications,
12674+ and which can sometimes be abused to exploit some weaknesses of
12675+ the architecture, opening new vulnerabilities.
12676+
12677+ For this reason this option allows one to enable or disable the
12678+ feature at runtime. It is recommended to say 'N' here to leave
12679+ the system protected, and to enable it at runtime only if needed
12680+ by setting the sys.kernel.modify_ldt sysctl.
12681+
12682 source "kernel/livepatch/Kconfig"
12683
12684 endmenu
12685diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
12686index 6983314..54ad7e8 100644
12687--- a/arch/x86/Kconfig.cpu
12688+++ b/arch/x86/Kconfig.cpu
12689@@ -319,7 +319,7 @@ config X86_PPRO_FENCE
12690
12691 config X86_F00F_BUG
12692 def_bool y
12693- depends on M586MMX || M586TSC || M586 || M486
12694+ depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
12695
12696 config X86_INVD_BUG
12697 def_bool y
12698@@ -327,7 +327,7 @@ config X86_INVD_BUG
12699
12700 config X86_ALIGNMENT_16
12701 def_bool y
12702- depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
12703+ depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
12704
12705 config X86_INTEL_USERCOPY
12706 def_bool y
12707@@ -369,7 +369,7 @@ config X86_CMPXCHG64
12708 # generates cmov.
12709 config X86_CMOV
12710 def_bool y
12711- depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
12712+ depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
12713
12714 config X86_MINIMUM_CPU_FAMILY
12715 int
12716diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
12717index 72484a6..83a4411 100644
12718--- a/arch/x86/Kconfig.debug
12719+++ b/arch/x86/Kconfig.debug
12720@@ -89,7 +89,7 @@ config EFI_PGT_DUMP
12721 config DEBUG_RODATA
12722 bool "Write protect kernel read-only data structures"
12723 default y
12724- depends on DEBUG_KERNEL
12725+ depends on DEBUG_KERNEL && BROKEN
12726 ---help---
12727 Mark the kernel read-only data as write-protected in the pagetables,
12728 in order to catch accidental (and incorrect) writes to such const
12729@@ -107,7 +107,7 @@ config DEBUG_RODATA_TEST
12730
12731 config DEBUG_SET_MODULE_RONX
12732 bool "Set loadable kernel module data as NX and text as RO"
12733- depends on MODULES
12734+ depends on MODULES && BROKEN
12735 ---help---
12736 This option helps catch unintended modifications to loadable
12737 kernel module's text and read-only data. It also prevents execution
12738diff --git a/arch/x86/Makefile b/arch/x86/Makefile
12739index 2fda005..2c72d40 100644
12740--- a/arch/x86/Makefile
12741+++ b/arch/x86/Makefile
12742@@ -65,9 +65,6 @@ ifeq ($(CONFIG_X86_32),y)
12743 # CPU-specific tuning. Anything which can be shared with UML should go here.
12744 include arch/x86/Makefile_32.cpu
12745 KBUILD_CFLAGS += $(cflags-y)
12746-
12747- # temporary until string.h is fixed
12748- KBUILD_CFLAGS += -ffreestanding
12749 else
12750 BITS := 64
12751 UTS_MACHINE := x86_64
12752@@ -107,6 +104,9 @@ else
12753 KBUILD_CFLAGS += $(call cc-option,-maccumulate-outgoing-args)
12754 endif
12755
12756+# temporary until string.h is fixed
12757+KBUILD_CFLAGS += -ffreestanding
12758+
12759 # Make sure compiler does not have buggy stack-protector support.
12760 ifdef CONFIG_CC_STACKPROTECTOR
12761 cc_has_sp := $(srctree)/scripts/gcc-x86_$(BITS)-has-stack-protector.sh
12762@@ -181,6 +181,7 @@ archheaders:
12763 $(Q)$(MAKE) $(build)=arch/x86/syscalls all
12764
12765 archprepare:
12766+ $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
12767 ifeq ($(CONFIG_KEXEC_FILE),y)
12768 $(Q)$(MAKE) $(build)=arch/x86/purgatory arch/x86/purgatory/kexec-purgatory.c
12769 endif
12770@@ -264,3 +265,9 @@ define archhelp
12771 echo ' FDARGS="..." arguments for the booted kernel'
12772 echo ' FDINITRD=file initrd for the booted kernel'
12773 endef
12774+
12775+define OLD_LD
12776+
12777+*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
12778+*** Please upgrade your binutils to 2.18 or newer
12779+endef
12780diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
12781index 57bbf2f..b100fce 100644
12782--- a/arch/x86/boot/Makefile
12783+++ b/arch/x86/boot/Makefile
12784@@ -58,6 +58,9 @@ clean-files += cpustr.h
12785 # ---------------------------------------------------------------------------
12786
12787 KBUILD_CFLAGS := $(USERINCLUDE) $(REALMODE_CFLAGS) -D_SETUP
12788+ifdef CONSTIFY_PLUGIN
12789+KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
12790+endif
12791 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
12792 GCOV_PROFILE := n
12793
12794diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
12795index 878e4b9..20537ab 100644
12796--- a/arch/x86/boot/bitops.h
12797+++ b/arch/x86/boot/bitops.h
12798@@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
12799 u8 v;
12800 const u32 *p = (const u32 *)addr;
12801
12802- asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
12803+ asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
12804 return v;
12805 }
12806
12807@@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
12808
12809 static inline void set_bit(int nr, void *addr)
12810 {
12811- asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
12812+ asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
12813 }
12814
12815 #endif /* BOOT_BITOPS_H */
12816diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
12817index bd49ec6..94c7f58 100644
12818--- a/arch/x86/boot/boot.h
12819+++ b/arch/x86/boot/boot.h
12820@@ -84,7 +84,7 @@ static inline void io_delay(void)
12821 static inline u16 ds(void)
12822 {
12823 u16 seg;
12824- asm("movw %%ds,%0" : "=rm" (seg));
12825+ asm volatile("movw %%ds,%0" : "=rm" (seg));
12826 return seg;
12827 }
12828
12829diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
12830index 0a291cd..9686efc 100644
12831--- a/arch/x86/boot/compressed/Makefile
12832+++ b/arch/x86/boot/compressed/Makefile
12833@@ -30,6 +30,9 @@ KBUILD_CFLAGS += $(cflags-y)
12834 KBUILD_CFLAGS += -mno-mmx -mno-sse
12835 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
12836 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
12837+ifdef CONSTIFY_PLUGIN
12838+KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
12839+endif
12840
12841 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
12842 GCOV_PROFILE := n
12843diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
12844index 48304b8..0cdc154 100644
12845--- a/arch/x86/boot/compressed/eboot.c
12846+++ b/arch/x86/boot/compressed/eboot.c
12847@@ -1193,6 +1193,10 @@ static efi_status_t setup_e820(struct boot_params *params,
12848 unsigned int e820_type = 0;
12849 unsigned long m = efi->efi_memmap;
12850
12851+#ifdef CONFIG_X86_64
12852+ m |= (u64)efi->efi_memmap_hi << 32;
12853+#endif
12854+
12855 d = (efi_memory_desc_t *)(m + (i * efi->efi_memdesc_size));
12856 switch (d->type) {
12857 case EFI_RESERVED_TYPE:
12858diff --git a/arch/x86/boot/compressed/efi_stub_32.S b/arch/x86/boot/compressed/efi_stub_32.S
12859index a53440e..c3dbf1e 100644
12860--- a/arch/x86/boot/compressed/efi_stub_32.S
12861+++ b/arch/x86/boot/compressed/efi_stub_32.S
12862@@ -46,16 +46,13 @@ ENTRY(efi_call_phys)
12863 * parameter 2, ..., param n. To make things easy, we save the return
12864 * address of efi_call_phys in a global variable.
12865 */
12866- popl %ecx
12867- movl %ecx, saved_return_addr(%edx)
12868- /* get the function pointer into ECX*/
12869- popl %ecx
12870- movl %ecx, efi_rt_function_ptr(%edx)
12871+ popl saved_return_addr(%edx)
12872+ popl efi_rt_function_ptr(%edx)
12873
12874 /*
12875 * 3. Call the physical function.
12876 */
12877- call *%ecx
12878+ call *efi_rt_function_ptr(%edx)
12879
12880 /*
12881 * 4. Balance the stack. And because EAX contain the return value,
12882@@ -67,15 +64,12 @@ ENTRY(efi_call_phys)
12883 1: popl %edx
12884 subl $1b, %edx
12885
12886- movl efi_rt_function_ptr(%edx), %ecx
12887- pushl %ecx
12888+ pushl efi_rt_function_ptr(%edx)
12889
12890 /*
12891 * 10. Push the saved return address onto the stack and return.
12892 */
12893- movl saved_return_addr(%edx), %ecx
12894- pushl %ecx
12895- ret
12896+ jmpl *saved_return_addr(%edx)
12897 ENDPROC(efi_call_phys)
12898 .previous
12899
12900diff --git a/arch/x86/boot/compressed/efi_thunk_64.S b/arch/x86/boot/compressed/efi_thunk_64.S
12901index 630384a..278e788 100644
12902--- a/arch/x86/boot/compressed/efi_thunk_64.S
12903+++ b/arch/x86/boot/compressed/efi_thunk_64.S
12904@@ -189,8 +189,8 @@ efi_gdt64:
12905 .long 0 /* Filled out by user */
12906 .word 0
12907 .quad 0x0000000000000000 /* NULL descriptor */
12908- .quad 0x00af9a000000ffff /* __KERNEL_CS */
12909- .quad 0x00cf92000000ffff /* __KERNEL_DS */
12910+ .quad 0x00af9b000000ffff /* __KERNEL_CS */
12911+ .quad 0x00cf93000000ffff /* __KERNEL_DS */
12912 .quad 0x0080890000000000 /* TS descriptor */
12913 .quad 0x0000000000000000 /* TS continued */
12914 efi_gdt64_end:
12915diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
12916index 8ef964d..fcfb8aa 100644
12917--- a/arch/x86/boot/compressed/head_32.S
12918+++ b/arch/x86/boot/compressed/head_32.S
12919@@ -141,10 +141,10 @@ preferred_addr:
12920 addl %eax, %ebx
12921 notl %eax
12922 andl %eax, %ebx
12923- cmpl $LOAD_PHYSICAL_ADDR, %ebx
12924+ cmpl $____LOAD_PHYSICAL_ADDR, %ebx
12925 jge 1f
12926 #endif
12927- movl $LOAD_PHYSICAL_ADDR, %ebx
12928+ movl $____LOAD_PHYSICAL_ADDR, %ebx
12929 1:
12930
12931 /* Target address to relocate to for decompression */
12932diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
12933index b0c0d16..3b44ff8 100644
12934--- a/arch/x86/boot/compressed/head_64.S
12935+++ b/arch/x86/boot/compressed/head_64.S
12936@@ -95,10 +95,10 @@ ENTRY(startup_32)
12937 addl %eax, %ebx
12938 notl %eax
12939 andl %eax, %ebx
12940- cmpl $LOAD_PHYSICAL_ADDR, %ebx
12941+ cmpl $____LOAD_PHYSICAL_ADDR, %ebx
12942 jge 1f
12943 #endif
12944- movl $LOAD_PHYSICAL_ADDR, %ebx
12945+ movl $____LOAD_PHYSICAL_ADDR, %ebx
12946 1:
12947
12948 /* Target address to relocate to for decompression */
12949@@ -323,10 +323,10 @@ preferred_addr:
12950 addq %rax, %rbp
12951 notq %rax
12952 andq %rax, %rbp
12953- cmpq $LOAD_PHYSICAL_ADDR, %rbp
12954+ cmpq $____LOAD_PHYSICAL_ADDR, %rbp
12955 jge 1f
12956 #endif
12957- movq $LOAD_PHYSICAL_ADDR, %rbp
12958+ movq $____LOAD_PHYSICAL_ADDR, %rbp
12959 1:
12960
12961 /* Target address to relocate to for decompression */
12962@@ -435,8 +435,8 @@ gdt:
12963 .long gdt
12964 .word 0
12965 .quad 0x0000000000000000 /* NULL descriptor */
12966- .quad 0x00af9a000000ffff /* __KERNEL_CS */
12967- .quad 0x00cf92000000ffff /* __KERNEL_DS */
12968+ .quad 0x00af9b000000ffff /* __KERNEL_CS */
12969+ .quad 0x00cf93000000ffff /* __KERNEL_DS */
12970 .quad 0x0080890000000000 /* TS descriptor */
12971 .quad 0x0000000000000000 /* TS continued */
12972 gdt_end:
12973diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
12974index a107b93..55602de 100644
12975--- a/arch/x86/boot/compressed/misc.c
12976+++ b/arch/x86/boot/compressed/misc.c
12977@@ -242,7 +242,7 @@ static void handle_relocations(void *output, unsigned long output_len)
12978 * Calculate the delta between where vmlinux was linked to load
12979 * and where it was actually loaded.
12980 */
12981- delta = min_addr - LOAD_PHYSICAL_ADDR;
12982+ delta = min_addr - ____LOAD_PHYSICAL_ADDR;
12983 if (!delta) {
12984 debug_putstr("No relocation needed... ");
12985 return;
12986@@ -324,7 +324,7 @@ static void parse_elf(void *output)
12987 Elf32_Ehdr ehdr;
12988 Elf32_Phdr *phdrs, *phdr;
12989 #endif
12990- void *dest;
12991+ void *dest, *prev;
12992 int i;
12993
12994 memcpy(&ehdr, output, sizeof(ehdr));
12995@@ -351,13 +351,16 @@ static void parse_elf(void *output)
12996 case PT_LOAD:
12997 #ifdef CONFIG_RELOCATABLE
12998 dest = output;
12999- dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
13000+ dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
13001 #else
13002 dest = (void *)(phdr->p_paddr);
13003 #endif
13004 memcpy(dest,
13005 output + phdr->p_offset,
13006 phdr->p_filesz);
13007+ if (i)
13008+ memset(prev, 0xff, dest - prev);
13009+ prev = dest + phdr->p_filesz;
13010 break;
13011 default: /* Ignore other PT_* */ break;
13012 }
13013@@ -419,7 +422,7 @@ asmlinkage __visible void *decompress_kernel(void *rmode, memptr heap,
13014 error("Destination address too large");
13015 #endif
13016 #ifndef CONFIG_RELOCATABLE
13017- if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
13018+ if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
13019 error("Wrong destination address");
13020 #endif
13021
13022diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
13023index 1fd7d57..0f7d096 100644
13024--- a/arch/x86/boot/cpucheck.c
13025+++ b/arch/x86/boot/cpucheck.c
13026@@ -125,9 +125,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
13027 u32 ecx = MSR_K7_HWCR;
13028 u32 eax, edx;
13029
13030- asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
13031+ asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
13032 eax &= ~(1 << 15);
13033- asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
13034+ asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
13035
13036 get_cpuflags(); /* Make sure it really did something */
13037 err = check_cpuflags();
13038@@ -140,9 +140,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
13039 u32 ecx = MSR_VIA_FCR;
13040 u32 eax, edx;
13041
13042- asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
13043+ asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
13044 eax |= (1<<1)|(1<<7);
13045- asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
13046+ asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
13047
13048 set_bit(X86_FEATURE_CX8, cpu.flags);
13049 err = check_cpuflags();
13050@@ -153,12 +153,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
13051 u32 eax, edx;
13052 u32 level = 1;
13053
13054- asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
13055- asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
13056- asm("cpuid"
13057+ asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
13058+ asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
13059+ asm volatile("cpuid"
13060 : "+a" (level), "=d" (cpu.flags[0])
13061 : : "ecx", "ebx");
13062- asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
13063+ asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
13064
13065 err = check_cpuflags();
13066 } else if (err == 0x01 &&
13067diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
13068index 16ef025..91e033b 100644
13069--- a/arch/x86/boot/header.S
13070+++ b/arch/x86/boot/header.S
13071@@ -438,10 +438,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
13072 # single linked list of
13073 # struct setup_data
13074
13075-pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
13076+pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
13077
13078 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
13079+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
13080+#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
13081+#else
13082 #define VO_INIT_SIZE (VO__end - VO__text)
13083+#endif
13084 #if ZO_INIT_SIZE > VO_INIT_SIZE
13085 #define INIT_SIZE ZO_INIT_SIZE
13086 #else
13087diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
13088index db75d07..8e6d0af 100644
13089--- a/arch/x86/boot/memory.c
13090+++ b/arch/x86/boot/memory.c
13091@@ -19,7 +19,7 @@
13092
13093 static int detect_memory_e820(void)
13094 {
13095- int count = 0;
13096+ unsigned int count = 0;
13097 struct biosregs ireg, oreg;
13098 struct e820entry *desc = boot_params.e820_map;
13099 static struct e820entry buf; /* static so it is zeroed */
13100diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
13101index ba3e100..6501b8f 100644
13102--- a/arch/x86/boot/video-vesa.c
13103+++ b/arch/x86/boot/video-vesa.c
13104@@ -201,6 +201,7 @@ static void vesa_store_pm_info(void)
13105
13106 boot_params.screen_info.vesapm_seg = oreg.es;
13107 boot_params.screen_info.vesapm_off = oreg.di;
13108+ boot_params.screen_info.vesapm_size = oreg.cx;
13109 }
13110
13111 /*
13112diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
13113index 05111bb..a1ae1f0 100644
13114--- a/arch/x86/boot/video.c
13115+++ b/arch/x86/boot/video.c
13116@@ -98,7 +98,7 @@ static void store_mode_params(void)
13117 static unsigned int get_entry(void)
13118 {
13119 char entry_buf[4];
13120- int i, len = 0;
13121+ unsigned int i, len = 0;
13122 int key;
13123 unsigned int v;
13124
13125diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
13126index 9105655..41779c1 100644
13127--- a/arch/x86/crypto/aes-x86_64-asm_64.S
13128+++ b/arch/x86/crypto/aes-x86_64-asm_64.S
13129@@ -8,6 +8,8 @@
13130 * including this sentence is retained in full.
13131 */
13132
13133+#include <asm/alternative-asm.h>
13134+
13135 .extern crypto_ft_tab
13136 .extern crypto_it_tab
13137 .extern crypto_fl_tab
13138@@ -70,6 +72,8 @@
13139 je B192; \
13140 leaq 32(r9),r9;
13141
13142+#define ret pax_force_retaddr; ret
13143+
13144 #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
13145 movq r1,r2; \
13146 movq r3,r4; \
13147diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
13148index 6bd2c6c..368c93e 100644
13149--- a/arch/x86/crypto/aesni-intel_asm.S
13150+++ b/arch/x86/crypto/aesni-intel_asm.S
13151@@ -31,6 +31,7 @@
13152
13153 #include <linux/linkage.h>
13154 #include <asm/inst.h>
13155+#include <asm/alternative-asm.h>
13156
13157 /*
13158 * The following macros are used to move an (un)aligned 16 byte value to/from
13159@@ -217,7 +218,7 @@ enc: .octa 0x2
13160 * num_initial_blocks = b mod 4
13161 * encrypt the initial num_initial_blocks blocks and apply ghash on
13162 * the ciphertext
13163-* %r10, %r11, %r12, %rax, %xmm5, %xmm6, %xmm7, %xmm8, %xmm9 registers
13164+* %r10, %r11, %r15, %rax, %xmm5, %xmm6, %xmm7, %xmm8, %xmm9 registers
13165 * are clobbered
13166 * arg1, %arg2, %arg3, %r14 are used as a pointer only, not modified
13167 */
13168@@ -227,8 +228,8 @@ enc: .octa 0x2
13169 XMM2 XMM3 XMM4 XMMDst TMP6 TMP7 i i_seq operation
13170 MOVADQ SHUF_MASK(%rip), %xmm14
13171 mov arg7, %r10 # %r10 = AAD
13172- mov arg8, %r12 # %r12 = aadLen
13173- mov %r12, %r11
13174+ mov arg8, %r15 # %r15 = aadLen
13175+ mov %r15, %r11
13176 pxor %xmm\i, %xmm\i
13177
13178 _get_AAD_loop\num_initial_blocks\operation:
13179@@ -237,17 +238,17 @@ _get_AAD_loop\num_initial_blocks\operation:
13180 psrldq $4, %xmm\i
13181 pxor \TMP1, %xmm\i
13182 add $4, %r10
13183- sub $4, %r12
13184+ sub $4, %r15
13185 jne _get_AAD_loop\num_initial_blocks\operation
13186
13187 cmp $16, %r11
13188 je _get_AAD_loop2_done\num_initial_blocks\operation
13189
13190- mov $16, %r12
13191+ mov $16, %r15
13192 _get_AAD_loop2\num_initial_blocks\operation:
13193 psrldq $4, %xmm\i
13194- sub $4, %r12
13195- cmp %r11, %r12
13196+ sub $4, %r15
13197+ cmp %r11, %r15
13198 jne _get_AAD_loop2\num_initial_blocks\operation
13199
13200 _get_AAD_loop2_done\num_initial_blocks\operation:
13201@@ -442,7 +443,7 @@ _initial_blocks_done\num_initial_blocks\operation:
13202 * num_initial_blocks = b mod 4
13203 * encrypt the initial num_initial_blocks blocks and apply ghash on
13204 * the ciphertext
13205-* %r10, %r11, %r12, %rax, %xmm5, %xmm6, %xmm7, %xmm8, %xmm9 registers
13206+* %r10, %r11, %r15, %rax, %xmm5, %xmm6, %xmm7, %xmm8, %xmm9 registers
13207 * are clobbered
13208 * arg1, %arg2, %arg3, %r14 are used as a pointer only, not modified
13209 */
13210@@ -452,8 +453,8 @@ _initial_blocks_done\num_initial_blocks\operation:
13211 XMM2 XMM3 XMM4 XMMDst TMP6 TMP7 i i_seq operation
13212 MOVADQ SHUF_MASK(%rip), %xmm14
13213 mov arg7, %r10 # %r10 = AAD
13214- mov arg8, %r12 # %r12 = aadLen
13215- mov %r12, %r11
13216+ mov arg8, %r15 # %r15 = aadLen
13217+ mov %r15, %r11
13218 pxor %xmm\i, %xmm\i
13219 _get_AAD_loop\num_initial_blocks\operation:
13220 movd (%r10), \TMP1
13221@@ -461,15 +462,15 @@ _get_AAD_loop\num_initial_blocks\operation:
13222 psrldq $4, %xmm\i
13223 pxor \TMP1, %xmm\i
13224 add $4, %r10
13225- sub $4, %r12
13226+ sub $4, %r15
13227 jne _get_AAD_loop\num_initial_blocks\operation
13228 cmp $16, %r11
13229 je _get_AAD_loop2_done\num_initial_blocks\operation
13230- mov $16, %r12
13231+ mov $16, %r15
13232 _get_AAD_loop2\num_initial_blocks\operation:
13233 psrldq $4, %xmm\i
13234- sub $4, %r12
13235- cmp %r11, %r12
13236+ sub $4, %r15
13237+ cmp %r11, %r15
13238 jne _get_AAD_loop2\num_initial_blocks\operation
13239 _get_AAD_loop2_done\num_initial_blocks\operation:
13240 PSHUFB_XMM %xmm14, %xmm\i # byte-reflect the AAD data
13241@@ -1280,7 +1281,7 @@ _esb_loop_\@:
13242 *
13243 *****************************************************************************/
13244 ENTRY(aesni_gcm_dec)
13245- push %r12
13246+ push %r15
13247 push %r13
13248 push %r14
13249 mov %rsp, %r14
13250@@ -1290,8 +1291,8 @@ ENTRY(aesni_gcm_dec)
13251 */
13252 sub $VARIABLE_OFFSET, %rsp
13253 and $~63, %rsp # align rsp to 64 bytes
13254- mov %arg6, %r12
13255- movdqu (%r12), %xmm13 # %xmm13 = HashKey
13256+ mov %arg6, %r15
13257+ movdqu (%r15), %xmm13 # %xmm13 = HashKey
13258 movdqa SHUF_MASK(%rip), %xmm2
13259 PSHUFB_XMM %xmm2, %xmm13
13260
13261@@ -1319,10 +1320,10 @@ ENTRY(aesni_gcm_dec)
13262 movdqa %xmm13, HashKey(%rsp) # store HashKey<<1 (mod poly)
13263 mov %arg4, %r13 # save the number of bytes of plaintext/ciphertext
13264 and $-16, %r13 # %r13 = %r13 - (%r13 mod 16)
13265- mov %r13, %r12
13266- and $(3<<4), %r12
13267+ mov %r13, %r15
13268+ and $(3<<4), %r15
13269 jz _initial_num_blocks_is_0_decrypt
13270- cmp $(2<<4), %r12
13271+ cmp $(2<<4), %r15
13272 jb _initial_num_blocks_is_1_decrypt
13273 je _initial_num_blocks_is_2_decrypt
13274 _initial_num_blocks_is_3_decrypt:
13275@@ -1372,16 +1373,16 @@ _zero_cipher_left_decrypt:
13276 sub $16, %r11
13277 add %r13, %r11
13278 movdqu (%arg3,%r11,1), %xmm1 # receive the last <16 byte block
13279- lea SHIFT_MASK+16(%rip), %r12
13280- sub %r13, %r12
13281+ lea SHIFT_MASK+16(%rip), %r15
13282+ sub %r13, %r15
13283 # adjust the shuffle mask pointer to be able to shift 16-%r13 bytes
13284 # (%r13 is the number of bytes in plaintext mod 16)
13285- movdqu (%r12), %xmm2 # get the appropriate shuffle mask
13286+ movdqu (%r15), %xmm2 # get the appropriate shuffle mask
13287 PSHUFB_XMM %xmm2, %xmm1 # right shift 16-%r13 butes
13288
13289 movdqa %xmm1, %xmm2
13290 pxor %xmm1, %xmm0 # Ciphertext XOR E(K, Yn)
13291- movdqu ALL_F-SHIFT_MASK(%r12), %xmm1
13292+ movdqu ALL_F-SHIFT_MASK(%r15), %xmm1
13293 # get the appropriate mask to mask out top 16-%r13 bytes of %xmm0
13294 pand %xmm1, %xmm0 # mask out top 16-%r13 bytes of %xmm0
13295 pand %xmm1, %xmm2
13296@@ -1410,9 +1411,9 @@ _less_than_8_bytes_left_decrypt:
13297 sub $1, %r13
13298 jne _less_than_8_bytes_left_decrypt
13299 _multiple_of_16_bytes_decrypt:
13300- mov arg8, %r12 # %r13 = aadLen (number of bytes)
13301- shl $3, %r12 # convert into number of bits
13302- movd %r12d, %xmm15 # len(A) in %xmm15
13303+ mov arg8, %r15 # %r13 = aadLen (number of bytes)
13304+ shl $3, %r15 # convert into number of bits
13305+ movd %r15d, %xmm15 # len(A) in %xmm15
13306 shl $3, %arg4 # len(C) in bits (*128)
13307 MOVQ_R64_XMM %arg4, %xmm1
13308 pslldq $8, %xmm15 # %xmm15 = len(A)||0x0000000000000000
13309@@ -1451,7 +1452,8 @@ _return_T_done_decrypt:
13310 mov %r14, %rsp
13311 pop %r14
13312 pop %r13
13313- pop %r12
13314+ pop %r15
13315+ pax_force_retaddr
13316 ret
13317 ENDPROC(aesni_gcm_dec)
13318
13319@@ -1540,7 +1542,7 @@ ENDPROC(aesni_gcm_dec)
13320 * poly = x^128 + x^127 + x^126 + x^121 + 1
13321 ***************************************************************************/
13322 ENTRY(aesni_gcm_enc)
13323- push %r12
13324+ push %r15
13325 push %r13
13326 push %r14
13327 mov %rsp, %r14
13328@@ -1550,8 +1552,8 @@ ENTRY(aesni_gcm_enc)
13329 #
13330 sub $VARIABLE_OFFSET, %rsp
13331 and $~63, %rsp
13332- mov %arg6, %r12
13333- movdqu (%r12), %xmm13
13334+ mov %arg6, %r15
13335+ movdqu (%r15), %xmm13
13336 movdqa SHUF_MASK(%rip), %xmm2
13337 PSHUFB_XMM %xmm2, %xmm13
13338
13339@@ -1575,13 +1577,13 @@ ENTRY(aesni_gcm_enc)
13340 movdqa %xmm13, HashKey(%rsp)
13341 mov %arg4, %r13 # %xmm13 holds HashKey<<1 (mod poly)
13342 and $-16, %r13
13343- mov %r13, %r12
13344+ mov %r13, %r15
13345
13346 # Encrypt first few blocks
13347
13348- and $(3<<4), %r12
13349+ and $(3<<4), %r15
13350 jz _initial_num_blocks_is_0_encrypt
13351- cmp $(2<<4), %r12
13352+ cmp $(2<<4), %r15
13353 jb _initial_num_blocks_is_1_encrypt
13354 je _initial_num_blocks_is_2_encrypt
13355 _initial_num_blocks_is_3_encrypt:
13356@@ -1634,14 +1636,14 @@ _zero_cipher_left_encrypt:
13357 sub $16, %r11
13358 add %r13, %r11
13359 movdqu (%arg3,%r11,1), %xmm1 # receive the last <16 byte blocks
13360- lea SHIFT_MASK+16(%rip), %r12
13361- sub %r13, %r12
13362+ lea SHIFT_MASK+16(%rip), %r15
13363+ sub %r13, %r15
13364 # adjust the shuffle mask pointer to be able to shift 16-r13 bytes
13365 # (%r13 is the number of bytes in plaintext mod 16)
13366- movdqu (%r12), %xmm2 # get the appropriate shuffle mask
13367+ movdqu (%r15), %xmm2 # get the appropriate shuffle mask
13368 PSHUFB_XMM %xmm2, %xmm1 # shift right 16-r13 byte
13369 pxor %xmm1, %xmm0 # Plaintext XOR Encrypt(K, Yn)
13370- movdqu ALL_F-SHIFT_MASK(%r12), %xmm1
13371+ movdqu ALL_F-SHIFT_MASK(%r15), %xmm1
13372 # get the appropriate mask to mask out top 16-r13 bytes of xmm0
13373 pand %xmm1, %xmm0 # mask out top 16-r13 bytes of xmm0
13374 movdqa SHUF_MASK(%rip), %xmm10
13375@@ -1674,9 +1676,9 @@ _less_than_8_bytes_left_encrypt:
13376 sub $1, %r13
13377 jne _less_than_8_bytes_left_encrypt
13378 _multiple_of_16_bytes_encrypt:
13379- mov arg8, %r12 # %r12 = addLen (number of bytes)
13380- shl $3, %r12
13381- movd %r12d, %xmm15 # len(A) in %xmm15
13382+ mov arg8, %r15 # %r15 = addLen (number of bytes)
13383+ shl $3, %r15
13384+ movd %r15d, %xmm15 # len(A) in %xmm15
13385 shl $3, %arg4 # len(C) in bits (*128)
13386 MOVQ_R64_XMM %arg4, %xmm1
13387 pslldq $8, %xmm15 # %xmm15 = len(A)||0x0000000000000000
13388@@ -1715,7 +1717,8 @@ _return_T_done_encrypt:
13389 mov %r14, %rsp
13390 pop %r14
13391 pop %r13
13392- pop %r12
13393+ pop %r15
13394+ pax_force_retaddr
13395 ret
13396 ENDPROC(aesni_gcm_enc)
13397
13398@@ -1733,6 +1736,7 @@ _key_expansion_256a:
13399 pxor %xmm1, %xmm0
13400 movaps %xmm0, (TKEYP)
13401 add $0x10, TKEYP
13402+ pax_force_retaddr
13403 ret
13404 ENDPROC(_key_expansion_128)
13405 ENDPROC(_key_expansion_256a)
13406@@ -1759,6 +1763,7 @@ _key_expansion_192a:
13407 shufps $0b01001110, %xmm2, %xmm1
13408 movaps %xmm1, 0x10(TKEYP)
13409 add $0x20, TKEYP
13410+ pax_force_retaddr
13411 ret
13412 ENDPROC(_key_expansion_192a)
13413
13414@@ -1779,6 +1784,7 @@ _key_expansion_192b:
13415
13416 movaps %xmm0, (TKEYP)
13417 add $0x10, TKEYP
13418+ pax_force_retaddr
13419 ret
13420 ENDPROC(_key_expansion_192b)
13421
13422@@ -1792,6 +1798,7 @@ _key_expansion_256b:
13423 pxor %xmm1, %xmm2
13424 movaps %xmm2, (TKEYP)
13425 add $0x10, TKEYP
13426+ pax_force_retaddr
13427 ret
13428 ENDPROC(_key_expansion_256b)
13429
13430@@ -1905,6 +1912,7 @@ ENTRY(aesni_set_key)
13431 #ifndef __x86_64__
13432 popl KEYP
13433 #endif
13434+ pax_force_retaddr
13435 ret
13436 ENDPROC(aesni_set_key)
13437
13438@@ -1927,6 +1935,7 @@ ENTRY(aesni_enc)
13439 popl KLEN
13440 popl KEYP
13441 #endif
13442+ pax_force_retaddr
13443 ret
13444 ENDPROC(aesni_enc)
13445
13446@@ -1985,6 +1994,7 @@ _aesni_enc1:
13447 AESENC KEY STATE
13448 movaps 0x70(TKEYP), KEY
13449 AESENCLAST KEY STATE
13450+ pax_force_retaddr
13451 ret
13452 ENDPROC(_aesni_enc1)
13453
13454@@ -2094,6 +2104,7 @@ _aesni_enc4:
13455 AESENCLAST KEY STATE2
13456 AESENCLAST KEY STATE3
13457 AESENCLAST KEY STATE4
13458+ pax_force_retaddr
13459 ret
13460 ENDPROC(_aesni_enc4)
13461
13462@@ -2117,6 +2128,7 @@ ENTRY(aesni_dec)
13463 popl KLEN
13464 popl KEYP
13465 #endif
13466+ pax_force_retaddr
13467 ret
13468 ENDPROC(aesni_dec)
13469
13470@@ -2175,6 +2187,7 @@ _aesni_dec1:
13471 AESDEC KEY STATE
13472 movaps 0x70(TKEYP), KEY
13473 AESDECLAST KEY STATE
13474+ pax_force_retaddr
13475 ret
13476 ENDPROC(_aesni_dec1)
13477
13478@@ -2284,6 +2297,7 @@ _aesni_dec4:
13479 AESDECLAST KEY STATE2
13480 AESDECLAST KEY STATE3
13481 AESDECLAST KEY STATE4
13482+ pax_force_retaddr
13483 ret
13484 ENDPROC(_aesni_dec4)
13485
13486@@ -2342,6 +2356,7 @@ ENTRY(aesni_ecb_enc)
13487 popl KEYP
13488 popl LEN
13489 #endif
13490+ pax_force_retaddr
13491 ret
13492 ENDPROC(aesni_ecb_enc)
13493
13494@@ -2401,6 +2416,7 @@ ENTRY(aesni_ecb_dec)
13495 popl KEYP
13496 popl LEN
13497 #endif
13498+ pax_force_retaddr
13499 ret
13500 ENDPROC(aesni_ecb_dec)
13501
13502@@ -2443,6 +2459,7 @@ ENTRY(aesni_cbc_enc)
13503 popl LEN
13504 popl IVP
13505 #endif
13506+ pax_force_retaddr
13507 ret
13508 ENDPROC(aesni_cbc_enc)
13509
13510@@ -2534,6 +2551,7 @@ ENTRY(aesni_cbc_dec)
13511 popl LEN
13512 popl IVP
13513 #endif
13514+ pax_force_retaddr
13515 ret
13516 ENDPROC(aesni_cbc_dec)
13517
13518@@ -2561,6 +2579,7 @@ _aesni_inc_init:
13519 mov $1, TCTR_LOW
13520 MOVQ_R64_XMM TCTR_LOW INC
13521 MOVQ_R64_XMM CTR TCTR_LOW
13522+ pax_force_retaddr
13523 ret
13524 ENDPROC(_aesni_inc_init)
13525
13526@@ -2590,6 +2609,7 @@ _aesni_inc:
13527 .Linc_low:
13528 movaps CTR, IV
13529 PSHUFB_XMM BSWAP_MASK IV
13530+ pax_force_retaddr
13531 ret
13532 ENDPROC(_aesni_inc)
13533
13534@@ -2651,6 +2671,7 @@ ENTRY(aesni_ctr_enc)
13535 .Lctr_enc_ret:
13536 movups IV, (IVP)
13537 .Lctr_enc_just_ret:
13538+ pax_force_retaddr
13539 ret
13540 ENDPROC(aesni_ctr_enc)
13541
13542@@ -2777,6 +2798,7 @@ ENTRY(aesni_xts_crypt8)
13543 pxor INC, STATE4
13544 movdqu STATE4, 0x70(OUTP)
13545
13546+ pax_force_retaddr
13547 ret
13548 ENDPROC(aesni_xts_crypt8)
13549
13550diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
13551index 246c670..466e2d6 100644
13552--- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
13553+++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
13554@@ -21,6 +21,7 @@
13555 */
13556
13557 #include <linux/linkage.h>
13558+#include <asm/alternative-asm.h>
13559
13560 .file "blowfish-x86_64-asm.S"
13561 .text
13562@@ -149,9 +150,11 @@ ENTRY(__blowfish_enc_blk)
13563 jnz .L__enc_xor;
13564
13565 write_block();
13566+ pax_force_retaddr
13567 ret;
13568 .L__enc_xor:
13569 xor_block();
13570+ pax_force_retaddr
13571 ret;
13572 ENDPROC(__blowfish_enc_blk)
13573
13574@@ -183,6 +186,7 @@ ENTRY(blowfish_dec_blk)
13575
13576 movq %r11, %rbp;
13577
13578+ pax_force_retaddr
13579 ret;
13580 ENDPROC(blowfish_dec_blk)
13581
13582@@ -334,6 +338,7 @@ ENTRY(__blowfish_enc_blk_4way)
13583
13584 popq %rbx;
13585 popq %rbp;
13586+ pax_force_retaddr
13587 ret;
13588
13589 .L__enc_xor4:
13590@@ -341,6 +346,7 @@ ENTRY(__blowfish_enc_blk_4way)
13591
13592 popq %rbx;
13593 popq %rbp;
13594+ pax_force_retaddr
13595 ret;
13596 ENDPROC(__blowfish_enc_blk_4way)
13597
13598@@ -375,5 +381,6 @@ ENTRY(blowfish_dec_blk_4way)
13599 popq %rbx;
13600 popq %rbp;
13601
13602+ pax_force_retaddr
13603 ret;
13604 ENDPROC(blowfish_dec_blk_4way)
13605diff --git a/arch/x86/crypto/camellia-aesni-avx-asm_64.S b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
13606index ce71f92..1dce7ec 100644
13607--- a/arch/x86/crypto/camellia-aesni-avx-asm_64.S
13608+++ b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
13609@@ -16,6 +16,7 @@
13610 */
13611
13612 #include <linux/linkage.h>
13613+#include <asm/alternative-asm.h>
13614
13615 #define CAMELLIA_TABLE_BYTE_LEN 272
13616
13617@@ -191,6 +192,7 @@ roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
13618 roundsm16(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
13619 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14, %xmm15,
13620 %rcx, (%r9));
13621+ pax_force_retaddr
13622 ret;
13623 ENDPROC(roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
13624
13625@@ -199,6 +201,7 @@ roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
13626 roundsm16(%xmm4, %xmm5, %xmm6, %xmm7, %xmm0, %xmm1, %xmm2, %xmm3,
13627 %xmm12, %xmm13, %xmm14, %xmm15, %xmm8, %xmm9, %xmm10, %xmm11,
13628 %rax, (%r9));
13629+ pax_force_retaddr
13630 ret;
13631 ENDPROC(roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
13632
13633@@ -780,6 +783,7 @@ __camellia_enc_blk16:
13634 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
13635 %xmm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 16(%rax));
13636
13637+ pax_force_retaddr
13638 ret;
13639
13640 .align 8
13641@@ -865,6 +869,7 @@ __camellia_dec_blk16:
13642 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
13643 %xmm15, (key_table)(CTX), (%rax), 1 * 16(%rax));
13644
13645+ pax_force_retaddr
13646 ret;
13647
13648 .align 8
13649@@ -904,6 +909,7 @@ ENTRY(camellia_ecb_enc_16way)
13650 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
13651 %xmm8, %rsi);
13652
13653+ pax_force_retaddr
13654 ret;
13655 ENDPROC(camellia_ecb_enc_16way)
13656
13657@@ -932,6 +938,7 @@ ENTRY(camellia_ecb_dec_16way)
13658 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
13659 %xmm8, %rsi);
13660
13661+ pax_force_retaddr
13662 ret;
13663 ENDPROC(camellia_ecb_dec_16way)
13664
13665@@ -981,6 +988,7 @@ ENTRY(camellia_cbc_dec_16way)
13666 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
13667 %xmm8, %rsi);
13668
13669+ pax_force_retaddr
13670 ret;
13671 ENDPROC(camellia_cbc_dec_16way)
13672
13673@@ -1092,6 +1100,7 @@ ENTRY(camellia_ctr_16way)
13674 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
13675 %xmm8, %rsi);
13676
13677+ pax_force_retaddr
13678 ret;
13679 ENDPROC(camellia_ctr_16way)
13680
13681@@ -1234,6 +1243,7 @@ camellia_xts_crypt_16way:
13682 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
13683 %xmm8, %rsi);
13684
13685+ pax_force_retaddr
13686 ret;
13687 ENDPROC(camellia_xts_crypt_16way)
13688
13689diff --git a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
13690index 0e0b886..5a3123c 100644
13691--- a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
13692+++ b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
13693@@ -11,6 +11,7 @@
13694 */
13695
13696 #include <linux/linkage.h>
13697+#include <asm/alternative-asm.h>
13698
13699 #define CAMELLIA_TABLE_BYTE_LEN 272
13700
13701@@ -230,6 +231,7 @@ roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
13702 roundsm32(%ymm0, %ymm1, %ymm2, %ymm3, %ymm4, %ymm5, %ymm6, %ymm7,
13703 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14, %ymm15,
13704 %rcx, (%r9));
13705+ pax_force_retaddr
13706 ret;
13707 ENDPROC(roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
13708
13709@@ -238,6 +240,7 @@ roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
13710 roundsm32(%ymm4, %ymm5, %ymm6, %ymm7, %ymm0, %ymm1, %ymm2, %ymm3,
13711 %ymm12, %ymm13, %ymm14, %ymm15, %ymm8, %ymm9, %ymm10, %ymm11,
13712 %rax, (%r9));
13713+ pax_force_retaddr
13714 ret;
13715 ENDPROC(roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
13716
13717@@ -820,6 +823,7 @@ __camellia_enc_blk32:
13718 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
13719 %ymm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 32(%rax));
13720
13721+ pax_force_retaddr
13722 ret;
13723
13724 .align 8
13725@@ -905,6 +909,7 @@ __camellia_dec_blk32:
13726 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
13727 %ymm15, (key_table)(CTX), (%rax), 1 * 32(%rax));
13728
13729+ pax_force_retaddr
13730 ret;
13731
13732 .align 8
13733@@ -948,6 +953,7 @@ ENTRY(camellia_ecb_enc_32way)
13734
13735 vzeroupper;
13736
13737+ pax_force_retaddr
13738 ret;
13739 ENDPROC(camellia_ecb_enc_32way)
13740
13741@@ -980,6 +986,7 @@ ENTRY(camellia_ecb_dec_32way)
13742
13743 vzeroupper;
13744
13745+ pax_force_retaddr
13746 ret;
13747 ENDPROC(camellia_ecb_dec_32way)
13748
13749@@ -1046,6 +1053,7 @@ ENTRY(camellia_cbc_dec_32way)
13750
13751 vzeroupper;
13752
13753+ pax_force_retaddr
13754 ret;
13755 ENDPROC(camellia_cbc_dec_32way)
13756
13757@@ -1184,6 +1192,7 @@ ENTRY(camellia_ctr_32way)
13758
13759 vzeroupper;
13760
13761+ pax_force_retaddr
13762 ret;
13763 ENDPROC(camellia_ctr_32way)
13764
13765@@ -1349,6 +1358,7 @@ camellia_xts_crypt_32way:
13766
13767 vzeroupper;
13768
13769+ pax_force_retaddr
13770 ret;
13771 ENDPROC(camellia_xts_crypt_32way)
13772
13773diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
13774index 310319c..db3d7b5 100644
13775--- a/arch/x86/crypto/camellia-x86_64-asm_64.S
13776+++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
13777@@ -21,6 +21,7 @@
13778 */
13779
13780 #include <linux/linkage.h>
13781+#include <asm/alternative-asm.h>
13782
13783 .file "camellia-x86_64-asm_64.S"
13784 .text
13785@@ -228,12 +229,14 @@ ENTRY(__camellia_enc_blk)
13786 enc_outunpack(mov, RT1);
13787
13788 movq RRBP, %rbp;
13789+ pax_force_retaddr
13790 ret;
13791
13792 .L__enc_xor:
13793 enc_outunpack(xor, RT1);
13794
13795 movq RRBP, %rbp;
13796+ pax_force_retaddr
13797 ret;
13798 ENDPROC(__camellia_enc_blk)
13799
13800@@ -272,6 +275,7 @@ ENTRY(camellia_dec_blk)
13801 dec_outunpack();
13802
13803 movq RRBP, %rbp;
13804+ pax_force_retaddr
13805 ret;
13806 ENDPROC(camellia_dec_blk)
13807
13808@@ -463,6 +467,7 @@ ENTRY(__camellia_enc_blk_2way)
13809
13810 movq RRBP, %rbp;
13811 popq %rbx;
13812+ pax_force_retaddr
13813 ret;
13814
13815 .L__enc2_xor:
13816@@ -470,6 +475,7 @@ ENTRY(__camellia_enc_blk_2way)
13817
13818 movq RRBP, %rbp;
13819 popq %rbx;
13820+ pax_force_retaddr
13821 ret;
13822 ENDPROC(__camellia_enc_blk_2way)
13823
13824@@ -510,5 +516,6 @@ ENTRY(camellia_dec_blk_2way)
13825
13826 movq RRBP, %rbp;
13827 movq RXOR, %rbx;
13828+ pax_force_retaddr
13829 ret;
13830 ENDPROC(camellia_dec_blk_2way)
13831diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
13832index c35fd5d..2d8c7db 100644
13833--- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
13834+++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
13835@@ -24,6 +24,7 @@
13836 */
13837
13838 #include <linux/linkage.h>
13839+#include <asm/alternative-asm.h>
13840
13841 .file "cast5-avx-x86_64-asm_64.S"
13842
13843@@ -281,6 +282,7 @@ __cast5_enc_blk16:
13844 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
13845 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
13846
13847+ pax_force_retaddr
13848 ret;
13849 ENDPROC(__cast5_enc_blk16)
13850
13851@@ -352,6 +354,7 @@ __cast5_dec_blk16:
13852 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
13853 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
13854
13855+ pax_force_retaddr
13856 ret;
13857
13858 .L__skip_dec:
13859@@ -388,6 +391,7 @@ ENTRY(cast5_ecb_enc_16way)
13860 vmovdqu RR4, (6*4*4)(%r11);
13861 vmovdqu RL4, (7*4*4)(%r11);
13862
13863+ pax_force_retaddr
13864 ret;
13865 ENDPROC(cast5_ecb_enc_16way)
13866
13867@@ -420,6 +424,7 @@ ENTRY(cast5_ecb_dec_16way)
13868 vmovdqu RR4, (6*4*4)(%r11);
13869 vmovdqu RL4, (7*4*4)(%r11);
13870
13871+ pax_force_retaddr
13872 ret;
13873 ENDPROC(cast5_ecb_dec_16way)
13874
13875@@ -430,10 +435,10 @@ ENTRY(cast5_cbc_dec_16way)
13876 * %rdx: src
13877 */
13878
13879- pushq %r12;
13880+ pushq %r14;
13881
13882 movq %rsi, %r11;
13883- movq %rdx, %r12;
13884+ movq %rdx, %r14;
13885
13886 vmovdqu (0*16)(%rdx), RL1;
13887 vmovdqu (1*16)(%rdx), RR1;
13888@@ -447,16 +452,16 @@ ENTRY(cast5_cbc_dec_16way)
13889 call __cast5_dec_blk16;
13890
13891 /* xor with src */
13892- vmovq (%r12), RX;
13893+ vmovq (%r14), RX;
13894 vpshufd $0x4f, RX, RX;
13895 vpxor RX, RR1, RR1;
13896- vpxor 0*16+8(%r12), RL1, RL1;
13897- vpxor 1*16+8(%r12), RR2, RR2;
13898- vpxor 2*16+8(%r12), RL2, RL2;
13899- vpxor 3*16+8(%r12), RR3, RR3;
13900- vpxor 4*16+8(%r12), RL3, RL3;
13901- vpxor 5*16+8(%r12), RR4, RR4;
13902- vpxor 6*16+8(%r12), RL4, RL4;
13903+ vpxor 0*16+8(%r14), RL1, RL1;
13904+ vpxor 1*16+8(%r14), RR2, RR2;
13905+ vpxor 2*16+8(%r14), RL2, RL2;
13906+ vpxor 3*16+8(%r14), RR3, RR3;
13907+ vpxor 4*16+8(%r14), RL3, RL3;
13908+ vpxor 5*16+8(%r14), RR4, RR4;
13909+ vpxor 6*16+8(%r14), RL4, RL4;
13910
13911 vmovdqu RR1, (0*16)(%r11);
13912 vmovdqu RL1, (1*16)(%r11);
13913@@ -467,8 +472,9 @@ ENTRY(cast5_cbc_dec_16way)
13914 vmovdqu RR4, (6*16)(%r11);
13915 vmovdqu RL4, (7*16)(%r11);
13916
13917- popq %r12;
13918+ popq %r14;
13919
13920+ pax_force_retaddr
13921 ret;
13922 ENDPROC(cast5_cbc_dec_16way)
13923
13924@@ -480,10 +486,10 @@ ENTRY(cast5_ctr_16way)
13925 * %rcx: iv (big endian, 64bit)
13926 */
13927
13928- pushq %r12;
13929+ pushq %r14;
13930
13931 movq %rsi, %r11;
13932- movq %rdx, %r12;
13933+ movq %rdx, %r14;
13934
13935 vpcmpeqd RTMP, RTMP, RTMP;
13936 vpsrldq $8, RTMP, RTMP; /* low: -1, high: 0 */
13937@@ -523,14 +529,14 @@ ENTRY(cast5_ctr_16way)
13938 call __cast5_enc_blk16;
13939
13940 /* dst = src ^ iv */
13941- vpxor (0*16)(%r12), RR1, RR1;
13942- vpxor (1*16)(%r12), RL1, RL1;
13943- vpxor (2*16)(%r12), RR2, RR2;
13944- vpxor (3*16)(%r12), RL2, RL2;
13945- vpxor (4*16)(%r12), RR3, RR3;
13946- vpxor (5*16)(%r12), RL3, RL3;
13947- vpxor (6*16)(%r12), RR4, RR4;
13948- vpxor (7*16)(%r12), RL4, RL4;
13949+ vpxor (0*16)(%r14), RR1, RR1;
13950+ vpxor (1*16)(%r14), RL1, RL1;
13951+ vpxor (2*16)(%r14), RR2, RR2;
13952+ vpxor (3*16)(%r14), RL2, RL2;
13953+ vpxor (4*16)(%r14), RR3, RR3;
13954+ vpxor (5*16)(%r14), RL3, RL3;
13955+ vpxor (6*16)(%r14), RR4, RR4;
13956+ vpxor (7*16)(%r14), RL4, RL4;
13957 vmovdqu RR1, (0*16)(%r11);
13958 vmovdqu RL1, (1*16)(%r11);
13959 vmovdqu RR2, (2*16)(%r11);
13960@@ -540,7 +546,8 @@ ENTRY(cast5_ctr_16way)
13961 vmovdqu RR4, (6*16)(%r11);
13962 vmovdqu RL4, (7*16)(%r11);
13963
13964- popq %r12;
13965+ popq %r14;
13966
13967+ pax_force_retaddr
13968 ret;
13969 ENDPROC(cast5_ctr_16way)
13970diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
13971index e3531f8..e123f35 100644
13972--- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
13973+++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
13974@@ -24,6 +24,7 @@
13975 */
13976
13977 #include <linux/linkage.h>
13978+#include <asm/alternative-asm.h>
13979 #include "glue_helper-asm-avx.S"
13980
13981 .file "cast6-avx-x86_64-asm_64.S"
13982@@ -295,6 +296,7 @@ __cast6_enc_blk8:
13983 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
13984 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
13985
13986+ pax_force_retaddr
13987 ret;
13988 ENDPROC(__cast6_enc_blk8)
13989
13990@@ -340,6 +342,7 @@ __cast6_dec_blk8:
13991 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
13992 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
13993
13994+ pax_force_retaddr
13995 ret;
13996 ENDPROC(__cast6_dec_blk8)
13997
13998@@ -358,6 +361,7 @@ ENTRY(cast6_ecb_enc_8way)
13999
14000 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14001
14002+ pax_force_retaddr
14003 ret;
14004 ENDPROC(cast6_ecb_enc_8way)
14005
14006@@ -376,6 +380,7 @@ ENTRY(cast6_ecb_dec_8way)
14007
14008 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14009
14010+ pax_force_retaddr
14011 ret;
14012 ENDPROC(cast6_ecb_dec_8way)
14013
14014@@ -386,19 +391,20 @@ ENTRY(cast6_cbc_dec_8way)
14015 * %rdx: src
14016 */
14017
14018- pushq %r12;
14019+ pushq %r14;
14020
14021 movq %rsi, %r11;
14022- movq %rdx, %r12;
14023+ movq %rdx, %r14;
14024
14025 load_8way(%rdx, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14026
14027 call __cast6_dec_blk8;
14028
14029- store_cbc_8way(%r12, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14030+ store_cbc_8way(%r14, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14031
14032- popq %r12;
14033+ popq %r14;
14034
14035+ pax_force_retaddr
14036 ret;
14037 ENDPROC(cast6_cbc_dec_8way)
14038
14039@@ -410,20 +416,21 @@ ENTRY(cast6_ctr_8way)
14040 * %rcx: iv (little endian, 128bit)
14041 */
14042
14043- pushq %r12;
14044+ pushq %r14;
14045
14046 movq %rsi, %r11;
14047- movq %rdx, %r12;
14048+ movq %rdx, %r14;
14049
14050 load_ctr_8way(%rcx, .Lbswap128_mask, RA1, RB1, RC1, RD1, RA2, RB2, RC2,
14051 RD2, RX, RKR, RKM);
14052
14053 call __cast6_enc_blk8;
14054
14055- store_ctr_8way(%r12, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14056+ store_ctr_8way(%r14, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14057
14058- popq %r12;
14059+ popq %r14;
14060
14061+ pax_force_retaddr
14062 ret;
14063 ENDPROC(cast6_ctr_8way)
14064
14065@@ -446,6 +453,7 @@ ENTRY(cast6_xts_enc_8way)
14066 /* dst <= regs xor IVs(in dst) */
14067 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14068
14069+ pax_force_retaddr
14070 ret;
14071 ENDPROC(cast6_xts_enc_8way)
14072
14073@@ -468,5 +476,6 @@ ENTRY(cast6_xts_dec_8way)
14074 /* dst <= regs xor IVs(in dst) */
14075 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14076
14077+ pax_force_retaddr
14078 ret;
14079 ENDPROC(cast6_xts_dec_8way)
14080diff --git a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
14081index 225be06..2885e731 100644
14082--- a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
14083+++ b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
14084@@ -45,6 +45,7 @@
14085
14086 #include <asm/inst.h>
14087 #include <linux/linkage.h>
14088+#include <asm/alternative-asm.h>
14089
14090 ## ISCSI CRC 32 Implementation with crc32 and pclmulqdq Instruction
14091
14092@@ -309,6 +310,7 @@ do_return:
14093 popq %rsi
14094 popq %rdi
14095 popq %rbx
14096+ pax_force_retaddr
14097 ret
14098
14099 ################################################################
14100@@ -330,7 +332,7 @@ ENDPROC(crc_pcl)
14101 ## PCLMULQDQ tables
14102 ## Table is 128 entries x 2 words (8 bytes) each
14103 ################################################################
14104-.section .rotata, "a", %progbits
14105+.section .rodata, "a", %progbits
14106 .align 8
14107 K_table:
14108 .long 0x493c7d27, 0x00000001
14109diff --git a/arch/x86/crypto/ghash-clmulni-intel_asm.S b/arch/x86/crypto/ghash-clmulni-intel_asm.S
14110index 5d1e007..098cb4f 100644
14111--- a/arch/x86/crypto/ghash-clmulni-intel_asm.S
14112+++ b/arch/x86/crypto/ghash-clmulni-intel_asm.S
14113@@ -18,6 +18,7 @@
14114
14115 #include <linux/linkage.h>
14116 #include <asm/inst.h>
14117+#include <asm/alternative-asm.h>
14118
14119 .data
14120
14121@@ -89,6 +90,7 @@ __clmul_gf128mul_ble:
14122 psrlq $1, T2
14123 pxor T2, T1
14124 pxor T1, DATA
14125+ pax_force_retaddr
14126 ret
14127 ENDPROC(__clmul_gf128mul_ble)
14128
14129@@ -101,6 +103,7 @@ ENTRY(clmul_ghash_mul)
14130 call __clmul_gf128mul_ble
14131 PSHUFB_XMM BSWAP DATA
14132 movups DATA, (%rdi)
14133+ pax_force_retaddr
14134 ret
14135 ENDPROC(clmul_ghash_mul)
14136
14137@@ -128,5 +131,6 @@ ENTRY(clmul_ghash_update)
14138 PSHUFB_XMM BSWAP DATA
14139 movups DATA, (%rdi)
14140 .Lupdate_just_ret:
14141+ pax_force_retaddr
14142 ret
14143 ENDPROC(clmul_ghash_update)
14144diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
14145index 9279e0b..c4b3d2c 100644
14146--- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
14147+++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
14148@@ -1,4 +1,5 @@
14149 #include <linux/linkage.h>
14150+#include <asm/alternative-asm.h>
14151
14152 # enter salsa20_encrypt_bytes
14153 ENTRY(salsa20_encrypt_bytes)
14154@@ -789,6 +790,7 @@ ENTRY(salsa20_encrypt_bytes)
14155 add %r11,%rsp
14156 mov %rdi,%rax
14157 mov %rsi,%rdx
14158+ pax_force_retaddr
14159 ret
14160 # bytesatleast65:
14161 ._bytesatleast65:
14162@@ -889,6 +891,7 @@ ENTRY(salsa20_keysetup)
14163 add %r11,%rsp
14164 mov %rdi,%rax
14165 mov %rsi,%rdx
14166+ pax_force_retaddr
14167 ret
14168 ENDPROC(salsa20_keysetup)
14169
14170@@ -914,5 +917,6 @@ ENTRY(salsa20_ivsetup)
14171 add %r11,%rsp
14172 mov %rdi,%rax
14173 mov %rsi,%rdx
14174+ pax_force_retaddr
14175 ret
14176 ENDPROC(salsa20_ivsetup)
14177diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
14178index 2f202f4..d9164d6 100644
14179--- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
14180+++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
14181@@ -24,6 +24,7 @@
14182 */
14183
14184 #include <linux/linkage.h>
14185+#include <asm/alternative-asm.h>
14186 #include "glue_helper-asm-avx.S"
14187
14188 .file "serpent-avx-x86_64-asm_64.S"
14189@@ -618,6 +619,7 @@ __serpent_enc_blk8_avx:
14190 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
14191 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
14192
14193+ pax_force_retaddr
14194 ret;
14195 ENDPROC(__serpent_enc_blk8_avx)
14196
14197@@ -672,6 +674,7 @@ __serpent_dec_blk8_avx:
14198 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
14199 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
14200
14201+ pax_force_retaddr
14202 ret;
14203 ENDPROC(__serpent_dec_blk8_avx)
14204
14205@@ -688,6 +691,7 @@ ENTRY(serpent_ecb_enc_8way_avx)
14206
14207 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14208
14209+ pax_force_retaddr
14210 ret;
14211 ENDPROC(serpent_ecb_enc_8way_avx)
14212
14213@@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_8way_avx)
14214
14215 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
14216
14217+ pax_force_retaddr
14218 ret;
14219 ENDPROC(serpent_ecb_dec_8way_avx)
14220
14221@@ -720,6 +725,7 @@ ENTRY(serpent_cbc_dec_8way_avx)
14222
14223 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
14224
14225+ pax_force_retaddr
14226 ret;
14227 ENDPROC(serpent_cbc_dec_8way_avx)
14228
14229@@ -738,6 +744,7 @@ ENTRY(serpent_ctr_8way_avx)
14230
14231 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14232
14233+ pax_force_retaddr
14234 ret;
14235 ENDPROC(serpent_ctr_8way_avx)
14236
14237@@ -758,6 +765,7 @@ ENTRY(serpent_xts_enc_8way_avx)
14238 /* dst <= regs xor IVs(in dst) */
14239 store_xts_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14240
14241+ pax_force_retaddr
14242 ret;
14243 ENDPROC(serpent_xts_enc_8way_avx)
14244
14245@@ -778,5 +786,6 @@ ENTRY(serpent_xts_dec_8way_avx)
14246 /* dst <= regs xor IVs(in dst) */
14247 store_xts_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
14248
14249+ pax_force_retaddr
14250 ret;
14251 ENDPROC(serpent_xts_dec_8way_avx)
14252diff --git a/arch/x86/crypto/serpent-avx2-asm_64.S b/arch/x86/crypto/serpent-avx2-asm_64.S
14253index b222085..abd483c 100644
14254--- a/arch/x86/crypto/serpent-avx2-asm_64.S
14255+++ b/arch/x86/crypto/serpent-avx2-asm_64.S
14256@@ -15,6 +15,7 @@
14257 */
14258
14259 #include <linux/linkage.h>
14260+#include <asm/alternative-asm.h>
14261 #include "glue_helper-asm-avx2.S"
14262
14263 .file "serpent-avx2-asm_64.S"
14264@@ -610,6 +611,7 @@ __serpent_enc_blk16:
14265 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
14266 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
14267
14268+ pax_force_retaddr
14269 ret;
14270 ENDPROC(__serpent_enc_blk16)
14271
14272@@ -664,6 +666,7 @@ __serpent_dec_blk16:
14273 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
14274 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
14275
14276+ pax_force_retaddr
14277 ret;
14278 ENDPROC(__serpent_dec_blk16)
14279
14280@@ -684,6 +687,7 @@ ENTRY(serpent_ecb_enc_16way)
14281
14282 vzeroupper;
14283
14284+ pax_force_retaddr
14285 ret;
14286 ENDPROC(serpent_ecb_enc_16way)
14287
14288@@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_16way)
14289
14290 vzeroupper;
14291
14292+ pax_force_retaddr
14293 ret;
14294 ENDPROC(serpent_ecb_dec_16way)
14295
14296@@ -725,6 +730,7 @@ ENTRY(serpent_cbc_dec_16way)
14297
14298 vzeroupper;
14299
14300+ pax_force_retaddr
14301 ret;
14302 ENDPROC(serpent_cbc_dec_16way)
14303
14304@@ -748,6 +754,7 @@ ENTRY(serpent_ctr_16way)
14305
14306 vzeroupper;
14307
14308+ pax_force_retaddr
14309 ret;
14310 ENDPROC(serpent_ctr_16way)
14311
14312@@ -772,6 +779,7 @@ ENTRY(serpent_xts_enc_16way)
14313
14314 vzeroupper;
14315
14316+ pax_force_retaddr
14317 ret;
14318 ENDPROC(serpent_xts_enc_16way)
14319
14320@@ -796,5 +804,6 @@ ENTRY(serpent_xts_dec_16way)
14321
14322 vzeroupper;
14323
14324+ pax_force_retaddr
14325 ret;
14326 ENDPROC(serpent_xts_dec_16way)
14327diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
14328index acc066c..1559cc4 100644
14329--- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
14330+++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
14331@@ -25,6 +25,7 @@
14332 */
14333
14334 #include <linux/linkage.h>
14335+#include <asm/alternative-asm.h>
14336
14337 .file "serpent-sse2-x86_64-asm_64.S"
14338 .text
14339@@ -690,12 +691,14 @@ ENTRY(__serpent_enc_blk_8way)
14340 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
14341 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
14342
14343+ pax_force_retaddr
14344 ret;
14345
14346 .L__enc_xor8:
14347 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
14348 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
14349
14350+ pax_force_retaddr
14351 ret;
14352 ENDPROC(__serpent_enc_blk_8way)
14353
14354@@ -750,5 +753,6 @@ ENTRY(serpent_dec_blk_8way)
14355 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
14356 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
14357
14358+ pax_force_retaddr
14359 ret;
14360 ENDPROC(serpent_dec_blk_8way)
14361diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
14362index a410950..9dfe7ad 100644
14363--- a/arch/x86/crypto/sha1_ssse3_asm.S
14364+++ b/arch/x86/crypto/sha1_ssse3_asm.S
14365@@ -29,6 +29,7 @@
14366 */
14367
14368 #include <linux/linkage.h>
14369+#include <asm/alternative-asm.h>
14370
14371 #define CTX %rdi // arg1
14372 #define BUF %rsi // arg2
14373@@ -75,9 +76,9 @@
14374
14375 push %rbx
14376 push %rbp
14377- push %r12
14378+ push %r14
14379
14380- mov %rsp, %r12
14381+ mov %rsp, %r14
14382 sub $64, %rsp # allocate workspace
14383 and $~15, %rsp # align stack
14384
14385@@ -99,11 +100,12 @@
14386 xor %rax, %rax
14387 rep stosq
14388
14389- mov %r12, %rsp # deallocate workspace
14390+ mov %r14, %rsp # deallocate workspace
14391
14392- pop %r12
14393+ pop %r14
14394 pop %rbp
14395 pop %rbx
14396+ pax_force_retaddr
14397 ret
14398
14399 ENDPROC(\name)
14400diff --git a/arch/x86/crypto/sha256-avx-asm.S b/arch/x86/crypto/sha256-avx-asm.S
14401index 92b3b5d..0dc1dcb 100644
14402--- a/arch/x86/crypto/sha256-avx-asm.S
14403+++ b/arch/x86/crypto/sha256-avx-asm.S
14404@@ -49,6 +49,7 @@
14405
14406 #ifdef CONFIG_AS_AVX
14407 #include <linux/linkage.h>
14408+#include <asm/alternative-asm.h>
14409
14410 ## assume buffers not aligned
14411 #define VMOVDQ vmovdqu
14412@@ -460,6 +461,7 @@ done_hash:
14413 popq %r13
14414 popq %rbp
14415 popq %rbx
14416+ pax_force_retaddr
14417 ret
14418 ENDPROC(sha256_transform_avx)
14419
14420diff --git a/arch/x86/crypto/sha256-avx2-asm.S b/arch/x86/crypto/sha256-avx2-asm.S
14421index 570ec5e..cf2b625 100644
14422--- a/arch/x86/crypto/sha256-avx2-asm.S
14423+++ b/arch/x86/crypto/sha256-avx2-asm.S
14424@@ -50,6 +50,7 @@
14425
14426 #ifdef CONFIG_AS_AVX2
14427 #include <linux/linkage.h>
14428+#include <asm/alternative-asm.h>
14429
14430 ## assume buffers not aligned
14431 #define VMOVDQ vmovdqu
14432@@ -720,6 +721,7 @@ done_hash:
14433 popq %r12
14434 popq %rbp
14435 popq %rbx
14436+ pax_force_retaddr
14437 ret
14438 ENDPROC(sha256_transform_rorx)
14439
14440diff --git a/arch/x86/crypto/sha256-ssse3-asm.S b/arch/x86/crypto/sha256-ssse3-asm.S
14441index 2cedc44..5144899 100644
14442--- a/arch/x86/crypto/sha256-ssse3-asm.S
14443+++ b/arch/x86/crypto/sha256-ssse3-asm.S
14444@@ -47,6 +47,7 @@
14445 ########################################################################
14446
14447 #include <linux/linkage.h>
14448+#include <asm/alternative-asm.h>
14449
14450 ## assume buffers not aligned
14451 #define MOVDQ movdqu
14452@@ -471,6 +472,7 @@ done_hash:
14453 popq %rbp
14454 popq %rbx
14455
14456+ pax_force_retaddr
14457 ret
14458 ENDPROC(sha256_transform_ssse3)
14459
14460diff --git a/arch/x86/crypto/sha512-avx-asm.S b/arch/x86/crypto/sha512-avx-asm.S
14461index 565274d..af6bc08 100644
14462--- a/arch/x86/crypto/sha512-avx-asm.S
14463+++ b/arch/x86/crypto/sha512-avx-asm.S
14464@@ -49,6 +49,7 @@
14465
14466 #ifdef CONFIG_AS_AVX
14467 #include <linux/linkage.h>
14468+#include <asm/alternative-asm.h>
14469
14470 .text
14471
14472@@ -364,6 +365,7 @@ updateblock:
14473 mov frame_RSPSAVE(%rsp), %rsp
14474
14475 nowork:
14476+ pax_force_retaddr
14477 ret
14478 ENDPROC(sha512_transform_avx)
14479
14480diff --git a/arch/x86/crypto/sha512-avx2-asm.S b/arch/x86/crypto/sha512-avx2-asm.S
14481index 1f20b35..f25c8c1 100644
14482--- a/arch/x86/crypto/sha512-avx2-asm.S
14483+++ b/arch/x86/crypto/sha512-avx2-asm.S
14484@@ -51,6 +51,7 @@
14485
14486 #ifdef CONFIG_AS_AVX2
14487 #include <linux/linkage.h>
14488+#include <asm/alternative-asm.h>
14489
14490 .text
14491
14492@@ -678,6 +679,7 @@ done_hash:
14493
14494 # Restore Stack Pointer
14495 mov frame_RSPSAVE(%rsp), %rsp
14496+ pax_force_retaddr
14497 ret
14498 ENDPROC(sha512_transform_rorx)
14499
14500diff --git a/arch/x86/crypto/sha512-ssse3-asm.S b/arch/x86/crypto/sha512-ssse3-asm.S
14501index e610e29..ffcb5ed 100644
14502--- a/arch/x86/crypto/sha512-ssse3-asm.S
14503+++ b/arch/x86/crypto/sha512-ssse3-asm.S
14504@@ -48,6 +48,7 @@
14505 ########################################################################
14506
14507 #include <linux/linkage.h>
14508+#include <asm/alternative-asm.h>
14509
14510 .text
14511
14512@@ -363,6 +364,7 @@ updateblock:
14513 mov frame_RSPSAVE(%rsp), %rsp
14514
14515 nowork:
14516+ pax_force_retaddr
14517 ret
14518 ENDPROC(sha512_transform_ssse3)
14519
14520diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
14521index 0505813..b067311 100644
14522--- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
14523+++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
14524@@ -24,6 +24,7 @@
14525 */
14526
14527 #include <linux/linkage.h>
14528+#include <asm/alternative-asm.h>
14529 #include "glue_helper-asm-avx.S"
14530
14531 .file "twofish-avx-x86_64-asm_64.S"
14532@@ -284,6 +285,7 @@ __twofish_enc_blk8:
14533 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
14534 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
14535
14536+ pax_force_retaddr
14537 ret;
14538 ENDPROC(__twofish_enc_blk8)
14539
14540@@ -324,6 +326,7 @@ __twofish_dec_blk8:
14541 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
14542 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
14543
14544+ pax_force_retaddr
14545 ret;
14546 ENDPROC(__twofish_dec_blk8)
14547
14548@@ -342,6 +345,7 @@ ENTRY(twofish_ecb_enc_8way)
14549
14550 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
14551
14552+ pax_force_retaddr
14553 ret;
14554 ENDPROC(twofish_ecb_enc_8way)
14555
14556@@ -360,6 +364,7 @@ ENTRY(twofish_ecb_dec_8way)
14557
14558 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14559
14560+ pax_force_retaddr
14561 ret;
14562 ENDPROC(twofish_ecb_dec_8way)
14563
14564@@ -370,19 +375,20 @@ ENTRY(twofish_cbc_dec_8way)
14565 * %rdx: src
14566 */
14567
14568- pushq %r12;
14569+ pushq %r14;
14570
14571 movq %rsi, %r11;
14572- movq %rdx, %r12;
14573+ movq %rdx, %r14;
14574
14575 load_8way(%rdx, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
14576
14577 call __twofish_dec_blk8;
14578
14579- store_cbc_8way(%r12, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14580+ store_cbc_8way(%r14, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14581
14582- popq %r12;
14583+ popq %r14;
14584
14585+ pax_force_retaddr
14586 ret;
14587 ENDPROC(twofish_cbc_dec_8way)
14588
14589@@ -394,20 +400,21 @@ ENTRY(twofish_ctr_8way)
14590 * %rcx: iv (little endian, 128bit)
14591 */
14592
14593- pushq %r12;
14594+ pushq %r14;
14595
14596 movq %rsi, %r11;
14597- movq %rdx, %r12;
14598+ movq %rdx, %r14;
14599
14600 load_ctr_8way(%rcx, .Lbswap128_mask, RA1, RB1, RC1, RD1, RA2, RB2, RC2,
14601 RD2, RX0, RX1, RY0);
14602
14603 call __twofish_enc_blk8;
14604
14605- store_ctr_8way(%r12, %r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
14606+ store_ctr_8way(%r14, %r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
14607
14608- popq %r12;
14609+ popq %r14;
14610
14611+ pax_force_retaddr
14612 ret;
14613 ENDPROC(twofish_ctr_8way)
14614
14615@@ -430,6 +437,7 @@ ENTRY(twofish_xts_enc_8way)
14616 /* dst <= regs xor IVs(in dst) */
14617 store_xts_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
14618
14619+ pax_force_retaddr
14620 ret;
14621 ENDPROC(twofish_xts_enc_8way)
14622
14623@@ -452,5 +460,6 @@ ENTRY(twofish_xts_dec_8way)
14624 /* dst <= regs xor IVs(in dst) */
14625 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
14626
14627+ pax_force_retaddr
14628 ret;
14629 ENDPROC(twofish_xts_dec_8way)
14630diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
14631index 1c3b7ce..02f578d 100644
14632--- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
14633+++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
14634@@ -21,6 +21,7 @@
14635 */
14636
14637 #include <linux/linkage.h>
14638+#include <asm/alternative-asm.h>
14639
14640 .file "twofish-x86_64-asm-3way.S"
14641 .text
14642@@ -258,6 +259,7 @@ ENTRY(__twofish_enc_blk_3way)
14643 popq %r13;
14644 popq %r14;
14645 popq %r15;
14646+ pax_force_retaddr
14647 ret;
14648
14649 .L__enc_xor3:
14650@@ -269,6 +271,7 @@ ENTRY(__twofish_enc_blk_3way)
14651 popq %r13;
14652 popq %r14;
14653 popq %r15;
14654+ pax_force_retaddr
14655 ret;
14656 ENDPROC(__twofish_enc_blk_3way)
14657
14658@@ -308,5 +311,6 @@ ENTRY(twofish_dec_blk_3way)
14659 popq %r13;
14660 popq %r14;
14661 popq %r15;
14662+ pax_force_retaddr
14663 ret;
14664 ENDPROC(twofish_dec_blk_3way)
14665diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
14666index a350c99..c1bac24 100644
14667--- a/arch/x86/crypto/twofish-x86_64-asm_64.S
14668+++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
14669@@ -22,6 +22,7 @@
14670
14671 #include <linux/linkage.h>
14672 #include <asm/asm-offsets.h>
14673+#include <asm/alternative-asm.h>
14674
14675 #define a_offset 0
14676 #define b_offset 4
14677@@ -265,6 +266,7 @@ ENTRY(twofish_enc_blk)
14678
14679 popq R1
14680 movl $1,%eax
14681+ pax_force_retaddr
14682 ret
14683 ENDPROC(twofish_enc_blk)
14684
14685@@ -317,5 +319,6 @@ ENTRY(twofish_dec_blk)
14686
14687 popq R1
14688 movl $1,%eax
14689+ pax_force_retaddr
14690 ret
14691 ENDPROC(twofish_dec_blk)
14692diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
14693index ae6aad1..719d6d9 100644
14694--- a/arch/x86/ia32/ia32_aout.c
14695+++ b/arch/x86/ia32/ia32_aout.c
14696@@ -153,6 +153,8 @@ static int aout_core_dump(struct coredump_params *cprm)
14697 unsigned long dump_start, dump_size;
14698 struct user32 dump;
14699
14700+ memset(&dump, 0, sizeof(dump));
14701+
14702 fs = get_fs();
14703 set_fs(KERNEL_DS);
14704 has_dumped = 1;
14705diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
14706index c81d35e6..3500144 100644
14707--- a/arch/x86/ia32/ia32_signal.c
14708+++ b/arch/x86/ia32/ia32_signal.c
14709@@ -216,7 +216,7 @@ asmlinkage long sys32_sigreturn(void)
14710 if (__get_user(set.sig[0], &frame->sc.oldmask)
14711 || (_COMPAT_NSIG_WORDS > 1
14712 && __copy_from_user((((char *) &set.sig) + 4),
14713- &frame->extramask,
14714+ frame->extramask,
14715 sizeof(frame->extramask))))
14716 goto badframe;
14717
14718@@ -335,7 +335,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
14719 sp -= frame_size;
14720 /* Align the stack pointer according to the i386 ABI,
14721 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
14722- sp = ((sp + 4) & -16ul) - 4;
14723+ sp = ((sp - 12) & -16ul) - 4;
14724 return (void __user *) sp;
14725 }
14726
14727@@ -380,10 +380,10 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
14728 } else {
14729 /* Return stub is in 32bit vsyscall page */
14730 if (current->mm->context.vdso)
14731- restorer = current->mm->context.vdso +
14732- selected_vdso32->sym___kernel_sigreturn;
14733+ restorer = (void __force_user *)(current->mm->context.vdso +
14734+ selected_vdso32->sym___kernel_sigreturn);
14735 else
14736- restorer = &frame->retcode;
14737+ restorer = frame->retcode;
14738 }
14739
14740 put_user_try {
14741@@ -393,7 +393,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
14742 * These are actually not used anymore, but left because some
14743 * gdb versions depend on them as a marker.
14744 */
14745- put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
14746+ put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
14747 } put_user_catch(err);
14748
14749 if (err)
14750@@ -435,7 +435,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
14751 0xb8,
14752 __NR_ia32_rt_sigreturn,
14753 0x80cd,
14754- 0,
14755+ 0
14756 };
14757
14758 frame = get_sigframe(ksig, regs, sizeof(*frame), &fpstate);
14759@@ -458,16 +458,19 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
14760
14761 if (ksig->ka.sa.sa_flags & SA_RESTORER)
14762 restorer = ksig->ka.sa.sa_restorer;
14763+ else if (current->mm->context.vdso)
14764+ /* Return stub is in 32bit vsyscall page */
14765+ restorer = (void __force_user *)(current->mm->context.vdso +
14766+ selected_vdso32->sym___kernel_rt_sigreturn);
14767 else
14768- restorer = current->mm->context.vdso +
14769- selected_vdso32->sym___kernel_rt_sigreturn;
14770+ restorer = frame->retcode;
14771 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
14772
14773 /*
14774 * Not actually used anymore, but left because some gdb
14775 * versions need it.
14776 */
14777- put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
14778+ put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
14779 } put_user_catch(err);
14780
14781 err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
14782diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
14783index 72bf268..127572a 100644
14784--- a/arch/x86/ia32/ia32entry.S
14785+++ b/arch/x86/ia32/ia32entry.S
14786@@ -15,8 +15,10 @@
14787 #include <asm/irqflags.h>
14788 #include <asm/asm.h>
14789 #include <asm/smap.h>
14790+#include <asm/pgtable.h>
14791 #include <linux/linkage.h>
14792 #include <linux/err.h>
14793+#include <asm/alternative-asm.h>
14794
14795 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
14796 #include <linux/elf-em.h>
14797@@ -85,6 +87,32 @@ ENTRY(native_irq_enable_sysexit)
14798 ENDPROC(native_irq_enable_sysexit)
14799 #endif
14800
14801+ .macro pax_enter_kernel_user
14802+ pax_set_fptr_mask
14803+#ifdef CONFIG_PAX_MEMORY_UDEREF
14804+ call pax_enter_kernel_user
14805+#endif
14806+ .endm
14807+
14808+ .macro pax_exit_kernel_user
14809+#ifdef CONFIG_PAX_MEMORY_UDEREF
14810+ call pax_exit_kernel_user
14811+#endif
14812+#ifdef CONFIG_PAX_RANDKSTACK
14813+ pushq %rax
14814+ pushq %r11
14815+ call pax_randomize_kstack
14816+ popq %r11
14817+ popq %rax
14818+#endif
14819+ .endm
14820+
14821+ .macro pax_erase_kstack
14822+#ifdef CONFIG_PAX_MEMORY_STACKLEAK
14823+ call pax_erase_kstack
14824+#endif
14825+ .endm
14826+
14827 /*
14828 * 32bit SYSENTER instruction entry.
14829 *
14830@@ -119,23 +147,24 @@ ENTRY(ia32_sysenter_target)
14831 * it is too small to ever cause noticeable irq latency.
14832 */
14833 SWAPGS_UNSAFE_STACK
14834- movq PER_CPU_VAR(cpu_tss + TSS_sp0), %rsp
14835- ENABLE_INTERRUPTS(CLBR_NONE)
14836+ movq PER_CPU_VAR(kernel_stack), %rsp
14837
14838 /* Zero-extending 32-bit regs, do not remove */
14839 movl %ebp, %ebp
14840 movl %eax, %eax
14841
14842- movl ASM_THREAD_INFO(TI_sysenter_return, %rsp, 0), %r10d
14843- CFI_REGISTER rip,r10
14844+ GET_THREAD_INFO(%r11)
14845+ movl TI_sysenter_return(%r11), %r11d
14846+ CFI_REGISTER rip,r11
14847
14848 /* Construct struct pt_regs on stack */
14849 pushq_cfi $__USER32_DS /* pt_regs->ss */
14850 pushq_cfi %rbp /* pt_regs->sp */
14851 CFI_REL_OFFSET rsp,0
14852 pushfq_cfi /* pt_regs->flags */
14853+ orl $X86_EFLAGS_IF,(%rsp)
14854 pushq_cfi $__USER32_CS /* pt_regs->cs */
14855- pushq_cfi %r10 /* pt_regs->ip = thread_info->sysenter_return */
14856+ pushq_cfi %r11 /* pt_regs->ip = thread_info->sysenter_return */
14857 CFI_REL_OFFSET rip,0
14858 pushq_cfi_reg rax /* pt_regs->orig_ax */
14859 pushq_cfi_reg rdi /* pt_regs->di */
14860@@ -147,15 +176,37 @@ ENTRY(ia32_sysenter_target)
14861 sub $(10*8),%rsp /* pt_regs->r8-11,bp,bx,r12-15 not saved */
14862 CFI_ADJUST_CFA_OFFSET 10*8
14863
14864+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
14865+ movq_cfi r12, R12
14866+#endif
14867+
14868+ pax_enter_kernel_user
14869+
14870+#ifdef CONFIG_PAX_RANDKSTACK
14871+ pax_erase_kstack
14872+#endif
14873+
14874+ ENABLE_INTERRUPTS(CLBR_NONE)
14875+
14876 /*
14877 * no need to do an access_ok check here because rbp has been
14878 * 32bit zero extended
14879 */
14880+
14881+#ifdef CONFIG_PAX_MEMORY_UDEREF
14882+ addq pax_user_shadow_base,%rbp
14883+ ASM_PAX_OPEN_USERLAND
14884+#endif
14885+
14886 ASM_STAC
14887 1: movl (%rbp),%ebp
14888 _ASM_EXTABLE(1b,ia32_badarg)
14889 ASM_CLAC
14890
14891+#ifdef CONFIG_PAX_MEMORY_UDEREF
14892+ ASM_PAX_CLOSE_USERLAND
14893+#endif
14894+
14895 /*
14896 * Sysenter doesn't filter flags, so we need to clear NT
14897 * ourselves. To save a few cycles, we can check whether
14898@@ -165,8 +216,9 @@ ENTRY(ia32_sysenter_target)
14899 jnz sysenter_fix_flags
14900 sysenter_flags_fixed:
14901
14902- orl $TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
14903- testl $_TIF_WORK_SYSCALL_ENTRY, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
14904+ GET_THREAD_INFO(%r11)
14905+ orl $TS_COMPAT,TI_status(%r11)
14906+ testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
14907 CFI_REMEMBER_STATE
14908 jnz sysenter_tracesys
14909 cmpq $(IA32_NR_syscalls-1),%rax
14910@@ -181,9 +233,10 @@ sysenter_do_call:
14911 sysenter_dispatch:
14912 call *ia32_sys_call_table(,%rax,8)
14913 movq %rax,RAX(%rsp)
14914+ GET_THREAD_INFO(%r11)
14915 DISABLE_INTERRUPTS(CLBR_NONE)
14916 TRACE_IRQS_OFF
14917- testl $_TIF_ALLWORK_MASK, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
14918+ testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
14919 jnz sysexit_audit
14920 sysexit_from_sys_call:
14921 /*
14922@@ -196,7 +249,9 @@ sysexit_from_sys_call:
14923 * This code path is still called 'sysexit' because it pairs
14924 * with 'sysenter' and it uses the SYSENTER calling convention.
14925 */
14926- andl $~TS_COMPAT,ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
14927+ pax_exit_kernel_user
14928+ pax_erase_kstack
14929+ andl $~TS_COMPAT,TI_status(%r11)
14930 movl RIP(%rsp),%ecx /* User %eip */
14931 CFI_REGISTER rip,rcx
14932 RESTORE_RSI_RDI
14933@@ -247,6 +302,9 @@ sysexit_from_sys_call:
14934 movl %ebx,%esi /* 2nd arg: 1st syscall arg */
14935 movl %eax,%edi /* 1st arg: syscall number */
14936 call __audit_syscall_entry
14937+
14938+ pax_erase_kstack
14939+
14940 movl RAX(%rsp),%eax /* reload syscall number */
14941 cmpq $(IA32_NR_syscalls-1),%rax
14942 ja ia32_badsys
14943@@ -258,7 +316,7 @@ sysexit_from_sys_call:
14944 .endm
14945
14946 .macro auditsys_exit exit
14947- testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT), ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
14948+ testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
14949 jnz ia32_ret_from_sys_call
14950 TRACE_IRQS_ON
14951 ENABLE_INTERRUPTS(CLBR_NONE)
14952@@ -269,11 +327,12 @@ sysexit_from_sys_call:
14953 1: setbe %al /* 1 if error, 0 if not */
14954 movzbl %al,%edi /* zero-extend that into %edi */
14955 call __audit_syscall_exit
14956+ GET_THREAD_INFO(%r11)
14957 movq RAX(%rsp),%rax /* reload syscall return value */
14958 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
14959 DISABLE_INTERRUPTS(CLBR_NONE)
14960 TRACE_IRQS_OFF
14961- testl %edi, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
14962+ testl %edi,TI_flags(%r11)
14963 jz \exit
14964 CLEAR_RREGS
14965 jmp int_with_check
14966@@ -295,7 +354,7 @@ sysenter_fix_flags:
14967
14968 sysenter_tracesys:
14969 #ifdef CONFIG_AUDITSYSCALL
14970- testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT), ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
14971+ testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
14972 jz sysenter_auditsys
14973 #endif
14974 SAVE_EXTRA_REGS
14975@@ -307,6 +366,9 @@ sysenter_tracesys:
14976 RESTORE_EXTRA_REGS
14977 cmpq $(IA32_NR_syscalls-1),%rax
14978 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
14979+
14980+ pax_erase_kstack
14981+
14982 jmp sysenter_do_call
14983 CFI_ENDPROC
14984 ENDPROC(ia32_sysenter_target)
14985@@ -357,7 +419,6 @@ ENTRY(ia32_cstar_target)
14986 movl %esp,%r8d
14987 CFI_REGISTER rsp,r8
14988 movq PER_CPU_VAR(kernel_stack),%rsp
14989- ENABLE_INTERRUPTS(CLBR_NONE)
14990
14991 /* Zero-extending 32-bit regs, do not remove */
14992 movl %eax,%eax
14993@@ -380,16 +441,41 @@ ENTRY(ia32_cstar_target)
14994 sub $(10*8),%rsp /* pt_regs->r8-11,bp,bx,r12-15 not saved */
14995 CFI_ADJUST_CFA_OFFSET 10*8
14996
14997+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
14998+ movq_cfi r12, R12
14999+#endif
15000+
15001+ pax_enter_kernel_user
15002+
15003+#ifdef CONFIG_PAX_RANDKSTACK
15004+ pax_erase_kstack
15005+#endif
15006+
15007+ ENABLE_INTERRUPTS(CLBR_NONE)
15008+
15009 /*
15010 * no need to do an access_ok check here because r8 has been
15011 * 32bit zero extended
15012 */
15013+
15014+#ifdef CONFIG_PAX_MEMORY_UDEREF
15015+ ASM_PAX_OPEN_USERLAND
15016+ movq pax_user_shadow_base,%r8
15017+ addq RSP(%rsp),%r8
15018+#endif
15019+
15020 ASM_STAC
15021 1: movl (%r8),%r9d
15022 _ASM_EXTABLE(1b,ia32_badarg)
15023 ASM_CLAC
15024- orl $TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
15025- testl $_TIF_WORK_SYSCALL_ENTRY, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
15026+
15027+#ifdef CONFIG_PAX_MEMORY_UDEREF
15028+ ASM_PAX_CLOSE_USERLAND
15029+#endif
15030+
15031+ GET_THREAD_INFO(%r11)
15032+ orl $TS_COMPAT,TI_status(%r11)
15033+ testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
15034 CFI_REMEMBER_STATE
15035 jnz cstar_tracesys
15036 cmpq $IA32_NR_syscalls-1,%rax
15037@@ -404,12 +490,15 @@ cstar_do_call:
15038 cstar_dispatch:
15039 call *ia32_sys_call_table(,%rax,8)
15040 movq %rax,RAX(%rsp)
15041+ GET_THREAD_INFO(%r11)
15042 DISABLE_INTERRUPTS(CLBR_NONE)
15043 TRACE_IRQS_OFF
15044- testl $_TIF_ALLWORK_MASK, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
15045+ testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
15046 jnz sysretl_audit
15047 sysretl_from_sys_call:
15048- andl $~TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
15049+ pax_exit_kernel_user
15050+ pax_erase_kstack
15051+ andl $~TS_COMPAT,TI_status(%r11)
15052 RESTORE_RSI_RDI_RDX
15053 movl RIP(%rsp),%ecx
15054 CFI_REGISTER rip,rcx
15055@@ -451,7 +540,7 @@ sysretl_audit:
15056
15057 cstar_tracesys:
15058 #ifdef CONFIG_AUDITSYSCALL
15059- testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT), ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
15060+ testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
15061 jz cstar_auditsys
15062 #endif
15063 xchgl %r9d,%ebp
15064@@ -465,11 +554,19 @@ cstar_tracesys:
15065 xchgl %ebp,%r9d
15066 cmpq $(IA32_NR_syscalls-1),%rax
15067 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
15068+
15069+ pax_erase_kstack
15070+
15071 jmp cstar_do_call
15072 END(ia32_cstar_target)
15073
15074 ia32_badarg:
15075 ASM_CLAC
15076+
15077+#ifdef CONFIG_PAX_MEMORY_UDEREF
15078+ ASM_PAX_CLOSE_USERLAND
15079+#endif
15080+
15081 movq $-EFAULT,%rax
15082 jmp ia32_sysret
15083 CFI_ENDPROC
15084@@ -505,14 +602,8 @@ ENTRY(ia32_syscall)
15085 /*CFI_REL_OFFSET cs,1*8 */
15086 CFI_REL_OFFSET rip,0*8
15087
15088- /*
15089- * Interrupts are off on entry.
15090- * We do not frame this tiny irq-off block with TRACE_IRQS_OFF/ON,
15091- * it is too small to ever cause noticeable irq latency.
15092- */
15093 PARAVIRT_ADJUST_EXCEPTION_FRAME
15094 SWAPGS
15095- ENABLE_INTERRUPTS(CLBR_NONE)
15096
15097 /* Zero-extending 32-bit regs, do not remove */
15098 movl %eax,%eax
15099@@ -528,8 +619,26 @@ ENTRY(ia32_syscall)
15100 sub $(10*8),%rsp /* pt_regs->r8-11,bp,bx,r12-15 not saved */
15101 CFI_ADJUST_CFA_OFFSET 10*8
15102
15103- orl $TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
15104- testl $_TIF_WORK_SYSCALL_ENTRY, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
15105+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
15106+ movq_cfi r12, R12
15107+#endif
15108+
15109+ pax_enter_kernel_user
15110+
15111+#ifdef CONFIG_PAX_RANDKSTACK
15112+ pax_erase_kstack
15113+#endif
15114+
15115+ /*
15116+ * Interrupts are off on entry.
15117+ * We do not frame this tiny irq-off block with TRACE_IRQS_OFF/ON,
15118+ * it is too small to ever cause noticeable irq latency.
15119+ */
15120+ ENABLE_INTERRUPTS(CLBR_NONE)
15121+
15122+ GET_THREAD_INFO(%r11)
15123+ orl $TS_COMPAT,TI_status(%r11)
15124+ testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
15125 jnz ia32_tracesys
15126 cmpq $(IA32_NR_syscalls-1),%rax
15127 ja ia32_badsys
15128@@ -557,6 +666,9 @@ ia32_tracesys:
15129 RESTORE_EXTRA_REGS
15130 cmpq $(IA32_NR_syscalls-1),%rax
15131 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
15132+
15133+ pax_erase_kstack
15134+
15135 jmp ia32_do_call
15136 END(ia32_syscall)
15137
15138diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
15139index 719cd70..69d576b 100644
15140--- a/arch/x86/ia32/sys_ia32.c
15141+++ b/arch/x86/ia32/sys_ia32.c
15142@@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
15143 */
15144 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
15145 {
15146- typeof(ubuf->st_uid) uid = 0;
15147- typeof(ubuf->st_gid) gid = 0;
15148+ typeof(((struct stat64 *)0)->st_uid) uid = 0;
15149+ typeof(((struct stat64 *)0)->st_gid) gid = 0;
15150 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
15151 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
15152 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
15153diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
15154index bdf02ee..51a4656 100644
15155--- a/arch/x86/include/asm/alternative-asm.h
15156+++ b/arch/x86/include/asm/alternative-asm.h
15157@@ -18,6 +18,45 @@
15158 .endm
15159 #endif
15160
15161+#ifdef KERNEXEC_PLUGIN
15162+ .macro pax_force_retaddr_bts rip=0
15163+ btsq $63,\rip(%rsp)
15164+ .endm
15165+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
15166+ .macro pax_force_retaddr rip=0, reload=0
15167+ btsq $63,\rip(%rsp)
15168+ .endm
15169+ .macro pax_force_fptr ptr
15170+ btsq $63,\ptr
15171+ .endm
15172+ .macro pax_set_fptr_mask
15173+ .endm
15174+#endif
15175+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
15176+ .macro pax_force_retaddr rip=0, reload=0
15177+ .if \reload
15178+ pax_set_fptr_mask
15179+ .endif
15180+ orq %r12,\rip(%rsp)
15181+ .endm
15182+ .macro pax_force_fptr ptr
15183+ orq %r12,\ptr
15184+ .endm
15185+ .macro pax_set_fptr_mask
15186+ movabs $0x8000000000000000,%r12
15187+ .endm
15188+#endif
15189+#else
15190+ .macro pax_force_retaddr rip=0, reload=0
15191+ .endm
15192+ .macro pax_force_fptr ptr
15193+ .endm
15194+ .macro pax_force_retaddr_bts rip=0
15195+ .endm
15196+ .macro pax_set_fptr_mask
15197+ .endm
15198+#endif
15199+
15200 .macro altinstruction_entry orig alt feature orig_len alt_len pad_len
15201 .long \orig - .
15202 .long \alt - .
15203@@ -38,7 +77,7 @@
15204 altinstruction_entry 140b,143f,\feature,142b-140b,144f-143f,142b-141b
15205 .popsection
15206
15207- .pushsection .altinstr_replacement,"ax"
15208+ .pushsection .altinstr_replacement,"a"
15209 143:
15210 \newinstr
15211 144:
15212@@ -68,7 +107,7 @@
15213 altinstruction_entry 140b,144f,\feature2,142b-140b,145f-144f,142b-141b
15214 .popsection
15215
15216- .pushsection .altinstr_replacement,"ax"
15217+ .pushsection .altinstr_replacement,"a"
15218 143:
15219 \newinstr1
15220 144:
15221diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
15222index ba32af0..ff42fc0 100644
15223--- a/arch/x86/include/asm/alternative.h
15224+++ b/arch/x86/include/asm/alternative.h
15225@@ -130,7 +130,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
15226 ".pushsection .altinstructions,\"a\"\n" \
15227 ALTINSTR_ENTRY(feature, 1) \
15228 ".popsection\n" \
15229- ".pushsection .altinstr_replacement, \"ax\"\n" \
15230+ ".pushsection .altinstr_replacement, \"a\"\n" \
15231 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
15232 ".popsection"
15233
15234@@ -140,7 +140,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
15235 ALTINSTR_ENTRY(feature1, 1) \
15236 ALTINSTR_ENTRY(feature2, 2) \
15237 ".popsection\n" \
15238- ".pushsection .altinstr_replacement, \"ax\"\n" \
15239+ ".pushsection .altinstr_replacement, \"a\"\n" \
15240 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
15241 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
15242 ".popsection"
15243diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
15244index 976b86a..f3bc83a 100644
15245--- a/arch/x86/include/asm/apic.h
15246+++ b/arch/x86/include/asm/apic.h
15247@@ -45,7 +45,7 @@ static inline void generic_apic_probe(void)
15248
15249 #ifdef CONFIG_X86_LOCAL_APIC
15250
15251-extern unsigned int apic_verbosity;
15252+extern int apic_verbosity;
15253 extern int local_apic_timer_c2_ok;
15254
15255 extern int disable_apic;
15256diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
15257index 20370c6..a2eb9b0 100644
15258--- a/arch/x86/include/asm/apm.h
15259+++ b/arch/x86/include/asm/apm.h
15260@@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
15261 __asm__ __volatile__(APM_DO_ZERO_SEGS
15262 "pushl %%edi\n\t"
15263 "pushl %%ebp\n\t"
15264- "lcall *%%cs:apm_bios_entry\n\t"
15265+ "lcall *%%ss:apm_bios_entry\n\t"
15266 "setc %%al\n\t"
15267 "popl %%ebp\n\t"
15268 "popl %%edi\n\t"
15269@@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
15270 __asm__ __volatile__(APM_DO_ZERO_SEGS
15271 "pushl %%edi\n\t"
15272 "pushl %%ebp\n\t"
15273- "lcall *%%cs:apm_bios_entry\n\t"
15274+ "lcall *%%ss:apm_bios_entry\n\t"
15275 "setc %%bl\n\t"
15276 "popl %%ebp\n\t"
15277 "popl %%edi\n\t"
15278diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
15279index 5e5cd12..51cdc93 100644
15280--- a/arch/x86/include/asm/atomic.h
15281+++ b/arch/x86/include/asm/atomic.h
15282@@ -28,6 +28,17 @@ static inline int atomic_read(const atomic_t *v)
15283 }
15284
15285 /**
15286+ * atomic_read_unchecked - read atomic variable
15287+ * @v: pointer of type atomic_unchecked_t
15288+ *
15289+ * Atomically reads the value of @v.
15290+ */
15291+static inline int __intentional_overflow(-1) atomic_read_unchecked(const atomic_unchecked_t *v)
15292+{
15293+ return ACCESS_ONCE((v)->counter);
15294+}
15295+
15296+/**
15297 * atomic_set - set atomic variable
15298 * @v: pointer of type atomic_t
15299 * @i: required value
15300@@ -40,6 +51,18 @@ static inline void atomic_set(atomic_t *v, int i)
15301 }
15302
15303 /**
15304+ * atomic_set_unchecked - set atomic variable
15305+ * @v: pointer of type atomic_unchecked_t
15306+ * @i: required value
15307+ *
15308+ * Atomically sets the value of @v to @i.
15309+ */
15310+static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
15311+{
15312+ v->counter = i;
15313+}
15314+
15315+/**
15316 * atomic_add - add integer to atomic variable
15317 * @i: integer value to add
15318 * @v: pointer of type atomic_t
15319@@ -48,7 +71,29 @@ static inline void atomic_set(atomic_t *v, int i)
15320 */
15321 static inline void atomic_add(int i, atomic_t *v)
15322 {
15323- asm volatile(LOCK_PREFIX "addl %1,%0"
15324+ asm volatile(LOCK_PREFIX "addl %1,%0\n"
15325+
15326+#ifdef CONFIG_PAX_REFCOUNT
15327+ "jno 0f\n"
15328+ LOCK_PREFIX "subl %1,%0\n"
15329+ "int $4\n0:\n"
15330+ _ASM_EXTABLE(0b, 0b)
15331+#endif
15332+
15333+ : "+m" (v->counter)
15334+ : "ir" (i));
15335+}
15336+
15337+/**
15338+ * atomic_add_unchecked - add integer to atomic variable
15339+ * @i: integer value to add
15340+ * @v: pointer of type atomic_unchecked_t
15341+ *
15342+ * Atomically adds @i to @v.
15343+ */
15344+static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
15345+{
15346+ asm volatile(LOCK_PREFIX "addl %1,%0\n"
15347 : "+m" (v->counter)
15348 : "ir" (i));
15349 }
15350@@ -62,7 +107,29 @@ static inline void atomic_add(int i, atomic_t *v)
15351 */
15352 static inline void atomic_sub(int i, atomic_t *v)
15353 {
15354- asm volatile(LOCK_PREFIX "subl %1,%0"
15355+ asm volatile(LOCK_PREFIX "subl %1,%0\n"
15356+
15357+#ifdef CONFIG_PAX_REFCOUNT
15358+ "jno 0f\n"
15359+ LOCK_PREFIX "addl %1,%0\n"
15360+ "int $4\n0:\n"
15361+ _ASM_EXTABLE(0b, 0b)
15362+#endif
15363+
15364+ : "+m" (v->counter)
15365+ : "ir" (i));
15366+}
15367+
15368+/**
15369+ * atomic_sub_unchecked - subtract integer from atomic variable
15370+ * @i: integer value to subtract
15371+ * @v: pointer of type atomic_unchecked_t
15372+ *
15373+ * Atomically subtracts @i from @v.
15374+ */
15375+static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
15376+{
15377+ asm volatile(LOCK_PREFIX "subl %1,%0\n"
15378 : "+m" (v->counter)
15379 : "ir" (i));
15380 }
15381@@ -78,7 +145,7 @@ static inline void atomic_sub(int i, atomic_t *v)
15382 */
15383 static inline int atomic_sub_and_test(int i, atomic_t *v)
15384 {
15385- GEN_BINARY_RMWcc(LOCK_PREFIX "subl", v->counter, "er", i, "%0", "e");
15386+ GEN_BINARY_RMWcc(LOCK_PREFIX "subl", LOCK_PREFIX "addl", v->counter, "er", i, "%0", "e");
15387 }
15388
15389 /**
15390@@ -89,7 +156,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
15391 */
15392 static inline void atomic_inc(atomic_t *v)
15393 {
15394- asm volatile(LOCK_PREFIX "incl %0"
15395+ asm volatile(LOCK_PREFIX "incl %0\n"
15396+
15397+#ifdef CONFIG_PAX_REFCOUNT
15398+ "jno 0f\n"
15399+ LOCK_PREFIX "decl %0\n"
15400+ "int $4\n0:\n"
15401+ _ASM_EXTABLE(0b, 0b)
15402+#endif
15403+
15404+ : "+m" (v->counter));
15405+}
15406+
15407+/**
15408+ * atomic_inc_unchecked - increment atomic variable
15409+ * @v: pointer of type atomic_unchecked_t
15410+ *
15411+ * Atomically increments @v by 1.
15412+ */
15413+static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
15414+{
15415+ asm volatile(LOCK_PREFIX "incl %0\n"
15416 : "+m" (v->counter));
15417 }
15418
15419@@ -101,7 +188,27 @@ static inline void atomic_inc(atomic_t *v)
15420 */
15421 static inline void atomic_dec(atomic_t *v)
15422 {
15423- asm volatile(LOCK_PREFIX "decl %0"
15424+ asm volatile(LOCK_PREFIX "decl %0\n"
15425+
15426+#ifdef CONFIG_PAX_REFCOUNT
15427+ "jno 0f\n"
15428+ LOCK_PREFIX "incl %0\n"
15429+ "int $4\n0:\n"
15430+ _ASM_EXTABLE(0b, 0b)
15431+#endif
15432+
15433+ : "+m" (v->counter));
15434+}
15435+
15436+/**
15437+ * atomic_dec_unchecked - decrement atomic variable
15438+ * @v: pointer of type atomic_unchecked_t
15439+ *
15440+ * Atomically decrements @v by 1.
15441+ */
15442+static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
15443+{
15444+ asm volatile(LOCK_PREFIX "decl %0\n"
15445 : "+m" (v->counter));
15446 }
15447
15448@@ -115,7 +222,7 @@ static inline void atomic_dec(atomic_t *v)
15449 */
15450 static inline int atomic_dec_and_test(atomic_t *v)
15451 {
15452- GEN_UNARY_RMWcc(LOCK_PREFIX "decl", v->counter, "%0", "e");
15453+ GEN_UNARY_RMWcc(LOCK_PREFIX "decl", LOCK_PREFIX "incl", v->counter, "%0", "e");
15454 }
15455
15456 /**
15457@@ -128,7 +235,20 @@ static inline int atomic_dec_and_test(atomic_t *v)
15458 */
15459 static inline int atomic_inc_and_test(atomic_t *v)
15460 {
15461- GEN_UNARY_RMWcc(LOCK_PREFIX "incl", v->counter, "%0", "e");
15462+ GEN_UNARY_RMWcc(LOCK_PREFIX "incl", LOCK_PREFIX "decl", v->counter, "%0", "e");
15463+}
15464+
15465+/**
15466+ * atomic_inc_and_test_unchecked - increment and test
15467+ * @v: pointer of type atomic_unchecked_t
15468+ *
15469+ * Atomically increments @v by 1
15470+ * and returns true if the result is zero, or false for all
15471+ * other cases.
15472+ */
15473+static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
15474+{
15475+ GEN_UNARY_RMWcc_unchecked(LOCK_PREFIX "incl", v->counter, "%0", "e");
15476 }
15477
15478 /**
15479@@ -142,7 +262,7 @@ static inline int atomic_inc_and_test(atomic_t *v)
15480 */
15481 static inline int atomic_add_negative(int i, atomic_t *v)
15482 {
15483- GEN_BINARY_RMWcc(LOCK_PREFIX "addl", v->counter, "er", i, "%0", "s");
15484+ GEN_BINARY_RMWcc(LOCK_PREFIX "addl", LOCK_PREFIX "subl", v->counter, "er", i, "%0", "s");
15485 }
15486
15487 /**
15488@@ -152,7 +272,19 @@ static inline int atomic_add_negative(int i, atomic_t *v)
15489 *
15490 * Atomically adds @i to @v and returns @i + @v
15491 */
15492-static inline int atomic_add_return(int i, atomic_t *v)
15493+static inline int __intentional_overflow(-1) atomic_add_return(int i, atomic_t *v)
15494+{
15495+ return i + xadd_check_overflow(&v->counter, i);
15496+}
15497+
15498+/**
15499+ * atomic_add_return_unchecked - add integer and return
15500+ * @i: integer value to add
15501+ * @v: pointer of type atomic_unchecked_t
15502+ *
15503+ * Atomically adds @i to @v and returns @i + @v
15504+ */
15505+static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
15506 {
15507 return i + xadd(&v->counter, i);
15508 }
15509@@ -164,15 +296,24 @@ static inline int atomic_add_return(int i, atomic_t *v)
15510 *
15511 * Atomically subtracts @i from @v and returns @v - @i
15512 */
15513-static inline int atomic_sub_return(int i, atomic_t *v)
15514+static inline int __intentional_overflow(-1) atomic_sub_return(int i, atomic_t *v)
15515 {
15516 return atomic_add_return(-i, v);
15517 }
15518
15519 #define atomic_inc_return(v) (atomic_add_return(1, v))
15520+static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
15521+{
15522+ return atomic_add_return_unchecked(1, v);
15523+}
15524 #define atomic_dec_return(v) (atomic_sub_return(1, v))
15525
15526-static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
15527+static inline int __intentional_overflow(-1) atomic_cmpxchg(atomic_t *v, int old, int new)
15528+{
15529+ return cmpxchg(&v->counter, old, new);
15530+}
15531+
15532+static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
15533 {
15534 return cmpxchg(&v->counter, old, new);
15535 }
15536@@ -182,6 +323,11 @@ static inline int atomic_xchg(atomic_t *v, int new)
15537 return xchg(&v->counter, new);
15538 }
15539
15540+static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
15541+{
15542+ return xchg(&v->counter, new);
15543+}
15544+
15545 /**
15546 * __atomic_add_unless - add unless the number is already a given value
15547 * @v: pointer of type atomic_t
15548@@ -193,12 +339,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
15549 */
15550 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
15551 {
15552- int c, old;
15553+ int c, old, new;
15554 c = atomic_read(v);
15555 for (;;) {
15556- if (unlikely(c == (u)))
15557+ if (unlikely(c == u))
15558 break;
15559- old = atomic_cmpxchg((v), c, c + (a));
15560+
15561+ asm volatile("addl %2,%0\n"
15562+
15563+#ifdef CONFIG_PAX_REFCOUNT
15564+ "jno 0f\n"
15565+ "subl %2,%0\n"
15566+ "int $4\n0:\n"
15567+ _ASM_EXTABLE(0b, 0b)
15568+#endif
15569+
15570+ : "=r" (new)
15571+ : "0" (c), "ir" (a));
15572+
15573+ old = atomic_cmpxchg(v, c, new);
15574 if (likely(old == c))
15575 break;
15576 c = old;
15577@@ -207,6 +366,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
15578 }
15579
15580 /**
15581+ * atomic_inc_not_zero_hint - increment if not null
15582+ * @v: pointer of type atomic_t
15583+ * @hint: probable value of the atomic before the increment
15584+ *
15585+ * This version of atomic_inc_not_zero() gives a hint of probable
15586+ * value of the atomic. This helps processor to not read the memory
15587+ * before doing the atomic read/modify/write cycle, lowering
15588+ * number of bus transactions on some arches.
15589+ *
15590+ * Returns: 0 if increment was not done, 1 otherwise.
15591+ */
15592+#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
15593+static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
15594+{
15595+ int val, c = hint, new;
15596+
15597+ /* sanity test, should be removed by compiler if hint is a constant */
15598+ if (!hint)
15599+ return __atomic_add_unless(v, 1, 0);
15600+
15601+ do {
15602+ asm volatile("incl %0\n"
15603+
15604+#ifdef CONFIG_PAX_REFCOUNT
15605+ "jno 0f\n"
15606+ "decl %0\n"
15607+ "int $4\n0:\n"
15608+ _ASM_EXTABLE(0b, 0b)
15609+#endif
15610+
15611+ : "=r" (new)
15612+ : "0" (c));
15613+
15614+ val = atomic_cmpxchg(v, c, new);
15615+ if (val == c)
15616+ return 1;
15617+ c = val;
15618+ } while (c);
15619+
15620+ return 0;
15621+}
15622+
15623+/**
15624 * atomic_inc_short - increment of a short integer
15625 * @v: pointer to type int
15626 *
15627@@ -220,14 +422,37 @@ static inline short int atomic_inc_short(short int *v)
15628 }
15629
15630 /* These are x86-specific, used by some header files */
15631-#define atomic_clear_mask(mask, addr) \
15632- asm volatile(LOCK_PREFIX "andl %0,%1" \
15633- : : "r" (~(mask)), "m" (*(addr)) : "memory")
15634+static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
15635+{
15636+ asm volatile(LOCK_PREFIX "andl %1,%0"
15637+ : "+m" (v->counter)
15638+ : "r" (~(mask))
15639+ : "memory");
15640+}
15641
15642-#define atomic_set_mask(mask, addr) \
15643- asm volatile(LOCK_PREFIX "orl %0,%1" \
15644- : : "r" ((unsigned)(mask)), "m" (*(addr)) \
15645- : "memory")
15646+static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
15647+{
15648+ asm volatile(LOCK_PREFIX "andl %1,%0"
15649+ : "+m" (v->counter)
15650+ : "r" (~(mask))
15651+ : "memory");
15652+}
15653+
15654+static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
15655+{
15656+ asm volatile(LOCK_PREFIX "orl %1,%0"
15657+ : "+m" (v->counter)
15658+ : "r" (mask)
15659+ : "memory");
15660+}
15661+
15662+static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
15663+{
15664+ asm volatile(LOCK_PREFIX "orl %1,%0"
15665+ : "+m" (v->counter)
15666+ : "r" (mask)
15667+ : "memory");
15668+}
15669
15670 #ifdef CONFIG_X86_32
15671 # include <asm/atomic64_32.h>
15672diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
15673index b154de7..bf18a5a 100644
15674--- a/arch/x86/include/asm/atomic64_32.h
15675+++ b/arch/x86/include/asm/atomic64_32.h
15676@@ -12,6 +12,14 @@ typedef struct {
15677 u64 __aligned(8) counter;
15678 } atomic64_t;
15679
15680+#ifdef CONFIG_PAX_REFCOUNT
15681+typedef struct {
15682+ u64 __aligned(8) counter;
15683+} atomic64_unchecked_t;
15684+#else
15685+typedef atomic64_t atomic64_unchecked_t;
15686+#endif
15687+
15688 #define ATOMIC64_INIT(val) { (val) }
15689
15690 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
15691@@ -37,21 +45,31 @@ typedef struct {
15692 ATOMIC64_DECL_ONE(sym##_386)
15693
15694 ATOMIC64_DECL_ONE(add_386);
15695+ATOMIC64_DECL_ONE(add_unchecked_386);
15696 ATOMIC64_DECL_ONE(sub_386);
15697+ATOMIC64_DECL_ONE(sub_unchecked_386);
15698 ATOMIC64_DECL_ONE(inc_386);
15699+ATOMIC64_DECL_ONE(inc_unchecked_386);
15700 ATOMIC64_DECL_ONE(dec_386);
15701+ATOMIC64_DECL_ONE(dec_unchecked_386);
15702 #endif
15703
15704 #define alternative_atomic64(f, out, in...) \
15705 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
15706
15707 ATOMIC64_DECL(read);
15708+ATOMIC64_DECL(read_unchecked);
15709 ATOMIC64_DECL(set);
15710+ATOMIC64_DECL(set_unchecked);
15711 ATOMIC64_DECL(xchg);
15712 ATOMIC64_DECL(add_return);
15713+ATOMIC64_DECL(add_return_unchecked);
15714 ATOMIC64_DECL(sub_return);
15715+ATOMIC64_DECL(sub_return_unchecked);
15716 ATOMIC64_DECL(inc_return);
15717+ATOMIC64_DECL(inc_return_unchecked);
15718 ATOMIC64_DECL(dec_return);
15719+ATOMIC64_DECL(dec_return_unchecked);
15720 ATOMIC64_DECL(dec_if_positive);
15721 ATOMIC64_DECL(inc_not_zero);
15722 ATOMIC64_DECL(add_unless);
15723@@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
15724 }
15725
15726 /**
15727+ * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
15728+ * @p: pointer to type atomic64_unchecked_t
15729+ * @o: expected value
15730+ * @n: new value
15731+ *
15732+ * Atomically sets @v to @n if it was equal to @o and returns
15733+ * the old value.
15734+ */
15735+
15736+static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
15737+{
15738+ return cmpxchg64(&v->counter, o, n);
15739+}
15740+
15741+/**
15742 * atomic64_xchg - xchg atomic64 variable
15743 * @v: pointer to type atomic64_t
15744 * @n: value to assign
15745@@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
15746 }
15747
15748 /**
15749+ * atomic64_set_unchecked - set atomic64 variable
15750+ * @v: pointer to type atomic64_unchecked_t
15751+ * @n: value to assign
15752+ *
15753+ * Atomically sets the value of @v to @n.
15754+ */
15755+static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
15756+{
15757+ unsigned high = (unsigned)(i >> 32);
15758+ unsigned low = (unsigned)i;
15759+ alternative_atomic64(set, /* no output */,
15760+ "S" (v), "b" (low), "c" (high)
15761+ : "eax", "edx", "memory");
15762+}
15763+
15764+/**
15765 * atomic64_read - read atomic64 variable
15766 * @v: pointer to type atomic64_t
15767 *
15768@@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
15769 }
15770
15771 /**
15772+ * atomic64_read_unchecked - read atomic64 variable
15773+ * @v: pointer to type atomic64_unchecked_t
15774+ *
15775+ * Atomically reads the value of @v and returns it.
15776+ */
15777+static inline long long __intentional_overflow(-1) atomic64_read_unchecked(atomic64_unchecked_t *v)
15778+{
15779+ long long r;
15780+ alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
15781+ return r;
15782+ }
15783+
15784+/**
15785 * atomic64_add_return - add and return
15786 * @i: integer value to add
15787 * @v: pointer to type atomic64_t
15788@@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
15789 return i;
15790 }
15791
15792+/**
15793+ * atomic64_add_return_unchecked - add and return
15794+ * @i: integer value to add
15795+ * @v: pointer to type atomic64_unchecked_t
15796+ *
15797+ * Atomically adds @i to @v and returns @i + *@v
15798+ */
15799+static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
15800+{
15801+ alternative_atomic64(add_return_unchecked,
15802+ ASM_OUTPUT2("+A" (i), "+c" (v)),
15803+ ASM_NO_INPUT_CLOBBER("memory"));
15804+ return i;
15805+}
15806+
15807 /*
15808 * Other variants with different arithmetic operators:
15809 */
15810@@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
15811 return a;
15812 }
15813
15814+static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
15815+{
15816+ long long a;
15817+ alternative_atomic64(inc_return_unchecked, "=&A" (a),
15818+ "S" (v) : "memory", "ecx");
15819+ return a;
15820+}
15821+
15822 static inline long long atomic64_dec_return(atomic64_t *v)
15823 {
15824 long long a;
15825@@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
15826 }
15827
15828 /**
15829+ * atomic64_add_unchecked - add integer to atomic64 variable
15830+ * @i: integer value to add
15831+ * @v: pointer to type atomic64_unchecked_t
15832+ *
15833+ * Atomically adds @i to @v.
15834+ */
15835+static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
15836+{
15837+ __alternative_atomic64(add_unchecked, add_return_unchecked,
15838+ ASM_OUTPUT2("+A" (i), "+c" (v)),
15839+ ASM_NO_INPUT_CLOBBER("memory"));
15840+ return i;
15841+}
15842+
15843+/**
15844 * atomic64_sub - subtract the atomic64 variable
15845 * @i: integer value to subtract
15846 * @v: pointer to type atomic64_t
15847diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
15848index f8d273e..02f39f3 100644
15849--- a/arch/x86/include/asm/atomic64_64.h
15850+++ b/arch/x86/include/asm/atomic64_64.h
15851@@ -22,6 +22,18 @@ static inline long atomic64_read(const atomic64_t *v)
15852 }
15853
15854 /**
15855+ * atomic64_read_unchecked - read atomic64 variable
15856+ * @v: pointer of type atomic64_unchecked_t
15857+ *
15858+ * Atomically reads the value of @v.
15859+ * Doesn't imply a read memory barrier.
15860+ */
15861+static inline long __intentional_overflow(-1) atomic64_read_unchecked(const atomic64_unchecked_t *v)
15862+{
15863+ return ACCESS_ONCE((v)->counter);
15864+}
15865+
15866+/**
15867 * atomic64_set - set atomic64 variable
15868 * @v: pointer to type atomic64_t
15869 * @i: required value
15870@@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
15871 }
15872
15873 /**
15874+ * atomic64_set_unchecked - set atomic64 variable
15875+ * @v: pointer to type atomic64_unchecked_t
15876+ * @i: required value
15877+ *
15878+ * Atomically sets the value of @v to @i.
15879+ */
15880+static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
15881+{
15882+ v->counter = i;
15883+}
15884+
15885+/**
15886 * atomic64_add - add integer to atomic64 variable
15887 * @i: integer value to add
15888 * @v: pointer to type atomic64_t
15889@@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
15890 */
15891 static inline void atomic64_add(long i, atomic64_t *v)
15892 {
15893+ asm volatile(LOCK_PREFIX "addq %1,%0\n"
15894+
15895+#ifdef CONFIG_PAX_REFCOUNT
15896+ "jno 0f\n"
15897+ LOCK_PREFIX "subq %1,%0\n"
15898+ "int $4\n0:\n"
15899+ _ASM_EXTABLE(0b, 0b)
15900+#endif
15901+
15902+ : "=m" (v->counter)
15903+ : "er" (i), "m" (v->counter));
15904+}
15905+
15906+/**
15907+ * atomic64_add_unchecked - add integer to atomic64 variable
15908+ * @i: integer value to add
15909+ * @v: pointer to type atomic64_unchecked_t
15910+ *
15911+ * Atomically adds @i to @v.
15912+ */
15913+static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
15914+{
15915 asm volatile(LOCK_PREFIX "addq %1,%0"
15916 : "=m" (v->counter)
15917 : "er" (i), "m" (v->counter));
15918@@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
15919 */
15920 static inline void atomic64_sub(long i, atomic64_t *v)
15921 {
15922- asm volatile(LOCK_PREFIX "subq %1,%0"
15923+ asm volatile(LOCK_PREFIX "subq %1,%0\n"
15924+
15925+#ifdef CONFIG_PAX_REFCOUNT
15926+ "jno 0f\n"
15927+ LOCK_PREFIX "addq %1,%0\n"
15928+ "int $4\n0:\n"
15929+ _ASM_EXTABLE(0b, 0b)
15930+#endif
15931+
15932+ : "=m" (v->counter)
15933+ : "er" (i), "m" (v->counter));
15934+}
15935+
15936+/**
15937+ * atomic64_sub_unchecked - subtract the atomic64 variable
15938+ * @i: integer value to subtract
15939+ * @v: pointer to type atomic64_unchecked_t
15940+ *
15941+ * Atomically subtracts @i from @v.
15942+ */
15943+static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
15944+{
15945+ asm volatile(LOCK_PREFIX "subq %1,%0\n"
15946 : "=m" (v->counter)
15947 : "er" (i), "m" (v->counter));
15948 }
15949@@ -72,7 +140,7 @@ static inline void atomic64_sub(long i, atomic64_t *v)
15950 */
15951 static inline int atomic64_sub_and_test(long i, atomic64_t *v)
15952 {
15953- GEN_BINARY_RMWcc(LOCK_PREFIX "subq", v->counter, "er", i, "%0", "e");
15954+ GEN_BINARY_RMWcc(LOCK_PREFIX "subq", LOCK_PREFIX "addq", v->counter, "er", i, "%0", "e");
15955 }
15956
15957 /**
15958@@ -83,6 +151,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
15959 */
15960 static inline void atomic64_inc(atomic64_t *v)
15961 {
15962+ asm volatile(LOCK_PREFIX "incq %0\n"
15963+
15964+#ifdef CONFIG_PAX_REFCOUNT
15965+ "jno 0f\n"
15966+ LOCK_PREFIX "decq %0\n"
15967+ "int $4\n0:\n"
15968+ _ASM_EXTABLE(0b, 0b)
15969+#endif
15970+
15971+ : "=m" (v->counter)
15972+ : "m" (v->counter));
15973+}
15974+
15975+/**
15976+ * atomic64_inc_unchecked - increment atomic64 variable
15977+ * @v: pointer to type atomic64_unchecked_t
15978+ *
15979+ * Atomically increments @v by 1.
15980+ */
15981+static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
15982+{
15983 asm volatile(LOCK_PREFIX "incq %0"
15984 : "=m" (v->counter)
15985 : "m" (v->counter));
15986@@ -96,7 +185,28 @@ static inline void atomic64_inc(atomic64_t *v)
15987 */
15988 static inline void atomic64_dec(atomic64_t *v)
15989 {
15990- asm volatile(LOCK_PREFIX "decq %0"
15991+ asm volatile(LOCK_PREFIX "decq %0\n"
15992+
15993+#ifdef CONFIG_PAX_REFCOUNT
15994+ "jno 0f\n"
15995+ LOCK_PREFIX "incq %0\n"
15996+ "int $4\n0:\n"
15997+ _ASM_EXTABLE(0b, 0b)
15998+#endif
15999+
16000+ : "=m" (v->counter)
16001+ : "m" (v->counter));
16002+}
16003+
16004+/**
16005+ * atomic64_dec_unchecked - decrement atomic64 variable
16006+ * @v: pointer to type atomic64_t
16007+ *
16008+ * Atomically decrements @v by 1.
16009+ */
16010+static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
16011+{
16012+ asm volatile(LOCK_PREFIX "decq %0\n"
16013 : "=m" (v->counter)
16014 : "m" (v->counter));
16015 }
16016@@ -111,7 +221,7 @@ static inline void atomic64_dec(atomic64_t *v)
16017 */
16018 static inline int atomic64_dec_and_test(atomic64_t *v)
16019 {
16020- GEN_UNARY_RMWcc(LOCK_PREFIX "decq", v->counter, "%0", "e");
16021+ GEN_UNARY_RMWcc(LOCK_PREFIX "decq", LOCK_PREFIX "incq", v->counter, "%0", "e");
16022 }
16023
16024 /**
16025@@ -124,7 +234,7 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
16026 */
16027 static inline int atomic64_inc_and_test(atomic64_t *v)
16028 {
16029- GEN_UNARY_RMWcc(LOCK_PREFIX "incq", v->counter, "%0", "e");
16030+ GEN_UNARY_RMWcc(LOCK_PREFIX "incq", LOCK_PREFIX "decq", v->counter, "%0", "e");
16031 }
16032
16033 /**
16034@@ -138,7 +248,7 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
16035 */
16036 static inline int atomic64_add_negative(long i, atomic64_t *v)
16037 {
16038- GEN_BINARY_RMWcc(LOCK_PREFIX "addq", v->counter, "er", i, "%0", "s");
16039+ GEN_BINARY_RMWcc(LOCK_PREFIX "addq", LOCK_PREFIX "subq", v->counter, "er", i, "%0", "s");
16040 }
16041
16042 /**
16043@@ -150,6 +260,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
16044 */
16045 static inline long atomic64_add_return(long i, atomic64_t *v)
16046 {
16047+ return i + xadd_check_overflow(&v->counter, i);
16048+}
16049+
16050+/**
16051+ * atomic64_add_return_unchecked - add and return
16052+ * @i: integer value to add
16053+ * @v: pointer to type atomic64_unchecked_t
16054+ *
16055+ * Atomically adds @i to @v and returns @i + @v
16056+ */
16057+static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
16058+{
16059 return i + xadd(&v->counter, i);
16060 }
16061
16062@@ -159,6 +281,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
16063 }
16064
16065 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
16066+static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
16067+{
16068+ return atomic64_add_return_unchecked(1, v);
16069+}
16070 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
16071
16072 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
16073@@ -166,6 +292,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
16074 return cmpxchg(&v->counter, old, new);
16075 }
16076
16077+static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
16078+{
16079+ return cmpxchg(&v->counter, old, new);
16080+}
16081+
16082 static inline long atomic64_xchg(atomic64_t *v, long new)
16083 {
16084 return xchg(&v->counter, new);
16085@@ -182,17 +313,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
16086 */
16087 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
16088 {
16089- long c, old;
16090+ long c, old, new;
16091 c = atomic64_read(v);
16092 for (;;) {
16093- if (unlikely(c == (u)))
16094+ if (unlikely(c == u))
16095 break;
16096- old = atomic64_cmpxchg((v), c, c + (a));
16097+
16098+ asm volatile("add %2,%0\n"
16099+
16100+#ifdef CONFIG_PAX_REFCOUNT
16101+ "jno 0f\n"
16102+ "sub %2,%0\n"
16103+ "int $4\n0:\n"
16104+ _ASM_EXTABLE(0b, 0b)
16105+#endif
16106+
16107+ : "=r" (new)
16108+ : "0" (c), "ir" (a));
16109+
16110+ old = atomic64_cmpxchg(v, c, new);
16111 if (likely(old == c))
16112 break;
16113 c = old;
16114 }
16115- return c != (u);
16116+ return c != u;
16117 }
16118
16119 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
16120diff --git a/arch/x86/include/asm/barrier.h b/arch/x86/include/asm/barrier.h
16121index 959e45b..6ea9bf6 100644
16122--- a/arch/x86/include/asm/barrier.h
16123+++ b/arch/x86/include/asm/barrier.h
16124@@ -57,7 +57,7 @@
16125 do { \
16126 compiletime_assert_atomic_type(*p); \
16127 smp_mb(); \
16128- ACCESS_ONCE(*p) = (v); \
16129+ ACCESS_ONCE_RW(*p) = (v); \
16130 } while (0)
16131
16132 #define smp_load_acquire(p) \
16133@@ -74,7 +74,7 @@ do { \
16134 do { \
16135 compiletime_assert_atomic_type(*p); \
16136 barrier(); \
16137- ACCESS_ONCE(*p) = (v); \
16138+ ACCESS_ONCE_RW(*p) = (v); \
16139 } while (0)
16140
16141 #define smp_load_acquire(p) \
16142diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
16143index cfe3b95..d01b118 100644
16144--- a/arch/x86/include/asm/bitops.h
16145+++ b/arch/x86/include/asm/bitops.h
16146@@ -50,7 +50,7 @@
16147 * a mask operation on a byte.
16148 */
16149 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
16150-#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
16151+#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
16152 #define CONST_MASK(nr) (1 << ((nr) & 7))
16153
16154 /**
16155@@ -203,7 +203,7 @@ static inline void change_bit(long nr, volatile unsigned long *addr)
16156 */
16157 static inline int test_and_set_bit(long nr, volatile unsigned long *addr)
16158 {
16159- GEN_BINARY_RMWcc(LOCK_PREFIX "bts", *addr, "Ir", nr, "%0", "c");
16160+ GEN_BINARY_RMWcc_unchecked(LOCK_PREFIX "bts", *addr, "Ir", nr, "%0", "c");
16161 }
16162
16163 /**
16164@@ -249,7 +249,7 @@ static inline int __test_and_set_bit(long nr, volatile unsigned long *addr)
16165 */
16166 static inline int test_and_clear_bit(long nr, volatile unsigned long *addr)
16167 {
16168- GEN_BINARY_RMWcc(LOCK_PREFIX "btr", *addr, "Ir", nr, "%0", "c");
16169+ GEN_BINARY_RMWcc_unchecked(LOCK_PREFIX "btr", *addr, "Ir", nr, "%0", "c");
16170 }
16171
16172 /**
16173@@ -302,7 +302,7 @@ static inline int __test_and_change_bit(long nr, volatile unsigned long *addr)
16174 */
16175 static inline int test_and_change_bit(long nr, volatile unsigned long *addr)
16176 {
16177- GEN_BINARY_RMWcc(LOCK_PREFIX "btc", *addr, "Ir", nr, "%0", "c");
16178+ GEN_BINARY_RMWcc_unchecked(LOCK_PREFIX "btc", *addr, "Ir", nr, "%0", "c");
16179 }
16180
16181 static __always_inline int constant_test_bit(long nr, const volatile unsigned long *addr)
16182@@ -343,7 +343,7 @@ static int test_bit(int nr, const volatile unsigned long *addr);
16183 *
16184 * Undefined if no bit exists, so code should check against 0 first.
16185 */
16186-static inline unsigned long __ffs(unsigned long word)
16187+static inline unsigned long __intentional_overflow(-1) __ffs(unsigned long word)
16188 {
16189 asm("rep; bsf %1,%0"
16190 : "=r" (word)
16191@@ -357,7 +357,7 @@ static inline unsigned long __ffs(unsigned long word)
16192 *
16193 * Undefined if no zero exists, so code should check against ~0UL first.
16194 */
16195-static inline unsigned long ffz(unsigned long word)
16196+static inline unsigned long __intentional_overflow(-1) ffz(unsigned long word)
16197 {
16198 asm("rep; bsf %1,%0"
16199 : "=r" (word)
16200@@ -371,7 +371,7 @@ static inline unsigned long ffz(unsigned long word)
16201 *
16202 * Undefined if no set bit exists, so code should check against 0 first.
16203 */
16204-static inline unsigned long __fls(unsigned long word)
16205+static inline unsigned long __intentional_overflow(-1) __fls(unsigned long word)
16206 {
16207 asm("bsr %1,%0"
16208 : "=r" (word)
16209@@ -434,7 +434,7 @@ static inline int ffs(int x)
16210 * set bit if value is nonzero. The last (most significant) bit is
16211 * at position 32.
16212 */
16213-static inline int fls(int x)
16214+static inline int __intentional_overflow(-1) fls(int x)
16215 {
16216 int r;
16217
16218@@ -476,7 +476,7 @@ static inline int fls(int x)
16219 * at position 64.
16220 */
16221 #ifdef CONFIG_X86_64
16222-static __always_inline int fls64(__u64 x)
16223+static __always_inline __intentional_overflow(-1) int fls64(__u64 x)
16224 {
16225 int bitpos = -1;
16226 /*
16227diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
16228index 4fa687a..60f2d39 100644
16229--- a/arch/x86/include/asm/boot.h
16230+++ b/arch/x86/include/asm/boot.h
16231@@ -6,10 +6,15 @@
16232 #include <uapi/asm/boot.h>
16233
16234 /* Physical address where kernel should be loaded. */
16235-#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
16236+#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
16237 + (CONFIG_PHYSICAL_ALIGN - 1)) \
16238 & ~(CONFIG_PHYSICAL_ALIGN - 1))
16239
16240+#ifndef __ASSEMBLY__
16241+extern unsigned char __LOAD_PHYSICAL_ADDR[];
16242+#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
16243+#endif
16244+
16245 /* Minimum kernel alignment, as a power of two */
16246 #ifdef CONFIG_X86_64
16247 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
16248diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
16249index 48f99f1..d78ebf9 100644
16250--- a/arch/x86/include/asm/cache.h
16251+++ b/arch/x86/include/asm/cache.h
16252@@ -5,12 +5,13 @@
16253
16254 /* L1 cache line size */
16255 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
16256-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
16257+#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
16258
16259 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
16260+#define __read_only __attribute__((__section__(".data..read_only")))
16261
16262 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
16263-#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
16264+#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
16265
16266 #ifdef CONFIG_X86_VSMP
16267 #ifdef CONFIG_SMP
16268diff --git a/arch/x86/include/asm/calling.h b/arch/x86/include/asm/calling.h
16269index 1c8b50e..166bcaa 100644
16270--- a/arch/x86/include/asm/calling.h
16271+++ b/arch/x86/include/asm/calling.h
16272@@ -96,23 +96,26 @@ For 32-bit we have the following conventions - kernel is built with
16273 .endm
16274
16275 .macro SAVE_C_REGS_HELPER offset=0 rax=1 rcx=1 r8910=1 r11=1
16276+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
16277+ movq_cfi r12, R12+\offset
16278+#endif
16279 .if \r11
16280- movq_cfi r11, 6*8+\offset
16281+ movq_cfi r11, R11+\offset
16282 .endif
16283 .if \r8910
16284- movq_cfi r10, 7*8+\offset
16285- movq_cfi r9, 8*8+\offset
16286- movq_cfi r8, 9*8+\offset
16287+ movq_cfi r10, R10+\offset
16288+ movq_cfi r9, R9+\offset
16289+ movq_cfi r8, R8+\offset
16290 .endif
16291 .if \rax
16292- movq_cfi rax, 10*8+\offset
16293+ movq_cfi rax, RAX+\offset
16294 .endif
16295 .if \rcx
16296- movq_cfi rcx, 11*8+\offset
16297+ movq_cfi rcx, RCX+\offset
16298 .endif
16299- movq_cfi rdx, 12*8+\offset
16300- movq_cfi rsi, 13*8+\offset
16301- movq_cfi rdi, 14*8+\offset
16302+ movq_cfi rdx, RDX+\offset
16303+ movq_cfi rsi, RSI+\offset
16304+ movq_cfi rdi, RDI+\offset
16305 .endm
16306 .macro SAVE_C_REGS offset=0
16307 SAVE_C_REGS_HELPER \offset, 1, 1, 1, 1
16308@@ -131,76 +134,87 @@ For 32-bit we have the following conventions - kernel is built with
16309 .endm
16310
16311 .macro SAVE_EXTRA_REGS offset=0
16312- movq_cfi r15, 0*8+\offset
16313- movq_cfi r14, 1*8+\offset
16314- movq_cfi r13, 2*8+\offset
16315- movq_cfi r12, 3*8+\offset
16316- movq_cfi rbp, 4*8+\offset
16317- movq_cfi rbx, 5*8+\offset
16318+ movq_cfi r15, R15+\offset
16319+ movq_cfi r14, R14+\offset
16320+ movq_cfi r13, R13+\offset
16321+#ifndef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
16322+ movq_cfi r12, R12+\offset
16323+#endif
16324+ movq_cfi rbp, RBP+\offset
16325+ movq_cfi rbx, RBX+\offset
16326 .endm
16327 .macro SAVE_EXTRA_REGS_RBP offset=0
16328- movq_cfi rbp, 4*8+\offset
16329+ movq_cfi rbp, RBP+\offset
16330 .endm
16331
16332 .macro RESTORE_EXTRA_REGS offset=0
16333- movq_cfi_restore 0*8+\offset, r15
16334- movq_cfi_restore 1*8+\offset, r14
16335- movq_cfi_restore 2*8+\offset, r13
16336- movq_cfi_restore 3*8+\offset, r12
16337- movq_cfi_restore 4*8+\offset, rbp
16338- movq_cfi_restore 5*8+\offset, rbx
16339+ movq_cfi_restore R15+\offset, r15
16340+ movq_cfi_restore R14+\offset, r14
16341+ movq_cfi_restore R13+\offset, r13
16342+#ifndef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
16343+ movq_cfi_restore R12+\offset, r12
16344+#endif
16345+ movq_cfi_restore RBP+\offset, rbp
16346+ movq_cfi_restore RBX+\offset, rbx
16347 .endm
16348
16349 .macro ZERO_EXTRA_REGS
16350 xorl %r15d, %r15d
16351 xorl %r14d, %r14d
16352 xorl %r13d, %r13d
16353+#ifndef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
16354 xorl %r12d, %r12d
16355+#endif
16356 xorl %ebp, %ebp
16357 xorl %ebx, %ebx
16358 .endm
16359
16360- .macro RESTORE_C_REGS_HELPER rstor_rax=1, rstor_rcx=1, rstor_r11=1, rstor_r8910=1, rstor_rdx=1
16361+ .macro RESTORE_C_REGS_HELPER rstor_rax=1, rstor_rcx=1, rstor_r11=1, rstor_r8910=1, rstor_rdx=1, rstor_r12=1
16362+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
16363+ .if \rstor_r12
16364+ movq_cfi_restore R12, r12
16365+ .endif
16366+#endif
16367 .if \rstor_r11
16368- movq_cfi_restore 6*8, r11
16369+ movq_cfi_restore R11, r11
16370 .endif
16371 .if \rstor_r8910
16372- movq_cfi_restore 7*8, r10
16373- movq_cfi_restore 8*8, r9
16374- movq_cfi_restore 9*8, r8
16375+ movq_cfi_restore R10, r10
16376+ movq_cfi_restore R9, r9
16377+ movq_cfi_restore R8, r8
16378 .endif
16379 .if \rstor_rax
16380- movq_cfi_restore 10*8, rax
16381+ movq_cfi_restore RAX, rax
16382 .endif
16383 .if \rstor_rcx
16384- movq_cfi_restore 11*8, rcx
16385+ movq_cfi_restore RCX, rcx
16386 .endif
16387 .if \rstor_rdx
16388- movq_cfi_restore 12*8, rdx
16389+ movq_cfi_restore RDX, rdx
16390 .endif
16391- movq_cfi_restore 13*8, rsi
16392- movq_cfi_restore 14*8, rdi
16393+ movq_cfi_restore RSI, rsi
16394+ movq_cfi_restore RDI, rdi
16395 .endm
16396 .macro RESTORE_C_REGS
16397- RESTORE_C_REGS_HELPER 1,1,1,1,1
16398+ RESTORE_C_REGS_HELPER 1,1,1,1,1,1
16399 .endm
16400 .macro RESTORE_C_REGS_EXCEPT_RAX
16401- RESTORE_C_REGS_HELPER 0,1,1,1,1
16402+ RESTORE_C_REGS_HELPER 0,1,1,1,1,0
16403 .endm
16404 .macro RESTORE_C_REGS_EXCEPT_RCX
16405- RESTORE_C_REGS_HELPER 1,0,1,1,1
16406+ RESTORE_C_REGS_HELPER 1,0,1,1,1,0
16407 .endm
16408 .macro RESTORE_C_REGS_EXCEPT_R11
16409- RESTORE_C_REGS_HELPER 1,1,0,1,1
16410+ RESTORE_C_REGS_HELPER 1,1,0,1,1,1
16411 .endm
16412 .macro RESTORE_C_REGS_EXCEPT_RCX_R11
16413- RESTORE_C_REGS_HELPER 1,0,0,1,1
16414+ RESTORE_C_REGS_HELPER 1,0,0,1,1,1
16415 .endm
16416 .macro RESTORE_RSI_RDI
16417- RESTORE_C_REGS_HELPER 0,0,0,0,0
16418+ RESTORE_C_REGS_HELPER 0,0,0,0,0,1
16419 .endm
16420 .macro RESTORE_RSI_RDI_RDX
16421- RESTORE_C_REGS_HELPER 0,0,0,0,1
16422+ RESTORE_C_REGS_HELPER 0,0,0,0,1,1
16423 .endm
16424
16425 .macro REMOVE_PT_GPREGS_FROM_STACK addskip=0
16426diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
16427index f50de69..2b0a458 100644
16428--- a/arch/x86/include/asm/checksum_32.h
16429+++ b/arch/x86/include/asm/checksum_32.h
16430@@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
16431 int len, __wsum sum,
16432 int *src_err_ptr, int *dst_err_ptr);
16433
16434+asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
16435+ int len, __wsum sum,
16436+ int *src_err_ptr, int *dst_err_ptr);
16437+
16438+asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
16439+ int len, __wsum sum,
16440+ int *src_err_ptr, int *dst_err_ptr);
16441+
16442 /*
16443 * Note: when you get a NULL pointer exception here this means someone
16444 * passed in an incorrect kernel address to one of these functions.
16445@@ -53,7 +61,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
16446
16447 might_sleep();
16448 stac();
16449- ret = csum_partial_copy_generic((__force void *)src, dst,
16450+ ret = csum_partial_copy_generic_from_user((__force void *)src, dst,
16451 len, sum, err_ptr, NULL);
16452 clac();
16453
16454@@ -187,7 +195,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
16455 might_sleep();
16456 if (access_ok(VERIFY_WRITE, dst, len)) {
16457 stac();
16458- ret = csum_partial_copy_generic(src, (__force void *)dst,
16459+ ret = csum_partial_copy_generic_to_user(src, (__force void *)dst,
16460 len, sum, NULL, err_ptr);
16461 clac();
16462 return ret;
16463diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
16464index 99c105d7..2f667ac 100644
16465--- a/arch/x86/include/asm/cmpxchg.h
16466+++ b/arch/x86/include/asm/cmpxchg.h
16467@@ -16,8 +16,12 @@ extern void __cmpxchg_wrong_size(void)
16468 __compiletime_error("Bad argument size for cmpxchg");
16469 extern void __xadd_wrong_size(void)
16470 __compiletime_error("Bad argument size for xadd");
16471+extern void __xadd_check_overflow_wrong_size(void)
16472+ __compiletime_error("Bad argument size for xadd_check_overflow");
16473 extern void __add_wrong_size(void)
16474 __compiletime_error("Bad argument size for add");
16475+extern void __add_check_overflow_wrong_size(void)
16476+ __compiletime_error("Bad argument size for add_check_overflow");
16477
16478 /*
16479 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
16480@@ -69,6 +73,38 @@ extern void __add_wrong_size(void)
16481 __ret; \
16482 })
16483
16484+#ifdef CONFIG_PAX_REFCOUNT
16485+#define __xchg_op_check_overflow(ptr, arg, op, lock) \
16486+ ({ \
16487+ __typeof__ (*(ptr)) __ret = (arg); \
16488+ switch (sizeof(*(ptr))) { \
16489+ case __X86_CASE_L: \
16490+ asm volatile (lock #op "l %0, %1\n" \
16491+ "jno 0f\n" \
16492+ "mov %0,%1\n" \
16493+ "int $4\n0:\n" \
16494+ _ASM_EXTABLE(0b, 0b) \
16495+ : "+r" (__ret), "+m" (*(ptr)) \
16496+ : : "memory", "cc"); \
16497+ break; \
16498+ case __X86_CASE_Q: \
16499+ asm volatile (lock #op "q %q0, %1\n" \
16500+ "jno 0f\n" \
16501+ "mov %0,%1\n" \
16502+ "int $4\n0:\n" \
16503+ _ASM_EXTABLE(0b, 0b) \
16504+ : "+r" (__ret), "+m" (*(ptr)) \
16505+ : : "memory", "cc"); \
16506+ break; \
16507+ default: \
16508+ __ ## op ## _check_overflow_wrong_size(); \
16509+ } \
16510+ __ret; \
16511+ })
16512+#else
16513+#define __xchg_op_check_overflow(ptr, arg, op, lock) __xchg_op(ptr, arg, op, lock)
16514+#endif
16515+
16516 /*
16517 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
16518 * Since this is generally used to protect other memory information, we
16519@@ -167,6 +203,9 @@ extern void __add_wrong_size(void)
16520 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
16521 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
16522
16523+#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
16524+#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
16525+
16526 #define __add(ptr, inc, lock) \
16527 ({ \
16528 __typeof__ (*(ptr)) __ret = (inc); \
16529diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
16530index acdee09..a553db3 100644
16531--- a/arch/x86/include/asm/compat.h
16532+++ b/arch/x86/include/asm/compat.h
16533@@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
16534 typedef u32 compat_uint_t;
16535 typedef u32 compat_ulong_t;
16536 typedef u64 __attribute__((aligned(4))) compat_u64;
16537-typedef u32 compat_uptr_t;
16538+typedef u32 __user compat_uptr_t;
16539
16540 struct compat_timespec {
16541 compat_time_t tv_sec;
16542diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
16543index 3d6606f..91703f1 100644
16544--- a/arch/x86/include/asm/cpufeature.h
16545+++ b/arch/x86/include/asm/cpufeature.h
16546@@ -214,7 +214,7 @@
16547 #define X86_FEATURE_PAUSEFILTER ( 8*32+13) /* AMD filtered pause intercept */
16548 #define X86_FEATURE_PFTHRESHOLD ( 8*32+14) /* AMD pause filter threshold */
16549 #define X86_FEATURE_VMMCALL ( 8*32+15) /* Prefer vmmcall to vmcall */
16550-
16551+#define X86_FEATURE_STRONGUDEREF (8*32+31) /* PaX PCID based strong UDEREF */
16552
16553 /* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx), word 9 */
16554 #define X86_FEATURE_FSGSBASE ( 9*32+ 0) /* {RD/WR}{FS/GS}BASE instructions*/
16555@@ -222,7 +222,7 @@
16556 #define X86_FEATURE_BMI1 ( 9*32+ 3) /* 1st group bit manipulation extensions */
16557 #define X86_FEATURE_HLE ( 9*32+ 4) /* Hardware Lock Elision */
16558 #define X86_FEATURE_AVX2 ( 9*32+ 5) /* AVX2 instructions */
16559-#define X86_FEATURE_SMEP ( 9*32+ 7) /* Supervisor Mode Execution Protection */
16560+#define X86_FEATURE_SMEP ( 9*32+ 7) /* Supervisor Mode Execution Prevention */
16561 #define X86_FEATURE_BMI2 ( 9*32+ 8) /* 2nd group bit manipulation extensions */
16562 #define X86_FEATURE_ERMS ( 9*32+ 9) /* Enhanced REP MOVSB/STOSB */
16563 #define X86_FEATURE_INVPCID ( 9*32+10) /* Invalidate Processor Context ID */
16564@@ -401,6 +401,7 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
16565 #define cpu_has_eager_fpu boot_cpu_has(X86_FEATURE_EAGER_FPU)
16566 #define cpu_has_topoext boot_cpu_has(X86_FEATURE_TOPOEXT)
16567 #define cpu_has_bpext boot_cpu_has(X86_FEATURE_BPEXT)
16568+#define cpu_has_pcid boot_cpu_has(X86_FEATURE_PCID)
16569
16570 #if __GNUC__ >= 4
16571 extern void warn_pre_alternatives(void);
16572@@ -454,7 +455,8 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
16573
16574 #ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS
16575 t_warn:
16576- warn_pre_alternatives();
16577+ if (bit != X86_FEATURE_PCID && bit != X86_FEATURE_INVPCID)
16578+ warn_pre_alternatives();
16579 return false;
16580 #endif
16581
16582@@ -475,7 +477,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
16583 ".section .discard,\"aw\",@progbits\n"
16584 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
16585 ".previous\n"
16586- ".section .altinstr_replacement,\"ax\"\n"
16587+ ".section .altinstr_replacement,\"a\"\n"
16588 "3: movb $1,%0\n"
16589 "4:\n"
16590 ".previous\n"
16591@@ -510,7 +512,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
16592 " .byte 5f - 4f\n" /* repl len */
16593 " .byte 3b - 2b\n" /* pad len */
16594 ".previous\n"
16595- ".section .altinstr_replacement,\"ax\"\n"
16596+ ".section .altinstr_replacement,\"a\"\n"
16597 "4: jmp %l[t_no]\n"
16598 "5:\n"
16599 ".previous\n"
16600@@ -545,7 +547,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
16601 ".section .discard,\"aw\",@progbits\n"
16602 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
16603 ".previous\n"
16604- ".section .altinstr_replacement,\"ax\"\n"
16605+ ".section .altinstr_replacement,\"a\"\n"
16606 "3: movb $0,%0\n"
16607 "4:\n"
16608 ".previous\n"
16609@@ -560,7 +562,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
16610 ".section .discard,\"aw\",@progbits\n"
16611 " .byte 0xff + (6f-5f) - (4b-3b)\n" /* size check */
16612 ".previous\n"
16613- ".section .altinstr_replacement,\"ax\"\n"
16614+ ".section .altinstr_replacement,\"a\"\n"
16615 "5: movb $1,%0\n"
16616 "6:\n"
16617 ".previous\n"
16618diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
16619index a0bf89f..56f0b2a 100644
16620--- a/arch/x86/include/asm/desc.h
16621+++ b/arch/x86/include/asm/desc.h
16622@@ -4,6 +4,7 @@
16623 #include <asm/desc_defs.h>
16624 #include <asm/ldt.h>
16625 #include <asm/mmu.h>
16626+#include <asm/pgtable.h>
16627
16628 #include <linux/smp.h>
16629 #include <linux/percpu.h>
16630@@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
16631
16632 desc->type = (info->read_exec_only ^ 1) << 1;
16633 desc->type |= info->contents << 2;
16634+ desc->type |= info->seg_not_present ^ 1;
16635
16636 desc->s = 1;
16637 desc->dpl = 0x3;
16638@@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
16639 }
16640
16641 extern struct desc_ptr idt_descr;
16642-extern gate_desc idt_table[];
16643-extern struct desc_ptr debug_idt_descr;
16644-extern gate_desc debug_idt_table[];
16645-
16646-struct gdt_page {
16647- struct desc_struct gdt[GDT_ENTRIES];
16648-} __attribute__((aligned(PAGE_SIZE)));
16649-
16650-DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
16651+extern gate_desc idt_table[IDT_ENTRIES];
16652+extern const struct desc_ptr debug_idt_descr;
16653+extern gate_desc debug_idt_table[IDT_ENTRIES];
16654
16655+extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
16656 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
16657 {
16658- return per_cpu(gdt_page, cpu).gdt;
16659+ return cpu_gdt_table[cpu];
16660 }
16661
16662 #ifdef CONFIG_X86_64
16663@@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
16664 unsigned long base, unsigned dpl, unsigned flags,
16665 unsigned short seg)
16666 {
16667- gate->a = (seg << 16) | (base & 0xffff);
16668- gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
16669+ gate->gate.offset_low = base;
16670+ gate->gate.seg = seg;
16671+ gate->gate.reserved = 0;
16672+ gate->gate.type = type;
16673+ gate->gate.s = 0;
16674+ gate->gate.dpl = dpl;
16675+ gate->gate.p = 1;
16676+ gate->gate.offset_high = base >> 16;
16677 }
16678
16679 #endif
16680@@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
16681
16682 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
16683 {
16684+ pax_open_kernel();
16685 memcpy(&idt[entry], gate, sizeof(*gate));
16686+ pax_close_kernel();
16687 }
16688
16689 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
16690 {
16691+ pax_open_kernel();
16692 memcpy(&ldt[entry], desc, 8);
16693+ pax_close_kernel();
16694 }
16695
16696 static inline void
16697@@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
16698 default: size = sizeof(*gdt); break;
16699 }
16700
16701+ pax_open_kernel();
16702 memcpy(&gdt[entry], desc, size);
16703+ pax_close_kernel();
16704 }
16705
16706 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
16707@@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
16708
16709 static inline void native_load_tr_desc(void)
16710 {
16711+ pax_open_kernel();
16712 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
16713+ pax_close_kernel();
16714 }
16715
16716 static inline void native_load_gdt(const struct desc_ptr *dtr)
16717@@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
16718 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
16719 unsigned int i;
16720
16721+ pax_open_kernel();
16722 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
16723 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
16724+ pax_close_kernel();
16725 }
16726
16727 /* This intentionally ignores lm, since 32-bit apps don't have that field. */
16728@@ -295,7 +308,7 @@ static inline void load_LDT(mm_context_t *pc)
16729 preempt_enable();
16730 }
16731
16732-static inline unsigned long get_desc_base(const struct desc_struct *desc)
16733+static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
16734 {
16735 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
16736 }
16737@@ -319,7 +332,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
16738 }
16739
16740 #ifdef CONFIG_X86_64
16741-static inline void set_nmi_gate(int gate, void *addr)
16742+static inline void set_nmi_gate(int gate, const void *addr)
16743 {
16744 gate_desc s;
16745
16746@@ -329,14 +342,14 @@ static inline void set_nmi_gate(int gate, void *addr)
16747 #endif
16748
16749 #ifdef CONFIG_TRACING
16750-extern struct desc_ptr trace_idt_descr;
16751-extern gate_desc trace_idt_table[];
16752+extern const struct desc_ptr trace_idt_descr;
16753+extern gate_desc trace_idt_table[IDT_ENTRIES];
16754 static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
16755 {
16756 write_idt_entry(trace_idt_table, entry, gate);
16757 }
16758
16759-static inline void _trace_set_gate(int gate, unsigned type, void *addr,
16760+static inline void _trace_set_gate(int gate, unsigned type, const void *addr,
16761 unsigned dpl, unsigned ist, unsigned seg)
16762 {
16763 gate_desc s;
16764@@ -356,7 +369,7 @@ static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
16765 #define _trace_set_gate(gate, type, addr, dpl, ist, seg)
16766 #endif
16767
16768-static inline void _set_gate(int gate, unsigned type, void *addr,
16769+static inline void _set_gate(int gate, unsigned type, const void *addr,
16770 unsigned dpl, unsigned ist, unsigned seg)
16771 {
16772 gate_desc s;
16773@@ -379,14 +392,14 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
16774 #define set_intr_gate_notrace(n, addr) \
16775 do { \
16776 BUG_ON((unsigned)n > 0xFF); \
16777- _set_gate(n, GATE_INTERRUPT, (void *)addr, 0, 0, \
16778+ _set_gate(n, GATE_INTERRUPT, (const void *)addr, 0, 0, \
16779 __KERNEL_CS); \
16780 } while (0)
16781
16782 #define set_intr_gate(n, addr) \
16783 do { \
16784 set_intr_gate_notrace(n, addr); \
16785- _trace_set_gate(n, GATE_INTERRUPT, (void *)trace_##addr,\
16786+ _trace_set_gate(n, GATE_INTERRUPT, (const void *)trace_##addr,\
16787 0, 0, __KERNEL_CS); \
16788 } while (0)
16789
16790@@ -414,19 +427,19 @@ static inline void alloc_system_vector(int vector)
16791 /*
16792 * This routine sets up an interrupt gate at directory privilege level 3.
16793 */
16794-static inline void set_system_intr_gate(unsigned int n, void *addr)
16795+static inline void set_system_intr_gate(unsigned int n, const void *addr)
16796 {
16797 BUG_ON((unsigned)n > 0xFF);
16798 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
16799 }
16800
16801-static inline void set_system_trap_gate(unsigned int n, void *addr)
16802+static inline void set_system_trap_gate(unsigned int n, const void *addr)
16803 {
16804 BUG_ON((unsigned)n > 0xFF);
16805 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
16806 }
16807
16808-static inline void set_trap_gate(unsigned int n, void *addr)
16809+static inline void set_trap_gate(unsigned int n, const void *addr)
16810 {
16811 BUG_ON((unsigned)n > 0xFF);
16812 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
16813@@ -435,16 +448,16 @@ static inline void set_trap_gate(unsigned int n, void *addr)
16814 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
16815 {
16816 BUG_ON((unsigned)n > 0xFF);
16817- _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
16818+ _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
16819 }
16820
16821-static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
16822+static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
16823 {
16824 BUG_ON((unsigned)n > 0xFF);
16825 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
16826 }
16827
16828-static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
16829+static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
16830 {
16831 BUG_ON((unsigned)n > 0xFF);
16832 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
16833@@ -516,4 +529,17 @@ static inline void load_current_idt(void)
16834 else
16835 load_idt((const struct desc_ptr *)&idt_descr);
16836 }
16837+
16838+#ifdef CONFIG_X86_32
16839+static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
16840+{
16841+ struct desc_struct d;
16842+
16843+ if (likely(limit))
16844+ limit = (limit - 1UL) >> PAGE_SHIFT;
16845+ pack_descriptor(&d, base, limit, 0xFB, 0xC);
16846+ write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
16847+}
16848+#endif
16849+
16850 #endif /* _ASM_X86_DESC_H */
16851diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
16852index 278441f..b95a174 100644
16853--- a/arch/x86/include/asm/desc_defs.h
16854+++ b/arch/x86/include/asm/desc_defs.h
16855@@ -31,6 +31,12 @@ struct desc_struct {
16856 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
16857 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
16858 };
16859+ struct {
16860+ u16 offset_low;
16861+ u16 seg;
16862+ unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
16863+ unsigned offset_high: 16;
16864+ } gate;
16865 };
16866 } __attribute__((packed));
16867
16868diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
16869index ced283a..ffe04cc 100644
16870--- a/arch/x86/include/asm/div64.h
16871+++ b/arch/x86/include/asm/div64.h
16872@@ -39,7 +39,7 @@
16873 __mod; \
16874 })
16875
16876-static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
16877+static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
16878 {
16879 union {
16880 u64 v64;
16881diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
16882index f161c18..97d43e8 100644
16883--- a/arch/x86/include/asm/elf.h
16884+++ b/arch/x86/include/asm/elf.h
16885@@ -75,9 +75,6 @@ typedef struct user_fxsr_struct elf_fpxregset_t;
16886
16887 #include <asm/vdso.h>
16888
16889-#ifdef CONFIG_X86_64
16890-extern unsigned int vdso64_enabled;
16891-#endif
16892 #if defined(CONFIG_X86_32) || defined(CONFIG_COMPAT)
16893 extern unsigned int vdso32_enabled;
16894 #endif
16895@@ -250,7 +247,25 @@ extern int force_personality32;
16896 the loader. We need to make sure that it is out of the way of the program
16897 that it will "exec", and that there is sufficient room for the brk. */
16898
16899+#ifdef CONFIG_PAX_SEGMEXEC
16900+#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
16901+#else
16902 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
16903+#endif
16904+
16905+#ifdef CONFIG_PAX_ASLR
16906+#ifdef CONFIG_X86_32
16907+#define PAX_ELF_ET_DYN_BASE 0x10000000UL
16908+
16909+#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
16910+#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
16911+#else
16912+#define PAX_ELF_ET_DYN_BASE 0x400000UL
16913+
16914+#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
16915+#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
16916+#endif
16917+#endif
16918
16919 /* This yields a mask that user programs can use to figure out what
16920 instruction set this CPU supports. This could be done in user space,
16921@@ -299,17 +314,13 @@ do { \
16922
16923 #define ARCH_DLINFO \
16924 do { \
16925- if (vdso64_enabled) \
16926- NEW_AUX_ENT(AT_SYSINFO_EHDR, \
16927- (unsigned long __force)current->mm->context.vdso); \
16928+ NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
16929 } while (0)
16930
16931 /* As a historical oddity, the x32 and x86_64 vDSOs are controlled together. */
16932 #define ARCH_DLINFO_X32 \
16933 do { \
16934- if (vdso64_enabled) \
16935- NEW_AUX_ENT(AT_SYSINFO_EHDR, \
16936- (unsigned long __force)current->mm->context.vdso); \
16937+ NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
16938 } while (0)
16939
16940 #define AT_SYSINFO 32
16941@@ -324,10 +335,10 @@ else \
16942
16943 #endif /* !CONFIG_X86_32 */
16944
16945-#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
16946+#define VDSO_CURRENT_BASE (current->mm->context.vdso)
16947
16948 #define VDSO_ENTRY \
16949- ((unsigned long)current->mm->context.vdso + \
16950+ (current->mm->context.vdso + \
16951 selected_vdso32->sym___kernel_vsyscall)
16952
16953 struct linux_binprm;
16954diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
16955index 77a99ac..39ff7f5 100644
16956--- a/arch/x86/include/asm/emergency-restart.h
16957+++ b/arch/x86/include/asm/emergency-restart.h
16958@@ -1,6 +1,6 @@
16959 #ifndef _ASM_X86_EMERGENCY_RESTART_H
16960 #define _ASM_X86_EMERGENCY_RESTART_H
16961
16962-extern void machine_emergency_restart(void);
16963+extern void machine_emergency_restart(void) __noreturn;
16964
16965 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
16966diff --git a/arch/x86/include/asm/floppy.h b/arch/x86/include/asm/floppy.h
16967index 1c7eefe..d0e4702 100644
16968--- a/arch/x86/include/asm/floppy.h
16969+++ b/arch/x86/include/asm/floppy.h
16970@@ -229,18 +229,18 @@ static struct fd_routine_l {
16971 int (*_dma_setup)(char *addr, unsigned long size, int mode, int io);
16972 } fd_routine[] = {
16973 {
16974- request_dma,
16975- free_dma,
16976- get_dma_residue,
16977- dma_mem_alloc,
16978- hard_dma_setup
16979+ ._request_dma = request_dma,
16980+ ._free_dma = free_dma,
16981+ ._get_dma_residue = get_dma_residue,
16982+ ._dma_mem_alloc = dma_mem_alloc,
16983+ ._dma_setup = hard_dma_setup
16984 },
16985 {
16986- vdma_request_dma,
16987- vdma_nop,
16988- vdma_get_dma_residue,
16989- vdma_mem_alloc,
16990- vdma_dma_setup
16991+ ._request_dma = vdma_request_dma,
16992+ ._free_dma = vdma_nop,
16993+ ._get_dma_residue = vdma_get_dma_residue,
16994+ ._dma_mem_alloc = vdma_mem_alloc,
16995+ ._dma_setup = vdma_dma_setup
16996 }
16997 };
16998
16999diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
17000index da5e967..ab07eec 100644
17001--- a/arch/x86/include/asm/fpu-internal.h
17002+++ b/arch/x86/include/asm/fpu-internal.h
17003@@ -151,8 +151,11 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
17004 #define user_insn(insn, output, input...) \
17005 ({ \
17006 int err; \
17007+ pax_open_userland(); \
17008 asm volatile(ASM_STAC "\n" \
17009- "1:" #insn "\n\t" \
17010+ "1:" \
17011+ __copyuser_seg \
17012+ #insn "\n\t" \
17013 "2: " ASM_CLAC "\n" \
17014 ".section .fixup,\"ax\"\n" \
17015 "3: movl $-1,%[err]\n" \
17016@@ -161,6 +164,7 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
17017 _ASM_EXTABLE(1b, 3b) \
17018 : [err] "=r" (err), output \
17019 : "0"(0), input); \
17020+ pax_close_userland(); \
17021 err; \
17022 })
17023
17024@@ -327,7 +331,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
17025 "fnclex\n\t"
17026 "emms\n\t"
17027 "fildl %P[addr]" /* set F?P to defined value */
17028- : : [addr] "m" (tsk->thread.fpu.has_fpu));
17029+ : : [addr] "m" (cpu_tss[raw_smp_processor_id()].x86_tss.sp0));
17030 }
17031
17032 return fpu_restore_checking(&tsk->thread.fpu);
17033diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
17034index b4c1f54..e290c08 100644
17035--- a/arch/x86/include/asm/futex.h
17036+++ b/arch/x86/include/asm/futex.h
17037@@ -12,6 +12,7 @@
17038 #include <asm/smap.h>
17039
17040 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
17041+ typecheck(u32 __user *, uaddr); \
17042 asm volatile("\t" ASM_STAC "\n" \
17043 "1:\t" insn "\n" \
17044 "2:\t" ASM_CLAC "\n" \
17045@@ -20,15 +21,16 @@
17046 "\tjmp\t2b\n" \
17047 "\t.previous\n" \
17048 _ASM_EXTABLE(1b, 3b) \
17049- : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
17050+ : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
17051 : "i" (-EFAULT), "0" (oparg), "1" (0))
17052
17053 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
17054+ typecheck(u32 __user *, uaddr); \
17055 asm volatile("\t" ASM_STAC "\n" \
17056 "1:\tmovl %2, %0\n" \
17057 "\tmovl\t%0, %3\n" \
17058 "\t" insn "\n" \
17059- "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
17060+ "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
17061 "\tjnz\t1b\n" \
17062 "3:\t" ASM_CLAC "\n" \
17063 "\t.section .fixup,\"ax\"\n" \
17064@@ -38,7 +40,7 @@
17065 _ASM_EXTABLE(1b, 4b) \
17066 _ASM_EXTABLE(2b, 4b) \
17067 : "=&a" (oldval), "=&r" (ret), \
17068- "+m" (*uaddr), "=&r" (tem) \
17069+ "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
17070 : "r" (oparg), "i" (-EFAULT), "1" (0))
17071
17072 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
17073@@ -57,12 +59,13 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
17074
17075 pagefault_disable();
17076
17077+ pax_open_userland();
17078 switch (op) {
17079 case FUTEX_OP_SET:
17080- __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
17081+ __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
17082 break;
17083 case FUTEX_OP_ADD:
17084- __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
17085+ __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
17086 uaddr, oparg);
17087 break;
17088 case FUTEX_OP_OR:
17089@@ -77,6 +80,7 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
17090 default:
17091 ret = -ENOSYS;
17092 }
17093+ pax_close_userland();
17094
17095 pagefault_enable();
17096
17097diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
17098index e9571dd..df5f542 100644
17099--- a/arch/x86/include/asm/hw_irq.h
17100+++ b/arch/x86/include/asm/hw_irq.h
17101@@ -160,8 +160,8 @@ static inline void unlock_vector_lock(void) {}
17102 #endif /* CONFIG_X86_LOCAL_APIC */
17103
17104 /* Statistics */
17105-extern atomic_t irq_err_count;
17106-extern atomic_t irq_mis_count;
17107+extern atomic_unchecked_t irq_err_count;
17108+extern atomic_unchecked_t irq_mis_count;
17109
17110 /* EISA */
17111 extern void eisa_set_level_irq(unsigned int irq);
17112diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
17113index ccffa53..3c90c87 100644
17114--- a/arch/x86/include/asm/i8259.h
17115+++ b/arch/x86/include/asm/i8259.h
17116@@ -62,7 +62,7 @@ struct legacy_pic {
17117 void (*init)(int auto_eoi);
17118 int (*irq_pending)(unsigned int irq);
17119 void (*make_irq)(unsigned int irq);
17120-};
17121+} __do_const;
17122
17123 extern struct legacy_pic *legacy_pic;
17124 extern struct legacy_pic null_legacy_pic;
17125diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
17126index 34a5b93..27e40a6 100644
17127--- a/arch/x86/include/asm/io.h
17128+++ b/arch/x86/include/asm/io.h
17129@@ -52,12 +52,12 @@ static inline void name(type val, volatile void __iomem *addr) \
17130 "m" (*(volatile type __force *)addr) barrier); }
17131
17132 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
17133-build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
17134-build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
17135+build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
17136+build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
17137
17138 build_mmio_read(__readb, "b", unsigned char, "=q", )
17139-build_mmio_read(__readw, "w", unsigned short, "=r", )
17140-build_mmio_read(__readl, "l", unsigned int, "=r", )
17141+build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
17142+build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
17143
17144 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
17145 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
17146@@ -113,7 +113,7 @@ build_mmio_write(writeq, "q", unsigned long, "r", :"memory")
17147 * this function
17148 */
17149
17150-static inline phys_addr_t virt_to_phys(volatile void *address)
17151+static inline phys_addr_t __intentional_overflow(-1) virt_to_phys(volatile void *address)
17152 {
17153 return __pa(address);
17154 }
17155@@ -189,7 +189,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
17156 return ioremap_nocache(offset, size);
17157 }
17158
17159-extern void iounmap(volatile void __iomem *addr);
17160+extern void iounmap(const volatile void __iomem *addr);
17161
17162 extern void set_iounmap_nonlazy(void);
17163
17164@@ -199,6 +199,17 @@ extern void set_iounmap_nonlazy(void);
17165
17166 #include <linux/vmalloc.h>
17167
17168+#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
17169+static inline int valid_phys_addr_range(unsigned long addr, size_t count)
17170+{
17171+ return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
17172+}
17173+
17174+static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
17175+{
17176+ return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
17177+}
17178+
17179 /*
17180 * Convert a virtual cached pointer to an uncached pointer
17181 */
17182diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
17183index b77f5ed..a2f791e 100644
17184--- a/arch/x86/include/asm/irqflags.h
17185+++ b/arch/x86/include/asm/irqflags.h
17186@@ -137,6 +137,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
17187 swapgs; \
17188 sysretl
17189
17190+#define GET_CR0_INTO_RDI mov %cr0, %rdi
17191+#define SET_RDI_INTO_CR0 mov %rdi, %cr0
17192+#define GET_CR3_INTO_RDI mov %cr3, %rdi
17193+#define SET_RDI_INTO_CR3 mov %rdi, %cr3
17194+
17195 #else
17196 #define INTERRUPT_RETURN iret
17197 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
17198diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
17199index 4421b5d..8543006 100644
17200--- a/arch/x86/include/asm/kprobes.h
17201+++ b/arch/x86/include/asm/kprobes.h
17202@@ -37,13 +37,8 @@ typedef u8 kprobe_opcode_t;
17203 #define RELATIVEJUMP_SIZE 5
17204 #define RELATIVECALL_OPCODE 0xe8
17205 #define RELATIVE_ADDR_SIZE 4
17206-#define MAX_STACK_SIZE 64
17207-#define MIN_STACK_SIZE(ADDR) \
17208- (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
17209- THREAD_SIZE - (unsigned long)(ADDR))) \
17210- ? (MAX_STACK_SIZE) \
17211- : (((unsigned long)current_thread_info()) + \
17212- THREAD_SIZE - (unsigned long)(ADDR)))
17213+#define MAX_STACK_SIZE 64UL
17214+#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
17215
17216 #define flush_insn_slot(p) do { } while (0)
17217
17218diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
17219index 4ad6560..75c7bdd 100644
17220--- a/arch/x86/include/asm/local.h
17221+++ b/arch/x86/include/asm/local.h
17222@@ -10,33 +10,97 @@ typedef struct {
17223 atomic_long_t a;
17224 } local_t;
17225
17226+typedef struct {
17227+ atomic_long_unchecked_t a;
17228+} local_unchecked_t;
17229+
17230 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
17231
17232 #define local_read(l) atomic_long_read(&(l)->a)
17233+#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
17234 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
17235+#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
17236
17237 static inline void local_inc(local_t *l)
17238 {
17239- asm volatile(_ASM_INC "%0"
17240+ asm volatile(_ASM_INC "%0\n"
17241+
17242+#ifdef CONFIG_PAX_REFCOUNT
17243+ "jno 0f\n"
17244+ _ASM_DEC "%0\n"
17245+ "int $4\n0:\n"
17246+ _ASM_EXTABLE(0b, 0b)
17247+#endif
17248+
17249+ : "+m" (l->a.counter));
17250+}
17251+
17252+static inline void local_inc_unchecked(local_unchecked_t *l)
17253+{
17254+ asm volatile(_ASM_INC "%0\n"
17255 : "+m" (l->a.counter));
17256 }
17257
17258 static inline void local_dec(local_t *l)
17259 {
17260- asm volatile(_ASM_DEC "%0"
17261+ asm volatile(_ASM_DEC "%0\n"
17262+
17263+#ifdef CONFIG_PAX_REFCOUNT
17264+ "jno 0f\n"
17265+ _ASM_INC "%0\n"
17266+ "int $4\n0:\n"
17267+ _ASM_EXTABLE(0b, 0b)
17268+#endif
17269+
17270+ : "+m" (l->a.counter));
17271+}
17272+
17273+static inline void local_dec_unchecked(local_unchecked_t *l)
17274+{
17275+ asm volatile(_ASM_DEC "%0\n"
17276 : "+m" (l->a.counter));
17277 }
17278
17279 static inline void local_add(long i, local_t *l)
17280 {
17281- asm volatile(_ASM_ADD "%1,%0"
17282+ asm volatile(_ASM_ADD "%1,%0\n"
17283+
17284+#ifdef CONFIG_PAX_REFCOUNT
17285+ "jno 0f\n"
17286+ _ASM_SUB "%1,%0\n"
17287+ "int $4\n0:\n"
17288+ _ASM_EXTABLE(0b, 0b)
17289+#endif
17290+
17291+ : "+m" (l->a.counter)
17292+ : "ir" (i));
17293+}
17294+
17295+static inline void local_add_unchecked(long i, local_unchecked_t *l)
17296+{
17297+ asm volatile(_ASM_ADD "%1,%0\n"
17298 : "+m" (l->a.counter)
17299 : "ir" (i));
17300 }
17301
17302 static inline void local_sub(long i, local_t *l)
17303 {
17304- asm volatile(_ASM_SUB "%1,%0"
17305+ asm volatile(_ASM_SUB "%1,%0\n"
17306+
17307+#ifdef CONFIG_PAX_REFCOUNT
17308+ "jno 0f\n"
17309+ _ASM_ADD "%1,%0\n"
17310+ "int $4\n0:\n"
17311+ _ASM_EXTABLE(0b, 0b)
17312+#endif
17313+
17314+ : "+m" (l->a.counter)
17315+ : "ir" (i));
17316+}
17317+
17318+static inline void local_sub_unchecked(long i, local_unchecked_t *l)
17319+{
17320+ asm volatile(_ASM_SUB "%1,%0\n"
17321 : "+m" (l->a.counter)
17322 : "ir" (i));
17323 }
17324@@ -52,7 +116,7 @@ static inline void local_sub(long i, local_t *l)
17325 */
17326 static inline int local_sub_and_test(long i, local_t *l)
17327 {
17328- GEN_BINARY_RMWcc(_ASM_SUB, l->a.counter, "er", i, "%0", "e");
17329+ GEN_BINARY_RMWcc(_ASM_SUB, _ASM_ADD, l->a.counter, "er", i, "%0", "e");
17330 }
17331
17332 /**
17333@@ -65,7 +129,7 @@ static inline int local_sub_and_test(long i, local_t *l)
17334 */
17335 static inline int local_dec_and_test(local_t *l)
17336 {
17337- GEN_UNARY_RMWcc(_ASM_DEC, l->a.counter, "%0", "e");
17338+ GEN_UNARY_RMWcc(_ASM_DEC, _ASM_INC, l->a.counter, "%0", "e");
17339 }
17340
17341 /**
17342@@ -78,7 +142,7 @@ static inline int local_dec_and_test(local_t *l)
17343 */
17344 static inline int local_inc_and_test(local_t *l)
17345 {
17346- GEN_UNARY_RMWcc(_ASM_INC, l->a.counter, "%0", "e");
17347+ GEN_UNARY_RMWcc(_ASM_INC, _ASM_DEC, l->a.counter, "%0", "e");
17348 }
17349
17350 /**
17351@@ -92,7 +156,7 @@ static inline int local_inc_and_test(local_t *l)
17352 */
17353 static inline int local_add_negative(long i, local_t *l)
17354 {
17355- GEN_BINARY_RMWcc(_ASM_ADD, l->a.counter, "er", i, "%0", "s");
17356+ GEN_BINARY_RMWcc(_ASM_ADD, _ASM_SUB, l->a.counter, "er", i, "%0", "s");
17357 }
17358
17359 /**
17360@@ -105,6 +169,30 @@ static inline int local_add_negative(long i, local_t *l)
17361 static inline long local_add_return(long i, local_t *l)
17362 {
17363 long __i = i;
17364+ asm volatile(_ASM_XADD "%0, %1\n"
17365+
17366+#ifdef CONFIG_PAX_REFCOUNT
17367+ "jno 0f\n"
17368+ _ASM_MOV "%0,%1\n"
17369+ "int $4\n0:\n"
17370+ _ASM_EXTABLE(0b, 0b)
17371+#endif
17372+
17373+ : "+r" (i), "+m" (l->a.counter)
17374+ : : "memory");
17375+ return i + __i;
17376+}
17377+
17378+/**
17379+ * local_add_return_unchecked - add and return
17380+ * @i: integer value to add
17381+ * @l: pointer to type local_unchecked_t
17382+ *
17383+ * Atomically adds @i to @l and returns @i + @l
17384+ */
17385+static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
17386+{
17387+ long __i = i;
17388 asm volatile(_ASM_XADD "%0, %1;"
17389 : "+r" (i), "+m" (l->a.counter)
17390 : : "memory");
17391@@ -121,6 +209,8 @@ static inline long local_sub_return(long i, local_t *l)
17392
17393 #define local_cmpxchg(l, o, n) \
17394 (cmpxchg_local(&((l)->a.counter), (o), (n)))
17395+#define local_cmpxchg_unchecked(l, o, n) \
17396+ (cmpxchg_local(&((l)->a.counter), (o), (n)))
17397 /* Always has a lock prefix */
17398 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
17399
17400diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
17401new file mode 100644
17402index 0000000..2bfd3ba
17403--- /dev/null
17404+++ b/arch/x86/include/asm/mman.h
17405@@ -0,0 +1,15 @@
17406+#ifndef _X86_MMAN_H
17407+#define _X86_MMAN_H
17408+
17409+#include <uapi/asm/mman.h>
17410+
17411+#ifdef __KERNEL__
17412+#ifndef __ASSEMBLY__
17413+#ifdef CONFIG_X86_32
17414+#define arch_mmap_check i386_mmap_check
17415+int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
17416+#endif
17417+#endif
17418+#endif
17419+
17420+#endif /* X86_MMAN_H */
17421diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
17422index 09b9620..923aecd 100644
17423--- a/arch/x86/include/asm/mmu.h
17424+++ b/arch/x86/include/asm/mmu.h
17425@@ -9,7 +9,7 @@
17426 * we put the segment information here.
17427 */
17428 typedef struct {
17429- void *ldt;
17430+ struct desc_struct *ldt;
17431 int size;
17432
17433 #ifdef CONFIG_X86_64
17434@@ -18,7 +18,19 @@ typedef struct {
17435 #endif
17436
17437 struct mutex lock;
17438- void __user *vdso;
17439+ unsigned long vdso;
17440+
17441+#ifdef CONFIG_X86_32
17442+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
17443+ unsigned long user_cs_base;
17444+ unsigned long user_cs_limit;
17445+
17446+#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
17447+ cpumask_t cpu_user_cs_mask;
17448+#endif
17449+
17450+#endif
17451+#endif
17452
17453 atomic_t perf_rdpmc_allowed; /* nonzero if rdpmc is allowed */
17454 } mm_context_t;
17455diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
17456index 883f6b93..bb405b5 100644
17457--- a/arch/x86/include/asm/mmu_context.h
17458+++ b/arch/x86/include/asm/mmu_context.h
17459@@ -42,6 +42,20 @@ void destroy_context(struct mm_struct *mm);
17460
17461 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
17462 {
17463+
17464+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17465+ if (!(static_cpu_has(X86_FEATURE_PCID))) {
17466+ unsigned int i;
17467+ pgd_t *pgd;
17468+
17469+ pax_open_kernel();
17470+ pgd = get_cpu_pgd(smp_processor_id(), kernel);
17471+ for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
17472+ set_pgd_batched(pgd+i, native_make_pgd(0));
17473+ pax_close_kernel();
17474+ }
17475+#endif
17476+
17477 #ifdef CONFIG_SMP
17478 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
17479 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
17480@@ -52,16 +66,59 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
17481 struct task_struct *tsk)
17482 {
17483 unsigned cpu = smp_processor_id();
17484+#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
17485+ int tlbstate = TLBSTATE_OK;
17486+#endif
17487
17488 if (likely(prev != next)) {
17489 #ifdef CONFIG_SMP
17490+#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
17491+ tlbstate = this_cpu_read(cpu_tlbstate.state);
17492+#endif
17493 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
17494 this_cpu_write(cpu_tlbstate.active_mm, next);
17495 #endif
17496 cpumask_set_cpu(cpu, mm_cpumask(next));
17497
17498 /* Re-load page tables */
17499+#ifdef CONFIG_PAX_PER_CPU_PGD
17500+ pax_open_kernel();
17501+
17502+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17503+ if (static_cpu_has(X86_FEATURE_PCID))
17504+ __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
17505+ else
17506+#endif
17507+
17508+ __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
17509+ __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
17510+ pax_close_kernel();
17511+ 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));
17512+
17513+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17514+ if (static_cpu_has(X86_FEATURE_PCID)) {
17515+ if (static_cpu_has(X86_FEATURE_INVPCID)) {
17516+ u64 descriptor[2];
17517+ descriptor[0] = PCID_USER;
17518+ asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
17519+ if (!static_cpu_has(X86_FEATURE_STRONGUDEREF)) {
17520+ descriptor[0] = PCID_KERNEL;
17521+ asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
17522+ }
17523+ } else {
17524+ write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
17525+ if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
17526+ write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
17527+ else
17528+ write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
17529+ }
17530+ } else
17531+#endif
17532+
17533+ load_cr3(get_cpu_pgd(cpu, kernel));
17534+#else
17535 load_cr3(next->pgd);
17536+#endif
17537 trace_tlb_flush(TLB_FLUSH_ON_TASK_SWITCH, TLB_FLUSH_ALL);
17538
17539 /* Stop flush ipis for the previous mm */
17540@@ -84,9 +141,67 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
17541 */
17542 if (unlikely(prev->context.ldt != next->context.ldt))
17543 load_LDT_nolock(&next->context);
17544+
17545+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
17546+ if (!(__supported_pte_mask & _PAGE_NX)) {
17547+ smp_mb__before_atomic();
17548+ cpumask_clear_cpu(cpu, &prev->context.cpu_user_cs_mask);
17549+ smp_mb__after_atomic();
17550+ cpumask_set_cpu(cpu, &next->context.cpu_user_cs_mask);
17551+ }
17552+#endif
17553+
17554+#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
17555+ if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
17556+ prev->context.user_cs_limit != next->context.user_cs_limit))
17557+ set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
17558+#ifdef CONFIG_SMP
17559+ else if (unlikely(tlbstate != TLBSTATE_OK))
17560+ set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
17561+#endif
17562+#endif
17563+
17564 }
17565+ else {
17566+
17567+#ifdef CONFIG_PAX_PER_CPU_PGD
17568+ pax_open_kernel();
17569+
17570+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17571+ if (static_cpu_has(X86_FEATURE_PCID))
17572+ __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
17573+ else
17574+#endif
17575+
17576+ __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
17577+ __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
17578+ pax_close_kernel();
17579+ 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));
17580+
17581+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17582+ if (static_cpu_has(X86_FEATURE_PCID)) {
17583+ if (static_cpu_has(X86_FEATURE_INVPCID)) {
17584+ u64 descriptor[2];
17585+ descriptor[0] = PCID_USER;
17586+ asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
17587+ if (!static_cpu_has(X86_FEATURE_STRONGUDEREF)) {
17588+ descriptor[0] = PCID_KERNEL;
17589+ asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
17590+ }
17591+ } else {
17592+ write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
17593+ if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
17594+ write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
17595+ else
17596+ write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
17597+ }
17598+ } else
17599+#endif
17600+
17601+ load_cr3(get_cpu_pgd(cpu, kernel));
17602+#endif
17603+
17604 #ifdef CONFIG_SMP
17605- else {
17606 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
17607 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
17608
17609@@ -103,13 +218,30 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
17610 * tlb flush IPI delivery. We must reload CR3
17611 * to make sure to use no freed page tables.
17612 */
17613+
17614+#ifndef CONFIG_PAX_PER_CPU_PGD
17615 load_cr3(next->pgd);
17616 trace_tlb_flush(TLB_FLUSH_ON_TASK_SWITCH, TLB_FLUSH_ALL);
17617+#endif
17618+
17619 load_mm_cr4(next);
17620 load_LDT_nolock(&next->context);
17621+
17622+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
17623+ if (!(__supported_pte_mask & _PAGE_NX))
17624+ cpumask_set_cpu(cpu, &next->context.cpu_user_cs_mask);
17625+#endif
17626+
17627+#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
17628+#ifdef CONFIG_PAX_PAGEEXEC
17629+ if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
17630+#endif
17631+ set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
17632+#endif
17633+
17634 }
17635+#endif
17636 }
17637-#endif
17638 }
17639
17640 #define activate_mm(prev, next) \
17641diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
17642index e3b7819..b257c64 100644
17643--- a/arch/x86/include/asm/module.h
17644+++ b/arch/x86/include/asm/module.h
17645@@ -5,6 +5,7 @@
17646
17647 #ifdef CONFIG_X86_64
17648 /* X86_64 does not define MODULE_PROC_FAMILY */
17649+#define MODULE_PROC_FAMILY ""
17650 #elif defined CONFIG_M486
17651 #define MODULE_PROC_FAMILY "486 "
17652 #elif defined CONFIG_M586
17653@@ -57,8 +58,20 @@
17654 #error unknown processor family
17655 #endif
17656
17657-#ifdef CONFIG_X86_32
17658-# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
17659+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
17660+#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
17661+#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
17662+#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
17663+#else
17664+#define MODULE_PAX_KERNEXEC ""
17665 #endif
17666
17667+#ifdef CONFIG_PAX_MEMORY_UDEREF
17668+#define MODULE_PAX_UDEREF "UDEREF "
17669+#else
17670+#define MODULE_PAX_UDEREF ""
17671+#endif
17672+
17673+#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
17674+
17675 #endif /* _ASM_X86_MODULE_H */
17676diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
17677index 5f2fc44..106caa6 100644
17678--- a/arch/x86/include/asm/nmi.h
17679+++ b/arch/x86/include/asm/nmi.h
17680@@ -36,26 +36,35 @@ enum {
17681
17682 typedef int (*nmi_handler_t)(unsigned int, struct pt_regs *);
17683
17684+struct nmiaction;
17685+
17686+struct nmiwork {
17687+ const struct nmiaction *action;
17688+ u64 max_duration;
17689+ struct irq_work irq_work;
17690+};
17691+
17692 struct nmiaction {
17693 struct list_head list;
17694 nmi_handler_t handler;
17695- u64 max_duration;
17696- struct irq_work irq_work;
17697 unsigned long flags;
17698 const char *name;
17699-};
17700+ struct nmiwork *work;
17701+} __do_const;
17702
17703 #define register_nmi_handler(t, fn, fg, n, init...) \
17704 ({ \
17705- static struct nmiaction init fn##_na = { \
17706+ static struct nmiwork fn##_nw; \
17707+ static const struct nmiaction init fn##_na = { \
17708 .handler = (fn), \
17709 .name = (n), \
17710 .flags = (fg), \
17711+ .work = &fn##_nw, \
17712 }; \
17713 __register_nmi_handler((t), &fn##_na); \
17714 })
17715
17716-int __register_nmi_handler(unsigned int, struct nmiaction *);
17717+int __register_nmi_handler(unsigned int, const struct nmiaction *);
17718
17719 void unregister_nmi_handler(unsigned int, const char *);
17720
17721diff --git a/arch/x86/include/asm/page.h b/arch/x86/include/asm/page.h
17722index 802dde3..9183e68 100644
17723--- a/arch/x86/include/asm/page.h
17724+++ b/arch/x86/include/asm/page.h
17725@@ -52,6 +52,7 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
17726 __phys_addr_symbol(__phys_reloc_hide((unsigned long)(x)))
17727
17728 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
17729+#define __early_va(x) ((void *)((unsigned long)(x)+__START_KERNEL_map - phys_base))
17730
17731 #define __boot_va(x) __va(x)
17732 #define __boot_pa(x) __pa(x)
17733@@ -60,11 +61,21 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
17734 * virt_to_page(kaddr) returns a valid pointer if and only if
17735 * virt_addr_valid(kaddr) returns true.
17736 */
17737-#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
17738 #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
17739 extern bool __virt_addr_valid(unsigned long kaddr);
17740 #define virt_addr_valid(kaddr) __virt_addr_valid((unsigned long) (kaddr))
17741
17742+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
17743+#define virt_to_page(kaddr) \
17744+ ({ \
17745+ const void *__kaddr = (const void *)(kaddr); \
17746+ BUG_ON(!virt_addr_valid(__kaddr)); \
17747+ pfn_to_page(__pa(__kaddr) >> PAGE_SHIFT); \
17748+ })
17749+#else
17750+#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
17751+#endif
17752+
17753 #endif /* __ASSEMBLY__ */
17754
17755 #include <asm-generic/memory_model.h>
17756diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
17757index b3bebf9..13ac22e 100644
17758--- a/arch/x86/include/asm/page_64.h
17759+++ b/arch/x86/include/asm/page_64.h
17760@@ -7,9 +7,9 @@
17761
17762 /* duplicated to the one in bootmem.h */
17763 extern unsigned long max_pfn;
17764-extern unsigned long phys_base;
17765+extern const unsigned long phys_base;
17766
17767-static inline unsigned long __phys_addr_nodebug(unsigned long x)
17768+static inline unsigned long __intentional_overflow(-1) __phys_addr_nodebug(unsigned long x)
17769 {
17770 unsigned long y = x - __START_KERNEL_map;
17771
17772@@ -20,8 +20,8 @@ static inline unsigned long __phys_addr_nodebug(unsigned long x)
17773 }
17774
17775 #ifdef CONFIG_DEBUG_VIRTUAL
17776-extern unsigned long __phys_addr(unsigned long);
17777-extern unsigned long __phys_addr_symbol(unsigned long);
17778+extern unsigned long __intentional_overflow(-1) __phys_addr(unsigned long);
17779+extern unsigned long __intentional_overflow(-1) __phys_addr_symbol(unsigned long);
17780 #else
17781 #define __phys_addr(x) __phys_addr_nodebug(x)
17782 #define __phys_addr_symbol(x) \
17783diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
17784index 8957810..f34efb4 100644
17785--- a/arch/x86/include/asm/paravirt.h
17786+++ b/arch/x86/include/asm/paravirt.h
17787@@ -560,7 +560,7 @@ static inline pmd_t __pmd(pmdval_t val)
17788 return (pmd_t) { ret };
17789 }
17790
17791-static inline pmdval_t pmd_val(pmd_t pmd)
17792+static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
17793 {
17794 pmdval_t ret;
17795
17796@@ -626,6 +626,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
17797 val);
17798 }
17799
17800+static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
17801+{
17802+ pgdval_t val = native_pgd_val(pgd);
17803+
17804+ if (sizeof(pgdval_t) > sizeof(long))
17805+ PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
17806+ val, (u64)val >> 32);
17807+ else
17808+ PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
17809+ val);
17810+}
17811+
17812 static inline void pgd_clear(pgd_t *pgdp)
17813 {
17814 set_pgd(pgdp, __pgd(0));
17815@@ -710,6 +722,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
17816 pv_mmu_ops.set_fixmap(idx, phys, flags);
17817 }
17818
17819+#ifdef CONFIG_PAX_KERNEXEC
17820+static inline unsigned long pax_open_kernel(void)
17821+{
17822+ return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
17823+}
17824+
17825+static inline unsigned long pax_close_kernel(void)
17826+{
17827+ return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
17828+}
17829+#else
17830+static inline unsigned long pax_open_kernel(void) { return 0; }
17831+static inline unsigned long pax_close_kernel(void) { return 0; }
17832+#endif
17833+
17834 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
17835
17836 static __always_inline void __ticket_lock_spinning(struct arch_spinlock *lock,
17837@@ -906,7 +933,7 @@ extern void default_banner(void);
17838
17839 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
17840 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
17841-#define PARA_INDIRECT(addr) *%cs:addr
17842+#define PARA_INDIRECT(addr) *%ss:addr
17843 #endif
17844
17845 #define INTERRUPT_RETURN \
17846@@ -976,6 +1003,21 @@ extern void default_banner(void);
17847 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_usergs_sysret64), \
17848 CLBR_NONE, \
17849 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_usergs_sysret64))
17850+
17851+#define GET_CR0_INTO_RDI \
17852+ call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
17853+ mov %rax,%rdi
17854+
17855+#define SET_RDI_INTO_CR0 \
17856+ call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
17857+
17858+#define GET_CR3_INTO_RDI \
17859+ call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
17860+ mov %rax,%rdi
17861+
17862+#define SET_RDI_INTO_CR3 \
17863+ call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
17864+
17865 #endif /* CONFIG_X86_32 */
17866
17867 #endif /* __ASSEMBLY__ */
17868diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
17869index f7b0b5c..cdd33f9 100644
17870--- a/arch/x86/include/asm/paravirt_types.h
17871+++ b/arch/x86/include/asm/paravirt_types.h
17872@@ -84,7 +84,7 @@ struct pv_init_ops {
17873 */
17874 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
17875 unsigned long addr, unsigned len);
17876-};
17877+} __no_const __no_randomize_layout;
17878
17879
17880 struct pv_lazy_ops {
17881@@ -92,13 +92,13 @@ struct pv_lazy_ops {
17882 void (*enter)(void);
17883 void (*leave)(void);
17884 void (*flush)(void);
17885-};
17886+} __no_randomize_layout;
17887
17888 struct pv_time_ops {
17889 unsigned long long (*sched_clock)(void);
17890 unsigned long long (*steal_clock)(int cpu);
17891 unsigned long (*get_tsc_khz)(void);
17892-};
17893+} __no_const __no_randomize_layout;
17894
17895 struct pv_cpu_ops {
17896 /* hooks for various privileged instructions */
17897@@ -192,7 +192,7 @@ struct pv_cpu_ops {
17898
17899 void (*start_context_switch)(struct task_struct *prev);
17900 void (*end_context_switch)(struct task_struct *next);
17901-};
17902+} __no_const __no_randomize_layout;
17903
17904 struct pv_irq_ops {
17905 /*
17906@@ -215,7 +215,7 @@ struct pv_irq_ops {
17907 #ifdef CONFIG_X86_64
17908 void (*adjust_exception_frame)(void);
17909 #endif
17910-};
17911+} __no_randomize_layout;
17912
17913 struct pv_apic_ops {
17914 #ifdef CONFIG_X86_LOCAL_APIC
17915@@ -223,7 +223,7 @@ struct pv_apic_ops {
17916 unsigned long start_eip,
17917 unsigned long start_esp);
17918 #endif
17919-};
17920+} __no_const __no_randomize_layout;
17921
17922 struct pv_mmu_ops {
17923 unsigned long (*read_cr2)(void);
17924@@ -313,6 +313,7 @@ struct pv_mmu_ops {
17925 struct paravirt_callee_save make_pud;
17926
17927 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
17928+ void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
17929 #endif /* CONFIG_PGTABLE_LEVELS == 4 */
17930 #endif /* CONFIG_PGTABLE_LEVELS >= 3 */
17931
17932@@ -324,7 +325,13 @@ struct pv_mmu_ops {
17933 an mfn. We can tell which is which from the index. */
17934 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
17935 phys_addr_t phys, pgprot_t flags);
17936-};
17937+
17938+#ifdef CONFIG_PAX_KERNEXEC
17939+ unsigned long (*pax_open_kernel)(void);
17940+ unsigned long (*pax_close_kernel)(void);
17941+#endif
17942+
17943+} __no_randomize_layout;
17944
17945 struct arch_spinlock;
17946 #ifdef CONFIG_SMP
17947@@ -336,11 +343,14 @@ typedef u16 __ticket_t;
17948 struct pv_lock_ops {
17949 struct paravirt_callee_save lock_spinning;
17950 void (*unlock_kick)(struct arch_spinlock *lock, __ticket_t ticket);
17951-};
17952+} __no_randomize_layout;
17953
17954 /* This contains all the paravirt structures: we get a convenient
17955 * number for each function using the offset which we use to indicate
17956- * what to patch. */
17957+ * what to patch.
17958+ * shouldn't be randomized due to the "NEAT TRICK" in paravirt.c
17959+ */
17960+
17961 struct paravirt_patch_template {
17962 struct pv_init_ops pv_init_ops;
17963 struct pv_time_ops pv_time_ops;
17964@@ -349,7 +359,7 @@ struct paravirt_patch_template {
17965 struct pv_apic_ops pv_apic_ops;
17966 struct pv_mmu_ops pv_mmu_ops;
17967 struct pv_lock_ops pv_lock_ops;
17968-};
17969+} __no_randomize_layout;
17970
17971 extern struct pv_info pv_info;
17972 extern struct pv_init_ops pv_init_ops;
17973diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
17974index bf7f8b5..ca5799d 100644
17975--- a/arch/x86/include/asm/pgalloc.h
17976+++ b/arch/x86/include/asm/pgalloc.h
17977@@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
17978 pmd_t *pmd, pte_t *pte)
17979 {
17980 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
17981+ set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
17982+}
17983+
17984+static inline void pmd_populate_user(struct mm_struct *mm,
17985+ pmd_t *pmd, pte_t *pte)
17986+{
17987+ paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
17988 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
17989 }
17990
17991@@ -108,12 +115,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
17992
17993 #ifdef CONFIG_X86_PAE
17994 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
17995+static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
17996+{
17997+ pud_populate(mm, pudp, pmd);
17998+}
17999 #else /* !CONFIG_X86_PAE */
18000 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
18001 {
18002 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
18003 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
18004 }
18005+
18006+static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
18007+{
18008+ paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
18009+ set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
18010+}
18011 #endif /* CONFIG_X86_PAE */
18012
18013 #if CONFIG_PGTABLE_LEVELS > 3
18014@@ -123,6 +140,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
18015 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
18016 }
18017
18018+static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
18019+{
18020+ paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
18021+ set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
18022+}
18023+
18024 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
18025 {
18026 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
18027diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
18028index fd74a11..35fd5af 100644
18029--- a/arch/x86/include/asm/pgtable-2level.h
18030+++ b/arch/x86/include/asm/pgtable-2level.h
18031@@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
18032
18033 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
18034 {
18035+ pax_open_kernel();
18036 *pmdp = pmd;
18037+ pax_close_kernel();
18038 }
18039
18040 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
18041diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
18042index cdaa58c..e61122b 100644
18043--- a/arch/x86/include/asm/pgtable-3level.h
18044+++ b/arch/x86/include/asm/pgtable-3level.h
18045@@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
18046
18047 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
18048 {
18049+ pax_open_kernel();
18050 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
18051+ pax_close_kernel();
18052 }
18053
18054 static inline void native_set_pud(pud_t *pudp, pud_t pud)
18055 {
18056+ pax_open_kernel();
18057 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
18058+ pax_close_kernel();
18059 }
18060
18061 /*
18062diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
18063index fe57e7a..0573d42 100644
18064--- a/arch/x86/include/asm/pgtable.h
18065+++ b/arch/x86/include/asm/pgtable.h
18066@@ -47,6 +47,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
18067
18068 #ifndef __PAGETABLE_PUD_FOLDED
18069 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
18070+#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
18071 #define pgd_clear(pgd) native_pgd_clear(pgd)
18072 #endif
18073
18074@@ -84,12 +85,53 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
18075
18076 #define arch_end_context_switch(prev) do {} while(0)
18077
18078+#define pax_open_kernel() native_pax_open_kernel()
18079+#define pax_close_kernel() native_pax_close_kernel()
18080 #endif /* CONFIG_PARAVIRT */
18081
18082+#define __HAVE_ARCH_PAX_OPEN_KERNEL
18083+#define __HAVE_ARCH_PAX_CLOSE_KERNEL
18084+
18085+#ifdef CONFIG_PAX_KERNEXEC
18086+static inline unsigned long native_pax_open_kernel(void)
18087+{
18088+ unsigned long cr0;
18089+
18090+ preempt_disable();
18091+ barrier();
18092+ cr0 = read_cr0() ^ X86_CR0_WP;
18093+ BUG_ON(cr0 & X86_CR0_WP);
18094+ write_cr0(cr0);
18095+ barrier();
18096+ return cr0 ^ X86_CR0_WP;
18097+}
18098+
18099+static inline unsigned long native_pax_close_kernel(void)
18100+{
18101+ unsigned long cr0;
18102+
18103+ barrier();
18104+ cr0 = read_cr0() ^ X86_CR0_WP;
18105+ BUG_ON(!(cr0 & X86_CR0_WP));
18106+ write_cr0(cr0);
18107+ barrier();
18108+ preempt_enable_no_resched();
18109+ return cr0 ^ X86_CR0_WP;
18110+}
18111+#else
18112+static inline unsigned long native_pax_open_kernel(void) { return 0; }
18113+static inline unsigned long native_pax_close_kernel(void) { return 0; }
18114+#endif
18115+
18116 /*
18117 * The following only work if pte_present() is true.
18118 * Undefined behaviour if not..
18119 */
18120+static inline int pte_user(pte_t pte)
18121+{
18122+ return pte_val(pte) & _PAGE_USER;
18123+}
18124+
18125 static inline int pte_dirty(pte_t pte)
18126 {
18127 return pte_flags(pte) & _PAGE_DIRTY;
18128@@ -150,6 +192,11 @@ static inline unsigned long pud_pfn(pud_t pud)
18129 return (pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT;
18130 }
18131
18132+static inline unsigned long pgd_pfn(pgd_t pgd)
18133+{
18134+ return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT;
18135+}
18136+
18137 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
18138
18139 static inline int pmd_large(pmd_t pte)
18140@@ -203,9 +250,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
18141 return pte_clear_flags(pte, _PAGE_RW);
18142 }
18143
18144+static inline pte_t pte_mkread(pte_t pte)
18145+{
18146+ return __pte(pte_val(pte) | _PAGE_USER);
18147+}
18148+
18149 static inline pte_t pte_mkexec(pte_t pte)
18150 {
18151- return pte_clear_flags(pte, _PAGE_NX);
18152+#ifdef CONFIG_X86_PAE
18153+ if (__supported_pte_mask & _PAGE_NX)
18154+ return pte_clear_flags(pte, _PAGE_NX);
18155+ else
18156+#endif
18157+ return pte_set_flags(pte, _PAGE_USER);
18158+}
18159+
18160+static inline pte_t pte_exprotect(pte_t pte)
18161+{
18162+#ifdef CONFIG_X86_PAE
18163+ if (__supported_pte_mask & _PAGE_NX)
18164+ return pte_set_flags(pte, _PAGE_NX);
18165+ else
18166+#endif
18167+ return pte_clear_flags(pte, _PAGE_USER);
18168 }
18169
18170 static inline pte_t pte_mkdirty(pte_t pte)
18171@@ -420,6 +487,16 @@ pte_t *populate_extra_pte(unsigned long vaddr);
18172 #endif
18173
18174 #ifndef __ASSEMBLY__
18175+
18176+#ifdef CONFIG_PAX_PER_CPU_PGD
18177+extern pgd_t cpu_pgd[NR_CPUS][2][PTRS_PER_PGD];
18178+enum cpu_pgd_type {kernel = 0, user = 1};
18179+static inline pgd_t *get_cpu_pgd(unsigned int cpu, enum cpu_pgd_type type)
18180+{
18181+ return cpu_pgd[cpu][type];
18182+}
18183+#endif
18184+
18185 #include <linux/mm_types.h>
18186 #include <linux/mmdebug.h>
18187 #include <linux/log2.h>
18188@@ -571,7 +648,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
18189 * Currently stuck as a macro due to indirect forward reference to
18190 * linux/mmzone.h's __section_mem_map_addr() definition:
18191 */
18192-#define pud_page(pud) pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
18193+#define pud_page(pud) pfn_to_page((pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT)
18194
18195 /* Find an entry in the second-level page table.. */
18196 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
18197@@ -611,7 +688,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
18198 * Currently stuck as a macro due to indirect forward reference to
18199 * linux/mmzone.h's __section_mem_map_addr() definition:
18200 */
18201-#define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)
18202+#define pgd_page(pgd) pfn_to_page((pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT)
18203
18204 /* to find an entry in a page-table-directory. */
18205 static inline unsigned long pud_index(unsigned long address)
18206@@ -626,7 +703,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
18207
18208 static inline int pgd_bad(pgd_t pgd)
18209 {
18210- return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
18211+ return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
18212 }
18213
18214 static inline int pgd_none(pgd_t pgd)
18215@@ -649,7 +726,12 @@ static inline int pgd_none(pgd_t pgd)
18216 * pgd_offset() returns a (pgd_t *)
18217 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
18218 */
18219-#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
18220+#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
18221+
18222+#ifdef CONFIG_PAX_PER_CPU_PGD
18223+#define pgd_offset_cpu(cpu, type, address) (get_cpu_pgd(cpu, type) + pgd_index(address))
18224+#endif
18225+
18226 /*
18227 * a shortcut which implies the use of the kernel's pgd, instead
18228 * of a process's
18229@@ -660,6 +742,25 @@ static inline int pgd_none(pgd_t pgd)
18230 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
18231 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
18232
18233+#ifdef CONFIG_X86_32
18234+#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
18235+#else
18236+#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
18237+#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
18238+
18239+#ifdef CONFIG_PAX_MEMORY_UDEREF
18240+#ifdef __ASSEMBLY__
18241+#define pax_user_shadow_base pax_user_shadow_base(%rip)
18242+#else
18243+extern unsigned long pax_user_shadow_base;
18244+extern pgdval_t clone_pgd_mask;
18245+#endif
18246+#else
18247+#define pax_user_shadow_base (0UL)
18248+#endif
18249+
18250+#endif
18251+
18252 #ifndef __ASSEMBLY__
18253
18254 extern int direct_gbpages;
18255@@ -826,11 +927,24 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
18256 * dst and src can be on the same page, but the range must not overlap,
18257 * and must not cross a page boundary.
18258 */
18259-static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
18260+static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
18261 {
18262- memcpy(dst, src, count * sizeof(pgd_t));
18263+ pax_open_kernel();
18264+ while (count--)
18265+ *dst++ = *src++;
18266+ pax_close_kernel();
18267 }
18268
18269+#ifdef CONFIG_PAX_PER_CPU_PGD
18270+extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
18271+#endif
18272+
18273+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18274+extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
18275+#else
18276+static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
18277+#endif
18278+
18279 #define PTE_SHIFT ilog2(PTRS_PER_PTE)
18280 static inline int page_level_shift(enum pg_level level)
18281 {
18282diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
18283index b6c0b40..3535d47 100644
18284--- a/arch/x86/include/asm/pgtable_32.h
18285+++ b/arch/x86/include/asm/pgtable_32.h
18286@@ -25,9 +25,6 @@
18287 struct mm_struct;
18288 struct vm_area_struct;
18289
18290-extern pgd_t swapper_pg_dir[1024];
18291-extern pgd_t initial_page_table[1024];
18292-
18293 static inline void pgtable_cache_init(void) { }
18294 static inline void check_pgt_cache(void) { }
18295 void paging_init(void);
18296@@ -45,6 +42,12 @@ void paging_init(void);
18297 # include <asm/pgtable-2level.h>
18298 #endif
18299
18300+extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
18301+extern pgd_t initial_page_table[PTRS_PER_PGD];
18302+#ifdef CONFIG_X86_PAE
18303+extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
18304+#endif
18305+
18306 #if defined(CONFIG_HIGHPTE)
18307 #define pte_offset_map(dir, address) \
18308 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
18309@@ -59,12 +62,17 @@ void paging_init(void);
18310 /* Clear a kernel PTE and flush it from the TLB */
18311 #define kpte_clear_flush(ptep, vaddr) \
18312 do { \
18313+ pax_open_kernel(); \
18314 pte_clear(&init_mm, (vaddr), (ptep)); \
18315+ pax_close_kernel(); \
18316 __flush_tlb_one((vaddr)); \
18317 } while (0)
18318
18319 #endif /* !__ASSEMBLY__ */
18320
18321+#define HAVE_ARCH_UNMAPPED_AREA
18322+#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
18323+
18324 /*
18325 * kern_addr_valid() is (1) for FLATMEM and (0) for
18326 * SPARSEMEM and DISCONTIGMEM
18327diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
18328index 9fb2f2b..b04b4bf 100644
18329--- a/arch/x86/include/asm/pgtable_32_types.h
18330+++ b/arch/x86/include/asm/pgtable_32_types.h
18331@@ -8,7 +8,7 @@
18332 */
18333 #ifdef CONFIG_X86_PAE
18334 # include <asm/pgtable-3level_types.h>
18335-# define PMD_SIZE (1UL << PMD_SHIFT)
18336+# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
18337 # define PMD_MASK (~(PMD_SIZE - 1))
18338 #else
18339 # include <asm/pgtable-2level_types.h>
18340@@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
18341 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
18342 #endif
18343
18344+#ifdef CONFIG_PAX_KERNEXEC
18345+#ifndef __ASSEMBLY__
18346+extern unsigned char MODULES_EXEC_VADDR[];
18347+extern unsigned char MODULES_EXEC_END[];
18348+#endif
18349+#include <asm/boot.h>
18350+#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
18351+#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
18352+#else
18353+#define ktla_ktva(addr) (addr)
18354+#define ktva_ktla(addr) (addr)
18355+#endif
18356+
18357 #define MODULES_VADDR VMALLOC_START
18358 #define MODULES_END VMALLOC_END
18359 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
18360diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
18361index 2ee7811..55aca24 100644
18362--- a/arch/x86/include/asm/pgtable_64.h
18363+++ b/arch/x86/include/asm/pgtable_64.h
18364@@ -16,11 +16,16 @@
18365
18366 extern pud_t level3_kernel_pgt[512];
18367 extern pud_t level3_ident_pgt[512];
18368+extern pud_t level3_vmalloc_start_pgt[512];
18369+extern pud_t level3_vmalloc_end_pgt[512];
18370+extern pud_t level3_vmemmap_pgt[512];
18371+extern pud_t level2_vmemmap_pgt[512];
18372 extern pmd_t level2_kernel_pgt[512];
18373 extern pmd_t level2_fixmap_pgt[512];
18374-extern pmd_t level2_ident_pgt[512];
18375-extern pte_t level1_fixmap_pgt[512];
18376-extern pgd_t init_level4_pgt[];
18377+extern pmd_t level2_ident_pgt[2][512];
18378+extern pte_t level1_fixmap_pgt[3][512];
18379+extern pte_t level1_vsyscall_pgt[512];
18380+extern pgd_t init_level4_pgt[512];
18381
18382 #define swapper_pg_dir init_level4_pgt
18383
18384@@ -62,7 +67,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
18385
18386 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
18387 {
18388+ pax_open_kernel();
18389 *pmdp = pmd;
18390+ pax_close_kernel();
18391 }
18392
18393 static inline void native_pmd_clear(pmd_t *pmd)
18394@@ -98,7 +105,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
18395
18396 static inline void native_set_pud(pud_t *pudp, pud_t pud)
18397 {
18398+ pax_open_kernel();
18399 *pudp = pud;
18400+ pax_close_kernel();
18401 }
18402
18403 static inline void native_pud_clear(pud_t *pud)
18404@@ -108,6 +117,13 @@ static inline void native_pud_clear(pud_t *pud)
18405
18406 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
18407 {
18408+ pax_open_kernel();
18409+ *pgdp = pgd;
18410+ pax_close_kernel();
18411+}
18412+
18413+static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
18414+{
18415 *pgdp = pgd;
18416 }
18417
18418diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
18419index e6844df..432b56e 100644
18420--- a/arch/x86/include/asm/pgtable_64_types.h
18421+++ b/arch/x86/include/asm/pgtable_64_types.h
18422@@ -60,11 +60,16 @@ typedef struct { pteval_t pte; } pte_t;
18423 #define MODULES_VADDR (__START_KERNEL_map + KERNEL_IMAGE_SIZE)
18424 #define MODULES_END _AC(0xffffffffff000000, UL)
18425 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
18426+#define MODULES_EXEC_VADDR MODULES_VADDR
18427+#define MODULES_EXEC_END MODULES_END
18428 #define ESPFIX_PGD_ENTRY _AC(-2, UL)
18429 #define ESPFIX_BASE_ADDR (ESPFIX_PGD_ENTRY << PGDIR_SHIFT)
18430 #define EFI_VA_START ( -4 * (_AC(1, UL) << 30))
18431 #define EFI_VA_END (-68 * (_AC(1, UL) << 30))
18432
18433+#define ktla_ktva(addr) (addr)
18434+#define ktva_ktla(addr) (addr)
18435+
18436 #define EARLY_DYNAMIC_PAGE_TABLES 64
18437
18438 #endif /* _ASM_X86_PGTABLE_64_DEFS_H */
18439diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
18440index 78f0c8c..4424bb0 100644
18441--- a/arch/x86/include/asm/pgtable_types.h
18442+++ b/arch/x86/include/asm/pgtable_types.h
18443@@ -85,8 +85,10 @@
18444
18445 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
18446 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
18447-#else
18448+#elif defined(CONFIG_KMEMCHECK) || defined(CONFIG_MEM_SOFT_DIRTY)
18449 #define _PAGE_NX (_AT(pteval_t, 0))
18450+#else
18451+#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
18452 #endif
18453
18454 #define _PAGE_PROTNONE (_AT(pteval_t, 1) << _PAGE_BIT_PROTNONE)
18455@@ -141,6 +143,9 @@ enum page_cache_mode {
18456 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
18457 _PAGE_ACCESSED)
18458
18459+#define PAGE_READONLY_NOEXEC PAGE_READONLY
18460+#define PAGE_SHARED_NOEXEC PAGE_SHARED
18461+
18462 #define __PAGE_KERNEL_EXEC \
18463 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
18464 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
18465@@ -148,7 +153,7 @@ enum page_cache_mode {
18466 #define __PAGE_KERNEL_RO (__PAGE_KERNEL & ~_PAGE_RW)
18467 #define __PAGE_KERNEL_RX (__PAGE_KERNEL_EXEC & ~_PAGE_RW)
18468 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_NOCACHE)
18469-#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
18470+#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
18471 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
18472 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
18473 #define __PAGE_KERNEL_LARGE_EXEC (__PAGE_KERNEL_EXEC | _PAGE_PSE)
18474@@ -194,7 +199,7 @@ enum page_cache_mode {
18475 #ifdef CONFIG_X86_64
18476 #define __PAGE_KERNEL_IDENT_LARGE_EXEC __PAGE_KERNEL_LARGE_EXEC
18477 #else
18478-#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
18479+#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
18480 #define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
18481 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
18482 #endif
18483@@ -233,7 +238,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
18484 {
18485 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
18486 }
18487+#endif
18488
18489+#if CONFIG_PGTABLE_LEVELS == 3
18490+#include <asm-generic/pgtable-nopud.h>
18491+#endif
18492+
18493+#if CONFIG_PGTABLE_LEVELS == 2
18494+#include <asm-generic/pgtable-nopmd.h>
18495+#endif
18496+
18497+#ifndef __ASSEMBLY__
18498 #if CONFIG_PGTABLE_LEVELS > 3
18499 typedef struct { pudval_t pud; } pud_t;
18500
18501@@ -247,8 +262,6 @@ static inline pudval_t native_pud_val(pud_t pud)
18502 return pud.pud;
18503 }
18504 #else
18505-#include <asm-generic/pgtable-nopud.h>
18506-
18507 static inline pudval_t native_pud_val(pud_t pud)
18508 {
18509 return native_pgd_val(pud.pgd);
18510@@ -268,8 +281,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
18511 return pmd.pmd;
18512 }
18513 #else
18514-#include <asm-generic/pgtable-nopmd.h>
18515-
18516 static inline pmdval_t native_pmd_val(pmd_t pmd)
18517 {
18518 return native_pgd_val(pmd.pud.pgd);
18519@@ -362,7 +373,6 @@ typedef struct page *pgtable_t;
18520
18521 extern pteval_t __supported_pte_mask;
18522 extern void set_nx(void);
18523-extern int nx_enabled;
18524
18525 #define pgprot_writecombine pgprot_writecombine
18526 extern pgprot_t pgprot_writecombine(pgprot_t prot);
18527diff --git a/arch/x86/include/asm/preempt.h b/arch/x86/include/asm/preempt.h
18528index 8f327184..368fb29 100644
18529--- a/arch/x86/include/asm/preempt.h
18530+++ b/arch/x86/include/asm/preempt.h
18531@@ -84,7 +84,7 @@ static __always_inline void __preempt_count_sub(int val)
18532 */
18533 static __always_inline bool __preempt_count_dec_and_test(void)
18534 {
18535- GEN_UNARY_RMWcc("decl", __preempt_count, __percpu_arg(0), "e");
18536+ GEN_UNARY_RMWcc("decl", "incl", __preempt_count, __percpu_arg(0), "e");
18537 }
18538
18539 /*
18540diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
18541index 23ba676..6584489 100644
18542--- a/arch/x86/include/asm/processor.h
18543+++ b/arch/x86/include/asm/processor.h
18544@@ -130,7 +130,7 @@ struct cpuinfo_x86 {
18545 /* Index into per_cpu list: */
18546 u16 cpu_index;
18547 u32 microcode;
18548-};
18549+} __randomize_layout;
18550
18551 #define X86_VENDOR_INTEL 0
18552 #define X86_VENDOR_CYRIX 1
18553@@ -201,9 +201,21 @@ static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
18554 : "memory");
18555 }
18556
18557+/* invpcid (%rdx),%rax */
18558+#define __ASM_INVPCID ".byte 0x66,0x0f,0x38,0x82,0x02"
18559+
18560+#define INVPCID_SINGLE_ADDRESS 0UL
18561+#define INVPCID_SINGLE_CONTEXT 1UL
18562+#define INVPCID_ALL_GLOBAL 2UL
18563+#define INVPCID_ALL_NONGLOBAL 3UL
18564+
18565+#define PCID_KERNEL 0UL
18566+#define PCID_USER 1UL
18567+#define PCID_NOFLUSH (1UL << 63)
18568+
18569 static inline void load_cr3(pgd_t *pgdir)
18570 {
18571- write_cr3(__pa(pgdir));
18572+ write_cr3(__pa(pgdir) | PCID_KERNEL);
18573 }
18574
18575 #ifdef CONFIG_X86_32
18576@@ -300,7 +312,7 @@ struct tss_struct {
18577
18578 } ____cacheline_aligned;
18579
18580-DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, cpu_tss);
18581+extern struct tss_struct cpu_tss[NR_CPUS];
18582
18583 #ifdef CONFIG_X86_32
18584 DECLARE_PER_CPU(unsigned long, cpu_current_top_of_stack);
18585@@ -500,6 +512,7 @@ struct thread_struct {
18586 unsigned short ds;
18587 unsigned short fsindex;
18588 unsigned short gsindex;
18589+ unsigned short ss;
18590 #endif
18591 #ifdef CONFIG_X86_32
18592 unsigned long ip;
18593@@ -585,10 +598,10 @@ static inline void native_swapgs(void)
18594 #endif
18595 }
18596
18597-static inline unsigned long current_top_of_stack(void)
18598+static inline unsigned long current_top_of_stack(unsigned int cpu)
18599 {
18600 #ifdef CONFIG_X86_64
18601- return this_cpu_read_stable(cpu_tss.x86_tss.sp0);
18602+ return cpu_tss[cpu].x86_tss.sp0;
18603 #else
18604 /* sp0 on x86_32 is special in and around vm86 mode. */
18605 return this_cpu_read_stable(cpu_current_top_of_stack);
18606@@ -837,8 +850,15 @@ static inline void spin_lock_prefetch(const void *x)
18607 */
18608 #define TASK_SIZE PAGE_OFFSET
18609 #define TASK_SIZE_MAX TASK_SIZE
18610+
18611+#ifdef CONFIG_PAX_SEGMEXEC
18612+#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
18613+#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
18614+#else
18615 #define STACK_TOP TASK_SIZE
18616-#define STACK_TOP_MAX STACK_TOP
18617+#endif
18618+
18619+#define STACK_TOP_MAX TASK_SIZE
18620
18621 #define INIT_THREAD { \
18622 .sp0 = TOP_OF_INIT_STACK, \
18623@@ -859,12 +879,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
18624 * "struct pt_regs" is possible, but they may contain the
18625 * completely wrong values.
18626 */
18627-#define task_pt_regs(task) \
18628-({ \
18629- unsigned long __ptr = (unsigned long)task_stack_page(task); \
18630- __ptr += THREAD_SIZE - TOP_OF_KERNEL_STACK_PADDING; \
18631- ((struct pt_regs *)__ptr) - 1; \
18632-})
18633+#define task_pt_regs(tsk) ((struct pt_regs *)(tsk)->thread.sp0 - 1)
18634
18635 #define KSTK_ESP(task) (task_pt_regs(task)->sp)
18636
18637@@ -878,13 +893,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
18638 * particular problem by preventing anything from being mapped
18639 * at the maximum canonical address.
18640 */
18641-#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
18642+#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
18643
18644 /* This decides where the kernel will search for a free chunk of vm
18645 * space during mmap's.
18646 */
18647 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
18648- 0xc0000000 : 0xFFFFe000)
18649+ 0xc0000000 : 0xFFFFf000)
18650
18651 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
18652 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
18653@@ -918,6 +933,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
18654 */
18655 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
18656
18657+#ifdef CONFIG_PAX_SEGMEXEC
18658+#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
18659+#endif
18660+
18661 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
18662
18663 /* Get/set a process' ability to use the timestamp counter instruction */
18664@@ -962,7 +981,7 @@ static inline uint32_t hypervisor_cpuid_base(const char *sig, uint32_t leaves)
18665 return 0;
18666 }
18667
18668-extern unsigned long arch_align_stack(unsigned long sp);
18669+#define arch_align_stack(x) ((x) & ~0xfUL)
18670 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
18671
18672 void default_idle(void);
18673@@ -972,6 +991,6 @@ bool xen_set_default_idle(void);
18674 #define xen_set_default_idle 0
18675 #endif
18676
18677-void stop_this_cpu(void *dummy);
18678+void stop_this_cpu(void *dummy) __noreturn;
18679 void df_debug(struct pt_regs *regs, long error_code);
18680 #endif /* _ASM_X86_PROCESSOR_H */
18681diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
18682index 5fabf13..7388158 100644
18683--- a/arch/x86/include/asm/ptrace.h
18684+++ b/arch/x86/include/asm/ptrace.h
18685@@ -125,15 +125,16 @@ static inline int v8086_mode(struct pt_regs *regs)
18686 #ifdef CONFIG_X86_64
18687 static inline bool user_64bit_mode(struct pt_regs *regs)
18688 {
18689+ unsigned long cs = regs->cs & 0xffff;
18690 #ifndef CONFIG_PARAVIRT
18691 /*
18692 * On non-paravirt systems, this is the only long mode CPL 3
18693 * selector. We do not allow long mode selectors in the LDT.
18694 */
18695- return regs->cs == __USER_CS;
18696+ return cs == __USER_CS;
18697 #else
18698 /* Headers are too twisted for this to go in paravirt.h. */
18699- return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
18700+ return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
18701 #endif
18702 }
18703
18704@@ -180,9 +181,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
18705 * Traps from the kernel do not save sp and ss.
18706 * Use the helper function to retrieve sp.
18707 */
18708- if (offset == offsetof(struct pt_regs, sp) &&
18709- regs->cs == __KERNEL_CS)
18710- return kernel_stack_pointer(regs);
18711+ if (offset == offsetof(struct pt_regs, sp)) {
18712+ unsigned long cs = regs->cs & 0xffff;
18713+ if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
18714+ return kernel_stack_pointer(regs);
18715+ }
18716 #endif
18717 return *(unsigned long *)((unsigned long)regs + offset);
18718 }
18719diff --git a/arch/x86/include/asm/qrwlock.h b/arch/x86/include/asm/qrwlock.h
18720index ae0e241..e80b10b 100644
18721--- a/arch/x86/include/asm/qrwlock.h
18722+++ b/arch/x86/include/asm/qrwlock.h
18723@@ -7,8 +7,8 @@
18724 #define queue_write_unlock queue_write_unlock
18725 static inline void queue_write_unlock(struct qrwlock *lock)
18726 {
18727- barrier();
18728- ACCESS_ONCE(*(u8 *)&lock->cnts) = 0;
18729+ barrier();
18730+ ACCESS_ONCE_RW(*(u8 *)&lock->cnts) = 0;
18731 }
18732 #endif
18733
18734diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
18735index 9c6b890..5305f53 100644
18736--- a/arch/x86/include/asm/realmode.h
18737+++ b/arch/x86/include/asm/realmode.h
18738@@ -22,16 +22,14 @@ struct real_mode_header {
18739 #endif
18740 /* APM/BIOS reboot */
18741 u32 machine_real_restart_asm;
18742-#ifdef CONFIG_X86_64
18743 u32 machine_real_restart_seg;
18744-#endif
18745 };
18746
18747 /* This must match data at trampoline_32/64.S */
18748 struct trampoline_header {
18749 #ifdef CONFIG_X86_32
18750 u32 start;
18751- u16 gdt_pad;
18752+ u16 boot_cs;
18753 u16 gdt_limit;
18754 u32 gdt_base;
18755 #else
18756diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
18757index a82c4f1..ac45053 100644
18758--- a/arch/x86/include/asm/reboot.h
18759+++ b/arch/x86/include/asm/reboot.h
18760@@ -6,13 +6,13 @@
18761 struct pt_regs;
18762
18763 struct machine_ops {
18764- void (*restart)(char *cmd);
18765- void (*halt)(void);
18766- void (*power_off)(void);
18767+ void (* __noreturn restart)(char *cmd);
18768+ void (* __noreturn halt)(void);
18769+ void (* __noreturn power_off)(void);
18770 void (*shutdown)(void);
18771 void (*crash_shutdown)(struct pt_regs *);
18772- void (*emergency_restart)(void);
18773-};
18774+ void (* __noreturn emergency_restart)(void);
18775+} __no_const;
18776
18777 extern struct machine_ops machine_ops;
18778
18779diff --git a/arch/x86/include/asm/rmwcc.h b/arch/x86/include/asm/rmwcc.h
18780index 8f7866a..e442f20 100644
18781--- a/arch/x86/include/asm/rmwcc.h
18782+++ b/arch/x86/include/asm/rmwcc.h
18783@@ -3,7 +3,34 @@
18784
18785 #ifdef CC_HAVE_ASM_GOTO
18786
18787-#define __GEN_RMWcc(fullop, var, cc, ...) \
18788+#ifdef CONFIG_PAX_REFCOUNT
18789+#define __GEN_RMWcc(fullop, fullantiop, var, cc, ...) \
18790+do { \
18791+ asm_volatile_goto (fullop \
18792+ ";jno 0f\n" \
18793+ fullantiop \
18794+ ";int $4\n0:\n" \
18795+ _ASM_EXTABLE(0b, 0b) \
18796+ ";j" cc " %l[cc_label]" \
18797+ : : "m" (var), ## __VA_ARGS__ \
18798+ : "memory" : cc_label); \
18799+ return 0; \
18800+cc_label: \
18801+ return 1; \
18802+} while (0)
18803+#else
18804+#define __GEN_RMWcc(fullop, fullantiop, var, cc, ...) \
18805+do { \
18806+ asm_volatile_goto (fullop ";j" cc " %l[cc_label]" \
18807+ : : "m" (var), ## __VA_ARGS__ \
18808+ : "memory" : cc_label); \
18809+ return 0; \
18810+cc_label: \
18811+ return 1; \
18812+} while (0)
18813+#endif
18814+
18815+#define __GEN_RMWcc_unchecked(fullop, var, cc, ...) \
18816 do { \
18817 asm_volatile_goto (fullop "; j" cc " %l[cc_label]" \
18818 : : "m" (var), ## __VA_ARGS__ \
18819@@ -13,15 +40,46 @@ cc_label: \
18820 return 1; \
18821 } while (0)
18822
18823-#define GEN_UNARY_RMWcc(op, var, arg0, cc) \
18824- __GEN_RMWcc(op " " arg0, var, cc)
18825+#define GEN_UNARY_RMWcc(op, antiop, var, arg0, cc) \
18826+ __GEN_RMWcc(op " " arg0, antiop " " arg0, var, cc)
18827
18828-#define GEN_BINARY_RMWcc(op, var, vcon, val, arg0, cc) \
18829- __GEN_RMWcc(op " %1, " arg0, var, cc, vcon (val))
18830+#define GEN_UNARY_RMWcc_unchecked(op, var, arg0, cc) \
18831+ __GEN_RMWcc_unchecked(op " " arg0, var, cc)
18832+
18833+#define GEN_BINARY_RMWcc(op, antiop, var, vcon, val, arg0, cc) \
18834+ __GEN_RMWcc(op " %1, " arg0, antiop " %1, " arg0, var, cc, vcon (val))
18835+
18836+#define GEN_BINARY_RMWcc_unchecked(op, var, vcon, val, arg0, cc) \
18837+ __GEN_RMWcc_unchecked(op " %1, " arg0, var, cc, vcon (val))
18838
18839 #else /* !CC_HAVE_ASM_GOTO */
18840
18841-#define __GEN_RMWcc(fullop, var, cc, ...) \
18842+#ifdef CONFIG_PAX_REFCOUNT
18843+#define __GEN_RMWcc(fullop, fullantiop, var, cc, ...) \
18844+do { \
18845+ char c; \
18846+ asm volatile (fullop \
18847+ ";jno 0f\n" \
18848+ fullantiop \
18849+ ";int $4\n0:\n" \
18850+ _ASM_EXTABLE(0b, 0b) \
18851+ "; set" cc " %1" \
18852+ : "+m" (var), "=qm" (c) \
18853+ : __VA_ARGS__ : "memory"); \
18854+ return c != 0; \
18855+} while (0)
18856+#else
18857+#define __GEN_RMWcc(fullop, fullantiop, var, cc, ...) \
18858+do { \
18859+ char c; \
18860+ asm volatile (fullop "; set" cc " %1" \
18861+ : "+m" (var), "=qm" (c) \
18862+ : __VA_ARGS__ : "memory"); \
18863+ return c != 0; \
18864+} while (0)
18865+#endif
18866+
18867+#define __GEN_RMWcc_unchecked(fullop, var, cc, ...) \
18868 do { \
18869 char c; \
18870 asm volatile (fullop "; set" cc " %1" \
18871@@ -30,11 +88,17 @@ do { \
18872 return c != 0; \
18873 } while (0)
18874
18875-#define GEN_UNARY_RMWcc(op, var, arg0, cc) \
18876- __GEN_RMWcc(op " " arg0, var, cc)
18877+#define GEN_UNARY_RMWcc(op, antiop, var, arg0, cc) \
18878+ __GEN_RMWcc(op " " arg0, antiop " " arg0, var, cc)
18879+
18880+#define GEN_UNARY_RMWcc_unchecked(op, var, arg0, cc) \
18881+ __GEN_RMWcc_unchecked(op " " arg0, var, cc)
18882+
18883+#define GEN_BINARY_RMWcc(op, antiop, var, vcon, val, arg0, cc) \
18884+ __GEN_RMWcc(op " %2, " arg0, antiop " %2, " arg0, var, cc, vcon (val))
18885
18886-#define GEN_BINARY_RMWcc(op, var, vcon, val, arg0, cc) \
18887- __GEN_RMWcc(op " %2, " arg0, var, cc, vcon (val))
18888+#define GEN_BINARY_RMWcc_unchecked(op, var, vcon, val, arg0, cc) \
18889+ __GEN_RMWcc_unchecked(op " %2, " arg0, var, cc, vcon (val))
18890
18891 #endif /* CC_HAVE_ASM_GOTO */
18892
18893diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
18894index cad82c9..2e5c5c1 100644
18895--- a/arch/x86/include/asm/rwsem.h
18896+++ b/arch/x86/include/asm/rwsem.h
18897@@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
18898 {
18899 asm volatile("# beginning down_read\n\t"
18900 LOCK_PREFIX _ASM_INC "(%1)\n\t"
18901+
18902+#ifdef CONFIG_PAX_REFCOUNT
18903+ "jno 0f\n"
18904+ LOCK_PREFIX _ASM_DEC "(%1)\n"
18905+ "int $4\n0:\n"
18906+ _ASM_EXTABLE(0b, 0b)
18907+#endif
18908+
18909 /* adds 0x00000001 */
18910 " jns 1f\n"
18911 " call call_rwsem_down_read_failed\n"
18912@@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
18913 "1:\n\t"
18914 " mov %1,%2\n\t"
18915 " add %3,%2\n\t"
18916+
18917+#ifdef CONFIG_PAX_REFCOUNT
18918+ "jno 0f\n"
18919+ "sub %3,%2\n"
18920+ "int $4\n0:\n"
18921+ _ASM_EXTABLE(0b, 0b)
18922+#endif
18923+
18924 " jle 2f\n\t"
18925 LOCK_PREFIX " cmpxchg %2,%0\n\t"
18926 " jnz 1b\n\t"
18927@@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
18928 long tmp;
18929 asm volatile("# beginning down_write\n\t"
18930 LOCK_PREFIX " xadd %1,(%2)\n\t"
18931+
18932+#ifdef CONFIG_PAX_REFCOUNT
18933+ "jno 0f\n"
18934+ "mov %1,(%2)\n"
18935+ "int $4\n0:\n"
18936+ _ASM_EXTABLE(0b, 0b)
18937+#endif
18938+
18939 /* adds 0xffff0001, returns the old value */
18940 " test " __ASM_SEL(%w1,%k1) "," __ASM_SEL(%w1,%k1) "\n\t"
18941 /* was the active mask 0 before? */
18942@@ -155,6 +179,14 @@ static inline void __up_read(struct rw_semaphore *sem)
18943 long tmp;
18944 asm volatile("# beginning __up_read\n\t"
18945 LOCK_PREFIX " xadd %1,(%2)\n\t"
18946+
18947+#ifdef CONFIG_PAX_REFCOUNT
18948+ "jno 0f\n"
18949+ "mov %1,(%2)\n"
18950+ "int $4\n0:\n"
18951+ _ASM_EXTABLE(0b, 0b)
18952+#endif
18953+
18954 /* subtracts 1, returns the old value */
18955 " jns 1f\n\t"
18956 " call call_rwsem_wake\n" /* expects old value in %edx */
18957@@ -173,6 +205,14 @@ static inline void __up_write(struct rw_semaphore *sem)
18958 long tmp;
18959 asm volatile("# beginning __up_write\n\t"
18960 LOCK_PREFIX " xadd %1,(%2)\n\t"
18961+
18962+#ifdef CONFIG_PAX_REFCOUNT
18963+ "jno 0f\n"
18964+ "mov %1,(%2)\n"
18965+ "int $4\n0:\n"
18966+ _ASM_EXTABLE(0b, 0b)
18967+#endif
18968+
18969 /* subtracts 0xffff0001, returns the old value */
18970 " jns 1f\n\t"
18971 " call call_rwsem_wake\n" /* expects old value in %edx */
18972@@ -190,6 +230,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
18973 {
18974 asm volatile("# beginning __downgrade_write\n\t"
18975 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
18976+
18977+#ifdef CONFIG_PAX_REFCOUNT
18978+ "jno 0f\n"
18979+ LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
18980+ "int $4\n0:\n"
18981+ _ASM_EXTABLE(0b, 0b)
18982+#endif
18983+
18984 /*
18985 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
18986 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
18987@@ -208,7 +256,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
18988 */
18989 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
18990 {
18991- asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
18992+ asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
18993+
18994+#ifdef CONFIG_PAX_REFCOUNT
18995+ "jno 0f\n"
18996+ LOCK_PREFIX _ASM_SUB "%1,%0\n"
18997+ "int $4\n0:\n"
18998+ _ASM_EXTABLE(0b, 0b)
18999+#endif
19000+
19001 : "+m" (sem->count)
19002 : "er" (delta));
19003 }
19004@@ -218,7 +274,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
19005 */
19006 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
19007 {
19008- return delta + xadd(&sem->count, delta);
19009+ return delta + xadd_check_overflow(&sem->count, delta);
19010 }
19011
19012 #endif /* __KERNEL__ */
19013diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
19014index 7d5a192..23ef1aa 100644
19015--- a/arch/x86/include/asm/segment.h
19016+++ b/arch/x86/include/asm/segment.h
19017@@ -82,14 +82,20 @@
19018 * 26 - ESPFIX small SS
19019 * 27 - per-cpu [ offset to per-cpu data area ]
19020 * 28 - stack_canary-20 [ for stack protector ] <=== cacheline #8
19021- * 29 - unused
19022- * 30 - unused
19023+ * 29 - PCI BIOS CS
19024+ * 30 - PCI BIOS DS
19025 * 31 - TSS for double fault handler
19026 */
19027+#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
19028+#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
19029+#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
19030+#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
19031+
19032 #define GDT_ENTRY_TLS_MIN 6
19033 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
19034
19035 #define GDT_ENTRY_KERNEL_CS 12
19036+#define GDT_ENTRY_KERNEXEC_KERNEL_CS 4
19037 #define GDT_ENTRY_KERNEL_DS 13
19038 #define GDT_ENTRY_DEFAULT_USER_CS 14
19039 #define GDT_ENTRY_DEFAULT_USER_DS 15
19040@@ -106,6 +112,12 @@
19041 #define GDT_ENTRY_PERCPU 27
19042 #define GDT_ENTRY_STACK_CANARY 28
19043
19044+#define GDT_ENTRY_PCIBIOS_CS 29
19045+#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
19046+
19047+#define GDT_ENTRY_PCIBIOS_DS 30
19048+#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
19049+
19050 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
19051
19052 /*
19053@@ -118,6 +130,7 @@
19054 */
19055
19056 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
19057+#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
19058 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
19059 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8 + 3)
19060 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8 + 3)
19061@@ -129,7 +142,7 @@
19062 #define PNP_CS16 (GDT_ENTRY_PNPBIOS_CS16*8)
19063
19064 /* "Is this PNP code selector (PNP_CS32 or PNP_CS16)?" */
19065-#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == PNP_CS32)
19066+#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
19067
19068 /* data segment for BIOS: */
19069 #define PNP_DS (GDT_ENTRY_PNPBIOS_DS*8)
19070@@ -176,6 +189,8 @@
19071 #define GDT_ENTRY_DEFAULT_USER_DS 5
19072 #define GDT_ENTRY_DEFAULT_USER_CS 6
19073
19074+#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
19075+
19076 /* Needs two entries */
19077 #define GDT_ENTRY_TSS 8
19078 /* Needs two entries */
19079@@ -187,10 +202,12 @@
19080 /* Abused to load per CPU data from limit */
19081 #define GDT_ENTRY_PER_CPU 15
19082
19083+#define GDT_ENTRY_UDEREF_KERNEL_DS 16
19084+
19085 /*
19086 * Number of entries in the GDT table:
19087 */
19088-#define GDT_ENTRIES 16
19089+#define GDT_ENTRIES 17
19090
19091 /*
19092 * Segment selector values corresponding to the above entries:
19093@@ -200,7 +217,9 @@
19094 */
19095 #define __KERNEL32_CS (GDT_ENTRY_KERNEL32_CS*8)
19096 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
19097+#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
19098 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
19099+#define __UDEREF_KERNEL_DS (GDT_ENTRY_UDEREF_KERNEL_DS*8)
19100 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8 + 3)
19101 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8 + 3)
19102 #define __USER32_DS __USER_DS
19103diff --git a/arch/x86/include/asm/smap.h b/arch/x86/include/asm/smap.h
19104index ba665eb..0f72938 100644
19105--- a/arch/x86/include/asm/smap.h
19106+++ b/arch/x86/include/asm/smap.h
19107@@ -25,6 +25,18 @@
19108
19109 #include <asm/alternative-asm.h>
19110
19111+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
19112+#define ASM_PAX_OPEN_USERLAND \
19113+ ALTERNATIVE "", "call __pax_open_userland", X86_FEATURE_STRONGUDEREF
19114+
19115+#define ASM_PAX_CLOSE_USERLAND \
19116+ ALTERNATIVE "", "call __pax_close_userland", X86_FEATURE_STRONGUDEREF
19117+
19118+#else
19119+#define ASM_PAX_OPEN_USERLAND
19120+#define ASM_PAX_CLOSE_USERLAND
19121+#endif
19122+
19123 #ifdef CONFIG_X86_SMAP
19124
19125 #define ASM_CLAC \
19126@@ -44,6 +56,37 @@
19127
19128 #include <asm/alternative.h>
19129
19130+#define __HAVE_ARCH_PAX_OPEN_USERLAND
19131+#define __HAVE_ARCH_PAX_CLOSE_USERLAND
19132+
19133+extern void __pax_open_userland(void);
19134+static __always_inline unsigned long pax_open_userland(void)
19135+{
19136+
19137+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
19138+ asm volatile(ALTERNATIVE("", "call %P[open]", X86_FEATURE_STRONGUDEREF)
19139+ :
19140+ : [open] "i" (__pax_open_userland)
19141+ : "memory", "rax");
19142+#endif
19143+
19144+ return 0;
19145+}
19146+
19147+extern void __pax_close_userland(void);
19148+static __always_inline unsigned long pax_close_userland(void)
19149+{
19150+
19151+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
19152+ asm volatile(ALTERNATIVE("", "call %P[close]", X86_FEATURE_STRONGUDEREF)
19153+ :
19154+ : [close] "i" (__pax_close_userland)
19155+ : "memory", "rax");
19156+#endif
19157+
19158+ return 0;
19159+}
19160+
19161 #ifdef CONFIG_X86_SMAP
19162
19163 static __always_inline void clac(void)
19164diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
19165index 17a8dce..79f7280 100644
19166--- a/arch/x86/include/asm/smp.h
19167+++ b/arch/x86/include/asm/smp.h
19168@@ -35,7 +35,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
19169 /* cpus sharing the last level cache: */
19170 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
19171 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
19172-DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
19173+DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
19174
19175 static inline struct cpumask *cpu_sibling_mask(int cpu)
19176 {
19177@@ -78,7 +78,7 @@ struct smp_ops {
19178
19179 void (*send_call_func_ipi)(const struct cpumask *mask);
19180 void (*send_call_func_single_ipi)(int cpu);
19181-};
19182+} __no_const;
19183
19184 /* Globals due to paravirt */
19185 extern void set_cpu_sibling_map(int cpu);
19186@@ -192,14 +192,8 @@ extern unsigned disabled_cpus;
19187 extern int safe_smp_processor_id(void);
19188
19189 #elif defined(CONFIG_X86_64_SMP)
19190-#define raw_smp_processor_id() (this_cpu_read(cpu_number))
19191-
19192-#define stack_smp_processor_id() \
19193-({ \
19194- struct thread_info *ti; \
19195- __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
19196- ti->cpu; \
19197-})
19198+#define raw_smp_processor_id() (this_cpu_read(cpu_number))
19199+#define stack_smp_processor_id() raw_smp_processor_id()
19200 #define safe_smp_processor_id() smp_processor_id()
19201
19202 #endif
19203diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
19204index 6a99859..03cb807 100644
19205--- a/arch/x86/include/asm/stackprotector.h
19206+++ b/arch/x86/include/asm/stackprotector.h
19207@@ -47,7 +47,7 @@
19208 * head_32 for boot CPU and setup_per_cpu_areas() for others.
19209 */
19210 #define GDT_STACK_CANARY_INIT \
19211- [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
19212+ [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
19213
19214 /*
19215 * Initialize the stackprotector canary value.
19216@@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
19217
19218 static inline void load_stack_canary_segment(void)
19219 {
19220-#ifdef CONFIG_X86_32
19221+#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
19222 asm volatile ("mov %0, %%gs" : : "r" (0));
19223 #endif
19224 }
19225diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
19226index 70bbe39..4ae2bd4 100644
19227--- a/arch/x86/include/asm/stacktrace.h
19228+++ b/arch/x86/include/asm/stacktrace.h
19229@@ -11,28 +11,20 @@
19230
19231 extern int kstack_depth_to_print;
19232
19233-struct thread_info;
19234+struct task_struct;
19235 struct stacktrace_ops;
19236
19237-typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
19238- unsigned long *stack,
19239- unsigned long bp,
19240- const struct stacktrace_ops *ops,
19241- void *data,
19242- unsigned long *end,
19243- int *graph);
19244+typedef unsigned long walk_stack_t(struct task_struct *task,
19245+ void *stack_start,
19246+ unsigned long *stack,
19247+ unsigned long bp,
19248+ const struct stacktrace_ops *ops,
19249+ void *data,
19250+ unsigned long *end,
19251+ int *graph);
19252
19253-extern unsigned long
19254-print_context_stack(struct thread_info *tinfo,
19255- unsigned long *stack, unsigned long bp,
19256- const struct stacktrace_ops *ops, void *data,
19257- unsigned long *end, int *graph);
19258-
19259-extern unsigned long
19260-print_context_stack_bp(struct thread_info *tinfo,
19261- unsigned long *stack, unsigned long bp,
19262- const struct stacktrace_ops *ops, void *data,
19263- unsigned long *end, int *graph);
19264+extern walk_stack_t print_context_stack;
19265+extern walk_stack_t print_context_stack_bp;
19266
19267 /* Generic stack tracer with callbacks */
19268
19269@@ -40,7 +32,7 @@ struct stacktrace_ops {
19270 void (*address)(void *data, unsigned long address, int reliable);
19271 /* On negative return stop dumping */
19272 int (*stack)(void *data, char *name);
19273- walk_stack_t walk_stack;
19274+ walk_stack_t *walk_stack;
19275 };
19276
19277 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
19278diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
19279index 751bf4b..a1278b5 100644
19280--- a/arch/x86/include/asm/switch_to.h
19281+++ b/arch/x86/include/asm/switch_to.h
19282@@ -112,7 +112,7 @@ do { \
19283 "call __switch_to\n\t" \
19284 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
19285 __switch_canary \
19286- "movq %P[thread_info](%%rsi),%%r8\n\t" \
19287+ "movq "__percpu_arg([thread_info])",%%r8\n\t" \
19288 "movq %%rax,%%rdi\n\t" \
19289 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
19290 "jnz ret_from_fork\n\t" \
19291@@ -123,7 +123,7 @@ do { \
19292 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
19293 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
19294 [_tif_fork] "i" (_TIF_FORK), \
19295- [thread_info] "i" (offsetof(struct task_struct, stack)), \
19296+ [thread_info] "m" (current_tinfo), \
19297 [current_task] "m" (current_task) \
19298 __switch_canary_iparam \
19299 : "memory", "cc" __EXTRA_CLOBBER)
19300diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
19301index b4bdec3..e8af9bc 100644
19302--- a/arch/x86/include/asm/thread_info.h
19303+++ b/arch/x86/include/asm/thread_info.h
19304@@ -36,7 +36,7 @@
19305 #ifdef CONFIG_X86_32
19306 # define TOP_OF_KERNEL_STACK_PADDING 8
19307 #else
19308-# define TOP_OF_KERNEL_STACK_PADDING 0
19309+# define TOP_OF_KERNEL_STACK_PADDING 16
19310 #endif
19311
19312 /*
19313@@ -50,27 +50,26 @@ struct task_struct;
19314 #include <linux/atomic.h>
19315
19316 struct thread_info {
19317- struct task_struct *task; /* main task structure */
19318 __u32 flags; /* low level flags */
19319 __u32 status; /* thread synchronous flags */
19320 __u32 cpu; /* current CPU */
19321 int saved_preempt_count;
19322 mm_segment_t addr_limit;
19323 void __user *sysenter_return;
19324+ unsigned long lowest_stack;
19325 unsigned int sig_on_uaccess_error:1;
19326 unsigned int uaccess_err:1; /* uaccess failed */
19327 };
19328
19329-#define INIT_THREAD_INFO(tsk) \
19330+#define INIT_THREAD_INFO \
19331 { \
19332- .task = &tsk, \
19333 .flags = 0, \
19334 .cpu = 0, \
19335 .saved_preempt_count = INIT_PREEMPT_COUNT, \
19336 .addr_limit = KERNEL_DS, \
19337 }
19338
19339-#define init_thread_info (init_thread_union.thread_info)
19340+#define init_thread_info (init_thread_union.stack)
19341 #define init_stack (init_thread_union.stack)
19342
19343 #else /* !__ASSEMBLY__ */
19344@@ -110,6 +109,7 @@ struct thread_info {
19345 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
19346 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
19347 #define TIF_X32 30 /* 32-bit native x86-64 binary */
19348+#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
19349
19350 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
19351 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
19352@@ -133,17 +133,18 @@ struct thread_info {
19353 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
19354 #define _TIF_ADDR32 (1 << TIF_ADDR32)
19355 #define _TIF_X32 (1 << TIF_X32)
19356+#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
19357
19358 /* work to do in syscall_trace_enter() */
19359 #define _TIF_WORK_SYSCALL_ENTRY \
19360 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
19361 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
19362- _TIF_NOHZ)
19363+ _TIF_NOHZ | _TIF_GRSEC_SETXID)
19364
19365 /* work to do in syscall_trace_leave() */
19366 #define _TIF_WORK_SYSCALL_EXIT \
19367 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
19368- _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
19369+ _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
19370
19371 /* work to do on interrupt/exception return */
19372 #define _TIF_WORK_MASK \
19373@@ -154,7 +155,7 @@ struct thread_info {
19374 /* work to do on any return to user space */
19375 #define _TIF_ALLWORK_MASK \
19376 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
19377- _TIF_NOHZ)
19378+ _TIF_NOHZ | _TIF_GRSEC_SETXID)
19379
19380 /* Only used for 64 bit */
19381 #define _TIF_DO_NOTIFY_MASK \
19382@@ -179,9 +180,11 @@ struct thread_info {
19383
19384 DECLARE_PER_CPU(unsigned long, kernel_stack);
19385
19386+DECLARE_PER_CPU(struct thread_info *, current_tinfo);
19387+
19388 static inline struct thread_info *current_thread_info(void)
19389 {
19390- return (struct thread_info *)(current_top_of_stack() - THREAD_SIZE);
19391+ return this_cpu_read_stable(current_tinfo);
19392 }
19393
19394 static inline unsigned long current_stack_pointer(void)
19395@@ -199,8 +202,7 @@ static inline unsigned long current_stack_pointer(void)
19396
19397 /* Load thread_info address into "reg" */
19398 #define GET_THREAD_INFO(reg) \
19399- _ASM_MOV PER_CPU_VAR(kernel_stack),reg ; \
19400- _ASM_SUB $(THREAD_SIZE),reg ;
19401+ _ASM_MOV PER_CPU_VAR(current_tinfo),reg ;
19402
19403 /*
19404 * ASM operand which evaluates to a 'thread_info' address of
19405@@ -293,5 +295,12 @@ static inline bool is_ia32_task(void)
19406 extern void arch_task_cache_init(void);
19407 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
19408 extern void arch_release_task_struct(struct task_struct *tsk);
19409+
19410+#define __HAVE_THREAD_FUNCTIONS
19411+#define task_thread_info(task) (&(task)->tinfo)
19412+#define task_stack_page(task) ((task)->stack)
19413+#define setup_thread_stack(p, org) do {} while (0)
19414+#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
19415+
19416 #endif
19417 #endif /* _ASM_X86_THREAD_INFO_H */
19418diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h
19419index cd79194..e7a9491 100644
19420--- a/arch/x86/include/asm/tlbflush.h
19421+++ b/arch/x86/include/asm/tlbflush.h
19422@@ -86,18 +86,44 @@ static inline void cr4_set_bits_and_update_boot(unsigned long mask)
19423
19424 static inline void __native_flush_tlb(void)
19425 {
19426+ if (static_cpu_has(X86_FEATURE_INVPCID)) {
19427+ u64 descriptor[2];
19428+
19429+ descriptor[0] = PCID_KERNEL;
19430+ asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_NONGLOBAL) : "memory");
19431+ return;
19432+ }
19433+
19434+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
19435+ if (static_cpu_has(X86_FEATURE_PCID)) {
19436+ unsigned int cpu = raw_get_cpu();
19437+
19438+ native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
19439+ native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
19440+ raw_put_cpu_no_resched();
19441+ return;
19442+ }
19443+#endif
19444+
19445 native_write_cr3(native_read_cr3());
19446 }
19447
19448 static inline void __native_flush_tlb_global_irq_disabled(void)
19449 {
19450- unsigned long cr4;
19451+ if (static_cpu_has(X86_FEATURE_INVPCID)) {
19452+ u64 descriptor[2];
19453
19454- cr4 = this_cpu_read(cpu_tlbstate.cr4);
19455- /* clear PGE */
19456- native_write_cr4(cr4 & ~X86_CR4_PGE);
19457- /* write old PGE again and flush TLBs */
19458- native_write_cr4(cr4);
19459+ descriptor[0] = PCID_KERNEL;
19460+ asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_GLOBAL) : "memory");
19461+ } else {
19462+ unsigned long cr4;
19463+
19464+ cr4 = this_cpu_read(cpu_tlbstate.cr4);
19465+ /* clear PGE */
19466+ native_write_cr4(cr4 & ~X86_CR4_PGE);
19467+ /* write old PGE again and flush TLBs */
19468+ native_write_cr4(cr4);
19469+ }
19470 }
19471
19472 static inline void __native_flush_tlb_global(void)
19473@@ -118,6 +144,41 @@ static inline void __native_flush_tlb_global(void)
19474
19475 static inline void __native_flush_tlb_single(unsigned long addr)
19476 {
19477+ if (static_cpu_has(X86_FEATURE_INVPCID)) {
19478+ u64 descriptor[2];
19479+
19480+ descriptor[0] = PCID_KERNEL;
19481+ descriptor[1] = addr;
19482+
19483+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
19484+ if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) || addr >= TASK_SIZE_MAX) {
19485+ if (addr < TASK_SIZE_MAX)
19486+ descriptor[1] += pax_user_shadow_base;
19487+ asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
19488+ }
19489+
19490+ descriptor[0] = PCID_USER;
19491+ descriptor[1] = addr;
19492+#endif
19493+
19494+ asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
19495+ return;
19496+ }
19497+
19498+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
19499+ if (static_cpu_has(X86_FEATURE_PCID)) {
19500+ unsigned int cpu = raw_get_cpu();
19501+
19502+ native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
19503+ asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
19504+ native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
19505+ raw_put_cpu_no_resched();
19506+
19507+ if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) && addr < TASK_SIZE_MAX)
19508+ addr += pax_user_shadow_base;
19509+ }
19510+#endif
19511+
19512 asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
19513 }
19514
19515diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
19516index ace9dec..3f9e253 100644
19517--- a/arch/x86/include/asm/uaccess.h
19518+++ b/arch/x86/include/asm/uaccess.h
19519@@ -7,6 +7,7 @@
19520 #include <linux/compiler.h>
19521 #include <linux/thread_info.h>
19522 #include <linux/string.h>
19523+#include <linux/spinlock.h>
19524 #include <asm/asm.h>
19525 #include <asm/page.h>
19526 #include <asm/smap.h>
19527@@ -29,7 +30,12 @@
19528
19529 #define get_ds() (KERNEL_DS)
19530 #define get_fs() (current_thread_info()->addr_limit)
19531+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
19532+void __set_fs(mm_segment_t x);
19533+void set_fs(mm_segment_t x);
19534+#else
19535 #define set_fs(x) (current_thread_info()->addr_limit = (x))
19536+#endif
19537
19538 #define segment_eq(a, b) ((a).seg == (b).seg)
19539
19540@@ -85,8 +91,36 @@ static inline bool __chk_range_not_ok(unsigned long addr, unsigned long size, un
19541 * checks that the pointer is in the user space range - after calling
19542 * this function, memory access functions may still return -EFAULT.
19543 */
19544-#define access_ok(type, addr, size) \
19545- likely(!__range_not_ok(addr, size, user_addr_max()))
19546+extern int _cond_resched(void);
19547+#define access_ok_noprefault(type, addr, size) (likely(!__range_not_ok(addr, size, user_addr_max())))
19548+#define access_ok(type, addr, size) \
19549+({ \
19550+ unsigned long __size = size; \
19551+ unsigned long __addr = (unsigned long)addr; \
19552+ bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
19553+ if (__ret_ao && __size) { \
19554+ unsigned long __addr_ao = __addr & PAGE_MASK; \
19555+ unsigned long __end_ao = __addr + __size - 1; \
19556+ if (unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
19557+ while (__addr_ao <= __end_ao) { \
19558+ char __c_ao; \
19559+ __addr_ao += PAGE_SIZE; \
19560+ if (__size > PAGE_SIZE) \
19561+ _cond_resched(); \
19562+ if (__get_user(__c_ao, (char __user *)__addr)) \
19563+ break; \
19564+ if (type != VERIFY_WRITE) { \
19565+ __addr = __addr_ao; \
19566+ continue; \
19567+ } \
19568+ if (__put_user(__c_ao, (char __user *)__addr)) \
19569+ break; \
19570+ __addr = __addr_ao; \
19571+ } \
19572+ } \
19573+ } \
19574+ __ret_ao; \
19575+})
19576
19577 /*
19578 * The exception table consists of pairs of addresses relative to the
19579@@ -134,11 +168,13 @@ extern int __get_user_8(void);
19580 extern int __get_user_bad(void);
19581
19582 /*
19583- * This is a type: either unsigned long, if the argument fits into
19584- * that type, or otherwise unsigned long long.
19585+ * This is a type: either (un)signed int, if the argument fits into
19586+ * that type, or otherwise (un)signed long long.
19587 */
19588 #define __inttype(x) \
19589-__typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
19590+__typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0U), \
19591+ __builtin_choose_expr(__type_is_unsigned(__typeof__(x)), 0ULL, 0LL),\
19592+ __builtin_choose_expr(__type_is_unsigned(__typeof__(x)), 0U, 0)))
19593
19594 /**
19595 * get_user: - Get a simple variable from user space.
19596@@ -176,10 +212,12 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
19597 register __inttype(*(ptr)) __val_gu asm("%"_ASM_DX); \
19598 __chk_user_ptr(ptr); \
19599 might_fault(); \
19600+ pax_open_userland(); \
19601 asm volatile("call __get_user_%P3" \
19602 : "=a" (__ret_gu), "=r" (__val_gu) \
19603 : "0" (ptr), "i" (sizeof(*(ptr)))); \
19604 (x) = (__force __typeof__(*(ptr))) __val_gu; \
19605+ pax_close_userland(); \
19606 __ret_gu; \
19607 })
19608
19609@@ -187,13 +225,21 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
19610 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
19611 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
19612
19613-
19614+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
19615+#define __copyuser_seg "gs;"
19616+#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
19617+#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
19618+#else
19619+#define __copyuser_seg
19620+#define __COPYUSER_SET_ES
19621+#define __COPYUSER_RESTORE_ES
19622+#endif
19623
19624 #ifdef CONFIG_X86_32
19625 #define __put_user_asm_u64(x, addr, err, errret) \
19626 asm volatile(ASM_STAC "\n" \
19627- "1: movl %%eax,0(%2)\n" \
19628- "2: movl %%edx,4(%2)\n" \
19629+ "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
19630+ "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
19631 "3: " ASM_CLAC "\n" \
19632 ".section .fixup,\"ax\"\n" \
19633 "4: movl %3,%0\n" \
19634@@ -206,8 +252,8 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
19635
19636 #define __put_user_asm_ex_u64(x, addr) \
19637 asm volatile(ASM_STAC "\n" \
19638- "1: movl %%eax,0(%1)\n" \
19639- "2: movl %%edx,4(%1)\n" \
19640+ "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
19641+ "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
19642 "3: " ASM_CLAC "\n" \
19643 _ASM_EXTABLE_EX(1b, 2b) \
19644 _ASM_EXTABLE_EX(2b, 3b) \
19645@@ -257,7 +303,8 @@ extern void __put_user_8(void);
19646 __typeof__(*(ptr)) __pu_val; \
19647 __chk_user_ptr(ptr); \
19648 might_fault(); \
19649- __pu_val = x; \
19650+ __pu_val = (x); \
19651+ pax_open_userland(); \
19652 switch (sizeof(*(ptr))) { \
19653 case 1: \
19654 __put_user_x(1, __pu_val, ptr, __ret_pu); \
19655@@ -275,6 +322,7 @@ extern void __put_user_8(void);
19656 __put_user_x(X, __pu_val, ptr, __ret_pu); \
19657 break; \
19658 } \
19659+ pax_close_userland(); \
19660 __ret_pu; \
19661 })
19662
19663@@ -355,8 +403,10 @@ do { \
19664 } while (0)
19665
19666 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
19667+do { \
19668+ pax_open_userland(); \
19669 asm volatile(ASM_STAC "\n" \
19670- "1: mov"itype" %2,%"rtype"1\n" \
19671+ "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
19672 "2: " ASM_CLAC "\n" \
19673 ".section .fixup,\"ax\"\n" \
19674 "3: mov %3,%0\n" \
19675@@ -364,8 +414,10 @@ do { \
19676 " jmp 2b\n" \
19677 ".previous\n" \
19678 _ASM_EXTABLE(1b, 3b) \
19679- : "=r" (err), ltype(x) \
19680- : "m" (__m(addr)), "i" (errret), "0" (err))
19681+ : "=r" (err), ltype (x) \
19682+ : "m" (__m(addr)), "i" (errret), "0" (err)); \
19683+ pax_close_userland(); \
19684+} while (0)
19685
19686 #define __get_user_size_ex(x, ptr, size) \
19687 do { \
19688@@ -389,7 +441,7 @@ do { \
19689 } while (0)
19690
19691 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
19692- asm volatile("1: mov"itype" %1,%"rtype"0\n" \
19693+ asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
19694 "2:\n" \
19695 _ASM_EXTABLE_EX(1b, 2b) \
19696 : ltype(x) : "m" (__m(addr)))
19697@@ -406,13 +458,24 @@ do { \
19698 int __gu_err; \
19699 unsigned long __gu_val; \
19700 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
19701- (x) = (__force __typeof__(*(ptr)))__gu_val; \
19702+ (x) = (__typeof__(*(ptr)))__gu_val; \
19703 __gu_err; \
19704 })
19705
19706 /* FIXME: this hack is definitely wrong -AK */
19707 struct __large_struct { unsigned long buf[100]; };
19708-#define __m(x) (*(struct __large_struct __user *)(x))
19709+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
19710+#define ____m(x) \
19711+({ \
19712+ unsigned long ____x = (unsigned long)(x); \
19713+ if (____x < pax_user_shadow_base) \
19714+ ____x += pax_user_shadow_base; \
19715+ (typeof(x))____x; \
19716+})
19717+#else
19718+#define ____m(x) (x)
19719+#endif
19720+#define __m(x) (*(struct __large_struct __user *)____m(x))
19721
19722 /*
19723 * Tell gcc we read from memory instead of writing: this is because
19724@@ -420,8 +483,10 @@ struct __large_struct { unsigned long buf[100]; };
19725 * aliasing issues.
19726 */
19727 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
19728+do { \
19729+ pax_open_userland(); \
19730 asm volatile(ASM_STAC "\n" \
19731- "1: mov"itype" %"rtype"1,%2\n" \
19732+ "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
19733 "2: " ASM_CLAC "\n" \
19734 ".section .fixup,\"ax\"\n" \
19735 "3: mov %3,%0\n" \
19736@@ -429,10 +494,12 @@ struct __large_struct { unsigned long buf[100]; };
19737 ".previous\n" \
19738 _ASM_EXTABLE(1b, 3b) \
19739 : "=r"(err) \
19740- : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
19741+ : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err));\
19742+ pax_close_userland(); \
19743+} while (0)
19744
19745 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
19746- asm volatile("1: mov"itype" %"rtype"0,%1\n" \
19747+ asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
19748 "2:\n" \
19749 _ASM_EXTABLE_EX(1b, 2b) \
19750 : : ltype(x), "m" (__m(addr)))
19751@@ -442,11 +509,13 @@ struct __large_struct { unsigned long buf[100]; };
19752 */
19753 #define uaccess_try do { \
19754 current_thread_info()->uaccess_err = 0; \
19755+ pax_open_userland(); \
19756 stac(); \
19757 barrier();
19758
19759 #define uaccess_catch(err) \
19760 clac(); \
19761+ pax_close_userland(); \
19762 (err) |= (current_thread_info()->uaccess_err ? -EFAULT : 0); \
19763 } while (0)
19764
19765@@ -471,8 +540,12 @@ struct __large_struct { unsigned long buf[100]; };
19766 * On error, the variable @x is set to zero.
19767 */
19768
19769+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
19770+#define __get_user(x, ptr) get_user((x), (ptr))
19771+#else
19772 #define __get_user(x, ptr) \
19773 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
19774+#endif
19775
19776 /**
19777 * __put_user: - Write a simple value into user space, with less checking.
19778@@ -494,8 +567,12 @@ struct __large_struct { unsigned long buf[100]; };
19779 * Returns zero on success, or -EFAULT on error.
19780 */
19781
19782+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
19783+#define __put_user(x, ptr) put_user((x), (ptr))
19784+#else
19785 #define __put_user(x, ptr) \
19786 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
19787+#endif
19788
19789 #define __get_user_unaligned __get_user
19790 #define __put_user_unaligned __put_user
19791@@ -513,7 +590,7 @@ struct __large_struct { unsigned long buf[100]; };
19792 #define get_user_ex(x, ptr) do { \
19793 unsigned long __gue_val; \
19794 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
19795- (x) = (__force __typeof__(*(ptr)))__gue_val; \
19796+ (x) = (__typeof__(*(ptr)))__gue_val; \
19797 } while (0)
19798
19799 #define put_user_try uaccess_try
19800@@ -531,7 +608,7 @@ extern __must_check long strlen_user(const char __user *str);
19801 extern __must_check long strnlen_user(const char __user *str, long n);
19802
19803 unsigned long __must_check clear_user(void __user *mem, unsigned long len);
19804-unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
19805+unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
19806
19807 extern void __cmpxchg_wrong_size(void)
19808 __compiletime_error("Bad argument size for cmpxchg");
19809@@ -542,18 +619,19 @@ extern void __cmpxchg_wrong_size(void)
19810 __typeof__(ptr) __uval = (uval); \
19811 __typeof__(*(ptr)) __old = (old); \
19812 __typeof__(*(ptr)) __new = (new); \
19813+ pax_open_userland(); \
19814 switch (size) { \
19815 case 1: \
19816 { \
19817 asm volatile("\t" ASM_STAC "\n" \
19818- "1:\t" LOCK_PREFIX "cmpxchgb %4, %2\n" \
19819+ "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgb %4, %2\n"\
19820 "2:\t" ASM_CLAC "\n" \
19821 "\t.section .fixup, \"ax\"\n" \
19822 "3:\tmov %3, %0\n" \
19823 "\tjmp 2b\n" \
19824 "\t.previous\n" \
19825 _ASM_EXTABLE(1b, 3b) \
19826- : "+r" (__ret), "=a" (__old), "+m" (*(ptr)) \
19827+ : "+r" (__ret), "=a" (__old), "+m" (*____m(ptr))\
19828 : "i" (-EFAULT), "q" (__new), "1" (__old) \
19829 : "memory" \
19830 ); \
19831@@ -562,14 +640,14 @@ extern void __cmpxchg_wrong_size(void)
19832 case 2: \
19833 { \
19834 asm volatile("\t" ASM_STAC "\n" \
19835- "1:\t" LOCK_PREFIX "cmpxchgw %4, %2\n" \
19836+ "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgw %4, %2\n"\
19837 "2:\t" ASM_CLAC "\n" \
19838 "\t.section .fixup, \"ax\"\n" \
19839 "3:\tmov %3, %0\n" \
19840 "\tjmp 2b\n" \
19841 "\t.previous\n" \
19842 _ASM_EXTABLE(1b, 3b) \
19843- : "+r" (__ret), "=a" (__old), "+m" (*(ptr)) \
19844+ : "+r" (__ret), "=a" (__old), "+m" (*____m(ptr))\
19845 : "i" (-EFAULT), "r" (__new), "1" (__old) \
19846 : "memory" \
19847 ); \
19848@@ -578,14 +656,14 @@ extern void __cmpxchg_wrong_size(void)
19849 case 4: \
19850 { \
19851 asm volatile("\t" ASM_STAC "\n" \
19852- "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n" \
19853+ "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"\
19854 "2:\t" ASM_CLAC "\n" \
19855 "\t.section .fixup, \"ax\"\n" \
19856 "3:\tmov %3, %0\n" \
19857 "\tjmp 2b\n" \
19858 "\t.previous\n" \
19859 _ASM_EXTABLE(1b, 3b) \
19860- : "+r" (__ret), "=a" (__old), "+m" (*(ptr)) \
19861+ : "+r" (__ret), "=a" (__old), "+m" (*____m(ptr))\
19862 : "i" (-EFAULT), "r" (__new), "1" (__old) \
19863 : "memory" \
19864 ); \
19865@@ -597,14 +675,14 @@ extern void __cmpxchg_wrong_size(void)
19866 __cmpxchg_wrong_size(); \
19867 \
19868 asm volatile("\t" ASM_STAC "\n" \
19869- "1:\t" LOCK_PREFIX "cmpxchgq %4, %2\n" \
19870+ "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgq %4, %2\n"\
19871 "2:\t" ASM_CLAC "\n" \
19872 "\t.section .fixup, \"ax\"\n" \
19873 "3:\tmov %3, %0\n" \
19874 "\tjmp 2b\n" \
19875 "\t.previous\n" \
19876 _ASM_EXTABLE(1b, 3b) \
19877- : "+r" (__ret), "=a" (__old), "+m" (*(ptr)) \
19878+ : "+r" (__ret), "=a" (__old), "+m" (*____m(ptr))\
19879 : "i" (-EFAULT), "r" (__new), "1" (__old) \
19880 : "memory" \
19881 ); \
19882@@ -613,6 +691,7 @@ extern void __cmpxchg_wrong_size(void)
19883 default: \
19884 __cmpxchg_wrong_size(); \
19885 } \
19886+ pax_close_userland(); \
19887 *__uval = __old; \
19888 __ret; \
19889 })
19890@@ -636,17 +715,6 @@ extern struct movsl_mask {
19891
19892 #define ARCH_HAS_NOCACHE_UACCESS 1
19893
19894-#ifdef CONFIG_X86_32
19895-# include <asm/uaccess_32.h>
19896-#else
19897-# include <asm/uaccess_64.h>
19898-#endif
19899-
19900-unsigned long __must_check _copy_from_user(void *to, const void __user *from,
19901- unsigned n);
19902-unsigned long __must_check _copy_to_user(void __user *to, const void *from,
19903- unsigned n);
19904-
19905 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
19906 # define copy_user_diag __compiletime_error
19907 #else
19908@@ -656,7 +724,7 @@ unsigned long __must_check _copy_to_user(void __user *to, const void *from,
19909 extern void copy_user_diag("copy_from_user() buffer size is too small")
19910 copy_from_user_overflow(void);
19911 extern void copy_user_diag("copy_to_user() buffer size is too small")
19912-copy_to_user_overflow(void) __asm__("copy_from_user_overflow");
19913+copy_to_user_overflow(void);
19914
19915 #undef copy_user_diag
19916
19917@@ -669,7 +737,7 @@ __copy_from_user_overflow(void) __asm__("copy_from_user_overflow");
19918
19919 extern void
19920 __compiletime_warning("copy_to_user() buffer size is not provably correct")
19921-__copy_to_user_overflow(void) __asm__("copy_from_user_overflow");
19922+__copy_to_user_overflow(void) __asm__("copy_to_user_overflow");
19923 #define __copy_to_user_overflow(size, count) __copy_to_user_overflow()
19924
19925 #else
19926@@ -684,10 +752,16 @@ __copy_from_user_overflow(int size, unsigned long count)
19927
19928 #endif
19929
19930+#ifdef CONFIG_X86_32
19931+# include <asm/uaccess_32.h>
19932+#else
19933+# include <asm/uaccess_64.h>
19934+#endif
19935+
19936 static inline unsigned long __must_check
19937 copy_from_user(void *to, const void __user *from, unsigned long n)
19938 {
19939- int sz = __compiletime_object_size(to);
19940+ size_t sz = __compiletime_object_size(to);
19941
19942 might_fault();
19943
19944@@ -709,12 +783,15 @@ copy_from_user(void *to, const void __user *from, unsigned long n)
19945 * case, and do only runtime checking for non-constant sizes.
19946 */
19947
19948- if (likely(sz < 0 || sz >= n))
19949- n = _copy_from_user(to, from, n);
19950- else if(__builtin_constant_p(n))
19951- copy_from_user_overflow();
19952- else
19953- __copy_from_user_overflow(sz, n);
19954+ if (likely(sz != (size_t)-1 && sz < n)) {
19955+ if(__builtin_constant_p(n))
19956+ copy_from_user_overflow();
19957+ else
19958+ __copy_from_user_overflow(sz, n);
19959+ } else if (access_ok(VERIFY_READ, from, n))
19960+ n = __copy_from_user(to, from, n);
19961+ else if ((long)n > 0)
19962+ memset(to, 0, n);
19963
19964 return n;
19965 }
19966@@ -722,17 +799,18 @@ copy_from_user(void *to, const void __user *from, unsigned long n)
19967 static inline unsigned long __must_check
19968 copy_to_user(void __user *to, const void *from, unsigned long n)
19969 {
19970- int sz = __compiletime_object_size(from);
19971+ size_t sz = __compiletime_object_size(from);
19972
19973 might_fault();
19974
19975 /* See the comment in copy_from_user() above. */
19976- if (likely(sz < 0 || sz >= n))
19977- n = _copy_to_user(to, from, n);
19978- else if(__builtin_constant_p(n))
19979- copy_to_user_overflow();
19980- else
19981- __copy_to_user_overflow(sz, n);
19982+ if (likely(sz != (size_t)-1 && sz < n)) {
19983+ if(__builtin_constant_p(n))
19984+ copy_to_user_overflow();
19985+ else
19986+ __copy_to_user_overflow(sz, n);
19987+ } else if (access_ok(VERIFY_WRITE, to, n))
19988+ n = __copy_to_user(to, from, n);
19989
19990 return n;
19991 }
19992diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
19993index 3c03a5d..edb68ae 100644
19994--- a/arch/x86/include/asm/uaccess_32.h
19995+++ b/arch/x86/include/asm/uaccess_32.h
19996@@ -40,9 +40,14 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
19997 * anything, so this is accurate.
19998 */
19999
20000-static __always_inline unsigned long __must_check
20001+static __always_inline __size_overflow(3) unsigned long __must_check
20002 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
20003 {
20004+ if ((long)n < 0)
20005+ return n;
20006+
20007+ check_object_size(from, n, true);
20008+
20009 if (__builtin_constant_p(n)) {
20010 unsigned long ret;
20011
20012@@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
20013 __copy_to_user(void __user *to, const void *from, unsigned long n)
20014 {
20015 might_fault();
20016+
20017 return __copy_to_user_inatomic(to, from, n);
20018 }
20019
20020-static __always_inline unsigned long
20021+static __always_inline __size_overflow(3) unsigned long
20022 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
20023 {
20024+ if ((long)n < 0)
20025+ return n;
20026+
20027 /* Avoid zeroing the tail if the copy fails..
20028 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
20029 * but as the zeroing behaviour is only significant when n is not
20030@@ -137,6 +146,12 @@ static __always_inline unsigned long
20031 __copy_from_user(void *to, const void __user *from, unsigned long n)
20032 {
20033 might_fault();
20034+
20035+ if ((long)n < 0)
20036+ return n;
20037+
20038+ check_object_size(to, n, false);
20039+
20040 if (__builtin_constant_p(n)) {
20041 unsigned long ret;
20042
20043@@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
20044 const void __user *from, unsigned long n)
20045 {
20046 might_fault();
20047+
20048+ if ((long)n < 0)
20049+ return n;
20050+
20051 if (__builtin_constant_p(n)) {
20052 unsigned long ret;
20053
20054@@ -181,7 +200,10 @@ static __always_inline unsigned long
20055 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
20056 unsigned long n)
20057 {
20058- return __copy_from_user_ll_nocache_nozero(to, from, n);
20059+ if ((long)n < 0)
20060+ return n;
20061+
20062+ return __copy_from_user_ll_nocache_nozero(to, from, n);
20063 }
20064
20065 #endif /* _ASM_X86_UACCESS_32_H */
20066diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
20067index f2f9b39..2ae1bf8 100644
20068--- a/arch/x86/include/asm/uaccess_64.h
20069+++ b/arch/x86/include/asm/uaccess_64.h
20070@@ -10,6 +10,9 @@
20071 #include <asm/alternative.h>
20072 #include <asm/cpufeature.h>
20073 #include <asm/page.h>
20074+#include <asm/pgtable.h>
20075+
20076+#define set_fs(x) (current_thread_info()->addr_limit = (x))
20077
20078 /*
20079 * Copy To/From Userspace
20080@@ -23,8 +26,8 @@ copy_user_generic_string(void *to, const void *from, unsigned len);
20081 __must_check unsigned long
20082 copy_user_generic_unrolled(void *to, const void *from, unsigned len);
20083
20084-static __always_inline __must_check unsigned long
20085-copy_user_generic(void *to, const void *from, unsigned len)
20086+static __always_inline __must_check __size_overflow(3) unsigned long
20087+copy_user_generic(void *to, const void *from, unsigned long len)
20088 {
20089 unsigned ret;
20090
20091@@ -46,121 +49,170 @@ copy_user_generic(void *to, const void *from, unsigned len)
20092 }
20093
20094 __must_check unsigned long
20095-copy_in_user(void __user *to, const void __user *from, unsigned len);
20096+copy_in_user(void __user *to, const void __user *from, unsigned long len);
20097
20098 static __always_inline __must_check
20099-int __copy_from_user_nocheck(void *dst, const void __user *src, unsigned size)
20100+unsigned long __copy_from_user_nocheck(void *dst, const void __user *src, unsigned long size)
20101 {
20102- int ret = 0;
20103+ size_t sz = __compiletime_object_size(dst);
20104+ unsigned ret = 0;
20105+
20106+ if (size > INT_MAX)
20107+ return size;
20108+
20109+ check_object_size(dst, size, false);
20110+
20111+#ifdef CONFIG_PAX_MEMORY_UDEREF
20112+ if (!access_ok_noprefault(VERIFY_READ, src, size))
20113+ return size;
20114+#endif
20115+
20116+ if (unlikely(sz != (size_t)-1 && sz < size)) {
20117+ if(__builtin_constant_p(size))
20118+ copy_from_user_overflow();
20119+ else
20120+ __copy_from_user_overflow(sz, size);
20121+ return size;
20122+ }
20123
20124 if (!__builtin_constant_p(size))
20125- return copy_user_generic(dst, (__force void *)src, size);
20126+ return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
20127 switch (size) {
20128- case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
20129+ case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
20130 ret, "b", "b", "=q", 1);
20131 return ret;
20132- case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
20133+ case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
20134 ret, "w", "w", "=r", 2);
20135 return ret;
20136- case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
20137+ case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
20138 ret, "l", "k", "=r", 4);
20139 return ret;
20140- case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
20141+ case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
20142 ret, "q", "", "=r", 8);
20143 return ret;
20144 case 10:
20145- __get_user_asm(*(u64 *)dst, (u64 __user *)src,
20146+ __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
20147 ret, "q", "", "=r", 10);
20148 if (unlikely(ret))
20149 return ret;
20150 __get_user_asm(*(u16 *)(8 + (char *)dst),
20151- (u16 __user *)(8 + (char __user *)src),
20152+ (const u16 __user *)(8 + (const char __user *)src),
20153 ret, "w", "w", "=r", 2);
20154 return ret;
20155 case 16:
20156- __get_user_asm(*(u64 *)dst, (u64 __user *)src,
20157+ __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
20158 ret, "q", "", "=r", 16);
20159 if (unlikely(ret))
20160 return ret;
20161 __get_user_asm(*(u64 *)(8 + (char *)dst),
20162- (u64 __user *)(8 + (char __user *)src),
20163+ (const u64 __user *)(8 + (const char __user *)src),
20164 ret, "q", "", "=r", 8);
20165 return ret;
20166 default:
20167- return copy_user_generic(dst, (__force void *)src, size);
20168+ return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
20169 }
20170 }
20171
20172 static __always_inline __must_check
20173-int __copy_from_user(void *dst, const void __user *src, unsigned size)
20174+unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
20175 {
20176 might_fault();
20177 return __copy_from_user_nocheck(dst, src, size);
20178 }
20179
20180 static __always_inline __must_check
20181-int __copy_to_user_nocheck(void __user *dst, const void *src, unsigned size)
20182+unsigned long __copy_to_user_nocheck(void __user *dst, const void *src, unsigned long size)
20183 {
20184- int ret = 0;
20185+ size_t sz = __compiletime_object_size(src);
20186+ unsigned ret = 0;
20187+
20188+ if (size > INT_MAX)
20189+ return size;
20190+
20191+ check_object_size(src, size, true);
20192+
20193+#ifdef CONFIG_PAX_MEMORY_UDEREF
20194+ if (!access_ok_noprefault(VERIFY_WRITE, dst, size))
20195+ return size;
20196+#endif
20197+
20198+ if (unlikely(sz != (size_t)-1 && sz < size)) {
20199+ if(__builtin_constant_p(size))
20200+ copy_to_user_overflow();
20201+ else
20202+ __copy_to_user_overflow(sz, size);
20203+ return size;
20204+ }
20205
20206 if (!__builtin_constant_p(size))
20207- return copy_user_generic((__force void *)dst, src, size);
20208+ return copy_user_generic((__force_kernel void *)____m(dst), src, size);
20209 switch (size) {
20210- case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
20211+ case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
20212 ret, "b", "b", "iq", 1);
20213 return ret;
20214- case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
20215+ case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
20216 ret, "w", "w", "ir", 2);
20217 return ret;
20218- case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
20219+ case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
20220 ret, "l", "k", "ir", 4);
20221 return ret;
20222- case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
20223+ case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
20224 ret, "q", "", "er", 8);
20225 return ret;
20226 case 10:
20227- __put_user_asm(*(u64 *)src, (u64 __user *)dst,
20228+ __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
20229 ret, "q", "", "er", 10);
20230 if (unlikely(ret))
20231 return ret;
20232 asm("":::"memory");
20233- __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
20234+ __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
20235 ret, "w", "w", "ir", 2);
20236 return ret;
20237 case 16:
20238- __put_user_asm(*(u64 *)src, (u64 __user *)dst,
20239+ __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
20240 ret, "q", "", "er", 16);
20241 if (unlikely(ret))
20242 return ret;
20243 asm("":::"memory");
20244- __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
20245+ __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
20246 ret, "q", "", "er", 8);
20247 return ret;
20248 default:
20249- return copy_user_generic((__force void *)dst, src, size);
20250+ return copy_user_generic((__force_kernel void *)____m(dst), src, size);
20251 }
20252 }
20253
20254 static __always_inline __must_check
20255-int __copy_to_user(void __user *dst, const void *src, unsigned size)
20256+unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
20257 {
20258 might_fault();
20259 return __copy_to_user_nocheck(dst, src, size);
20260 }
20261
20262 static __always_inline __must_check
20263-int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
20264+unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned size)
20265 {
20266- int ret = 0;
20267+ unsigned ret = 0;
20268
20269 might_fault();
20270+
20271+ if (size > INT_MAX)
20272+ return size;
20273+
20274+#ifdef CONFIG_PAX_MEMORY_UDEREF
20275+ if (!access_ok_noprefault(VERIFY_READ, src, size))
20276+ return size;
20277+ if (!access_ok_noprefault(VERIFY_WRITE, dst, size))
20278+ return size;
20279+#endif
20280+
20281 if (!__builtin_constant_p(size))
20282- return copy_user_generic((__force void *)dst,
20283- (__force void *)src, size);
20284+ return copy_user_generic((__force_kernel void *)____m(dst),
20285+ (__force_kernel const void *)____m(src), size);
20286 switch (size) {
20287 case 1: {
20288 u8 tmp;
20289- __get_user_asm(tmp, (u8 __user *)src,
20290+ __get_user_asm(tmp, (const u8 __user *)src,
20291 ret, "b", "b", "=q", 1);
20292 if (likely(!ret))
20293 __put_user_asm(tmp, (u8 __user *)dst,
20294@@ -169,7 +221,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
20295 }
20296 case 2: {
20297 u16 tmp;
20298- __get_user_asm(tmp, (u16 __user *)src,
20299+ __get_user_asm(tmp, (const u16 __user *)src,
20300 ret, "w", "w", "=r", 2);
20301 if (likely(!ret))
20302 __put_user_asm(tmp, (u16 __user *)dst,
20303@@ -179,7 +231,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
20304
20305 case 4: {
20306 u32 tmp;
20307- __get_user_asm(tmp, (u32 __user *)src,
20308+ __get_user_asm(tmp, (const u32 __user *)src,
20309 ret, "l", "k", "=r", 4);
20310 if (likely(!ret))
20311 __put_user_asm(tmp, (u32 __user *)dst,
20312@@ -188,7 +240,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
20313 }
20314 case 8: {
20315 u64 tmp;
20316- __get_user_asm(tmp, (u64 __user *)src,
20317+ __get_user_asm(tmp, (const u64 __user *)src,
20318 ret, "q", "", "=r", 8);
20319 if (likely(!ret))
20320 __put_user_asm(tmp, (u64 __user *)dst,
20321@@ -196,41 +248,58 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
20322 return ret;
20323 }
20324 default:
20325- return copy_user_generic((__force void *)dst,
20326- (__force void *)src, size);
20327+ return copy_user_generic((__force_kernel void *)____m(dst),
20328+ (__force_kernel const void *)____m(src), size);
20329 }
20330 }
20331
20332-static __must_check __always_inline int
20333-__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
20334+static __must_check __always_inline unsigned long
20335+__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
20336 {
20337 return __copy_from_user_nocheck(dst, src, size);
20338 }
20339
20340-static __must_check __always_inline int
20341-__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
20342+static __must_check __always_inline unsigned long
20343+__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
20344 {
20345 return __copy_to_user_nocheck(dst, src, size);
20346 }
20347
20348-extern long __copy_user_nocache(void *dst, const void __user *src,
20349- unsigned size, int zerorest);
20350+extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
20351+ unsigned long size, int zerorest);
20352
20353-static inline int
20354-__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
20355+static inline unsigned long
20356+__copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
20357 {
20358 might_fault();
20359+
20360+ if (size > INT_MAX)
20361+ return size;
20362+
20363+#ifdef CONFIG_PAX_MEMORY_UDEREF
20364+ if (!access_ok_noprefault(VERIFY_READ, src, size))
20365+ return size;
20366+#endif
20367+
20368 return __copy_user_nocache(dst, src, size, 1);
20369 }
20370
20371-static inline int
20372+static inline unsigned long
20373 __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
20374- unsigned size)
20375+ unsigned long size)
20376 {
20377+ if (size > INT_MAX)
20378+ return size;
20379+
20380+#ifdef CONFIG_PAX_MEMORY_UDEREF
20381+ if (!access_ok_noprefault(VERIFY_READ, src, size))
20382+ return size;
20383+#endif
20384+
20385 return __copy_user_nocache(dst, src, size, 0);
20386 }
20387
20388 unsigned long
20389-copy_user_handle_tail(char *to, char *from, unsigned len);
20390+copy_user_handle_tail(char __user *to, char __user *from, unsigned long len) __size_overflow(3);
20391
20392 #endif /* _ASM_X86_UACCESS_64_H */
20393diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
20394index 5b238981..77fdd78 100644
20395--- a/arch/x86/include/asm/word-at-a-time.h
20396+++ b/arch/x86/include/asm/word-at-a-time.h
20397@@ -11,7 +11,7 @@
20398 * and shift, for example.
20399 */
20400 struct word_at_a_time {
20401- const unsigned long one_bits, high_bits;
20402+ unsigned long one_bits, high_bits;
20403 };
20404
20405 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
20406diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
20407index f58a9c7..dc378042a 100644
20408--- a/arch/x86/include/asm/x86_init.h
20409+++ b/arch/x86/include/asm/x86_init.h
20410@@ -129,7 +129,7 @@ struct x86_init_ops {
20411 struct x86_init_timers timers;
20412 struct x86_init_iommu iommu;
20413 struct x86_init_pci pci;
20414-};
20415+} __no_const;
20416
20417 /**
20418 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
20419@@ -140,7 +140,7 @@ struct x86_cpuinit_ops {
20420 void (*setup_percpu_clockev)(void);
20421 void (*early_percpu_clock_init)(void);
20422 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
20423-};
20424+} __no_const;
20425
20426 struct timespec;
20427
20428@@ -168,7 +168,7 @@ struct x86_platform_ops {
20429 void (*save_sched_clock_state)(void);
20430 void (*restore_sched_clock_state)(void);
20431 void (*apic_post_init)(void);
20432-};
20433+} __no_const;
20434
20435 struct pci_dev;
20436 struct msi_msg;
20437@@ -182,7 +182,7 @@ struct x86_msi_ops {
20438 void (*teardown_msi_irqs)(struct pci_dev *dev);
20439 void (*restore_msi_irqs)(struct pci_dev *dev);
20440 int (*setup_hpet_msi)(unsigned int irq, unsigned int id);
20441-};
20442+} __no_const;
20443
20444 struct IO_APIC_route_entry;
20445 struct io_apic_irq_attr;
20446@@ -203,7 +203,7 @@ struct x86_io_apic_ops {
20447 unsigned int destination, int vector,
20448 struct io_apic_irq_attr *attr);
20449 void (*eoi_ioapic_pin)(int apic, int pin, int vector);
20450-};
20451+} __no_const;
20452
20453 extern struct x86_init_ops x86_init;
20454 extern struct x86_cpuinit_ops x86_cpuinit;
20455diff --git a/arch/x86/include/asm/xen/page.h b/arch/x86/include/asm/xen/page.h
20456index c44a5d5..7f83cfc 100644
20457--- a/arch/x86/include/asm/xen/page.h
20458+++ b/arch/x86/include/asm/xen/page.h
20459@@ -82,7 +82,7 @@ static inline int xen_safe_read_ulong(unsigned long *addr, unsigned long *val)
20460 * - get_phys_to_machine() is to be called by __pfn_to_mfn() only in special
20461 * cases needing an extended handling.
20462 */
20463-static inline unsigned long __pfn_to_mfn(unsigned long pfn)
20464+static inline unsigned long __intentional_overflow(-1) __pfn_to_mfn(unsigned long pfn)
20465 {
20466 unsigned long mfn;
20467
20468diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
20469index c9a6d68..cb57f42 100644
20470--- a/arch/x86/include/asm/xsave.h
20471+++ b/arch/x86/include/asm/xsave.h
20472@@ -223,12 +223,16 @@ static inline int xsave_user(struct xsave_struct __user *buf)
20473 if (unlikely(err))
20474 return -EFAULT;
20475
20476+ pax_open_userland();
20477 __asm__ __volatile__(ASM_STAC "\n"
20478- "1:"XSAVE"\n"
20479+ "1:"
20480+ __copyuser_seg
20481+ XSAVE"\n"
20482 "2: " ASM_CLAC "\n"
20483 xstate_fault
20484 : "D" (buf), "a" (-1), "d" (-1), "0" (0)
20485 : "memory");
20486+ pax_close_userland();
20487 return err;
20488 }
20489
20490@@ -238,16 +242,20 @@ static inline int xsave_user(struct xsave_struct __user *buf)
20491 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
20492 {
20493 int err = 0;
20494- struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
20495+ struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
20496 u32 lmask = mask;
20497 u32 hmask = mask >> 32;
20498
20499+ pax_open_userland();
20500 __asm__ __volatile__(ASM_STAC "\n"
20501- "1:"XRSTOR"\n"
20502+ "1:"
20503+ __copyuser_seg
20504+ XRSTOR"\n"
20505 "2: " ASM_CLAC "\n"
20506 xstate_fault
20507 : "D" (xstate), "a" (lmask), "d" (hmask), "0" (0)
20508 : "memory"); /* memory required? */
20509+ pax_close_userland();
20510 return err;
20511 }
20512
20513diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
20514index 960a8a9..404daf7 100644
20515--- a/arch/x86/include/uapi/asm/e820.h
20516+++ b/arch/x86/include/uapi/asm/e820.h
20517@@ -68,7 +68,7 @@ struct e820map {
20518 #define ISA_START_ADDRESS 0xa0000
20519 #define ISA_END_ADDRESS 0x100000
20520
20521-#define BIOS_BEGIN 0x000a0000
20522+#define BIOS_BEGIN 0x000c0000
20523 #define BIOS_END 0x00100000
20524
20525 #define BIOS_ROM_BASE 0xffe00000
20526diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
20527index 9bcd0b5..750f1b7 100644
20528--- a/arch/x86/kernel/Makefile
20529+++ b/arch/x86/kernel/Makefile
20530@@ -28,7 +28,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
20531 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
20532 obj-$(CONFIG_IRQ_WORK) += irq_work.o
20533 obj-y += probe_roms.o
20534-obj-$(CONFIG_X86_32) += i386_ksyms_32.o
20535+obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
20536 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
20537 obj-$(CONFIG_X86_64) += mcount_64.o
20538 obj-y += syscall_$(BITS).o vsyscall_gtod.o
20539diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
20540index dbe76a1..e2ec334 100644
20541--- a/arch/x86/kernel/acpi/boot.c
20542+++ b/arch/x86/kernel/acpi/boot.c
20543@@ -1361,7 +1361,7 @@ static void __init acpi_reduced_hw_init(void)
20544 * If your system is blacklisted here, but you find that acpi=force
20545 * works for you, please contact linux-acpi@vger.kernel.org
20546 */
20547-static struct dmi_system_id __initdata acpi_dmi_table[] = {
20548+static const struct dmi_system_id __initconst acpi_dmi_table[] = {
20549 /*
20550 * Boxes that need ACPI disabled
20551 */
20552@@ -1436,7 +1436,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
20553 };
20554
20555 /* second table for DMI checks that should run after early-quirks */
20556-static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
20557+static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
20558 /*
20559 * HP laptops which use a DSDT reporting as HP/SB400/10000,
20560 * which includes some code which overrides all temperature
20561diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
20562index d1daead..acd77e2 100644
20563--- a/arch/x86/kernel/acpi/sleep.c
20564+++ b/arch/x86/kernel/acpi/sleep.c
20565@@ -99,8 +99,12 @@ int x86_acpi_suspend_lowlevel(void)
20566 #else /* CONFIG_64BIT */
20567 #ifdef CONFIG_SMP
20568 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
20569+
20570+ pax_open_kernel();
20571 early_gdt_descr.address =
20572 (unsigned long)get_cpu_gdt_table(smp_processor_id());
20573+ pax_close_kernel();
20574+
20575 initial_gs = per_cpu_offset(smp_processor_id());
20576 #endif
20577 initial_code = (unsigned long)wakeup_long64;
20578diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
20579index 665c6b7..eae4d56 100644
20580--- a/arch/x86/kernel/acpi/wakeup_32.S
20581+++ b/arch/x86/kernel/acpi/wakeup_32.S
20582@@ -29,13 +29,11 @@ wakeup_pmode_return:
20583 # and restore the stack ... but you need gdt for this to work
20584 movl saved_context_esp, %esp
20585
20586- movl %cs:saved_magic, %eax
20587- cmpl $0x12345678, %eax
20588+ cmpl $0x12345678, saved_magic
20589 jne bogus_magic
20590
20591 # jump to place where we left off
20592- movl saved_eip, %eax
20593- jmp *%eax
20594+ jmp *(saved_eip)
20595
20596 bogus_magic:
20597 jmp bogus_magic
20598diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
20599index aef6531..2044b66 100644
20600--- a/arch/x86/kernel/alternative.c
20601+++ b/arch/x86/kernel/alternative.c
20602@@ -248,7 +248,9 @@ static void __init_or_module add_nops(void *insns, unsigned int len)
20603 unsigned int noplen = len;
20604 if (noplen > ASM_NOP_MAX)
20605 noplen = ASM_NOP_MAX;
20606+ pax_open_kernel();
20607 memcpy(insns, ideal_nops[noplen], noplen);
20608+ pax_close_kernel();
20609 insns += noplen;
20610 len -= noplen;
20611 }
20612@@ -276,6 +278,11 @@ recompute_jump(struct alt_instr *a, u8 *orig_insn, u8 *repl_insn, u8 *insnbuf)
20613 if (a->replacementlen != 5)
20614 return;
20615
20616+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
20617+ if (orig_insn < (u8 *)_text || (u8 *)_einittext <= orig_insn)
20618+ orig_insn = ktva_ktla(orig_insn);
20619+#endif
20620+
20621 o_dspl = *(s32 *)(insnbuf + 1);
20622
20623 /* next_rip of the replacement JMP */
20624@@ -362,7 +369,23 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
20625 int insnbuf_sz = 0;
20626
20627 instr = (u8 *)&a->instr_offset + a->instr_offset;
20628+
20629+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
20630+ if ((u8 *)_text <= instr && instr < (u8 *)_einittext) {
20631+ instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
20632+ instr = ktla_ktva(instr);
20633+ }
20634+#endif
20635+
20636 replacement = (u8 *)&a->repl_offset + a->repl_offset;
20637+
20638+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
20639+ if ((u8 *)_text <= replacement && replacement < (u8 *)_einittext) {
20640+ replacement += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
20641+ replacement = ktla_ktva(replacement);
20642+ }
20643+#endif
20644+
20645 BUG_ON(a->instrlen > sizeof(insnbuf));
20646 BUG_ON(a->cpuid >= (NCAPINTS + NBUGINTS) * 32);
20647 if (!boot_cpu_has(a->cpuid)) {
20648@@ -402,6 +425,11 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
20649 }
20650 DUMP_BYTES(insnbuf, insnbuf_sz, "%p: final_insn: ", instr);
20651
20652+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
20653+ if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
20654+ instr = ktva_ktla(instr);
20655+#endif
20656+
20657 text_poke_early(instr, insnbuf, insnbuf_sz);
20658 }
20659 }
20660@@ -416,10 +444,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
20661 for (poff = start; poff < end; poff++) {
20662 u8 *ptr = (u8 *)poff + *poff;
20663
20664+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
20665+ ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
20666+ if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
20667+ ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
20668+#endif
20669+
20670 if (!*poff || ptr < text || ptr >= text_end)
20671 continue;
20672 /* turn DS segment override prefix into lock prefix */
20673- if (*ptr == 0x3e)
20674+ if (*ktla_ktva(ptr) == 0x3e)
20675 text_poke(ptr, ((unsigned char []){0xf0}), 1);
20676 }
20677 mutex_unlock(&text_mutex);
20678@@ -434,10 +468,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
20679 for (poff = start; poff < end; poff++) {
20680 u8 *ptr = (u8 *)poff + *poff;
20681
20682+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
20683+ ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
20684+ if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
20685+ ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
20686+#endif
20687+
20688 if (!*poff || ptr < text || ptr >= text_end)
20689 continue;
20690 /* turn lock prefix into DS segment override prefix */
20691- if (*ptr == 0xf0)
20692+ if (*ktla_ktva(ptr) == 0xf0)
20693 text_poke(ptr, ((unsigned char []){0x3E}), 1);
20694 }
20695 mutex_unlock(&text_mutex);
20696@@ -574,7 +614,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
20697
20698 BUG_ON(p->len > MAX_PATCH_LEN);
20699 /* prep the buffer with the original instructions */
20700- memcpy(insnbuf, p->instr, p->len);
20701+ memcpy(insnbuf, ktla_ktva(p->instr), p->len);
20702 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
20703 (unsigned long)p->instr, p->len);
20704
20705@@ -621,7 +661,7 @@ void __init alternative_instructions(void)
20706 if (!uniproc_patched || num_possible_cpus() == 1)
20707 free_init_pages("SMP alternatives",
20708 (unsigned long)__smp_locks,
20709- (unsigned long)__smp_locks_end);
20710+ PAGE_ALIGN((unsigned long)__smp_locks_end));
20711 #endif
20712
20713 apply_paravirt(__parainstructions, __parainstructions_end);
20714@@ -641,13 +681,17 @@ void __init alternative_instructions(void)
20715 * instructions. And on the local CPU you need to be protected again NMI or MCE
20716 * handlers seeing an inconsistent instruction while you patch.
20717 */
20718-void *__init_or_module text_poke_early(void *addr, const void *opcode,
20719+void *__kprobes text_poke_early(void *addr, const void *opcode,
20720 size_t len)
20721 {
20722 unsigned long flags;
20723 local_irq_save(flags);
20724- memcpy(addr, opcode, len);
20725+
20726+ pax_open_kernel();
20727+ memcpy(ktla_ktva(addr), opcode, len);
20728 sync_core();
20729+ pax_close_kernel();
20730+
20731 local_irq_restore(flags);
20732 /* Could also do a CLFLUSH here to speed up CPU recovery; but
20733 that causes hangs on some VIA CPUs. */
20734@@ -669,36 +713,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
20735 */
20736 void *text_poke(void *addr, const void *opcode, size_t len)
20737 {
20738- unsigned long flags;
20739- char *vaddr;
20740+ unsigned char *vaddr = ktla_ktva(addr);
20741 struct page *pages[2];
20742- int i;
20743+ size_t i;
20744
20745 if (!core_kernel_text((unsigned long)addr)) {
20746- pages[0] = vmalloc_to_page(addr);
20747- pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
20748+ pages[0] = vmalloc_to_page(vaddr);
20749+ pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
20750 } else {
20751- pages[0] = virt_to_page(addr);
20752+ pages[0] = virt_to_page(vaddr);
20753 WARN_ON(!PageReserved(pages[0]));
20754- pages[1] = virt_to_page(addr + PAGE_SIZE);
20755+ pages[1] = virt_to_page(vaddr + PAGE_SIZE);
20756 }
20757 BUG_ON(!pages[0]);
20758- local_irq_save(flags);
20759- set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
20760- if (pages[1])
20761- set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
20762- vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
20763- memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
20764- clear_fixmap(FIX_TEXT_POKE0);
20765- if (pages[1])
20766- clear_fixmap(FIX_TEXT_POKE1);
20767- local_flush_tlb();
20768- sync_core();
20769- /* Could also do a CLFLUSH here to speed up CPU recovery; but
20770- that causes hangs on some VIA CPUs. */
20771+ text_poke_early(addr, opcode, len);
20772 for (i = 0; i < len; i++)
20773- BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
20774- local_irq_restore(flags);
20775+ BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
20776 return addr;
20777 }
20778
20779@@ -752,7 +782,7 @@ int poke_int3_handler(struct pt_regs *regs)
20780 */
20781 void *text_poke_bp(void *addr, const void *opcode, size_t len, void *handler)
20782 {
20783- unsigned char int3 = 0xcc;
20784+ const unsigned char int3 = 0xcc;
20785
20786 bp_int3_handler = handler;
20787 bp_int3_addr = (u8 *)addr + sizeof(int3);
20788diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
20789index dcb5285..cc79e9d 100644
20790--- a/arch/x86/kernel/apic/apic.c
20791+++ b/arch/x86/kernel/apic/apic.c
20792@@ -171,7 +171,7 @@ int first_system_vector = FIRST_SYSTEM_VECTOR;
20793 /*
20794 * Debug level, exported for io_apic.c
20795 */
20796-unsigned int apic_verbosity;
20797+int apic_verbosity;
20798
20799 int pic_mode;
20800
20801@@ -1857,7 +1857,7 @@ static inline void __smp_error_interrupt(struct pt_regs *regs)
20802 apic_write(APIC_ESR, 0);
20803 v = apic_read(APIC_ESR);
20804 ack_APIC_irq();
20805- atomic_inc(&irq_err_count);
20806+ atomic_inc_unchecked(&irq_err_count);
20807
20808 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x",
20809 smp_processor_id(), v);
20810diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
20811index de918c4..32eed23 100644
20812--- a/arch/x86/kernel/apic/apic_flat_64.c
20813+++ b/arch/x86/kernel/apic/apic_flat_64.c
20814@@ -154,7 +154,7 @@ static int flat_probe(void)
20815 return 1;
20816 }
20817
20818-static struct apic apic_flat = {
20819+static struct apic apic_flat __read_only = {
20820 .name = "flat",
20821 .probe = flat_probe,
20822 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
20823@@ -260,7 +260,7 @@ static int physflat_probe(void)
20824 return 0;
20825 }
20826
20827-static struct apic apic_physflat = {
20828+static struct apic apic_physflat __read_only = {
20829
20830 .name = "physical flat",
20831 .probe = physflat_probe,
20832diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
20833index b205cdb..d8503ff 100644
20834--- a/arch/x86/kernel/apic/apic_noop.c
20835+++ b/arch/x86/kernel/apic/apic_noop.c
20836@@ -108,7 +108,7 @@ static void noop_apic_write(u32 reg, u32 v)
20837 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
20838 }
20839
20840-struct apic apic_noop = {
20841+struct apic apic_noop __read_only = {
20842 .name = "noop",
20843 .probe = noop_probe,
20844 .acpi_madt_oem_check = NULL,
20845diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
20846index c4a8d63..fe893ac 100644
20847--- a/arch/x86/kernel/apic/bigsmp_32.c
20848+++ b/arch/x86/kernel/apic/bigsmp_32.c
20849@@ -147,7 +147,7 @@ static int probe_bigsmp(void)
20850 return dmi_bigsmp;
20851 }
20852
20853-static struct apic apic_bigsmp = {
20854+static struct apic apic_bigsmp __read_only = {
20855
20856 .name = "bigsmp",
20857 .probe = probe_bigsmp,
20858diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
20859index f4dc246..fbab133 100644
20860--- a/arch/x86/kernel/apic/io_apic.c
20861+++ b/arch/x86/kernel/apic/io_apic.c
20862@@ -1862,7 +1862,7 @@ int native_ioapic_set_affinity(struct irq_data *data,
20863 return ret;
20864 }
20865
20866-atomic_t irq_mis_count;
20867+atomic_unchecked_t irq_mis_count;
20868
20869 #ifdef CONFIG_GENERIC_PENDING_IRQ
20870 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
20871@@ -2003,7 +2003,7 @@ static void ack_ioapic_level(struct irq_data *data)
20872 * at the cpu.
20873 */
20874 if (!(v & (1 << (i & 0x1f)))) {
20875- atomic_inc(&irq_mis_count);
20876+ atomic_inc_unchecked(&irq_mis_count);
20877
20878 eoi_ioapic_irq(irq, cfg);
20879 }
20880@@ -2011,7 +2011,7 @@ static void ack_ioapic_level(struct irq_data *data)
20881 ioapic_irqd_unmask(data, cfg, masked);
20882 }
20883
20884-static struct irq_chip ioapic_chip __read_mostly = {
20885+static struct irq_chip ioapic_chip = {
20886 .name = "IO-APIC",
20887 .irq_startup = startup_ioapic_irq,
20888 .irq_mask = mask_ioapic_irq,
20889@@ -2070,7 +2070,7 @@ static void ack_lapic_irq(struct irq_data *data)
20890 ack_APIC_irq();
20891 }
20892
20893-static struct irq_chip lapic_chip __read_mostly = {
20894+static struct irq_chip lapic_chip = {
20895 .name = "local-APIC",
20896 .irq_mask = mask_lapic_irq,
20897 .irq_unmask = unmask_lapic_irq,
20898diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
20899index bda4886..f9c7195 100644
20900--- a/arch/x86/kernel/apic/probe_32.c
20901+++ b/arch/x86/kernel/apic/probe_32.c
20902@@ -72,7 +72,7 @@ static int probe_default(void)
20903 return 1;
20904 }
20905
20906-static struct apic apic_default = {
20907+static struct apic apic_default __read_only = {
20908
20909 .name = "default",
20910 .probe = probe_default,
20911diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c
20912index 6cedd79..023ff8e 100644
20913--- a/arch/x86/kernel/apic/vector.c
20914+++ b/arch/x86/kernel/apic/vector.c
20915@@ -21,7 +21,7 @@
20916
20917 static DEFINE_RAW_SPINLOCK(vector_lock);
20918
20919-void lock_vector_lock(void)
20920+void lock_vector_lock(void) __acquires(vector_lock)
20921 {
20922 /* Used to the online set of cpus does not change
20923 * during assign_irq_vector.
20924@@ -29,7 +29,7 @@ void lock_vector_lock(void)
20925 raw_spin_lock(&vector_lock);
20926 }
20927
20928-void unlock_vector_lock(void)
20929+void unlock_vector_lock(void) __releases(vector_lock)
20930 {
20931 raw_spin_unlock(&vector_lock);
20932 }
20933diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
20934index ab3219b..e8033eb 100644
20935--- a/arch/x86/kernel/apic/x2apic_cluster.c
20936+++ b/arch/x86/kernel/apic/x2apic_cluster.c
20937@@ -182,7 +182,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
20938 return notifier_from_errno(err);
20939 }
20940
20941-static struct notifier_block __refdata x2apic_cpu_notifier = {
20942+static struct notifier_block x2apic_cpu_notifier = {
20943 .notifier_call = update_clusterinfo,
20944 };
20945
20946@@ -234,7 +234,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
20947 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
20948 }
20949
20950-static struct apic apic_x2apic_cluster = {
20951+static struct apic apic_x2apic_cluster __read_only = {
20952
20953 .name = "cluster x2apic",
20954 .probe = x2apic_cluster_probe,
20955diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
20956index 6fae733..5ca17af 100644
20957--- a/arch/x86/kernel/apic/x2apic_phys.c
20958+++ b/arch/x86/kernel/apic/x2apic_phys.c
20959@@ -88,7 +88,7 @@ static int x2apic_phys_probe(void)
20960 return apic == &apic_x2apic_phys;
20961 }
20962
20963-static struct apic apic_x2apic_phys = {
20964+static struct apic apic_x2apic_phys __read_only = {
20965
20966 .name = "physical x2apic",
20967 .probe = x2apic_phys_probe,
20968diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
20969index c8d9295..9af2d03 100644
20970--- a/arch/x86/kernel/apic/x2apic_uv_x.c
20971+++ b/arch/x86/kernel/apic/x2apic_uv_x.c
20972@@ -375,7 +375,7 @@ static int uv_probe(void)
20973 return apic == &apic_x2apic_uv_x;
20974 }
20975
20976-static struct apic __refdata apic_x2apic_uv_x = {
20977+static struct apic apic_x2apic_uv_x __read_only = {
20978
20979 .name = "UV large system",
20980 .probe = uv_probe,
20981diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
20982index 927ec92..de68f32 100644
20983--- a/arch/x86/kernel/apm_32.c
20984+++ b/arch/x86/kernel/apm_32.c
20985@@ -432,7 +432,7 @@ static DEFINE_MUTEX(apm_mutex);
20986 * This is for buggy BIOS's that refer to (real mode) segment 0x40
20987 * even though they are called in protected mode.
20988 */
20989-static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
20990+static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
20991 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
20992
20993 static const char driver_version[] = "1.16ac"; /* no spaces */
20994@@ -610,7 +610,10 @@ static long __apm_bios_call(void *_call)
20995 BUG_ON(cpu != 0);
20996 gdt = get_cpu_gdt_table(cpu);
20997 save_desc_40 = gdt[0x40 / 8];
20998+
20999+ pax_open_kernel();
21000 gdt[0x40 / 8] = bad_bios_desc;
21001+ pax_close_kernel();
21002
21003 apm_irq_save(flags);
21004 APM_DO_SAVE_SEGS;
21005@@ -619,7 +622,11 @@ static long __apm_bios_call(void *_call)
21006 &call->esi);
21007 APM_DO_RESTORE_SEGS;
21008 apm_irq_restore(flags);
21009+
21010+ pax_open_kernel();
21011 gdt[0x40 / 8] = save_desc_40;
21012+ pax_close_kernel();
21013+
21014 put_cpu();
21015
21016 return call->eax & 0xff;
21017@@ -686,7 +693,10 @@ static long __apm_bios_call_simple(void *_call)
21018 BUG_ON(cpu != 0);
21019 gdt = get_cpu_gdt_table(cpu);
21020 save_desc_40 = gdt[0x40 / 8];
21021+
21022+ pax_open_kernel();
21023 gdt[0x40 / 8] = bad_bios_desc;
21024+ pax_close_kernel();
21025
21026 apm_irq_save(flags);
21027 APM_DO_SAVE_SEGS;
21028@@ -694,7 +704,11 @@ static long __apm_bios_call_simple(void *_call)
21029 &call->eax);
21030 APM_DO_RESTORE_SEGS;
21031 apm_irq_restore(flags);
21032+
21033+ pax_open_kernel();
21034 gdt[0x40 / 8] = save_desc_40;
21035+ pax_close_kernel();
21036+
21037 put_cpu();
21038 return error;
21039 }
21040@@ -2039,7 +2053,7 @@ static int __init swab_apm_power_in_minutes(const struct dmi_system_id *d)
21041 return 0;
21042 }
21043
21044-static struct dmi_system_id __initdata apm_dmi_table[] = {
21045+static const struct dmi_system_id __initconst apm_dmi_table[] = {
21046 {
21047 print_if_true,
21048 KERN_WARNING "IBM T23 - BIOS 1.03b+ and controller firmware 1.02+ may be needed for Linux APM.",
21049@@ -2349,12 +2363,15 @@ static int __init apm_init(void)
21050 * code to that CPU.
21051 */
21052 gdt = get_cpu_gdt_table(0);
21053+
21054+ pax_open_kernel();
21055 set_desc_base(&gdt[APM_CS >> 3],
21056 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
21057 set_desc_base(&gdt[APM_CS_16 >> 3],
21058 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
21059 set_desc_base(&gdt[APM_DS >> 3],
21060 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
21061+ pax_close_kernel();
21062
21063 proc_create("apm", 0, NULL, &apm_file_ops);
21064
21065diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
21066index 9f6b934..cf5ffb3 100644
21067--- a/arch/x86/kernel/asm-offsets.c
21068+++ b/arch/x86/kernel/asm-offsets.c
21069@@ -32,6 +32,8 @@ void common(void) {
21070 OFFSET(TI_flags, thread_info, flags);
21071 OFFSET(TI_status, thread_info, status);
21072 OFFSET(TI_addr_limit, thread_info, addr_limit);
21073+ OFFSET(TI_lowest_stack, thread_info, lowest_stack);
21074+ DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
21075
21076 BLANK();
21077 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
21078@@ -52,8 +54,26 @@ void common(void) {
21079 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
21080 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
21081 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
21082+
21083+#ifdef CONFIG_PAX_KERNEXEC
21084+ OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
21085 #endif
21086
21087+#ifdef CONFIG_PAX_MEMORY_UDEREF
21088+ OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
21089+ OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
21090+#ifdef CONFIG_X86_64
21091+ OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
21092+#endif
21093+#endif
21094+
21095+#endif
21096+
21097+ BLANK();
21098+ DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
21099+ DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
21100+ DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
21101+
21102 #ifdef CONFIG_XEN
21103 BLANK();
21104 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
21105diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
21106index 5ce6f2d..9e738f3 100644
21107--- a/arch/x86/kernel/asm-offsets_64.c
21108+++ b/arch/x86/kernel/asm-offsets_64.c
21109@@ -80,6 +80,7 @@ int main(void)
21110 BLANK();
21111 #undef ENTRY
21112
21113+ DEFINE(TSS_size, sizeof(struct tss_struct));
21114 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
21115 OFFSET(TSS_sp0, tss_struct, x86_tss.sp0);
21116 BLANK();
21117diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
21118index 9bff687..5b899fb 100644
21119--- a/arch/x86/kernel/cpu/Makefile
21120+++ b/arch/x86/kernel/cpu/Makefile
21121@@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
21122 CFLAGS_REMOVE_perf_event.o = -pg
21123 endif
21124
21125-# Make sure load_percpu_segment has no stackprotector
21126-nostackp := $(call cc-option, -fno-stack-protector)
21127-CFLAGS_common.o := $(nostackp)
21128-
21129 obj-y := intel_cacheinfo.o scattered.o topology.o
21130 obj-y += common.o
21131 obj-y += rdrand.o
21132diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
21133index e4cf633..941f450 100644
21134--- a/arch/x86/kernel/cpu/amd.c
21135+++ b/arch/x86/kernel/cpu/amd.c
21136@@ -729,7 +729,7 @@ static void init_amd(struct cpuinfo_x86 *c)
21137 static unsigned int amd_size_cache(struct cpuinfo_x86 *c, unsigned int size)
21138 {
21139 /* AMD errata T13 (order #21922) */
21140- if ((c->x86 == 6)) {
21141+ if (c->x86 == 6) {
21142 /* Duron Rev A0 */
21143 if (c->x86_model == 3 && c->x86_mask == 0)
21144 size = 64;
21145diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
21146index a62cf04..041e39c 100644
21147--- a/arch/x86/kernel/cpu/common.c
21148+++ b/arch/x86/kernel/cpu/common.c
21149@@ -91,60 +91,6 @@ static const struct cpu_dev default_cpu = {
21150
21151 static const struct cpu_dev *this_cpu = &default_cpu;
21152
21153-DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
21154-#ifdef CONFIG_X86_64
21155- /*
21156- * We need valid kernel segments for data and code in long mode too
21157- * IRET will check the segment types kkeil 2000/10/28
21158- * Also sysret mandates a special GDT layout
21159- *
21160- * TLS descriptors are currently at a different place compared to i386.
21161- * Hopefully nobody expects them at a fixed place (Wine?)
21162- */
21163- [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
21164- [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
21165- [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
21166- [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
21167- [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
21168- [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
21169-#else
21170- [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
21171- [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
21172- [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
21173- [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
21174- /*
21175- * Segments used for calling PnP BIOS have byte granularity.
21176- * They code segments and data segments have fixed 64k limits,
21177- * the transfer segment sizes are set at run time.
21178- */
21179- /* 32-bit code */
21180- [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
21181- /* 16-bit code */
21182- [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
21183- /* 16-bit data */
21184- [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
21185- /* 16-bit data */
21186- [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
21187- /* 16-bit data */
21188- [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
21189- /*
21190- * The APM segments have byte granularity and their bases
21191- * are set at run time. All have 64k limits.
21192- */
21193- /* 32-bit code */
21194- [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
21195- /* 16-bit code */
21196- [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
21197- /* data */
21198- [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
21199-
21200- [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
21201- [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
21202- GDT_STACK_CANARY_INIT
21203-#endif
21204-} };
21205-EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
21206-
21207 static int __init x86_xsave_setup(char *s)
21208 {
21209 if (strlen(s))
21210@@ -306,6 +252,59 @@ static __always_inline void setup_smap(struct cpuinfo_x86 *c)
21211 }
21212 }
21213
21214+#ifdef CONFIG_X86_64
21215+static __init int setup_disable_pcid(char *arg)
21216+{
21217+ setup_clear_cpu_cap(X86_FEATURE_PCID);
21218+ setup_clear_cpu_cap(X86_FEATURE_INVPCID);
21219+
21220+#ifdef CONFIG_PAX_MEMORY_UDEREF
21221+ if (clone_pgd_mask != ~(pgdval_t)0UL)
21222+ pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
21223+#endif
21224+
21225+ return 1;
21226+}
21227+__setup("nopcid", setup_disable_pcid);
21228+
21229+static void setup_pcid(struct cpuinfo_x86 *c)
21230+{
21231+ if (!cpu_has(c, X86_FEATURE_PCID)) {
21232+ clear_cpu_cap(c, X86_FEATURE_INVPCID);
21233+
21234+#ifdef CONFIG_PAX_MEMORY_UDEREF
21235+ if (clone_pgd_mask != ~(pgdval_t)0UL) {
21236+ pax_open_kernel();
21237+ pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
21238+ pax_close_kernel();
21239+ printk("PAX: slow and weak UDEREF enabled\n");
21240+ } else
21241+ printk("PAX: UDEREF disabled\n");
21242+#endif
21243+
21244+ return;
21245+ }
21246+
21247+ printk("PAX: PCID detected\n");
21248+ cr4_set_bits(X86_CR4_PCIDE);
21249+
21250+#ifdef CONFIG_PAX_MEMORY_UDEREF
21251+ pax_open_kernel();
21252+ clone_pgd_mask = ~(pgdval_t)0UL;
21253+ pax_close_kernel();
21254+ if (pax_user_shadow_base)
21255+ printk("PAX: weak UDEREF enabled\n");
21256+ else {
21257+ set_cpu_cap(c, X86_FEATURE_STRONGUDEREF);
21258+ printk("PAX: strong UDEREF enabled\n");
21259+ }
21260+#endif
21261+
21262+ if (cpu_has(c, X86_FEATURE_INVPCID))
21263+ printk("PAX: INVPCID detected\n");
21264+}
21265+#endif
21266+
21267 /*
21268 * Some CPU features depend on higher CPUID levels, which may not always
21269 * be available due to CPUID level capping or broken virtualization
21270@@ -406,7 +405,7 @@ void switch_to_new_gdt(int cpu)
21271 {
21272 struct desc_ptr gdt_descr;
21273
21274- gdt_descr.address = (long)get_cpu_gdt_table(cpu);
21275+ gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
21276 gdt_descr.size = GDT_SIZE - 1;
21277 load_gdt(&gdt_descr);
21278 /* Reload the per-cpu base */
21279@@ -935,6 +934,20 @@ static void identify_cpu(struct cpuinfo_x86 *c)
21280 setup_smep(c);
21281 setup_smap(c);
21282
21283+#ifdef CONFIG_X86_32
21284+#ifdef CONFIG_PAX_PAGEEXEC
21285+ if (!(__supported_pte_mask & _PAGE_NX))
21286+ clear_cpu_cap(c, X86_FEATURE_PSE);
21287+#endif
21288+#if defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21289+ clear_cpu_cap(c, X86_FEATURE_SEP);
21290+#endif
21291+#endif
21292+
21293+#ifdef CONFIG_X86_64
21294+ setup_pcid(c);
21295+#endif
21296+
21297 /*
21298 * The vendor-specific functions might have changed features.
21299 * Now we do "generic changes."
21300@@ -1009,7 +1022,7 @@ void enable_sep_cpu(void)
21301 int cpu;
21302
21303 cpu = get_cpu();
21304- tss = &per_cpu(cpu_tss, cpu);
21305+ tss = cpu_tss + cpu;
21306
21307 if (!boot_cpu_has(X86_FEATURE_SEP))
21308 goto out;
21309@@ -1155,14 +1168,16 @@ static __init int setup_disablecpuid(char *arg)
21310 }
21311 __setup("clearcpuid=", setup_disablecpuid);
21312
21313+DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
21314+EXPORT_PER_CPU_SYMBOL(current_tinfo);
21315+
21316 DEFINE_PER_CPU(unsigned long, kernel_stack) =
21317- (unsigned long)&init_thread_union + THREAD_SIZE;
21318+ (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
21319 EXPORT_PER_CPU_SYMBOL(kernel_stack);
21320
21321 #ifdef CONFIG_X86_64
21322-struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
21323-struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1,
21324- (unsigned long) debug_idt_table };
21325+struct desc_ptr idt_descr __read_only = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
21326+const struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) debug_idt_table };
21327
21328 DEFINE_PER_CPU_FIRST(union irq_stack_union,
21329 irq_stack_union) __aligned(PAGE_SIZE) __visible;
21330@@ -1367,7 +1382,7 @@ void cpu_init(void)
21331 */
21332 load_ucode_ap();
21333
21334- t = &per_cpu(cpu_tss, cpu);
21335+ t = cpu_tss + cpu;
21336 oist = &per_cpu(orig_ist, cpu);
21337
21338 #ifdef CONFIG_NUMA
21339@@ -1399,7 +1414,6 @@ void cpu_init(void)
21340 wrmsrl(MSR_KERNEL_GS_BASE, 0);
21341 barrier();
21342
21343- x86_configure_nx();
21344 x2apic_setup();
21345
21346 /*
21347@@ -1451,7 +1465,7 @@ void cpu_init(void)
21348 {
21349 int cpu = smp_processor_id();
21350 struct task_struct *curr = current;
21351- struct tss_struct *t = &per_cpu(cpu_tss, cpu);
21352+ struct tss_struct *t = cpu_tss + cpu;
21353 struct thread_struct *thread = &curr->thread;
21354
21355 wait_for_master_cpu(cpu);
21356diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
21357index edcb0e2..a138233 100644
21358--- a/arch/x86/kernel/cpu/intel_cacheinfo.c
21359+++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
21360@@ -519,25 +519,23 @@ cache_private_attrs_is_visible(struct kobject *kobj,
21361 return 0;
21362 }
21363
21364+static struct attribute *amd_l3_attrs[4];
21365+
21366 static struct attribute_group cache_private_group = {
21367 .is_visible = cache_private_attrs_is_visible,
21368+ .attrs = amd_l3_attrs,
21369 };
21370
21371 static void init_amd_l3_attrs(void)
21372 {
21373 int n = 1;
21374- static struct attribute **amd_l3_attrs;
21375-
21376- if (amd_l3_attrs) /* already initialized */
21377- return;
21378
21379 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
21380 n += 2;
21381 if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
21382 n += 1;
21383
21384- amd_l3_attrs = kcalloc(n, sizeof(*amd_l3_attrs), GFP_KERNEL);
21385- if (!amd_l3_attrs)
21386+ if (n > 1 && amd_l3_attrs[0]) /* already initialized */
21387 return;
21388
21389 n = 0;
21390@@ -547,8 +545,6 @@ static void init_amd_l3_attrs(void)
21391 }
21392 if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
21393 amd_l3_attrs[n++] = &dev_attr_subcaches.attr;
21394-
21395- cache_private_group.attrs = amd_l3_attrs;
21396 }
21397
21398 const struct attribute_group *
21399@@ -559,7 +555,7 @@ cache_get_priv_group(struct cacheinfo *this_leaf)
21400 if (this_leaf->level < 3 || !nb)
21401 return NULL;
21402
21403- if (nb && nb->l3_cache.indices)
21404+ if (nb->l3_cache.indices)
21405 init_amd_l3_attrs();
21406
21407 return &cache_private_group;
21408diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
21409index 20190bd..cadb2ab 100644
21410--- a/arch/x86/kernel/cpu/mcheck/mce.c
21411+++ b/arch/x86/kernel/cpu/mcheck/mce.c
21412@@ -47,6 +47,7 @@
21413 #include <asm/tlbflush.h>
21414 #include <asm/mce.h>
21415 #include <asm/msr.h>
21416+#include <asm/local.h>
21417
21418 #include "mce-internal.h"
21419
21420@@ -256,7 +257,7 @@ static void print_mce(struct mce *m)
21421 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
21422 m->cs, m->ip);
21423
21424- if (m->cs == __KERNEL_CS)
21425+ if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
21426 print_symbol("{%s}", m->ip);
21427 pr_cont("\n");
21428 }
21429@@ -289,10 +290,10 @@ static void print_mce(struct mce *m)
21430
21431 #define PANIC_TIMEOUT 5 /* 5 seconds */
21432
21433-static atomic_t mce_panicked;
21434+static atomic_unchecked_t mce_panicked;
21435
21436 static int fake_panic;
21437-static atomic_t mce_fake_panicked;
21438+static atomic_unchecked_t mce_fake_panicked;
21439
21440 /* Panic in progress. Enable interrupts and wait for final IPI */
21441 static void wait_for_panic(void)
21442@@ -316,7 +317,7 @@ static void mce_panic(const char *msg, struct mce *final, char *exp)
21443 /*
21444 * Make sure only one CPU runs in machine check panic
21445 */
21446- if (atomic_inc_return(&mce_panicked) > 1)
21447+ if (atomic_inc_return_unchecked(&mce_panicked) > 1)
21448 wait_for_panic();
21449 barrier();
21450
21451@@ -324,7 +325,7 @@ static void mce_panic(const char *msg, struct mce *final, char *exp)
21452 console_verbose();
21453 } else {
21454 /* Don't log too much for fake panic */
21455- if (atomic_inc_return(&mce_fake_panicked) > 1)
21456+ if (atomic_inc_return_unchecked(&mce_fake_panicked) > 1)
21457 return;
21458 }
21459 /* First print corrected ones that are still unlogged */
21460@@ -363,7 +364,7 @@ static void mce_panic(const char *msg, struct mce *final, char *exp)
21461 if (!fake_panic) {
21462 if (panic_timeout == 0)
21463 panic_timeout = mca_cfg.panic_timeout;
21464- panic(msg);
21465+ panic("%s", msg);
21466 } else
21467 pr_emerg(HW_ERR "Fake kernel panic: %s\n", msg);
21468 }
21469@@ -749,7 +750,7 @@ static int mce_timed_out(u64 *t, const char *msg)
21470 * might have been modified by someone else.
21471 */
21472 rmb();
21473- if (atomic_read(&mce_panicked))
21474+ if (atomic_read_unchecked(&mce_panicked))
21475 wait_for_panic();
21476 if (!mca_cfg.monarch_timeout)
21477 goto out;
21478@@ -1679,7 +1680,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
21479 }
21480
21481 /* Call the installed machine check handler for this CPU setup. */
21482-void (*machine_check_vector)(struct pt_regs *, long error_code) =
21483+void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
21484 unexpected_machine_check;
21485
21486 /*
21487@@ -1702,7 +1703,9 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
21488 return;
21489 }
21490
21491+ pax_open_kernel();
21492 machine_check_vector = do_machine_check;
21493+ pax_close_kernel();
21494
21495 __mcheck_cpu_init_generic();
21496 __mcheck_cpu_init_vendor(c);
21497@@ -1716,7 +1719,7 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
21498 */
21499
21500 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
21501-static int mce_chrdev_open_count; /* #times opened */
21502+static local_t mce_chrdev_open_count; /* #times opened */
21503 static int mce_chrdev_open_exclu; /* already open exclusive? */
21504
21505 static int mce_chrdev_open(struct inode *inode, struct file *file)
21506@@ -1724,7 +1727,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
21507 spin_lock(&mce_chrdev_state_lock);
21508
21509 if (mce_chrdev_open_exclu ||
21510- (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
21511+ (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
21512 spin_unlock(&mce_chrdev_state_lock);
21513
21514 return -EBUSY;
21515@@ -1732,7 +1735,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
21516
21517 if (file->f_flags & O_EXCL)
21518 mce_chrdev_open_exclu = 1;
21519- mce_chrdev_open_count++;
21520+ local_inc(&mce_chrdev_open_count);
21521
21522 spin_unlock(&mce_chrdev_state_lock);
21523
21524@@ -1743,7 +1746,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
21525 {
21526 spin_lock(&mce_chrdev_state_lock);
21527
21528- mce_chrdev_open_count--;
21529+ local_dec(&mce_chrdev_open_count);
21530 mce_chrdev_open_exclu = 0;
21531
21532 spin_unlock(&mce_chrdev_state_lock);
21533@@ -2419,7 +2422,7 @@ static __init void mce_init_banks(void)
21534
21535 for (i = 0; i < mca_cfg.banks; i++) {
21536 struct mce_bank *b = &mce_banks[i];
21537- struct device_attribute *a = &b->attr;
21538+ device_attribute_no_const *a = &b->attr;
21539
21540 sysfs_attr_init(&a->attr);
21541 a->attr.name = b->attrname;
21542@@ -2526,7 +2529,7 @@ struct dentry *mce_get_debugfs_dir(void)
21543 static void mce_reset(void)
21544 {
21545 cpu_missing = 0;
21546- atomic_set(&mce_fake_panicked, 0);
21547+ atomic_set_unchecked(&mce_fake_panicked, 0);
21548 atomic_set(&mce_executing, 0);
21549 atomic_set(&mce_callin, 0);
21550 atomic_set(&global_nwo, 0);
21551diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
21552index 737b0ad..09ec66e 100644
21553--- a/arch/x86/kernel/cpu/mcheck/p5.c
21554+++ b/arch/x86/kernel/cpu/mcheck/p5.c
21555@@ -12,6 +12,7 @@
21556 #include <asm/tlbflush.h>
21557 #include <asm/mce.h>
21558 #include <asm/msr.h>
21559+#include <asm/pgtable.h>
21560
21561 /* By default disabled */
21562 int mce_p5_enabled __read_mostly;
21563@@ -55,7 +56,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
21564 if (!cpu_has(c, X86_FEATURE_MCE))
21565 return;
21566
21567+ pax_open_kernel();
21568 machine_check_vector = pentium_machine_check;
21569+ pax_close_kernel();
21570 /* Make sure the vector pointer is visible before we enable MCEs: */
21571 wmb();
21572
21573diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
21574index 44f1382..315b292 100644
21575--- a/arch/x86/kernel/cpu/mcheck/winchip.c
21576+++ b/arch/x86/kernel/cpu/mcheck/winchip.c
21577@@ -11,6 +11,7 @@
21578 #include <asm/tlbflush.h>
21579 #include <asm/mce.h>
21580 #include <asm/msr.h>
21581+#include <asm/pgtable.h>
21582
21583 /* Machine check handler for WinChip C6: */
21584 static void winchip_machine_check(struct pt_regs *regs, long error_code)
21585@@ -28,7 +29,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
21586 {
21587 u32 lo, hi;
21588
21589+ pax_open_kernel();
21590 machine_check_vector = winchip_machine_check;
21591+ pax_close_kernel();
21592 /* Make sure the vector pointer is visible before we enable MCEs: */
21593 wmb();
21594
21595diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
21596index 36a8361..e7058c2 100644
21597--- a/arch/x86/kernel/cpu/microcode/core.c
21598+++ b/arch/x86/kernel/cpu/microcode/core.c
21599@@ -518,7 +518,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
21600 return NOTIFY_OK;
21601 }
21602
21603-static struct notifier_block __refdata mc_cpu_notifier = {
21604+static struct notifier_block mc_cpu_notifier = {
21605 .notifier_call = mc_cpu_callback,
21606 };
21607
21608diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
21609index a41bead..4e3685b 100644
21610--- a/arch/x86/kernel/cpu/microcode/intel.c
21611+++ b/arch/x86/kernel/cpu/microcode/intel.c
21612@@ -298,13 +298,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
21613
21614 static int get_ucode_user(void *to, const void *from, size_t n)
21615 {
21616- return copy_from_user(to, from, n);
21617+ return copy_from_user(to, (const void __force_user *)from, n);
21618 }
21619
21620 static enum ucode_state
21621 request_microcode_user(int cpu, const void __user *buf, size_t size)
21622 {
21623- return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
21624+ return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
21625 }
21626
21627 static void microcode_fini_cpu(int cpu)
21628diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
21629index ea5f363..cb0e905 100644
21630--- a/arch/x86/kernel/cpu/mtrr/main.c
21631+++ b/arch/x86/kernel/cpu/mtrr/main.c
21632@@ -66,7 +66,7 @@ static DEFINE_MUTEX(mtrr_mutex);
21633 u64 size_or_mask, size_and_mask;
21634 static bool mtrr_aps_delayed_init;
21635
21636-static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
21637+static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
21638
21639 const struct mtrr_ops *mtrr_if;
21640
21641diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
21642index df5e41f..816c719 100644
21643--- a/arch/x86/kernel/cpu/mtrr/mtrr.h
21644+++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
21645@@ -25,7 +25,7 @@ struct mtrr_ops {
21646 int (*validate_add_page)(unsigned long base, unsigned long size,
21647 unsigned int type);
21648 int (*have_wrcomb)(void);
21649-};
21650+} __do_const;
21651
21652 extern int generic_get_free_region(unsigned long base, unsigned long size,
21653 int replace_reg);
21654diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
21655index aa4e3a7..469370f 100644
21656--- a/arch/x86/kernel/cpu/perf_event.c
21657+++ b/arch/x86/kernel/cpu/perf_event.c
21658@@ -1509,7 +1509,7 @@ static void __init pmu_check_apic(void)
21659
21660 }
21661
21662-static struct attribute_group x86_pmu_format_group = {
21663+static attribute_group_no_const x86_pmu_format_group = {
21664 .name = "format",
21665 .attrs = NULL,
21666 };
21667@@ -1608,7 +1608,7 @@ static struct attribute *events_attr[] = {
21668 NULL,
21669 };
21670
21671-static struct attribute_group x86_pmu_events_group = {
21672+static attribute_group_no_const x86_pmu_events_group = {
21673 .name = "events",
21674 .attrs = events_attr,
21675 };
21676@@ -2181,7 +2181,7 @@ static unsigned long get_segment_base(unsigned int segment)
21677 if (idx > GDT_ENTRIES)
21678 return 0;
21679
21680- desc = raw_cpu_ptr(gdt_page.gdt);
21681+ desc = get_cpu_gdt_table(smp_processor_id());
21682 }
21683
21684 return get_desc_base(desc + idx);
21685@@ -2271,7 +2271,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
21686 break;
21687
21688 perf_callchain_store(entry, frame.return_address);
21689- fp = frame.next_frame;
21690+ fp = (const void __force_user *)frame.next_frame;
21691 }
21692 }
21693
21694diff --git a/arch/x86/kernel/cpu/perf_event_amd_iommu.c b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
21695index 97242a9..cf9c30e 100644
21696--- a/arch/x86/kernel/cpu/perf_event_amd_iommu.c
21697+++ b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
21698@@ -402,7 +402,7 @@ static void perf_iommu_del(struct perf_event *event, int flags)
21699 static __init int _init_events_attrs(struct perf_amd_iommu *perf_iommu)
21700 {
21701 struct attribute **attrs;
21702- struct attribute_group *attr_group;
21703+ attribute_group_no_const *attr_group;
21704 int i = 0, j;
21705
21706 while (amd_iommu_v2_event_descs[i].attr.attr.name)
21707diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
21708index 2813ea0..3ef5969c8 100644
21709--- a/arch/x86/kernel/cpu/perf_event_intel.c
21710+++ b/arch/x86/kernel/cpu/perf_event_intel.c
21711@@ -3033,10 +3033,10 @@ __init int intel_pmu_init(void)
21712 x86_pmu.num_counters_fixed = max((int)edx.split.num_counters_fixed, 3);
21713
21714 if (boot_cpu_has(X86_FEATURE_PDCM)) {
21715- u64 capabilities;
21716+ u64 capabilities = x86_pmu.intel_cap.capabilities;
21717
21718- rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
21719- x86_pmu.intel_cap.capabilities = capabilities;
21720+ if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
21721+ x86_pmu.intel_cap.capabilities = capabilities;
21722 }
21723
21724 intel_ds_init();
21725diff --git a/arch/x86/kernel/cpu/perf_event_intel_bts.c b/arch/x86/kernel/cpu/perf_event_intel_bts.c
21726index 7795f3f..3535b76 100644
21727--- a/arch/x86/kernel/cpu/perf_event_intel_bts.c
21728+++ b/arch/x86/kernel/cpu/perf_event_intel_bts.c
21729@@ -252,7 +252,7 @@ static void bts_event_start(struct perf_event *event, int flags)
21730 __bts_event_start(event);
21731
21732 /* PMI handler: this counter is running and likely generating PMIs */
21733- ACCESS_ONCE(bts->started) = 1;
21734+ ACCESS_ONCE_RW(bts->started) = 1;
21735 }
21736
21737 static void __bts_event_stop(struct perf_event *event)
21738@@ -266,7 +266,7 @@ static void __bts_event_stop(struct perf_event *event)
21739 if (event->hw.state & PERF_HES_STOPPED)
21740 return;
21741
21742- ACCESS_ONCE(event->hw.state) |= PERF_HES_STOPPED;
21743+ ACCESS_ONCE_RW(event->hw.state) |= PERF_HES_STOPPED;
21744 }
21745
21746 static void bts_event_stop(struct perf_event *event, int flags)
21747@@ -274,7 +274,7 @@ static void bts_event_stop(struct perf_event *event, int flags)
21748 struct bts_ctx *bts = this_cpu_ptr(&bts_ctx);
21749
21750 /* PMI handler: don't restart this counter */
21751- ACCESS_ONCE(bts->started) = 0;
21752+ ACCESS_ONCE_RW(bts->started) = 0;
21753
21754 __bts_event_stop(event);
21755
21756diff --git a/arch/x86/kernel/cpu/perf_event_intel_cqm.c b/arch/x86/kernel/cpu/perf_event_intel_cqm.c
21757index e4d1b8b..8867302 100644
21758--- a/arch/x86/kernel/cpu/perf_event_intel_cqm.c
21759+++ b/arch/x86/kernel/cpu/perf_event_intel_cqm.c
21760@@ -934,6 +934,14 @@ static u64 intel_cqm_event_count(struct perf_event *event)
21761 return 0;
21762
21763 /*
21764+ * Getting up-to-date values requires an SMP IPI which is not
21765+ * possible if we're being called in interrupt context. Return
21766+ * the cached values instead.
21767+ */
21768+ if (unlikely(in_interrupt()))
21769+ goto out;
21770+
21771+ /*
21772 * Notice that we don't perform the reading of an RMID
21773 * atomically, because we can't hold a spin lock across the
21774 * IPIs.
21775@@ -1352,7 +1360,9 @@ static int __init intel_cqm_init(void)
21776 goto out;
21777 }
21778
21779- event_attr_intel_cqm_llc_scale.event_str = str;
21780+ pax_open_kernel();
21781+ *(const char **)&event_attr_intel_cqm_llc_scale.event_str = str;
21782+ pax_close_kernel();
21783
21784 ret = intel_cqm_setup_rmid_cache();
21785 if (ret)
21786diff --git a/arch/x86/kernel/cpu/perf_event_intel_pt.c b/arch/x86/kernel/cpu/perf_event_intel_pt.c
21787index 123ff1b..d53e500 100644
21788--- a/arch/x86/kernel/cpu/perf_event_intel_pt.c
21789+++ b/arch/x86/kernel/cpu/perf_event_intel_pt.c
21790@@ -116,16 +116,12 @@ static const struct attribute_group *pt_attr_groups[] = {
21791
21792 static int __init pt_pmu_hw_init(void)
21793 {
21794- struct dev_ext_attribute *de_attrs;
21795- struct attribute **attrs;
21796- size_t size;
21797- int ret;
21798+ static struct dev_ext_attribute de_attrs[ARRAY_SIZE(pt_caps)];
21799+ static struct attribute *attrs[ARRAY_SIZE(pt_caps)];
21800 long i;
21801
21802- attrs = NULL;
21803- ret = -ENODEV;
21804 if (!test_cpu_cap(&boot_cpu_data, X86_FEATURE_INTEL_PT))
21805- goto fail;
21806+ return -ENODEV;
21807
21808 for (i = 0; i < PT_CPUID_LEAVES; i++) {
21809 cpuid_count(20, i,
21810@@ -135,39 +131,25 @@ static int __init pt_pmu_hw_init(void)
21811 &pt_pmu.caps[CR_EDX + i*4]);
21812 }
21813
21814- ret = -ENOMEM;
21815- size = sizeof(struct attribute *) * (ARRAY_SIZE(pt_caps)+1);
21816- attrs = kzalloc(size, GFP_KERNEL);
21817- if (!attrs)
21818- goto fail;
21819-
21820- size = sizeof(struct dev_ext_attribute) * (ARRAY_SIZE(pt_caps)+1);
21821- de_attrs = kzalloc(size, GFP_KERNEL);
21822- if (!de_attrs)
21823- goto fail;
21824-
21825+ pax_open_kernel();
21826 for (i = 0; i < ARRAY_SIZE(pt_caps); i++) {
21827- struct dev_ext_attribute *de_attr = de_attrs + i;
21828+ struct dev_ext_attribute *de_attr = &de_attrs[i];
21829
21830- de_attr->attr.attr.name = pt_caps[i].name;
21831+ *(const char **)&de_attr->attr.attr.name = pt_caps[i].name;
21832
21833 sysfs_attr_init(&de_attr->attr.attr);
21834
21835- de_attr->attr.attr.mode = S_IRUGO;
21836- de_attr->attr.show = pt_cap_show;
21837- de_attr->var = (void *)i;
21838+ *(umode_t *)&de_attr->attr.attr.mode = S_IRUGO;
21839+ *(void **)&de_attr->attr.show = pt_cap_show;
21840+ *(void **)&de_attr->var = (void *)i;
21841
21842 attrs[i] = &de_attr->attr.attr;
21843 }
21844
21845- pt_cap_group.attrs = attrs;
21846+ *(struct attribute ***)&pt_cap_group.attrs = attrs;
21847+ pax_close_kernel();
21848
21849 return 0;
21850-
21851-fail:
21852- kfree(attrs);
21853-
21854- return ret;
21855 }
21856
21857 #define PT_CONFIG_MASK (RTIT_CTL_TSC_EN | RTIT_CTL_DISRETC)
21858@@ -928,7 +910,7 @@ static void pt_event_start(struct perf_event *event, int mode)
21859 return;
21860 }
21861
21862- ACCESS_ONCE(pt->handle_nmi) = 1;
21863+ ACCESS_ONCE_RW(pt->handle_nmi) = 1;
21864 event->hw.state = 0;
21865
21866 pt_config_buffer(buf->cur->table, buf->cur_idx,
21867@@ -945,7 +927,7 @@ static void pt_event_stop(struct perf_event *event, int mode)
21868 * Protect against the PMI racing with disabling wrmsr,
21869 * see comment in intel_pt_interrupt().
21870 */
21871- ACCESS_ONCE(pt->handle_nmi) = 0;
21872+ ACCESS_ONCE_RW(pt->handle_nmi) = 0;
21873 pt_config_start(false);
21874
21875 if (event->hw.state == PERF_HES_STOPPED)
21876diff --git a/arch/x86/kernel/cpu/perf_event_intel_rapl.c b/arch/x86/kernel/cpu/perf_event_intel_rapl.c
21877index 358c54a..f068235 100644
21878--- a/arch/x86/kernel/cpu/perf_event_intel_rapl.c
21879+++ b/arch/x86/kernel/cpu/perf_event_intel_rapl.c
21880@@ -487,7 +487,7 @@ static struct attribute *rapl_events_hsw_attr[] = {
21881 NULL,
21882 };
21883
21884-static struct attribute_group rapl_pmu_events_group = {
21885+static attribute_group_no_const rapl_pmu_events_group __read_only = {
21886 .name = "events",
21887 .attrs = NULL, /* patched at runtime */
21888 };
21889diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
21890index 90b7c50..7863ae3 100644
21891--- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
21892+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
21893@@ -732,7 +732,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
21894 static int __init uncore_type_init(struct intel_uncore_type *type)
21895 {
21896 struct intel_uncore_pmu *pmus;
21897- struct attribute_group *attr_group;
21898+ attribute_group_no_const *attr_group;
21899 struct attribute **attrs;
21900 int i, j;
21901
21902diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
21903index ceac8f5..a562de7 100644
21904--- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
21905+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
21906@@ -115,7 +115,7 @@ struct intel_uncore_box {
21907 struct uncore_event_desc {
21908 struct kobj_attribute attr;
21909 const char *config;
21910-};
21911+} __do_const;
21912
21913 ssize_t uncore_event_show(struct kobject *kobj,
21914 struct kobj_attribute *attr, char *buf);
21915diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
21916index 83741a7..bd3507d 100644
21917--- a/arch/x86/kernel/cpuid.c
21918+++ b/arch/x86/kernel/cpuid.c
21919@@ -170,7 +170,7 @@ static int cpuid_class_cpu_callback(struct notifier_block *nfb,
21920 return notifier_from_errno(err);
21921 }
21922
21923-static struct notifier_block __refdata cpuid_class_cpu_notifier =
21924+static struct notifier_block cpuid_class_cpu_notifier =
21925 {
21926 .notifier_call = cpuid_class_cpu_callback,
21927 };
21928diff --git a/arch/x86/kernel/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c
21929index afa64ad..dce67dd 100644
21930--- a/arch/x86/kernel/crash_dump_64.c
21931+++ b/arch/x86/kernel/crash_dump_64.c
21932@@ -36,7 +36,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
21933 return -ENOMEM;
21934
21935 if (userbuf) {
21936- if (copy_to_user(buf, vaddr + offset, csize)) {
21937+ if (copy_to_user((char __force_user *)buf, vaddr + offset, csize)) {
21938 iounmap(vaddr);
21939 return -EFAULT;
21940 }
21941diff --git a/arch/x86/kernel/doublefault.c b/arch/x86/kernel/doublefault.c
21942index f6dfd93..892ade4 100644
21943--- a/arch/x86/kernel/doublefault.c
21944+++ b/arch/x86/kernel/doublefault.c
21945@@ -12,7 +12,7 @@
21946
21947 #define DOUBLEFAULT_STACKSIZE (1024)
21948 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
21949-#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
21950+#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
21951
21952 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
21953
21954@@ -22,7 +22,7 @@ static void doublefault_fn(void)
21955 unsigned long gdt, tss;
21956
21957 native_store_gdt(&gdt_desc);
21958- gdt = gdt_desc.address;
21959+ gdt = (unsigned long)gdt_desc.address;
21960
21961 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
21962
21963@@ -59,10 +59,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
21964 /* 0x2 bit is always set */
21965 .flags = X86_EFLAGS_SF | 0x2,
21966 .sp = STACK_START,
21967- .es = __USER_DS,
21968+ .es = __KERNEL_DS,
21969 .cs = __KERNEL_CS,
21970 .ss = __KERNEL_DS,
21971- .ds = __USER_DS,
21972+ .ds = __KERNEL_DS,
21973 .fs = __KERNEL_PERCPU,
21974
21975 .__cr3 = __pa_nodebug(swapper_pg_dir),
21976diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
21977index 9c30acf..8cf2411 100644
21978--- a/arch/x86/kernel/dumpstack.c
21979+++ b/arch/x86/kernel/dumpstack.c
21980@@ -2,6 +2,9 @@
21981 * Copyright (C) 1991, 1992 Linus Torvalds
21982 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
21983 */
21984+#ifdef CONFIG_GRKERNSEC_HIDESYM
21985+#define __INCLUDED_BY_HIDESYM 1
21986+#endif
21987 #include <linux/kallsyms.h>
21988 #include <linux/kprobes.h>
21989 #include <linux/uaccess.h>
21990@@ -35,23 +38,21 @@ static void printk_stack_address(unsigned long address, int reliable,
21991
21992 void printk_address(unsigned long address)
21993 {
21994- pr_cont(" [<%p>] %pS\n", (void *)address, (void *)address);
21995+ pr_cont(" [<%p>] %pA\n", (void *)address, (void *)address);
21996 }
21997
21998 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
21999 static void
22000 print_ftrace_graph_addr(unsigned long addr, void *data,
22001 const struct stacktrace_ops *ops,
22002- struct thread_info *tinfo, int *graph)
22003+ struct task_struct *task, int *graph)
22004 {
22005- struct task_struct *task;
22006 unsigned long ret_addr;
22007 int index;
22008
22009 if (addr != (unsigned long)return_to_handler)
22010 return;
22011
22012- task = tinfo->task;
22013 index = task->curr_ret_stack;
22014
22015 if (!task->ret_stack || index < *graph)
22016@@ -68,7 +69,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
22017 static inline void
22018 print_ftrace_graph_addr(unsigned long addr, void *data,
22019 const struct stacktrace_ops *ops,
22020- struct thread_info *tinfo, int *graph)
22021+ struct task_struct *task, int *graph)
22022 { }
22023 #endif
22024
22025@@ -79,10 +80,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
22026 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
22027 */
22028
22029-static inline int valid_stack_ptr(struct thread_info *tinfo,
22030- void *p, unsigned int size, void *end)
22031+static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
22032 {
22033- void *t = tinfo;
22034 if (end) {
22035 if (p < end && p >= (end-THREAD_SIZE))
22036 return 1;
22037@@ -93,14 +92,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
22038 }
22039
22040 unsigned long
22041-print_context_stack(struct thread_info *tinfo,
22042+print_context_stack(struct task_struct *task, void *stack_start,
22043 unsigned long *stack, unsigned long bp,
22044 const struct stacktrace_ops *ops, void *data,
22045 unsigned long *end, int *graph)
22046 {
22047 struct stack_frame *frame = (struct stack_frame *)bp;
22048
22049- while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
22050+ while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
22051 unsigned long addr;
22052
22053 addr = *stack;
22054@@ -112,7 +111,7 @@ print_context_stack(struct thread_info *tinfo,
22055 } else {
22056 ops->address(data, addr, 0);
22057 }
22058- print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
22059+ print_ftrace_graph_addr(addr, data, ops, task, graph);
22060 }
22061 stack++;
22062 }
22063@@ -121,7 +120,7 @@ print_context_stack(struct thread_info *tinfo,
22064 EXPORT_SYMBOL_GPL(print_context_stack);
22065
22066 unsigned long
22067-print_context_stack_bp(struct thread_info *tinfo,
22068+print_context_stack_bp(struct task_struct *task, void *stack_start,
22069 unsigned long *stack, unsigned long bp,
22070 const struct stacktrace_ops *ops, void *data,
22071 unsigned long *end, int *graph)
22072@@ -129,7 +128,7 @@ print_context_stack_bp(struct thread_info *tinfo,
22073 struct stack_frame *frame = (struct stack_frame *)bp;
22074 unsigned long *ret_addr = &frame->return_address;
22075
22076- while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
22077+ while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
22078 unsigned long addr = *ret_addr;
22079
22080 if (!__kernel_text_address(addr))
22081@@ -138,7 +137,7 @@ print_context_stack_bp(struct thread_info *tinfo,
22082 ops->address(data, addr, 1);
22083 frame = frame->next_frame;
22084 ret_addr = &frame->return_address;
22085- print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
22086+ print_ftrace_graph_addr(addr, data, ops, task, graph);
22087 }
22088
22089 return (unsigned long)frame;
22090@@ -226,6 +225,8 @@ unsigned long oops_begin(void)
22091 EXPORT_SYMBOL_GPL(oops_begin);
22092 NOKPROBE_SYMBOL(oops_begin);
22093
22094+extern void gr_handle_kernel_exploit(void);
22095+
22096 void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
22097 {
22098 if (regs && kexec_should_crash(current))
22099@@ -247,7 +248,10 @@ void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
22100 panic("Fatal exception in interrupt");
22101 if (panic_on_oops)
22102 panic("Fatal exception");
22103- do_exit(signr);
22104+
22105+ gr_handle_kernel_exploit();
22106+
22107+ do_group_exit(signr);
22108 }
22109 NOKPROBE_SYMBOL(oops_end);
22110
22111diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
22112index 464ffd6..01f2cda 100644
22113--- a/arch/x86/kernel/dumpstack_32.c
22114+++ b/arch/x86/kernel/dumpstack_32.c
22115@@ -61,15 +61,14 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
22116 bp = stack_frame(task, regs);
22117
22118 for (;;) {
22119- struct thread_info *context;
22120+ void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
22121 void *end_stack;
22122
22123 end_stack = is_hardirq_stack(stack, cpu);
22124 if (!end_stack)
22125 end_stack = is_softirq_stack(stack, cpu);
22126
22127- context = task_thread_info(task);
22128- bp = ops->walk_stack(context, stack, bp, ops, data,
22129+ bp = ops->walk_stack(task, stack_start, stack, bp, ops, data,
22130 end_stack, &graph);
22131
22132 /* Stop if not on irq stack */
22133@@ -137,16 +136,17 @@ void show_regs(struct pt_regs *regs)
22134 unsigned int code_len = code_bytes;
22135 unsigned char c;
22136 u8 *ip;
22137+ unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
22138
22139 pr_emerg("Stack:\n");
22140 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
22141
22142 pr_emerg("Code:");
22143
22144- ip = (u8 *)regs->ip - code_prologue;
22145+ ip = (u8 *)regs->ip - code_prologue + cs_base;
22146 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
22147 /* try starting at IP */
22148- ip = (u8 *)regs->ip;
22149+ ip = (u8 *)regs->ip + cs_base;
22150 code_len = code_len - code_prologue + 1;
22151 }
22152 for (i = 0; i < code_len; i++, ip++) {
22153@@ -155,7 +155,7 @@ void show_regs(struct pt_regs *regs)
22154 pr_cont(" Bad EIP value.");
22155 break;
22156 }
22157- if (ip == (u8 *)regs->ip)
22158+ if (ip == (u8 *)regs->ip + cs_base)
22159 pr_cont(" <%02x>", c);
22160 else
22161 pr_cont(" %02x", c);
22162@@ -168,6 +168,7 @@ int is_valid_bugaddr(unsigned long ip)
22163 {
22164 unsigned short ud2;
22165
22166+ ip = ktla_ktva(ip);
22167 if (ip < PAGE_OFFSET)
22168 return 0;
22169 if (probe_kernel_address((unsigned short *)ip, ud2))
22170@@ -175,3 +176,15 @@ int is_valid_bugaddr(unsigned long ip)
22171
22172 return ud2 == 0x0b0f;
22173 }
22174+
22175+#if defined(CONFIG_PAX_MEMORY_STACKLEAK) || defined(CONFIG_PAX_USERCOPY)
22176+void __used pax_check_alloca(unsigned long size)
22177+{
22178+ unsigned long sp = (unsigned long)&sp, stack_left;
22179+
22180+ /* all kernel stacks are of the same size */
22181+ stack_left = sp & (THREAD_SIZE - 1);
22182+ BUG_ON(stack_left < 256 || size >= stack_left - 256);
22183+}
22184+EXPORT_SYMBOL(pax_check_alloca);
22185+#endif
22186diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
22187index 5f1c626..1cba97e 100644
22188--- a/arch/x86/kernel/dumpstack_64.c
22189+++ b/arch/x86/kernel/dumpstack_64.c
22190@@ -153,12 +153,12 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
22191 const struct stacktrace_ops *ops, void *data)
22192 {
22193 const unsigned cpu = get_cpu();
22194- struct thread_info *tinfo;
22195 unsigned long *irq_stack = (unsigned long *)per_cpu(irq_stack_ptr, cpu);
22196 unsigned long dummy;
22197 unsigned used = 0;
22198 int graph = 0;
22199 int done = 0;
22200+ void *stack_start;
22201
22202 if (!task)
22203 task = current;
22204@@ -179,7 +179,6 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
22205 * current stack address. If the stacks consist of nested
22206 * exceptions
22207 */
22208- tinfo = task_thread_info(task);
22209 while (!done) {
22210 unsigned long *stack_end;
22211 enum stack_type stype;
22212@@ -202,7 +201,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
22213 if (ops->stack(data, id) < 0)
22214 break;
22215
22216- bp = ops->walk_stack(tinfo, stack, bp, ops,
22217+ bp = ops->walk_stack(task, stack_end - EXCEPTION_STKSZ, stack, bp, ops,
22218 data, stack_end, &graph);
22219 ops->stack(data, "<EOE>");
22220 /*
22221@@ -210,6 +209,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
22222 * second-to-last pointer (index -2 to end) in the
22223 * exception stack:
22224 */
22225+ if ((u16)stack_end[-1] != __KERNEL_DS)
22226+ goto out;
22227 stack = (unsigned long *) stack_end[-2];
22228 done = 0;
22229 break;
22230@@ -218,7 +219,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
22231
22232 if (ops->stack(data, "IRQ") < 0)
22233 break;
22234- bp = ops->walk_stack(tinfo, stack, bp,
22235+ bp = ops->walk_stack(task, irq_stack, stack, bp,
22236 ops, data, stack_end, &graph);
22237 /*
22238 * We link to the next stack (which would be
22239@@ -240,7 +241,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
22240 /*
22241 * This handles the process stack:
22242 */
22243- bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
22244+ stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
22245+ bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
22246+out:
22247 put_cpu();
22248 }
22249 EXPORT_SYMBOL(dump_trace);
22250@@ -347,8 +350,55 @@ int is_valid_bugaddr(unsigned long ip)
22251 {
22252 unsigned short ud2;
22253
22254- if (__copy_from_user(&ud2, (const void __user *) ip, sizeof(ud2)))
22255+ if (probe_kernel_address((unsigned short *)ip, ud2))
22256 return 0;
22257
22258 return ud2 == 0x0b0f;
22259 }
22260+
22261+#if defined(CONFIG_PAX_MEMORY_STACKLEAK) || defined(CONFIG_PAX_USERCOPY)
22262+void __used pax_check_alloca(unsigned long size)
22263+{
22264+ unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
22265+ unsigned cpu, used;
22266+ char *id;
22267+
22268+ /* check the process stack first */
22269+ stack_start = (unsigned long)task_stack_page(current);
22270+ stack_end = stack_start + THREAD_SIZE;
22271+ if (likely(stack_start <= sp && sp < stack_end)) {
22272+ unsigned long stack_left = sp & (THREAD_SIZE - 1);
22273+ BUG_ON(stack_left < 256 || size >= stack_left - 256);
22274+ return;
22275+ }
22276+
22277+ cpu = get_cpu();
22278+
22279+ /* check the irq stacks */
22280+ stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
22281+ stack_start = stack_end - IRQ_STACK_SIZE;
22282+ if (stack_start <= sp && sp < stack_end) {
22283+ unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
22284+ put_cpu();
22285+ BUG_ON(stack_left < 256 || size >= stack_left - 256);
22286+ return;
22287+ }
22288+
22289+ /* check the exception stacks */
22290+ used = 0;
22291+ stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
22292+ stack_start = stack_end - EXCEPTION_STKSZ;
22293+ if (stack_end && stack_start <= sp && sp < stack_end) {
22294+ unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
22295+ put_cpu();
22296+ BUG_ON(stack_left < 256 || size >= stack_left - 256);
22297+ return;
22298+ }
22299+
22300+ put_cpu();
22301+
22302+ /* unknown stack */
22303+ BUG();
22304+}
22305+EXPORT_SYMBOL(pax_check_alloca);
22306+#endif
22307diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
22308index e2ce85d..00ccad0 100644
22309--- a/arch/x86/kernel/e820.c
22310+++ b/arch/x86/kernel/e820.c
22311@@ -802,8 +802,8 @@ unsigned long __init e820_end_of_low_ram_pfn(void)
22312
22313 static void early_panic(char *msg)
22314 {
22315- early_printk(msg);
22316- panic(msg);
22317+ early_printk("%s", msg);
22318+ panic("%s", msg);
22319 }
22320
22321 static int userdef __initdata;
22322diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
22323index 89427d8..00c0d52 100644
22324--- a/arch/x86/kernel/early_printk.c
22325+++ b/arch/x86/kernel/early_printk.c
22326@@ -7,6 +7,7 @@
22327 #include <linux/pci_regs.h>
22328 #include <linux/pci_ids.h>
22329 #include <linux/errno.h>
22330+#include <linux/sched.h>
22331 #include <asm/io.h>
22332 #include <asm/processor.h>
22333 #include <asm/fcntl.h>
22334diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
22335index 1c30976..71b41b9 100644
22336--- a/arch/x86/kernel/entry_32.S
22337+++ b/arch/x86/kernel/entry_32.S
22338@@ -177,13 +177,154 @@
22339 /*CFI_REL_OFFSET gs, PT_GS*/
22340 .endm
22341 .macro SET_KERNEL_GS reg
22342+
22343+#ifdef CONFIG_CC_STACKPROTECTOR
22344 movl $(__KERNEL_STACK_CANARY), \reg
22345+#elif defined(CONFIG_PAX_MEMORY_UDEREF)
22346+ movl $(__USER_DS), \reg
22347+#else
22348+ xorl \reg, \reg
22349+#endif
22350+
22351 movl \reg, %gs
22352 .endm
22353
22354 #endif /* CONFIG_X86_32_LAZY_GS */
22355
22356-.macro SAVE_ALL
22357+.macro pax_enter_kernel
22358+#ifdef CONFIG_PAX_KERNEXEC
22359+ call pax_enter_kernel
22360+#endif
22361+.endm
22362+
22363+.macro pax_exit_kernel
22364+#ifdef CONFIG_PAX_KERNEXEC
22365+ call pax_exit_kernel
22366+#endif
22367+.endm
22368+
22369+#ifdef CONFIG_PAX_KERNEXEC
22370+ENTRY(pax_enter_kernel)
22371+#ifdef CONFIG_PARAVIRT
22372+ pushl %eax
22373+ pushl %ecx
22374+ call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
22375+ mov %eax, %esi
22376+#else
22377+ mov %cr0, %esi
22378+#endif
22379+ bts $X86_CR0_WP_BIT, %esi
22380+ jnc 1f
22381+ mov %cs, %esi
22382+ cmp $__KERNEL_CS, %esi
22383+ jz 3f
22384+ ljmp $__KERNEL_CS, $3f
22385+1: ljmp $__KERNEXEC_KERNEL_CS, $2f
22386+2:
22387+#ifdef CONFIG_PARAVIRT
22388+ mov %esi, %eax
22389+ call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
22390+#else
22391+ mov %esi, %cr0
22392+#endif
22393+3:
22394+#ifdef CONFIG_PARAVIRT
22395+ popl %ecx
22396+ popl %eax
22397+#endif
22398+ ret
22399+ENDPROC(pax_enter_kernel)
22400+
22401+ENTRY(pax_exit_kernel)
22402+#ifdef CONFIG_PARAVIRT
22403+ pushl %eax
22404+ pushl %ecx
22405+#endif
22406+ mov %cs, %esi
22407+ cmp $__KERNEXEC_KERNEL_CS, %esi
22408+ jnz 2f
22409+#ifdef CONFIG_PARAVIRT
22410+ call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
22411+ mov %eax, %esi
22412+#else
22413+ mov %cr0, %esi
22414+#endif
22415+ btr $X86_CR0_WP_BIT, %esi
22416+ ljmp $__KERNEL_CS, $1f
22417+1:
22418+#ifdef CONFIG_PARAVIRT
22419+ mov %esi, %eax
22420+ call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
22421+#else
22422+ mov %esi, %cr0
22423+#endif
22424+2:
22425+#ifdef CONFIG_PARAVIRT
22426+ popl %ecx
22427+ popl %eax
22428+#endif
22429+ ret
22430+ENDPROC(pax_exit_kernel)
22431+#endif
22432+
22433+ .macro pax_erase_kstack
22434+#ifdef CONFIG_PAX_MEMORY_STACKLEAK
22435+ call pax_erase_kstack
22436+#endif
22437+ .endm
22438+
22439+#ifdef CONFIG_PAX_MEMORY_STACKLEAK
22440+/*
22441+ * ebp: thread_info
22442+ */
22443+ENTRY(pax_erase_kstack)
22444+ pushl %edi
22445+ pushl %ecx
22446+ pushl %eax
22447+
22448+ mov TI_lowest_stack(%ebp), %edi
22449+ mov $-0xBEEF, %eax
22450+ std
22451+
22452+1: mov %edi, %ecx
22453+ and $THREAD_SIZE_asm - 1, %ecx
22454+ shr $2, %ecx
22455+ repne scasl
22456+ jecxz 2f
22457+
22458+ cmp $2*16, %ecx
22459+ jc 2f
22460+
22461+ mov $2*16, %ecx
22462+ repe scasl
22463+ jecxz 2f
22464+ jne 1b
22465+
22466+2: cld
22467+ or $2*4, %edi
22468+ mov %esp, %ecx
22469+ sub %edi, %ecx
22470+
22471+ cmp $THREAD_SIZE_asm, %ecx
22472+ jb 3f
22473+ ud2
22474+3:
22475+
22476+ shr $2, %ecx
22477+ rep stosl
22478+
22479+ mov TI_task_thread_sp0(%ebp), %edi
22480+ sub $128, %edi
22481+ mov %edi, TI_lowest_stack(%ebp)
22482+
22483+ popl %eax
22484+ popl %ecx
22485+ popl %edi
22486+ ret
22487+ENDPROC(pax_erase_kstack)
22488+#endif
22489+
22490+.macro __SAVE_ALL _DS
22491 cld
22492 PUSH_GS
22493 pushl_cfi %fs
22494@@ -206,7 +347,7 @@
22495 CFI_REL_OFFSET ecx, 0
22496 pushl_cfi %ebx
22497 CFI_REL_OFFSET ebx, 0
22498- movl $(__USER_DS), %edx
22499+ movl $\_DS, %edx
22500 movl %edx, %ds
22501 movl %edx, %es
22502 movl $(__KERNEL_PERCPU), %edx
22503@@ -214,6 +355,15 @@
22504 SET_KERNEL_GS %edx
22505 .endm
22506
22507+.macro SAVE_ALL
22508+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22509+ __SAVE_ALL __KERNEL_DS
22510+ pax_enter_kernel
22511+#else
22512+ __SAVE_ALL __USER_DS
22513+#endif
22514+.endm
22515+
22516 .macro RESTORE_INT_REGS
22517 popl_cfi %ebx
22518 CFI_RESTORE ebx
22519@@ -297,7 +447,7 @@ ENTRY(ret_from_fork)
22520 popfl_cfi
22521 jmp syscall_exit
22522 CFI_ENDPROC
22523-END(ret_from_fork)
22524+ENDPROC(ret_from_fork)
22525
22526 ENTRY(ret_from_kernel_thread)
22527 CFI_STARTPROC
22528@@ -340,7 +490,15 @@ ret_from_intr:
22529 andl $SEGMENT_RPL_MASK, %eax
22530 #endif
22531 cmpl $USER_RPL, %eax
22532+
22533+#ifdef CONFIG_PAX_KERNEXEC
22534+ jae resume_userspace
22535+
22536+ pax_exit_kernel
22537+ jmp resume_kernel
22538+#else
22539 jb resume_kernel # not returning to v8086 or userspace
22540+#endif
22541
22542 ENTRY(resume_userspace)
22543 LOCKDEP_SYS_EXIT
22544@@ -352,8 +510,8 @@ ENTRY(resume_userspace)
22545 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
22546 # int/exception return?
22547 jne work_pending
22548- jmp restore_all
22549-END(ret_from_exception)
22550+ jmp restore_all_pax
22551+ENDPROC(ret_from_exception)
22552
22553 #ifdef CONFIG_PREEMPT
22554 ENTRY(resume_kernel)
22555@@ -365,7 +523,7 @@ need_resched:
22556 jz restore_all
22557 call preempt_schedule_irq
22558 jmp need_resched
22559-END(resume_kernel)
22560+ENDPROC(resume_kernel)
22561 #endif
22562 CFI_ENDPROC
22563
22564@@ -395,33 +553,45 @@ sysenter_past_esp:
22565 /*CFI_REL_OFFSET cs, 0*/
22566 /*
22567 * Push current_thread_info()->sysenter_return to the stack.
22568- * A tiny bit of offset fixup is necessary: TI_sysenter_return
22569- * is relative to thread_info, which is at the bottom of the
22570- * kernel stack page. 4*4 means the 4 words pushed above;
22571- * TOP_OF_KERNEL_STACK_PADDING takes us to the top of the stack;
22572- * and THREAD_SIZE takes us to the bottom.
22573 */
22574- pushl_cfi ((TI_sysenter_return) - THREAD_SIZE + TOP_OF_KERNEL_STACK_PADDING + 4*4)(%esp)
22575+ pushl_cfi $0
22576 CFI_REL_OFFSET eip, 0
22577
22578 pushl_cfi %eax
22579 SAVE_ALL
22580+ GET_THREAD_INFO(%ebp)
22581+ movl TI_sysenter_return(%ebp),%ebp
22582+ movl %ebp,PT_EIP(%esp)
22583 ENABLE_INTERRUPTS(CLBR_NONE)
22584
22585 /*
22586 * Load the potential sixth argument from user stack.
22587 * Careful about security.
22588 */
22589+ movl PT_OLDESP(%esp),%ebp
22590+
22591+#ifdef CONFIG_PAX_MEMORY_UDEREF
22592+ mov PT_OLDSS(%esp),%ds
22593+1: movl %ds:(%ebp),%ebp
22594+ push %ss
22595+ pop %ds
22596+#else
22597 cmpl $__PAGE_OFFSET-3,%ebp
22598 jae syscall_fault
22599 ASM_STAC
22600 1: movl (%ebp),%ebp
22601 ASM_CLAC
22602+#endif
22603+
22604 movl %ebp,PT_EBP(%esp)
22605 _ASM_EXTABLE(1b,syscall_fault)
22606
22607 GET_THREAD_INFO(%ebp)
22608
22609+#ifdef CONFIG_PAX_RANDKSTACK
22610+ pax_erase_kstack
22611+#endif
22612+
22613 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
22614 jnz sysenter_audit
22615 sysenter_do_call:
22616@@ -437,12 +607,24 @@ sysenter_after_call:
22617 testl $_TIF_ALLWORK_MASK, %ecx
22618 jnz sysexit_audit
22619 sysenter_exit:
22620+
22621+#ifdef CONFIG_PAX_RANDKSTACK
22622+ pushl_cfi %eax
22623+ movl %esp, %eax
22624+ call pax_randomize_kstack
22625+ popl_cfi %eax
22626+#endif
22627+
22628+ pax_erase_kstack
22629+
22630 /* if something modifies registers it must also disable sysexit */
22631 movl PT_EIP(%esp), %edx
22632 movl PT_OLDESP(%esp), %ecx
22633 xorl %ebp,%ebp
22634 TRACE_IRQS_ON
22635 1: mov PT_FS(%esp), %fs
22636+2: mov PT_DS(%esp), %ds
22637+3: mov PT_ES(%esp), %es
22638 PTGS_TO_GS
22639 ENABLE_INTERRUPTS_SYSEXIT
22640
22641@@ -456,6 +638,9 @@ sysenter_audit:
22642 pushl_cfi PT_ESI(%esp) /* a3: 5th arg */
22643 pushl_cfi PT_EDX+4(%esp) /* a2: 4th arg */
22644 call __audit_syscall_entry
22645+
22646+ pax_erase_kstack
22647+
22648 popl_cfi %ecx /* get that remapped edx off the stack */
22649 popl_cfi %ecx /* get that remapped esi off the stack */
22650 movl PT_EAX(%esp),%eax /* reload syscall number */
22651@@ -482,10 +667,16 @@ sysexit_audit:
22652
22653 CFI_ENDPROC
22654 .pushsection .fixup,"ax"
22655-2: movl $0,PT_FS(%esp)
22656+4: movl $0,PT_FS(%esp)
22657+ jmp 1b
22658+5: movl $0,PT_DS(%esp)
22659+ jmp 1b
22660+6: movl $0,PT_ES(%esp)
22661 jmp 1b
22662 .popsection
22663- _ASM_EXTABLE(1b,2b)
22664+ _ASM_EXTABLE(1b,4b)
22665+ _ASM_EXTABLE(2b,5b)
22666+ _ASM_EXTABLE(3b,6b)
22667 PTGS_TO_GS_EX
22668 ENDPROC(ia32_sysenter_target)
22669
22670@@ -496,6 +687,11 @@ ENTRY(system_call)
22671 pushl_cfi %eax # save orig_eax
22672 SAVE_ALL
22673 GET_THREAD_INFO(%ebp)
22674+
22675+#ifdef CONFIG_PAX_RANDKSTACK
22676+ pax_erase_kstack
22677+#endif
22678+
22679 # system call tracing in operation / emulation
22680 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
22681 jnz syscall_trace_entry
22682@@ -515,6 +711,15 @@ syscall_exit:
22683 testl $_TIF_ALLWORK_MASK, %ecx # current->work
22684 jnz syscall_exit_work
22685
22686+restore_all_pax:
22687+
22688+#ifdef CONFIG_PAX_RANDKSTACK
22689+ movl %esp, %eax
22690+ call pax_randomize_kstack
22691+#endif
22692+
22693+ pax_erase_kstack
22694+
22695 restore_all:
22696 TRACE_IRQS_IRET
22697 restore_all_notrace:
22698@@ -569,14 +774,34 @@ ldt_ss:
22699 * compensating for the offset by changing to the ESPFIX segment with
22700 * a base address that matches for the difference.
22701 */
22702-#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
22703+#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
22704 mov %esp, %edx /* load kernel esp */
22705 mov PT_OLDESP(%esp), %eax /* load userspace esp */
22706 mov %dx, %ax /* eax: new kernel esp */
22707 sub %eax, %edx /* offset (low word is 0) */
22708+#ifdef CONFIG_SMP
22709+ movl PER_CPU_VAR(cpu_number), %ebx
22710+ shll $PAGE_SHIFT_asm, %ebx
22711+ addl $cpu_gdt_table, %ebx
22712+#else
22713+ movl $cpu_gdt_table, %ebx
22714+#endif
22715 shr $16, %edx
22716- mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
22717- mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
22718+
22719+#ifdef CONFIG_PAX_KERNEXEC
22720+ mov %cr0, %esi
22721+ btr $X86_CR0_WP_BIT, %esi
22722+ mov %esi, %cr0
22723+#endif
22724+
22725+ mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
22726+ mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
22727+
22728+#ifdef CONFIG_PAX_KERNEXEC
22729+ bts $X86_CR0_WP_BIT, %esi
22730+ mov %esi, %cr0
22731+#endif
22732+
22733 pushl_cfi $__ESPFIX_SS
22734 pushl_cfi %eax /* new kernel esp */
22735 /* Disable interrupts, but do not irqtrace this section: we
22736@@ -606,20 +831,18 @@ work_resched:
22737 movl TI_flags(%ebp), %ecx
22738 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
22739 # than syscall tracing?
22740- jz restore_all
22741+ jz restore_all_pax
22742 testb $_TIF_NEED_RESCHED, %cl
22743 jnz work_resched
22744
22745 work_notifysig: # deal with pending signals and
22746 # notify-resume requests
22747+ movl %esp, %eax
22748 #ifdef CONFIG_VM86
22749 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
22750- movl %esp, %eax
22751 jnz work_notifysig_v86 # returning to kernel-space or
22752 # vm86-space
22753 1:
22754-#else
22755- movl %esp, %eax
22756 #endif
22757 TRACE_IRQS_ON
22758 ENABLE_INTERRUPTS(CLBR_NONE)
22759@@ -640,7 +863,7 @@ work_notifysig_v86:
22760 movl %eax, %esp
22761 jmp 1b
22762 #endif
22763-END(work_pending)
22764+ENDPROC(work_pending)
22765
22766 # perform syscall exit tracing
22767 ALIGN
22768@@ -648,11 +871,14 @@ syscall_trace_entry:
22769 movl $-ENOSYS,PT_EAX(%esp)
22770 movl %esp, %eax
22771 call syscall_trace_enter
22772+
22773+ pax_erase_kstack
22774+
22775 /* What it returned is what we'll actually use. */
22776 cmpl $(NR_syscalls), %eax
22777 jnae syscall_call
22778 jmp syscall_exit
22779-END(syscall_trace_entry)
22780+ENDPROC(syscall_trace_entry)
22781
22782 # perform syscall exit tracing
22783 ALIGN
22784@@ -665,26 +891,30 @@ syscall_exit_work:
22785 movl %esp, %eax
22786 call syscall_trace_leave
22787 jmp resume_userspace
22788-END(syscall_exit_work)
22789+ENDPROC(syscall_exit_work)
22790 CFI_ENDPROC
22791
22792 RING0_INT_FRAME # can't unwind into user space anyway
22793 syscall_fault:
22794+#ifdef CONFIG_PAX_MEMORY_UDEREF
22795+ push %ss
22796+ pop %ds
22797+#endif
22798 ASM_CLAC
22799 GET_THREAD_INFO(%ebp)
22800 movl $-EFAULT,PT_EAX(%esp)
22801 jmp resume_userspace
22802-END(syscall_fault)
22803+ENDPROC(syscall_fault)
22804
22805 syscall_badsys:
22806 movl $-ENOSYS,%eax
22807 jmp syscall_after_call
22808-END(syscall_badsys)
22809+ENDPROC(syscall_badsys)
22810
22811 sysenter_badsys:
22812 movl $-ENOSYS,%eax
22813 jmp sysenter_after_call
22814-END(sysenter_badsys)
22815+ENDPROC(sysenter_badsys)
22816 CFI_ENDPROC
22817
22818 .macro FIXUP_ESPFIX_STACK
22819@@ -697,8 +927,15 @@ END(sysenter_badsys)
22820 */
22821 #ifdef CONFIG_X86_ESPFIX32
22822 /* fixup the stack */
22823- mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
22824- mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
22825+#ifdef CONFIG_SMP
22826+ movl PER_CPU_VAR(cpu_number), %ebx
22827+ shll $PAGE_SHIFT_asm, %ebx
22828+ addl $cpu_gdt_table, %ebx
22829+#else
22830+ movl $cpu_gdt_table, %ebx
22831+#endif
22832+ mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
22833+ mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
22834 shl $16, %eax
22835 addl %esp, %eax /* the adjusted stack pointer */
22836 pushl_cfi $__KERNEL_DS
22837@@ -737,7 +974,7 @@ ENTRY(irq_entries_start)
22838 CFI_ADJUST_CFA_OFFSET -4
22839 .align 8
22840 .endr
22841-END(irq_entries_start)
22842+ENDPROC(irq_entries_start)
22843
22844 /*
22845 * the CPU automatically disables interrupts when executing an IRQ vector,
22846@@ -790,7 +1027,7 @@ ENTRY(coprocessor_error)
22847 pushl_cfi $do_coprocessor_error
22848 jmp error_code
22849 CFI_ENDPROC
22850-END(coprocessor_error)
22851+ENDPROC(coprocessor_error)
22852
22853 ENTRY(simd_coprocessor_error)
22854 RING0_INT_FRAME
22855@@ -806,7 +1043,7 @@ ENTRY(simd_coprocessor_error)
22856 #endif
22857 jmp error_code
22858 CFI_ENDPROC
22859-END(simd_coprocessor_error)
22860+ENDPROC(simd_coprocessor_error)
22861
22862 ENTRY(device_not_available)
22863 RING0_INT_FRAME
22864@@ -815,18 +1052,18 @@ ENTRY(device_not_available)
22865 pushl_cfi $do_device_not_available
22866 jmp error_code
22867 CFI_ENDPROC
22868-END(device_not_available)
22869+ENDPROC(device_not_available)
22870
22871 #ifdef CONFIG_PARAVIRT
22872 ENTRY(native_iret)
22873 iret
22874 _ASM_EXTABLE(native_iret, iret_exc)
22875-END(native_iret)
22876+ENDPROC(native_iret)
22877
22878 ENTRY(native_irq_enable_sysexit)
22879 sti
22880 sysexit
22881-END(native_irq_enable_sysexit)
22882+ENDPROC(native_irq_enable_sysexit)
22883 #endif
22884
22885 ENTRY(overflow)
22886@@ -836,7 +1073,7 @@ ENTRY(overflow)
22887 pushl_cfi $do_overflow
22888 jmp error_code
22889 CFI_ENDPROC
22890-END(overflow)
22891+ENDPROC(overflow)
22892
22893 ENTRY(bounds)
22894 RING0_INT_FRAME
22895@@ -845,7 +1082,7 @@ ENTRY(bounds)
22896 pushl_cfi $do_bounds
22897 jmp error_code
22898 CFI_ENDPROC
22899-END(bounds)
22900+ENDPROC(bounds)
22901
22902 ENTRY(invalid_op)
22903 RING0_INT_FRAME
22904@@ -854,7 +1091,7 @@ ENTRY(invalid_op)
22905 pushl_cfi $do_invalid_op
22906 jmp error_code
22907 CFI_ENDPROC
22908-END(invalid_op)
22909+ENDPROC(invalid_op)
22910
22911 ENTRY(coprocessor_segment_overrun)
22912 RING0_INT_FRAME
22913@@ -863,7 +1100,7 @@ ENTRY(coprocessor_segment_overrun)
22914 pushl_cfi $do_coprocessor_segment_overrun
22915 jmp error_code
22916 CFI_ENDPROC
22917-END(coprocessor_segment_overrun)
22918+ENDPROC(coprocessor_segment_overrun)
22919
22920 ENTRY(invalid_TSS)
22921 RING0_EC_FRAME
22922@@ -871,7 +1108,7 @@ ENTRY(invalid_TSS)
22923 pushl_cfi $do_invalid_TSS
22924 jmp error_code
22925 CFI_ENDPROC
22926-END(invalid_TSS)
22927+ENDPROC(invalid_TSS)
22928
22929 ENTRY(segment_not_present)
22930 RING0_EC_FRAME
22931@@ -879,7 +1116,7 @@ ENTRY(segment_not_present)
22932 pushl_cfi $do_segment_not_present
22933 jmp error_code
22934 CFI_ENDPROC
22935-END(segment_not_present)
22936+ENDPROC(segment_not_present)
22937
22938 ENTRY(stack_segment)
22939 RING0_EC_FRAME
22940@@ -887,7 +1124,7 @@ ENTRY(stack_segment)
22941 pushl_cfi $do_stack_segment
22942 jmp error_code
22943 CFI_ENDPROC
22944-END(stack_segment)
22945+ENDPROC(stack_segment)
22946
22947 ENTRY(alignment_check)
22948 RING0_EC_FRAME
22949@@ -895,7 +1132,7 @@ ENTRY(alignment_check)
22950 pushl_cfi $do_alignment_check
22951 jmp error_code
22952 CFI_ENDPROC
22953-END(alignment_check)
22954+ENDPROC(alignment_check)
22955
22956 ENTRY(divide_error)
22957 RING0_INT_FRAME
22958@@ -904,7 +1141,7 @@ ENTRY(divide_error)
22959 pushl_cfi $do_divide_error
22960 jmp error_code
22961 CFI_ENDPROC
22962-END(divide_error)
22963+ENDPROC(divide_error)
22964
22965 #ifdef CONFIG_X86_MCE
22966 ENTRY(machine_check)
22967@@ -914,7 +1151,7 @@ ENTRY(machine_check)
22968 pushl_cfi machine_check_vector
22969 jmp error_code
22970 CFI_ENDPROC
22971-END(machine_check)
22972+ENDPROC(machine_check)
22973 #endif
22974
22975 ENTRY(spurious_interrupt_bug)
22976@@ -924,7 +1161,7 @@ ENTRY(spurious_interrupt_bug)
22977 pushl_cfi $do_spurious_interrupt_bug
22978 jmp error_code
22979 CFI_ENDPROC
22980-END(spurious_interrupt_bug)
22981+ENDPROC(spurious_interrupt_bug)
22982
22983 #ifdef CONFIG_XEN
22984 /* Xen doesn't set %esp to be precisely what the normal sysenter
22985@@ -1033,7 +1270,7 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
22986
22987 ENTRY(mcount)
22988 ret
22989-END(mcount)
22990+ENDPROC(mcount)
22991
22992 ENTRY(ftrace_caller)
22993 pushl %eax
22994@@ -1063,7 +1300,7 @@ ftrace_graph_call:
22995 .globl ftrace_stub
22996 ftrace_stub:
22997 ret
22998-END(ftrace_caller)
22999+ENDPROC(ftrace_caller)
23000
23001 ENTRY(ftrace_regs_caller)
23002 pushf /* push flags before compare (in cs location) */
23003@@ -1161,7 +1398,7 @@ trace:
23004 popl %ecx
23005 popl %eax
23006 jmp ftrace_stub
23007-END(mcount)
23008+ENDPROC(mcount)
23009 #endif /* CONFIG_DYNAMIC_FTRACE */
23010 #endif /* CONFIG_FUNCTION_TRACER */
23011
23012@@ -1179,7 +1416,7 @@ ENTRY(ftrace_graph_caller)
23013 popl %ecx
23014 popl %eax
23015 ret
23016-END(ftrace_graph_caller)
23017+ENDPROC(ftrace_graph_caller)
23018
23019 .globl return_to_handler
23020 return_to_handler:
23021@@ -1233,15 +1470,18 @@ error_code:
23022 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
23023 REG_TO_PTGS %ecx
23024 SET_KERNEL_GS %ecx
23025- movl $(__USER_DS), %ecx
23026+ movl $(__KERNEL_DS), %ecx
23027 movl %ecx, %ds
23028 movl %ecx, %es
23029+
23030+ pax_enter_kernel
23031+
23032 TRACE_IRQS_OFF
23033 movl %esp,%eax # pt_regs pointer
23034 call *%edi
23035 jmp ret_from_exception
23036 CFI_ENDPROC
23037-END(page_fault)
23038+ENDPROC(page_fault)
23039
23040 /*
23041 * Debug traps and NMI can happen at the one SYSENTER instruction
23042@@ -1284,7 +1524,7 @@ debug_stack_correct:
23043 call do_debug
23044 jmp ret_from_exception
23045 CFI_ENDPROC
23046-END(debug)
23047+ENDPROC(debug)
23048
23049 /*
23050 * NMI is doubly nasty. It can happen _while_ we're handling
23051@@ -1324,6 +1564,9 @@ nmi_stack_correct:
23052 xorl %edx,%edx # zero error code
23053 movl %esp,%eax # pt_regs pointer
23054 call do_nmi
23055+
23056+ pax_exit_kernel
23057+
23058 jmp restore_all_notrace
23059 CFI_ENDPROC
23060
23061@@ -1361,13 +1604,16 @@ nmi_espfix_stack:
23062 FIXUP_ESPFIX_STACK # %eax == %esp
23063 xorl %edx,%edx # zero error code
23064 call do_nmi
23065+
23066+ pax_exit_kernel
23067+
23068 RESTORE_REGS
23069 lss 12+4(%esp), %esp # back to espfix stack
23070 CFI_ADJUST_CFA_OFFSET -24
23071 jmp irq_return
23072 #endif
23073 CFI_ENDPROC
23074-END(nmi)
23075+ENDPROC(nmi)
23076
23077 ENTRY(int3)
23078 RING0_INT_FRAME
23079@@ -1380,14 +1626,14 @@ ENTRY(int3)
23080 call do_int3
23081 jmp ret_from_exception
23082 CFI_ENDPROC
23083-END(int3)
23084+ENDPROC(int3)
23085
23086 ENTRY(general_protection)
23087 RING0_EC_FRAME
23088 pushl_cfi $do_general_protection
23089 jmp error_code
23090 CFI_ENDPROC
23091-END(general_protection)
23092+ENDPROC(general_protection)
23093
23094 #ifdef CONFIG_KVM_GUEST
23095 ENTRY(async_page_fault)
23096@@ -1396,6 +1642,6 @@ ENTRY(async_page_fault)
23097 pushl_cfi $do_async_page_fault
23098 jmp error_code
23099 CFI_ENDPROC
23100-END(async_page_fault)
23101+ENDPROC(async_page_fault)
23102 #endif
23103
23104diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
23105index 02c2eff..a13739f 100644
23106--- a/arch/x86/kernel/entry_64.S
23107+++ b/arch/x86/kernel/entry_64.S
23108@@ -46,6 +46,8 @@
23109 #include <asm/smap.h>
23110 #include <asm/pgtable_types.h>
23111 #include <linux/err.h>
23112+#include <asm/pgtable.h>
23113+#include <asm/alternative-asm.h>
23114
23115 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
23116 #include <linux/elf-em.h>
23117@@ -64,6 +66,401 @@ ENTRY(native_usergs_sysret64)
23118 ENDPROC(native_usergs_sysret64)
23119 #endif /* CONFIG_PARAVIRT */
23120
23121+ .macro ljmpq sel, off
23122+#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
23123+ .byte 0x48; ljmp *1234f(%rip)
23124+ .pushsection .rodata
23125+ .align 16
23126+ 1234: .quad \off; .word \sel
23127+ .popsection
23128+#else
23129+ pushq $\sel
23130+ pushq $\off
23131+ lretq
23132+#endif
23133+ .endm
23134+
23135+ .macro pax_enter_kernel
23136+ pax_set_fptr_mask
23137+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
23138+ call pax_enter_kernel
23139+#endif
23140+ .endm
23141+
23142+ .macro pax_exit_kernel
23143+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
23144+ call pax_exit_kernel
23145+#endif
23146+
23147+ .endm
23148+
23149+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
23150+ENTRY(pax_enter_kernel)
23151+ pushq %rdi
23152+
23153+#ifdef CONFIG_PARAVIRT
23154+ PV_SAVE_REGS(CLBR_RDI)
23155+#endif
23156+
23157+#ifdef CONFIG_PAX_KERNEXEC
23158+ GET_CR0_INTO_RDI
23159+ bts $X86_CR0_WP_BIT,%rdi
23160+ jnc 3f
23161+ mov %cs,%edi
23162+ cmp $__KERNEL_CS,%edi
23163+ jnz 2f
23164+1:
23165+#endif
23166+
23167+#ifdef CONFIG_PAX_MEMORY_UDEREF
23168+ ALTERNATIVE "jmp 111f", "", X86_FEATURE_PCID
23169+ GET_CR3_INTO_RDI
23170+ cmp $0,%dil
23171+ jnz 112f
23172+ mov $__KERNEL_DS,%edi
23173+ mov %edi,%ss
23174+ jmp 111f
23175+112: cmp $1,%dil
23176+ jz 113f
23177+ ud2
23178+113: sub $4097,%rdi
23179+ bts $63,%rdi
23180+ SET_RDI_INTO_CR3
23181+ mov $__UDEREF_KERNEL_DS,%edi
23182+ mov %edi,%ss
23183+111:
23184+#endif
23185+
23186+#ifdef CONFIG_PARAVIRT
23187+ PV_RESTORE_REGS(CLBR_RDI)
23188+#endif
23189+
23190+ popq %rdi
23191+ pax_force_retaddr
23192+ retq
23193+
23194+#ifdef CONFIG_PAX_KERNEXEC
23195+2: ljmpq __KERNEL_CS,1b
23196+3: ljmpq __KERNEXEC_KERNEL_CS,4f
23197+4: SET_RDI_INTO_CR0
23198+ jmp 1b
23199+#endif
23200+ENDPROC(pax_enter_kernel)
23201+
23202+ENTRY(pax_exit_kernel)
23203+ pushq %rdi
23204+
23205+#ifdef CONFIG_PARAVIRT
23206+ PV_SAVE_REGS(CLBR_RDI)
23207+#endif
23208+
23209+#ifdef CONFIG_PAX_KERNEXEC
23210+ mov %cs,%rdi
23211+ cmp $__KERNEXEC_KERNEL_CS,%edi
23212+ jz 2f
23213+ GET_CR0_INTO_RDI
23214+ bts $X86_CR0_WP_BIT,%rdi
23215+ jnc 4f
23216+1:
23217+#endif
23218+
23219+#ifdef CONFIG_PAX_MEMORY_UDEREF
23220+ ALTERNATIVE "jmp 111f", "", X86_FEATURE_PCID
23221+ mov %ss,%edi
23222+ cmp $__UDEREF_KERNEL_DS,%edi
23223+ jnz 111f
23224+ GET_CR3_INTO_RDI
23225+ cmp $0,%dil
23226+ jz 112f
23227+ ud2
23228+112: add $4097,%rdi
23229+ bts $63,%rdi
23230+ SET_RDI_INTO_CR3
23231+ mov $__KERNEL_DS,%edi
23232+ mov %edi,%ss
23233+111:
23234+#endif
23235+
23236+#ifdef CONFIG_PARAVIRT
23237+ PV_RESTORE_REGS(CLBR_RDI);
23238+#endif
23239+
23240+ popq %rdi
23241+ pax_force_retaddr
23242+ retq
23243+
23244+#ifdef CONFIG_PAX_KERNEXEC
23245+2: GET_CR0_INTO_RDI
23246+ btr $X86_CR0_WP_BIT,%rdi
23247+ jnc 4f
23248+ ljmpq __KERNEL_CS,3f
23249+3: SET_RDI_INTO_CR0
23250+ jmp 1b
23251+4: ud2
23252+ jmp 4b
23253+#endif
23254+ENDPROC(pax_exit_kernel)
23255+#endif
23256+
23257+ .macro pax_enter_kernel_user
23258+ pax_set_fptr_mask
23259+#ifdef CONFIG_PAX_MEMORY_UDEREF
23260+ call pax_enter_kernel_user
23261+#endif
23262+ .endm
23263+
23264+ .macro pax_exit_kernel_user
23265+#ifdef CONFIG_PAX_MEMORY_UDEREF
23266+ call pax_exit_kernel_user
23267+#endif
23268+#ifdef CONFIG_PAX_RANDKSTACK
23269+ pushq %rax
23270+ pushq %r11
23271+ call pax_randomize_kstack
23272+ popq %r11
23273+ popq %rax
23274+#endif
23275+ .endm
23276+
23277+#ifdef CONFIG_PAX_MEMORY_UDEREF
23278+ENTRY(pax_enter_kernel_user)
23279+ pushq %rdi
23280+ pushq %rbx
23281+
23282+#ifdef CONFIG_PARAVIRT
23283+ PV_SAVE_REGS(CLBR_RDI)
23284+#endif
23285+
23286+ ALTERNATIVE "jmp 111f", "", X86_FEATURE_PCID
23287+ GET_CR3_INTO_RDI
23288+ cmp $1,%dil
23289+ jnz 4f
23290+ sub $4097,%rdi
23291+ bts $63,%rdi
23292+ SET_RDI_INTO_CR3
23293+ jmp 3f
23294+111:
23295+
23296+ GET_CR3_INTO_RDI
23297+ mov %rdi,%rbx
23298+ add $__START_KERNEL_map,%rbx
23299+ sub phys_base(%rip),%rbx
23300+
23301+#ifdef CONFIG_PARAVIRT
23302+ cmpl $0, pv_info+PARAVIRT_enabled
23303+ jz 1f
23304+ pushq %rdi
23305+ i = 0
23306+ .rept USER_PGD_PTRS
23307+ mov i*8(%rbx),%rsi
23308+ mov $0,%sil
23309+ lea i*8(%rbx),%rdi
23310+ call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
23311+ i = i + 1
23312+ .endr
23313+ popq %rdi
23314+ jmp 2f
23315+1:
23316+#endif
23317+
23318+ i = 0
23319+ .rept USER_PGD_PTRS
23320+ movb $0,i*8(%rbx)
23321+ i = i + 1
23322+ .endr
23323+
23324+2: SET_RDI_INTO_CR3
23325+
23326+#ifdef CONFIG_PAX_KERNEXEC
23327+ GET_CR0_INTO_RDI
23328+ bts $X86_CR0_WP_BIT,%rdi
23329+ SET_RDI_INTO_CR0
23330+#endif
23331+
23332+3:
23333+
23334+#ifdef CONFIG_PARAVIRT
23335+ PV_RESTORE_REGS(CLBR_RDI)
23336+#endif
23337+
23338+ popq %rbx
23339+ popq %rdi
23340+ pax_force_retaddr
23341+ retq
23342+4: ud2
23343+ENDPROC(pax_enter_kernel_user)
23344+
23345+ENTRY(pax_exit_kernel_user)
23346+ pushq %rdi
23347+ pushq %rbx
23348+
23349+#ifdef CONFIG_PARAVIRT
23350+ PV_SAVE_REGS(CLBR_RDI)
23351+#endif
23352+
23353+ GET_CR3_INTO_RDI
23354+ ALTERNATIVE "jmp 1f", "", X86_FEATURE_PCID
23355+ cmp $0,%dil
23356+ jnz 3f
23357+ add $4097,%rdi
23358+ bts $63,%rdi
23359+ SET_RDI_INTO_CR3
23360+ jmp 2f
23361+1:
23362+
23363+ mov %rdi,%rbx
23364+
23365+#ifdef CONFIG_PAX_KERNEXEC
23366+ GET_CR0_INTO_RDI
23367+ btr $X86_CR0_WP_BIT,%rdi
23368+ jnc 3f
23369+ SET_RDI_INTO_CR0
23370+#endif
23371+
23372+ add $__START_KERNEL_map,%rbx
23373+ sub phys_base(%rip),%rbx
23374+
23375+#ifdef CONFIG_PARAVIRT
23376+ cmpl $0, pv_info+PARAVIRT_enabled
23377+ jz 1f
23378+ i = 0
23379+ .rept USER_PGD_PTRS
23380+ mov i*8(%rbx),%rsi
23381+ mov $0x67,%sil
23382+ lea i*8(%rbx),%rdi
23383+ call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
23384+ i = i + 1
23385+ .endr
23386+ jmp 2f
23387+1:
23388+#endif
23389+
23390+ i = 0
23391+ .rept USER_PGD_PTRS
23392+ movb $0x67,i*8(%rbx)
23393+ i = i + 1
23394+ .endr
23395+2:
23396+
23397+#ifdef CONFIG_PARAVIRT
23398+ PV_RESTORE_REGS(CLBR_RDI)
23399+#endif
23400+
23401+ popq %rbx
23402+ popq %rdi
23403+ pax_force_retaddr
23404+ retq
23405+3: ud2
23406+ENDPROC(pax_exit_kernel_user)
23407+#endif
23408+
23409+ .macro pax_enter_kernel_nmi
23410+ pax_set_fptr_mask
23411+
23412+#ifdef CONFIG_PAX_KERNEXEC
23413+ GET_CR0_INTO_RDI
23414+ bts $X86_CR0_WP_BIT,%rdi
23415+ jc 110f
23416+ SET_RDI_INTO_CR0
23417+ or $2,%ebx
23418+110:
23419+#endif
23420+
23421+#ifdef CONFIG_PAX_MEMORY_UDEREF
23422+ ALTERNATIVE "jmp 111f", "", X86_FEATURE_PCID
23423+ GET_CR3_INTO_RDI
23424+ cmp $0,%dil
23425+ jz 111f
23426+ sub $4097,%rdi
23427+ or $4,%ebx
23428+ bts $63,%rdi
23429+ SET_RDI_INTO_CR3
23430+ mov $__UDEREF_KERNEL_DS,%edi
23431+ mov %edi,%ss
23432+111:
23433+#endif
23434+ .endm
23435+
23436+ .macro pax_exit_kernel_nmi
23437+#ifdef CONFIG_PAX_KERNEXEC
23438+ btr $1,%ebx
23439+ jnc 110f
23440+ GET_CR0_INTO_RDI
23441+ btr $X86_CR0_WP_BIT,%rdi
23442+ SET_RDI_INTO_CR0
23443+110:
23444+#endif
23445+
23446+#ifdef CONFIG_PAX_MEMORY_UDEREF
23447+ btr $2,%ebx
23448+ jnc 111f
23449+ GET_CR3_INTO_RDI
23450+ add $4097,%rdi
23451+ bts $63,%rdi
23452+ SET_RDI_INTO_CR3
23453+ mov $__KERNEL_DS,%edi
23454+ mov %edi,%ss
23455+111:
23456+#endif
23457+ .endm
23458+
23459+ .macro pax_erase_kstack
23460+#ifdef CONFIG_PAX_MEMORY_STACKLEAK
23461+ call pax_erase_kstack
23462+#endif
23463+ .endm
23464+
23465+#ifdef CONFIG_PAX_MEMORY_STACKLEAK
23466+ENTRY(pax_erase_kstack)
23467+ pushq %rdi
23468+ pushq %rcx
23469+ pushq %rax
23470+ pushq %r11
23471+
23472+ GET_THREAD_INFO(%r11)
23473+ mov TI_lowest_stack(%r11), %rdi
23474+ mov $-0xBEEF, %rax
23475+ std
23476+
23477+1: mov %edi, %ecx
23478+ and $THREAD_SIZE_asm - 1, %ecx
23479+ shr $3, %ecx
23480+ repne scasq
23481+ jecxz 2f
23482+
23483+ cmp $2*8, %ecx
23484+ jc 2f
23485+
23486+ mov $2*8, %ecx
23487+ repe scasq
23488+ jecxz 2f
23489+ jne 1b
23490+
23491+2: cld
23492+ or $2*8, %rdi
23493+ mov %esp, %ecx
23494+ sub %edi, %ecx
23495+
23496+ cmp $THREAD_SIZE_asm, %rcx
23497+ jb 3f
23498+ ud2
23499+3:
23500+
23501+ shr $3, %ecx
23502+ rep stosq
23503+
23504+ mov TI_task_thread_sp0(%r11), %rdi
23505+ sub $256, %rdi
23506+ mov %rdi, TI_lowest_stack(%r11)
23507+
23508+ popq %r11
23509+ popq %rax
23510+ popq %rcx
23511+ popq %rdi
23512+ pax_force_retaddr
23513+ ret
23514+ENDPROC(pax_erase_kstack)
23515+#endif
23516
23517 .macro TRACE_IRQS_IRETQ
23518 #ifdef CONFIG_TRACE_IRQFLAGS
23519@@ -100,7 +497,7 @@ ENDPROC(native_usergs_sysret64)
23520 .endm
23521
23522 .macro TRACE_IRQS_IRETQ_DEBUG
23523- bt $9,EFLAGS(%rsp) /* interrupts off? */
23524+ bt $X86_EFLAGS_IF_BIT,EFLAGS(%rsp) /* interrupts off? */
23525 jnc 1f
23526 TRACE_IRQS_ON_DEBUG
23527 1:
23528@@ -221,14 +618,6 @@ GLOBAL(system_call_after_swapgs)
23529 /* Construct struct pt_regs on stack */
23530 pushq_cfi $__USER_DS /* pt_regs->ss */
23531 pushq_cfi PER_CPU_VAR(rsp_scratch) /* pt_regs->sp */
23532- /*
23533- * Re-enable interrupts.
23534- * We use 'rsp_scratch' as a scratch space, hence irq-off block above
23535- * must execute atomically in the face of possible interrupt-driven
23536- * task preemption. We must enable interrupts only after we're done
23537- * with using rsp_scratch:
23538- */
23539- ENABLE_INTERRUPTS(CLBR_NONE)
23540 pushq_cfi %r11 /* pt_regs->flags */
23541 pushq_cfi $__USER_CS /* pt_regs->cs */
23542 pushq_cfi %rcx /* pt_regs->ip */
23543@@ -246,7 +635,27 @@ GLOBAL(system_call_after_swapgs)
23544 sub $(6*8),%rsp /* pt_regs->bp,bx,r12-15 not saved */
23545 CFI_ADJUST_CFA_OFFSET 6*8
23546
23547- testl $_TIF_WORK_SYSCALL_ENTRY, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
23548+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
23549+ movq_cfi r12, R12
23550+#endif
23551+
23552+ pax_enter_kernel_user
23553+
23554+#ifdef CONFIG_PAX_RANDKSTACK
23555+ pax_erase_kstack
23556+#endif
23557+
23558+ /*
23559+ * Re-enable interrupts.
23560+ * We use 'rsp_scratch' as a scratch space, hence irq-off block above
23561+ * must execute atomically in the face of possible interrupt-driven
23562+ * task preemption. We must enable interrupts only after we're done
23563+ * with using rsp_scratch:
23564+ */
23565+ ENABLE_INTERRUPTS(CLBR_NONE)
23566+
23567+ GET_THREAD_INFO(%rcx)
23568+ testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
23569 jnz tracesys
23570 system_call_fastpath:
23571 #if __SYSCALL_MASK == ~0
23572@@ -279,10 +688,13 @@ system_call_fastpath:
23573 * flags (TIF_NOTIFY_RESUME, TIF_USER_RETURN_NOTIFY, etc) set is
23574 * very bad.
23575 */
23576- testl $_TIF_ALLWORK_MASK, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
23577+ GET_THREAD_INFO(%rcx)
23578+ testl $_TIF_ALLWORK_MASK,TI_flags(%rcx)
23579 jnz int_ret_from_sys_call_irqs_off /* Go to the slow path */
23580
23581 CFI_REMEMBER_STATE
23582+ pax_exit_kernel_user
23583+ pax_erase_kstack
23584
23585 RESTORE_C_REGS_EXCEPT_RCX_R11
23586 movq RIP(%rsp),%rcx
23587@@ -316,6 +728,9 @@ tracesys:
23588 call syscall_trace_enter_phase1
23589 test %rax, %rax
23590 jnz tracesys_phase2 /* if needed, run the slow path */
23591+
23592+ pax_erase_kstack
23593+
23594 RESTORE_C_REGS_EXCEPT_RAX /* else restore clobbered regs */
23595 movq ORIG_RAX(%rsp), %rax
23596 jmp system_call_fastpath /* and return to the fast path */
23597@@ -327,6 +742,8 @@ tracesys_phase2:
23598 movq %rax,%rdx
23599 call syscall_trace_enter_phase2
23600
23601+ pax_erase_kstack
23602+
23603 /*
23604 * Reload registers from stack in case ptrace changed them.
23605 * We don't reload %rax because syscall_trace_entry_phase2() returned
23606@@ -364,6 +781,8 @@ GLOBAL(int_with_check)
23607 andl %edi,%edx
23608 jnz int_careful
23609 andl $~TS_COMPAT,TI_status(%rcx)
23610+ pax_exit_kernel_user
23611+ pax_erase_kstack
23612 jmp syscall_return
23613
23614 /* Either reschedule or signal or syscall exit tracking needed. */
23615@@ -485,7 +904,7 @@ opportunistic_sysret_failed:
23616 SWAPGS
23617 jmp restore_c_regs_and_iret
23618 CFI_ENDPROC
23619-END(system_call)
23620+ENDPROC(system_call)
23621
23622
23623 .macro FORK_LIKE func
23624@@ -495,7 +914,7 @@ ENTRY(stub_\func)
23625 SAVE_EXTRA_REGS 8
23626 jmp sys_\func
23627 CFI_ENDPROC
23628-END(stub_\func)
23629+ENDPROC(stub_\func)
23630 .endm
23631
23632 FORK_LIKE clone
23633@@ -519,7 +938,7 @@ return_from_execve:
23634 movq %rax,RAX(%rsp)
23635 jmp int_ret_from_sys_call
23636 CFI_ENDPROC
23637-END(stub_execve)
23638+ENDPROC(stub_execve)
23639 /*
23640 * Remaining execve stubs are only 7 bytes long.
23641 * ENTRY() often aligns to 16 bytes, which in this case has no benefits.
23642@@ -531,7 +950,7 @@ GLOBAL(stub_execveat)
23643 call sys_execveat
23644 jmp return_from_execve
23645 CFI_ENDPROC
23646-END(stub_execveat)
23647+ENDPROC(stub_execveat)
23648
23649 #ifdef CONFIG_X86_X32_ABI
23650 .align 8
23651@@ -541,7 +960,7 @@ GLOBAL(stub_x32_execve)
23652 call compat_sys_execve
23653 jmp return_from_execve
23654 CFI_ENDPROC
23655-END(stub_x32_execve)
23656+ENDPROC(stub_x32_execve)
23657 .align 8
23658 GLOBAL(stub_x32_execveat)
23659 CFI_STARTPROC
23660@@ -549,7 +968,7 @@ GLOBAL(stub_x32_execveat)
23661 call compat_sys_execveat
23662 jmp return_from_execve
23663 CFI_ENDPROC
23664-END(stub_x32_execveat)
23665+ENDPROC(stub_x32_execveat)
23666 #endif
23667
23668 #ifdef CONFIG_IA32_EMULATION
23669@@ -592,7 +1011,7 @@ return_from_stub:
23670 movq %rax,RAX(%rsp)
23671 jmp int_ret_from_sys_call
23672 CFI_ENDPROC
23673-END(stub_rt_sigreturn)
23674+ENDPROC(stub_rt_sigreturn)
23675
23676 #ifdef CONFIG_X86_X32_ABI
23677 ENTRY(stub_x32_rt_sigreturn)
23678@@ -602,7 +1021,7 @@ ENTRY(stub_x32_rt_sigreturn)
23679 call sys32_x32_rt_sigreturn
23680 jmp return_from_stub
23681 CFI_ENDPROC
23682-END(stub_x32_rt_sigreturn)
23683+ENDPROC(stub_x32_rt_sigreturn)
23684 #endif
23685
23686 /*
23687@@ -622,7 +1041,7 @@ ENTRY(ret_from_fork)
23688
23689 RESTORE_EXTRA_REGS
23690
23691- testl $3,CS(%rsp) # from kernel_thread?
23692+ testb $3,CS(%rsp) # from kernel_thread?
23693
23694 /*
23695 * By the time we get here, we have no idea whether our pt_regs,
23696@@ -641,7 +1060,7 @@ ENTRY(ret_from_fork)
23697 RESTORE_EXTRA_REGS
23698 jmp int_ret_from_sys_call
23699 CFI_ENDPROC
23700-END(ret_from_fork)
23701+ENDPROC(ret_from_fork)
23702
23703 /*
23704 * Build the entry stubs with some assembler magic.
23705@@ -659,7 +1078,7 @@ ENTRY(irq_entries_start)
23706 .align 8
23707 .endr
23708 CFI_ENDPROC
23709-END(irq_entries_start)
23710+ENDPROC(irq_entries_start)
23711
23712 /*
23713 * Interrupt entry/exit.
23714@@ -672,21 +1091,13 @@ END(irq_entries_start)
23715 /* 0(%rsp): ~(interrupt number) */
23716 .macro interrupt func
23717 cld
23718- /*
23719- * Since nothing in interrupt handling code touches r12...r15 members
23720- * of "struct pt_regs", and since interrupts can nest, we can save
23721- * four stack slots and simultaneously provide
23722- * an unwind-friendly stack layout by saving "truncated" pt_regs
23723- * exactly up to rbp slot, without these members.
23724- */
23725- ALLOC_PT_GPREGS_ON_STACK -RBP
23726- SAVE_C_REGS -RBP
23727- /* this goes to 0(%rsp) for unwinder, not for saving the value: */
23728- SAVE_EXTRA_REGS_RBP -RBP
23729+ ALLOC_PT_GPREGS_ON_STACK
23730+ SAVE_C_REGS
23731+ SAVE_EXTRA_REGS
23732
23733- leaq -RBP(%rsp),%rdi /* arg1 for \func (pointer to pt_regs) */
23734+ movq %rsp,%rdi /* arg1 for \func (pointer to pt_regs) */
23735
23736- testl $3, CS-RBP(%rsp)
23737+ testb $3, CS(%rsp)
23738 je 1f
23739 SWAPGS
23740 1:
23741@@ -709,8 +1120,20 @@ END(irq_entries_start)
23742 CFI_ESCAPE 0x0f /* DW_CFA_def_cfa_expression */, 6, \
23743 0x77 /* DW_OP_breg7 (rsp) */, 0, \
23744 0x06 /* DW_OP_deref */, \
23745- 0x08 /* DW_OP_const1u */, SIZEOF_PTREGS-RBP, \
23746+ 0x08 /* DW_OP_const1u */, SIZEOF_PTREGS, \
23747 0x22 /* DW_OP_plus */
23748+
23749+#ifdef CONFIG_PAX_MEMORY_UDEREF
23750+ testb $3, CS(%rdi)
23751+ jnz 1f
23752+ pax_enter_kernel
23753+ jmp 2f
23754+1: pax_enter_kernel_user
23755+2:
23756+#else
23757+ pax_enter_kernel
23758+#endif
23759+
23760 /* We entered an interrupt context - irqs are off: */
23761 TRACE_IRQS_OFF
23762
23763@@ -735,13 +1158,12 @@ ret_from_intr:
23764
23765 /* Restore saved previous stack */
23766 popq %rsi
23767- CFI_DEF_CFA rsi,SIZEOF_PTREGS-RBP /* reg/off reset after def_cfa_expr */
23768- /* return code expects complete pt_regs - adjust rsp accordingly: */
23769- leaq -RBP(%rsi),%rsp
23770+ CFI_DEF_CFA rsi,SIZEOF_PTREGS /* reg/off reset after def_cfa_expr */
23771+ movq %rsi, %rsp
23772 CFI_DEF_CFA_REGISTER rsp
23773- CFI_ADJUST_CFA_OFFSET RBP
23774+ CFI_ADJUST_CFA_OFFSET 0
23775
23776- testl $3,CS(%rsp)
23777+ testb $3,CS(%rsp)
23778 je retint_kernel
23779 /* Interrupt came from user space */
23780
23781@@ -763,6 +1185,8 @@ retint_swapgs: /* return to user-space */
23782 * The iretq could re-enable interrupts:
23783 */
23784 DISABLE_INTERRUPTS(CLBR_ANY)
23785+ pax_exit_kernel_user
23786+# pax_erase_kstack
23787 TRACE_IRQS_IRETQ
23788
23789 SWAPGS
23790@@ -781,6 +1205,21 @@ retint_kernel:
23791 jmp 0b
23792 1:
23793 #endif
23794+
23795+ pax_exit_kernel
23796+
23797+#if defined(CONFIG_EFI) && defined(CONFIG_PAX_KERNEXEC)
23798+ /* This is a quirk to allow IRQs/NMIs/MCEs during early EFI setup,
23799+ * namely calling EFI runtime services with a phys mapping. We're
23800+ * starting off with NOPs and patch in the real instrumentation
23801+ * (BTS/OR) before starting any userland process; even before starting
23802+ * up the APs.
23803+ */
23804+ ALTERNATIVE "", "pax_force_retaddr 16*8", X86_FEATURE_ALWAYS
23805+#else
23806+ pax_force_retaddr RIP
23807+#endif
23808+
23809 /*
23810 * The iretq could re-enable interrupts:
23811 */
23812@@ -793,8 +1232,6 @@ retint_kernel:
23813 restore_c_regs_and_iret:
23814 RESTORE_C_REGS
23815 REMOVE_PT_GPREGS_FROM_STACK 8
23816-
23817-irq_return:
23818 INTERRUPT_RETURN
23819
23820 ENTRY(native_iret)
23821@@ -824,15 +1261,15 @@ native_irq_return_ldt:
23822 SWAPGS
23823 movq PER_CPU_VAR(espfix_waddr),%rdi
23824 movq %rax,(0*8)(%rdi) /* RAX */
23825- movq (2*8)(%rsp),%rax /* RIP */
23826+ movq (2*8 + RIP-RIP)(%rsp),%rax /* RIP */
23827 movq %rax,(1*8)(%rdi)
23828- movq (3*8)(%rsp),%rax /* CS */
23829+ movq (2*8 + CS-RIP)(%rsp),%rax /* CS */
23830 movq %rax,(2*8)(%rdi)
23831- movq (4*8)(%rsp),%rax /* RFLAGS */
23832+ movq (2*8 + EFLAGS-RIP)(%rsp),%rax /* RFLAGS */
23833 movq %rax,(3*8)(%rdi)
23834- movq (6*8)(%rsp),%rax /* SS */
23835+ movq (2*8 + SS-RIP)(%rsp),%rax /* SS */
23836 movq %rax,(5*8)(%rdi)
23837- movq (5*8)(%rsp),%rax /* RSP */
23838+ movq (2*8 + RSP-RIP)(%rsp),%rax /* RSP */
23839 movq %rax,(4*8)(%rdi)
23840 andl $0xffff0000,%eax
23841 popq_cfi %rdi
23842@@ -875,7 +1312,7 @@ retint_signal:
23843 jmp retint_with_reschedule
23844
23845 CFI_ENDPROC
23846-END(common_interrupt)
23847+ENDPROC(common_interrupt)
23848
23849 /*
23850 * APIC interrupts.
23851@@ -889,7 +1326,7 @@ ENTRY(\sym)
23852 interrupt \do_sym
23853 jmp ret_from_intr
23854 CFI_ENDPROC
23855-END(\sym)
23856+ENDPROC(\sym)
23857 .endm
23858
23859 #ifdef CONFIG_TRACING
23860@@ -962,7 +1399,7 @@ apicinterrupt IRQ_WORK_VECTOR \
23861 /*
23862 * Exception entry points.
23863 */
23864-#define CPU_TSS_IST(x) PER_CPU_VAR(cpu_tss) + (TSS_ist + ((x) - 1) * 8)
23865+#define CPU_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r13)
23866
23867 .macro idtentry sym do_sym has_error_code:req paranoid=0 shift_ist=-1
23868 ENTRY(\sym)
23869@@ -1018,6 +1455,12 @@ ENTRY(\sym)
23870 .endif
23871
23872 .if \shift_ist != -1
23873+#ifdef CONFIG_SMP
23874+ imul $TSS_size, PER_CPU_VAR(cpu_number), %r13d
23875+ lea cpu_tss(%r13), %r13
23876+#else
23877+ lea cpu_tss(%rip), %r13
23878+#endif
23879 subq $EXCEPTION_STKSZ, CPU_TSS_IST(\shift_ist)
23880 .endif
23881
23882@@ -1065,7 +1508,7 @@ ENTRY(\sym)
23883 .endif
23884
23885 CFI_ENDPROC
23886-END(\sym)
23887+ENDPROC(\sym)
23888 .endm
23889
23890 #ifdef CONFIG_TRACING
23891@@ -1106,9 +1549,10 @@ gs_change:
23892 2: mfence /* workaround */
23893 SWAPGS
23894 popfq_cfi
23895+ pax_force_retaddr
23896 ret
23897 CFI_ENDPROC
23898-END(native_load_gs_index)
23899+ENDPROC(native_load_gs_index)
23900
23901 _ASM_EXTABLE(gs_change,bad_gs)
23902 .section .fixup,"ax"
23903@@ -1136,9 +1580,10 @@ ENTRY(do_softirq_own_stack)
23904 CFI_DEF_CFA_REGISTER rsp
23905 CFI_ADJUST_CFA_OFFSET -8
23906 decl PER_CPU_VAR(irq_count)
23907+ pax_force_retaddr
23908 ret
23909 CFI_ENDPROC
23910-END(do_softirq_own_stack)
23911+ENDPROC(do_softirq_own_stack)
23912
23913 #ifdef CONFIG_XEN
23914 idtentry xen_hypervisor_callback xen_do_hypervisor_callback has_error_code=0
23915@@ -1179,7 +1624,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
23916 #endif
23917 jmp error_exit
23918 CFI_ENDPROC
23919-END(xen_do_hypervisor_callback)
23920+ENDPROC(xen_do_hypervisor_callback)
23921
23922 /*
23923 * Hypervisor uses this for application faults while it executes.
23924@@ -1240,7 +1685,7 @@ ENTRY(xen_failsafe_callback)
23925 SAVE_EXTRA_REGS
23926 jmp error_exit
23927 CFI_ENDPROC
23928-END(xen_failsafe_callback)
23929+ENDPROC(xen_failsafe_callback)
23930
23931 apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \
23932 xen_hvm_callback_vector xen_evtchn_do_upcall
23933@@ -1286,9 +1731,39 @@ ENTRY(paranoid_entry)
23934 js 1f /* negative -> in kernel */
23935 SWAPGS
23936 xorl %ebx,%ebx
23937-1: ret
23938+1:
23939+#ifdef CONFIG_PAX_MEMORY_UDEREF
23940+ testb $3, CS+8(%rsp)
23941+ jnz 1f
23942+ pax_enter_kernel
23943+ jmp 2f
23944+1: pax_enter_kernel_user
23945+2:
23946+#else
23947+ pax_enter_kernel
23948+#endif
23949+ pax_force_retaddr
23950+ ret
23951 CFI_ENDPROC
23952-END(paranoid_entry)
23953+ENDPROC(paranoid_entry)
23954+
23955+ENTRY(paranoid_entry_nmi)
23956+ XCPT_FRAME 1 15*8
23957+ cld
23958+ SAVE_C_REGS 8
23959+ SAVE_EXTRA_REGS 8
23960+ movl $1,%ebx
23961+ movl $MSR_GS_BASE,%ecx
23962+ rdmsr
23963+ testl %edx,%edx
23964+ js 1f /* negative -> in kernel */
23965+ SWAPGS
23966+ xorl %ebx,%ebx
23967+1: pax_enter_kernel_nmi
23968+ pax_force_retaddr
23969+ ret
23970+ CFI_ENDPROC
23971+ENDPROC(paranoid_entry_nmi)
23972
23973 /*
23974 * "Paranoid" exit path from exception stack. This is invoked
23975@@ -1305,20 +1780,27 @@ ENTRY(paranoid_exit)
23976 DEFAULT_FRAME
23977 DISABLE_INTERRUPTS(CLBR_NONE)
23978 TRACE_IRQS_OFF_DEBUG
23979- testl %ebx,%ebx /* swapgs needed? */
23980+ testl $1,%ebx /* swapgs needed? */
23981 jnz paranoid_exit_no_swapgs
23982+#ifdef CONFIG_PAX_MEMORY_UDEREF
23983+ pax_exit_kernel_user
23984+#else
23985+ pax_exit_kernel
23986+#endif
23987 TRACE_IRQS_IRETQ
23988 SWAPGS_UNSAFE_STACK
23989 jmp paranoid_exit_restore
23990 paranoid_exit_no_swapgs:
23991+ pax_exit_kernel
23992 TRACE_IRQS_IRETQ_DEBUG
23993 paranoid_exit_restore:
23994 RESTORE_EXTRA_REGS
23995 RESTORE_C_REGS
23996 REMOVE_PT_GPREGS_FROM_STACK 8
23997+ pax_force_retaddr_bts
23998 INTERRUPT_RETURN
23999 CFI_ENDPROC
24000-END(paranoid_exit)
24001+ENDPROC(paranoid_exit)
24002
24003 /*
24004 * Save all registers in pt_regs, and switch gs if needed.
24005@@ -1330,12 +1812,23 @@ ENTRY(error_entry)
24006 SAVE_C_REGS 8
24007 SAVE_EXTRA_REGS 8
24008 xorl %ebx,%ebx
24009- testl $3,CS+8(%rsp)
24010+ testb $3,CS+8(%rsp)
24011 je error_kernelspace
24012 error_swapgs:
24013 SWAPGS
24014 error_sti:
24015+#ifdef CONFIG_PAX_MEMORY_UDEREF
24016+ testb $3, CS+8(%rsp)
24017+ jnz 1f
24018+ pax_enter_kernel
24019+ jmp 2f
24020+1: pax_enter_kernel_user
24021+2:
24022+#else
24023+ pax_enter_kernel
24024+#endif
24025 TRACE_IRQS_OFF
24026+ pax_force_retaddr
24027 ret
24028
24029 /*
24030@@ -1370,7 +1863,7 @@ error_bad_iret:
24031 decl %ebx /* Return to usergs */
24032 jmp error_sti
24033 CFI_ENDPROC
24034-END(error_entry)
24035+ENDPROC(error_entry)
24036
24037
24038 /* On entry, ebx is "no swapgs" flag (1: don't need swapgs, 0: need it) */
24039@@ -1381,7 +1874,7 @@ ENTRY(error_exit)
24040 DISABLE_INTERRUPTS(CLBR_NONE)
24041 TRACE_IRQS_OFF
24042 GET_THREAD_INFO(%rcx)
24043- testl %eax,%eax
24044+ testl $1,%eax
24045 jne retint_kernel
24046 LOCKDEP_SYS_EXIT_IRQ
24047 movl TI_flags(%rcx),%edx
24048@@ -1390,7 +1883,7 @@ ENTRY(error_exit)
24049 jnz retint_careful
24050 jmp retint_swapgs
24051 CFI_ENDPROC
24052-END(error_exit)
24053+ENDPROC(error_exit)
24054
24055 /* Runs on exception stack */
24056 ENTRY(nmi)
24057@@ -1413,11 +1906,12 @@ ENTRY(nmi)
24058 * If the variable is not set and the stack is not the NMI
24059 * stack then:
24060 * o Set the special variable on the stack
24061- * o Copy the interrupt frame into a "saved" location on the stack
24062- * o Copy the interrupt frame into a "copy" location on the stack
24063+ * o Copy the interrupt frame into an "outermost" location on the
24064+ * stack
24065+ * o Copy the interrupt frame into an "iret" location on the stack
24066 * o Continue processing the NMI
24067 * If the variable is set or the previous stack is the NMI stack:
24068- * o Modify the "copy" location to jump to the repeate_nmi
24069+ * o Modify the "iret" location to jump to the repeat_nmi
24070 * o return back to the first NMI
24071 *
24072 * Now on exit of the first NMI, we first clear the stack variable
24073@@ -1426,32 +1920,185 @@ ENTRY(nmi)
24074 * a nested NMI that updated the copy interrupt stack frame, a
24075 * jump will be made to the repeat_nmi code that will handle the second
24076 * NMI.
24077+ *
24078+ * However, espfix prevents us from directly returning to userspace
24079+ * with a single IRET instruction. Similarly, IRET to user mode
24080+ * can fault. We therefore handle NMIs from user space like
24081+ * other IST entries.
24082 */
24083
24084 /* Use %rdx as our temp variable throughout */
24085 pushq_cfi %rdx
24086 CFI_REL_OFFSET rdx, 0
24087
24088+ testb $3, CS-RIP+8(%rsp)
24089+ jz .Lnmi_from_kernel
24090+
24091+ /*
24092+ * NMI from user mode. We need to run on the thread stack, but we
24093+ * can't go through the normal entry paths: NMIs are masked, and
24094+ * we don't want to enable interrupts, because then we'll end
24095+ * up in an awkward situation in which IRQs are on but NMIs
24096+ * are off.
24097+ */
24098+
24099+ SWAPGS
24100+ cld
24101+ movq %rsp, %rdx
24102+ movq PER_CPU_VAR(kernel_stack), %rsp
24103+ pushq 5*8(%rdx) /* pt_regs->ss */
24104+ pushq 4*8(%rdx) /* pt_regs->rsp */
24105+ pushq 3*8(%rdx) /* pt_regs->flags */
24106+ pushq 2*8(%rdx) /* pt_regs->cs */
24107+ pushq 1*8(%rdx) /* pt_regs->rip */
24108+ pushq $-1 /* pt_regs->orig_ax */
24109+ pushq %rdi /* pt_regs->di */
24110+ pushq %rsi /* pt_regs->si */
24111+ pushq (%rdx) /* pt_regs->dx */
24112+ pushq %rcx /* pt_regs->cx */
24113+ pushq %rax /* pt_regs->ax */
24114+ pushq %r8 /* pt_regs->r8 */
24115+ pushq %r9 /* pt_regs->r9 */
24116+ pushq %r10 /* pt_regs->r10 */
24117+ pushq %r11 /* pt_regs->r11 */
24118+ pushq %rbx /* pt_regs->rbx */
24119+ pushq %rbp /* pt_regs->rbp */
24120+ pushq %r12 /* pt_regs->r12 */
24121+ pushq %r13 /* pt_regs->r13 */
24122+ pushq %r14 /* pt_regs->r14 */
24123+ pushq %r15 /* pt_regs->r15 */
24124+
24125+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
24126+ xorl %ebx,%ebx
24127+#endif
24128+
24129+ pax_enter_kernel_nmi
24130+
24131 /*
24132- * If %cs was not the kernel segment, then the NMI triggered in user
24133- * space, which means it is definitely not nested.
24134+ * At this point we no longer need to worry about stack damage
24135+ * due to nesting -- we're on the normal thread stack and we're
24136+ * done with the NMI stack.
24137 */
24138- cmpl $__KERNEL_CS, 16(%rsp)
24139- jne first_nmi
24140+
24141+ movq %rsp, %rdi
24142+ movq $-1, %rsi
24143+ call do_nmi
24144+
24145+ pax_exit_kernel_nmi
24146+
24147+ /*
24148+ * Return back to user mode. We must *not* do the normal exit
24149+ * work, because we don't want to enable interrupts. Fortunately,
24150+ * do_nmi doesn't modify pt_regs.
24151+ */
24152+ SWAPGS
24153+
24154+ /*
24155+ * Open-code the entire return process for compatibility with varying
24156+ * register layouts across different kernel versions.
24157+ */
24158+
24159+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
24160+ movq RBX(%rsp), %rbx /* pt_regs->rbx*/
24161+#endif
24162+
24163+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
24164+ movq R12(%rsp), %r12 /* pt_regs->r12*/
24165+#endif
24166+
24167+ addq $6*8, %rsp /* skip bx, bp, and r12-r15 */
24168+ popq %r11 /* pt_regs->r11 */
24169+ popq %r10 /* pt_regs->r10 */
24170+ popq %r9 /* pt_regs->r9 */
24171+ popq %r8 /* pt_regs->r8 */
24172+ popq %rax /* pt_regs->ax */
24173+ popq %rcx /* pt_regs->cx */
24174+ popq %rdx /* pt_regs->dx */
24175+ popq %rsi /* pt_regs->si */
24176+ popq %rdi /* pt_regs->di */
24177+ addq $8, %rsp /* skip orig_ax */
24178+ INTERRUPT_RETURN
24179+
24180+.Lnmi_from_kernel:
24181+ /*
24182+ * Here's what our stack frame will look like:
24183+ * +---------------------------------------------------------+
24184+ * | original SS |
24185+ * | original Return RSP |
24186+ * | original RFLAGS |
24187+ * | original CS |
24188+ * | original RIP |
24189+ * +---------------------------------------------------------+
24190+ * | temp storage for rdx |
24191+ * +---------------------------------------------------------+
24192+ * | "NMI executing" variable |
24193+ * +---------------------------------------------------------+
24194+ * | iret SS } Copied from "outermost" frame |
24195+ * | iret Return RSP } on each loop iteration; overwritten |
24196+ * | iret RFLAGS } by a nested NMI to force another |
24197+ * | iret CS } iteration if needed. |
24198+ * | iret RIP } |
24199+ * +---------------------------------------------------------+
24200+ * | outermost SS } initialized in first_nmi; |
24201+ * | outermost Return RSP } will not be changed before |
24202+ * | outermost RFLAGS } NMI processing is done. |
24203+ * | outermost CS } Copied to "iret" frame on each |
24204+ * | outermost RIP } iteration. |
24205+ * +---------------------------------------------------------+
24206+ * | pt_regs |
24207+ * +---------------------------------------------------------+
24208+ *
24209+ * The "original" frame is used by hardware. Before re-enabling
24210+ * NMIs, we need to be done with it, and we need to leave enough
24211+ * space for the asm code here.
24212+ *
24213+ * We return by executing IRET while RSP points to the "iret" frame.
24214+ * That will either return for real or it will loop back into NMI
24215+ * processing.
24216+ *
24217+ * The "outermost" frame is copied to the "iret" frame on each
24218+ * iteration of the loop, so each iteration starts with the "iret"
24219+ * frame pointing to the final return target.
24220+ */
24221+
24222+ /*
24223+ * If we interrupted kernel code between repeat_nmi and
24224+ * end_repeat_nmi, then we are a nested NMI. We must not
24225+ * modify the "iret" frame because it's being written by
24226+ * the outer NMI. That's okay: the outer NMI handler is
24227+ * about to about to call do_nmi anyway, so we can just
24228+ * resume the outer NMI.
24229+ */
24230+
24231+ movq $repeat_nmi, %rdx
24232+ cmpq 8(%rsp), %rdx
24233+ ja 1f
24234+ movq $end_repeat_nmi, %rdx
24235+ cmpq 8(%rsp), %rdx
24236+ ja nested_nmi_out
24237+1:
24238
24239 /*
24240- * Check the special variable on the stack to see if NMIs are
24241- * executing.
24242+ * Now check "NMI executing". If it's set, then we're nested.
24243+ *
24244+ * First check "NMI executing". If it's set, then we're nested.
24245+ * This will not detect if we interrupted an outer NMI just
24246+ * before IRET.
24247 */
24248 cmpl $1, -8(%rsp)
24249 je nested_nmi
24250
24251 /*
24252- * Now test if the previous stack was an NMI stack.
24253- * We need the double check. We check the NMI stack to satisfy the
24254- * race when the first NMI clears the variable before returning.
24255- * We check the variable because the first NMI could be in a
24256- * breakpoint routine using a breakpoint stack.
24257+ * Now test if the previous stack was an NMI stack. This covers
24258+ * the case where we interrupt an outer NMI after it clears
24259+ * "NMI executing" but before IRET. We need to be careful, though:
24260+ * there is one case in which RSP could point to the NMI stack
24261+ * despite there being no NMI active: naughty userspace controls
24262+ * RSP at the very beginning of the SYSCALL targets. We can
24263+ * pull a fast one on naughty userspace, though: we program
24264+ * SYSCALL to mask DF, so userspace cannot cause DF to be set
24265+ * if it controls the kernel's RSP. We set DF before we clear
24266+ * "NMI executing".
24267 */
24268 lea 6*8(%rsp), %rdx
24269 /* Compare the NMI stack (rdx) with the stack we came from (4*8(%rsp)) */
24270@@ -1462,27 +2109,22 @@ ENTRY(nmi)
24271 cmpq %rdx, 4*8(%rsp)
24272 /* If it is below the NMI stack, it is a normal NMI */
24273 jb first_nmi
24274- /* Ah, it is within the NMI stack, treat it as nested */
24275+
24276+ /* Ah, it is within the NMI stack. */
24277+
24278+ testb $(X86_EFLAGS_DF >> 8), (3*8 + 1)(%rsp)
24279+ jz first_nmi /* RSP was user controlled. */
24280
24281 CFI_REMEMBER_STATE
24282
24283+ /* This is a nested NMI. */
24284+
24285 nested_nmi:
24286 /*
24287- * Do nothing if we interrupted the fixup in repeat_nmi.
24288- * It's about to repeat the NMI handler, so we are fine
24289- * with ignoring this one.
24290+ * Modify the "iret" frame to point to repeat_nmi, forcing another
24291+ * iteration of NMI handling.
24292 */
24293- movq $repeat_nmi, %rdx
24294- cmpq 8(%rsp), %rdx
24295- ja 1f
24296- movq $end_repeat_nmi, %rdx
24297- cmpq 8(%rsp), %rdx
24298- ja nested_nmi_out
24299-
24300-1:
24301- /* Set up the interrupted NMIs stack to jump to repeat_nmi */
24302- leaq -1*8(%rsp), %rdx
24303- movq %rdx, %rsp
24304+ subq $8, %rsp
24305 CFI_ADJUST_CFA_OFFSET 1*8
24306 leaq -10*8(%rsp), %rdx
24307 pushq_cfi $__KERNEL_DS
24308@@ -1499,60 +2141,24 @@ nested_nmi_out:
24309 popq_cfi %rdx
24310 CFI_RESTORE rdx
24311
24312- /* No need to check faults here */
24313+ /* We are returning to kernel mode, so this cannot result in a fault. */
24314+# pax_force_retaddr_bts
24315 INTERRUPT_RETURN
24316
24317 CFI_RESTORE_STATE
24318 first_nmi:
24319- /*
24320- * Because nested NMIs will use the pushed location that we
24321- * stored in rdx, we must keep that space available.
24322- * Here's what our stack frame will look like:
24323- * +-------------------------+
24324- * | original SS |
24325- * | original Return RSP |
24326- * | original RFLAGS |
24327- * | original CS |
24328- * | original RIP |
24329- * +-------------------------+
24330- * | temp storage for rdx |
24331- * +-------------------------+
24332- * | NMI executing variable |
24333- * +-------------------------+
24334- * | copied SS |
24335- * | copied Return RSP |
24336- * | copied RFLAGS |
24337- * | copied CS |
24338- * | copied RIP |
24339- * +-------------------------+
24340- * | Saved SS |
24341- * | Saved Return RSP |
24342- * | Saved RFLAGS |
24343- * | Saved CS |
24344- * | Saved RIP |
24345- * +-------------------------+
24346- * | pt_regs |
24347- * +-------------------------+
24348- *
24349- * The saved stack frame is used to fix up the copied stack frame
24350- * that a nested NMI may change to make the interrupted NMI iret jump
24351- * to the repeat_nmi. The original stack frame and the temp storage
24352- * is also used by nested NMIs and can not be trusted on exit.
24353- */
24354- /* Do not pop rdx, nested NMIs will corrupt that part of the stack */
24355+ /* Restore rdx. */
24356 movq (%rsp), %rdx
24357 CFI_RESTORE rdx
24358
24359 /* Set the NMI executing variable on the stack. */
24360 pushq_cfi $1
24361
24362- /*
24363- * Leave room for the "copied" frame
24364- */
24365+ /* Leave room for the "iret" frame */
24366 subq $(5*8), %rsp
24367 CFI_ADJUST_CFA_OFFSET 5*8
24368
24369- /* Copy the stack frame to the Saved frame */
24370+ /* Copy the "original" frame to the "outermost" frame */
24371 .rept 5
24372 pushq_cfi 11*8(%rsp)
24373 .endr
24374@@ -1560,6 +2166,7 @@ first_nmi:
24375
24376 /* Everything up to here is safe from nested NMIs */
24377
24378+repeat_nmi:
24379 /*
24380 * If there was a nested NMI, the first NMI's iret will return
24381 * here. But NMIs are still enabled and we can take another
24382@@ -1568,16 +2175,21 @@ first_nmi:
24383 * it will just return, as we are about to repeat an NMI anyway.
24384 * This makes it safe to copy to the stack frame that a nested
24385 * NMI will update.
24386- */
24387-repeat_nmi:
24388- /*
24389- * Update the stack variable to say we are still in NMI (the update
24390- * is benign for the non-repeat case, where 1 was pushed just above
24391- * to this very stack slot).
24392+ *
24393+ * RSP is pointing to "outermost RIP". gsbase is unknown, but, if
24394+ * we're repeating an NMI, gsbase has the same value that it had on
24395+ * the first iteration. paranoid_entry will load the kernel
24396+ * gsbase if needed before we call do_nmi.
24397+ *
24398+ * Set "NMI executing" in case we came back here via IRET.
24399 */
24400 movq $1, 10*8(%rsp)
24401
24402- /* Make another copy, this one may be modified by nested NMIs */
24403+ /*
24404+ * Copy the "outermost" frame to the "iret" frame. NMIs that nest
24405+ * here must not modify the "iret" frame while we're writing to
24406+ * it or it will end up containing garbage.
24407+ */
24408 addq $(10*8), %rsp
24409 CFI_ADJUST_CFA_OFFSET -10*8
24410 .rept 5
24411@@ -1588,66 +2200,65 @@ repeat_nmi:
24412 end_repeat_nmi:
24413
24414 /*
24415- * Everything below this point can be preempted by a nested
24416- * NMI if the first NMI took an exception and reset our iret stack
24417- * so that we repeat another NMI.
24418+ * Everything below this point can be preempted by a nested NMI.
24419+ * If this happens, then the inner NMI will change the "iret"
24420+ * frame to point back to repeat_nmi.
24421 */
24422 pushq_cfi $-1 /* ORIG_RAX: no syscall to restart */
24423 ALLOC_PT_GPREGS_ON_STACK
24424
24425 /*
24426- * Use paranoid_entry to handle SWAPGS, but no need to use paranoid_exit
24427+ * Use paranoid_entry_nmi to handle SWAPGS, but no need to use paranoid_exit
24428 * as we should not be calling schedule in NMI context.
24429 * Even with normal interrupts enabled. An NMI should not be
24430 * setting NEED_RESCHED or anything that normal interrupts and
24431 * exceptions might do.
24432 */
24433- call paranoid_entry
24434+ call paranoid_entry_nmi
24435 DEFAULT_FRAME 0
24436
24437- /*
24438- * Save off the CR2 register. If we take a page fault in the NMI then
24439- * it could corrupt the CR2 value. If the NMI preempts a page fault
24440- * handler before it was able to read the CR2 register, and then the
24441- * NMI itself takes a page fault, the page fault that was preempted
24442- * will read the information from the NMI page fault and not the
24443- * origin fault. Save it off and restore it if it changes.
24444- * Use the r12 callee-saved register.
24445- */
24446- movq %cr2, %r12
24447-
24448 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
24449 movq %rsp,%rdi
24450 movq $-1,%rsi
24451 call do_nmi
24452
24453- /* Did the NMI take a page fault? Restore cr2 if it did */
24454- movq %cr2, %rcx
24455- cmpq %rcx, %r12
24456- je 1f
24457- movq %r12, %cr2
24458-1:
24459-
24460- testl %ebx,%ebx /* swapgs needed? */
24461+ testl $1,%ebx /* swapgs needed? */
24462 jnz nmi_restore
24463 nmi_swapgs:
24464 SWAPGS_UNSAFE_STACK
24465 nmi_restore:
24466+ pax_exit_kernel_nmi
24467 RESTORE_EXTRA_REGS
24468 RESTORE_C_REGS
24469- /* Pop the extra iret frame at once */
24470+
24471 REMOVE_PT_GPREGS_FROM_STACK 6*8
24472
24473- /* Clear the NMI executing stack variable */
24474- movq $0, 5*8(%rsp)
24475- jmp irq_return
24476+ pax_force_retaddr_bts
24477+
24478+ /*
24479+ * Clear "NMI executing". Set DF first so that we can easily
24480+ * distinguish the remaining code between here and IRET from
24481+ * the SYSCALL entry and exit paths. On a native kernel, we
24482+ * could just inspect RIP, but, on paravirt kernels,
24483+ * INTERRUPT_RETURN can translate into a jump into a
24484+ * hypercall page.
24485+ */
24486+ std
24487+ movq $0, 5*8(%rsp) /* clear "NMI executing" */
24488+
24489+ /*
24490+ * INTERRUPT_RETURN reads the "iret" frame and exits the NMI
24491+ * stack in a single instruction. We are returning to kernel
24492+ * mode, so this cannot result in a fault.
24493+ */
24494+ INTERRUPT_RETURN
24495 CFI_ENDPROC
24496-END(nmi)
24497+ENDPROC(nmi)
24498
24499 ENTRY(ignore_sysret)
24500 CFI_STARTPROC
24501 mov $-ENOSYS,%eax
24502 sysret
24503 CFI_ENDPROC
24504-END(ignore_sysret)
24505+ENDPROC(ignore_sysret)
24506
24507diff --git a/arch/x86/kernel/espfix_64.c b/arch/x86/kernel/espfix_64.c
24508index f5d0730..5bce89c 100644
24509--- a/arch/x86/kernel/espfix_64.c
24510+++ b/arch/x86/kernel/espfix_64.c
24511@@ -70,8 +70,7 @@ static DEFINE_MUTEX(espfix_init_mutex);
24512 #define ESPFIX_MAX_PAGES DIV_ROUND_UP(CONFIG_NR_CPUS, ESPFIX_STACKS_PER_PAGE)
24513 static void *espfix_pages[ESPFIX_MAX_PAGES];
24514
24515-static __page_aligned_bss pud_t espfix_pud_page[PTRS_PER_PUD]
24516- __aligned(PAGE_SIZE);
24517+static pud_t espfix_pud_page[PTRS_PER_PUD] __page_aligned_rodata;
24518
24519 static unsigned int page_random, slot_random;
24520
24521@@ -122,11 +121,17 @@ static void init_espfix_random(void)
24522 void __init init_espfix_bsp(void)
24523 {
24524 pgd_t *pgd_p;
24525+ unsigned long index = pgd_index(ESPFIX_BASE_ADDR);
24526
24527 /* Install the espfix pud into the kernel page directory */
24528- pgd_p = &init_level4_pgt[pgd_index(ESPFIX_BASE_ADDR)];
24529+ pgd_p = &init_level4_pgt[index];
24530 pgd_populate(&init_mm, pgd_p, (pud_t *)espfix_pud_page);
24531
24532+#ifdef CONFIG_PAX_PER_CPU_PGD
24533+ clone_pgd_range(get_cpu_pgd(0, kernel) + index, swapper_pg_dir + index, 1);
24534+ clone_pgd_range(get_cpu_pgd(0, user) + index, swapper_pg_dir + index, 1);
24535+#endif
24536+
24537 /* Randomize the locations */
24538 init_espfix_random();
24539
24540@@ -194,7 +199,7 @@ void init_espfix_ap(void)
24541 set_pte(&pte_p[n*PTE_STRIDE], pte);
24542
24543 /* Job is done for this CPU and any CPU which shares this page */
24544- ACCESS_ONCE(espfix_pages[page]) = stack_page;
24545+ ACCESS_ONCE_RW(espfix_pages[page]) = stack_page;
24546
24547 unlock_done:
24548 mutex_unlock(&espfix_init_mutex);
24549diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
24550index 8b7b0a5..02219db 100644
24551--- a/arch/x86/kernel/ftrace.c
24552+++ b/arch/x86/kernel/ftrace.c
24553@@ -89,7 +89,7 @@ static unsigned long text_ip_addr(unsigned long ip)
24554 * kernel identity mapping to modify code.
24555 */
24556 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
24557- ip = (unsigned long)__va(__pa_symbol(ip));
24558+ ip = (unsigned long)__va(__pa_symbol(ktla_ktva(ip)));
24559
24560 return ip;
24561 }
24562@@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
24563 {
24564 unsigned char replaced[MCOUNT_INSN_SIZE];
24565
24566+ ip = ktla_ktva(ip);
24567+
24568 /*
24569 * Note: Due to modules and __init, code can
24570 * disappear and change, we need to protect against faulting
24571@@ -230,7 +232,7 @@ static int update_ftrace_func(unsigned long ip, void *new)
24572 unsigned char old[MCOUNT_INSN_SIZE];
24573 int ret;
24574
24575- memcpy(old, (void *)ip, MCOUNT_INSN_SIZE);
24576+ memcpy(old, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE);
24577
24578 ftrace_update_func = ip;
24579 /* Make sure the breakpoints see the ftrace_update_func update */
24580@@ -311,7 +313,7 @@ static int add_break(unsigned long ip, const char *old)
24581 unsigned char replaced[MCOUNT_INSN_SIZE];
24582 unsigned char brk = BREAKPOINT_INSTRUCTION;
24583
24584- if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
24585+ if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
24586 return -EFAULT;
24587
24588 /* Make sure it is what we expect it to be */
24589@@ -670,11 +672,11 @@ static unsigned char *ftrace_jmp_replace(unsigned long ip, unsigned long addr)
24590 /* Module allocation simplifies allocating memory for code */
24591 static inline void *alloc_tramp(unsigned long size)
24592 {
24593- return module_alloc(size);
24594+ return module_alloc_exec(size);
24595 }
24596 static inline void tramp_free(void *tramp)
24597 {
24598- module_memfree(tramp);
24599+ module_memfree_exec(tramp);
24600 }
24601 #else
24602 /* Trampolines can only be created if modules are supported */
24603@@ -753,7 +755,9 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)
24604 *tramp_size = size + MCOUNT_INSN_SIZE + sizeof(void *);
24605
24606 /* Copy ftrace_caller onto the trampoline memory */
24607+ pax_open_kernel();
24608 ret = probe_kernel_read(trampoline, (void *)start_offset, size);
24609+ pax_close_kernel();
24610 if (WARN_ON(ret < 0)) {
24611 tramp_free(trampoline);
24612 return 0;
24613@@ -763,6 +767,7 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)
24614
24615 /* The trampoline ends with a jmp to ftrace_return */
24616 jmp = ftrace_jmp_replace(ip, (unsigned long)ftrace_return);
24617+ pax_open_kernel();
24618 memcpy(trampoline + size, jmp, MCOUNT_INSN_SIZE);
24619
24620 /*
24621@@ -775,6 +780,7 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)
24622
24623 ptr = (unsigned long *)(trampoline + size + MCOUNT_INSN_SIZE);
24624 *ptr = (unsigned long)ops;
24625+ pax_close_kernel();
24626
24627 op_offset -= start_offset;
24628 memcpy(&op_ptr, trampoline + op_offset, OP_REF_SIZE);
24629@@ -792,7 +798,9 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)
24630 op_ptr.offset = offset;
24631
24632 /* put in the new offset to the ftrace_ops */
24633+ pax_open_kernel();
24634 memcpy(trampoline + op_offset, &op_ptr, OP_REF_SIZE);
24635+ pax_close_kernel();
24636
24637 /* ALLOC_TRAMP flags lets us know we created it */
24638 ops->flags |= FTRACE_OPS_FL_ALLOC_TRAMP;
24639diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
24640index 5a46681..1ef7ffa 100644
24641--- a/arch/x86/kernel/head64.c
24642+++ b/arch/x86/kernel/head64.c
24643@@ -68,12 +68,12 @@ again:
24644 pgd = *pgd_p;
24645
24646 /*
24647- * The use of __START_KERNEL_map rather than __PAGE_OFFSET here is
24648- * critical -- __PAGE_OFFSET would point us back into the dynamic
24649+ * The use of __early_va rather than __va here is critical:
24650+ * __va would point us back into the dynamic
24651 * range and we might end up looping forever...
24652 */
24653 if (pgd)
24654- pud_p = (pudval_t *)((pgd & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
24655+ pud_p = (pudval_t *)(__early_va(pgd & PTE_PFN_MASK));
24656 else {
24657 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
24658 reset_early_page_tables();
24659@@ -83,13 +83,13 @@ again:
24660 pud_p = (pudval_t *)early_dynamic_pgts[next_early_pgt++];
24661 for (i = 0; i < PTRS_PER_PUD; i++)
24662 pud_p[i] = 0;
24663- *pgd_p = (pgdval_t)pud_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
24664+ *pgd_p = (pgdval_t)__pa(pud_p) + _KERNPG_TABLE;
24665 }
24666 pud_p += pud_index(address);
24667 pud = *pud_p;
24668
24669 if (pud)
24670- pmd_p = (pmdval_t *)((pud & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
24671+ pmd_p = (pmdval_t *)(__early_va(pud & PTE_PFN_MASK));
24672 else {
24673 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
24674 reset_early_page_tables();
24675@@ -99,7 +99,7 @@ again:
24676 pmd_p = (pmdval_t *)early_dynamic_pgts[next_early_pgt++];
24677 for (i = 0; i < PTRS_PER_PMD; i++)
24678 pmd_p[i] = 0;
24679- *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
24680+ *pud_p = (pudval_t)__pa(pmd_p) + _KERNPG_TABLE;
24681 }
24682 pmd = (physaddr & PMD_MASK) + early_pmd_flags;
24683 pmd_p[pmd_index(address)] = pmd;
24684@@ -177,7 +177,6 @@ asmlinkage __visible void __init x86_64_start_kernel(char * real_mode_data)
24685 */
24686 load_ucode_bsp();
24687
24688- clear_page(init_level4_pgt);
24689 /* set init_level4_pgt kernel high mapping*/
24690 init_level4_pgt[511] = early_level4_pgt[511];
24691
24692diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
24693index 7e429c9..7244a52 100644
24694--- a/arch/x86/kernel/head_32.S
24695+++ b/arch/x86/kernel/head_32.S
24696@@ -27,6 +27,12 @@
24697 /* Physical address */
24698 #define pa(X) ((X) - __PAGE_OFFSET)
24699
24700+#ifdef CONFIG_PAX_KERNEXEC
24701+#define ta(X) (X)
24702+#else
24703+#define ta(X) ((X) - __PAGE_OFFSET)
24704+#endif
24705+
24706 /*
24707 * References to members of the new_cpu_data structure.
24708 */
24709@@ -56,11 +62,7 @@
24710 * and small than max_low_pfn, otherwise will waste some page table entries
24711 */
24712
24713-#if PTRS_PER_PMD > 1
24714-#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
24715-#else
24716-#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
24717-#endif
24718+#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
24719
24720 /*
24721 * Number of possible pages in the lowmem region.
24722@@ -86,6 +88,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
24723 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
24724
24725 /*
24726+ * Real beginning of normal "text" segment
24727+ */
24728+ENTRY(stext)
24729+ENTRY(_stext)
24730+
24731+/*
24732 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
24733 * %esi points to the real-mode code as a 32-bit pointer.
24734 * CS and DS must be 4 GB flat segments, but we don't depend on
24735@@ -93,6 +101,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
24736 * can.
24737 */
24738 __HEAD
24739+
24740+#ifdef CONFIG_PAX_KERNEXEC
24741+ jmp startup_32
24742+/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
24743+.fill PAGE_SIZE-5,1,0xcc
24744+#endif
24745+
24746 ENTRY(startup_32)
24747 movl pa(stack_start),%ecx
24748
24749@@ -114,6 +129,59 @@ ENTRY(startup_32)
24750 2:
24751 leal -__PAGE_OFFSET(%ecx),%esp
24752
24753+#ifdef CONFIG_SMP
24754+ movl $pa(cpu_gdt_table),%edi
24755+ movl $__per_cpu_load,%eax
24756+ movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
24757+ rorl $16,%eax
24758+ movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
24759+ movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
24760+ movl $__per_cpu_end - 1,%eax
24761+ subl $__per_cpu_start,%eax
24762+ movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
24763+#endif
24764+
24765+#ifdef CONFIG_PAX_MEMORY_UDEREF
24766+ movl $NR_CPUS,%ecx
24767+ movl $pa(cpu_gdt_table),%edi
24768+1:
24769+ movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
24770+ movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
24771+ movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
24772+ addl $PAGE_SIZE_asm,%edi
24773+ loop 1b
24774+#endif
24775+
24776+#ifdef CONFIG_PAX_KERNEXEC
24777+ movl $pa(boot_gdt),%edi
24778+ movl $__LOAD_PHYSICAL_ADDR,%eax
24779+ movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
24780+ rorl $16,%eax
24781+ movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
24782+ movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
24783+ rorl $16,%eax
24784+
24785+ ljmp $(__BOOT_CS),$1f
24786+1:
24787+
24788+ movl $NR_CPUS,%ecx
24789+ movl $pa(cpu_gdt_table),%edi
24790+ addl $__PAGE_OFFSET,%eax
24791+1:
24792+ movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
24793+ movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
24794+ movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
24795+ movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
24796+ rorl $16,%eax
24797+ movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
24798+ movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
24799+ movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
24800+ movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
24801+ rorl $16,%eax
24802+ addl $PAGE_SIZE_asm,%edi
24803+ loop 1b
24804+#endif
24805+
24806 /*
24807 * Clear BSS first so that there are no surprises...
24808 */
24809@@ -209,8 +277,11 @@ ENTRY(startup_32)
24810 movl %eax, pa(max_pfn_mapped)
24811
24812 /* Do early initialization of the fixmap area */
24813- movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
24814- movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
24815+#ifdef CONFIG_COMPAT_VDSO
24816+ movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
24817+#else
24818+ movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
24819+#endif
24820 #else /* Not PAE */
24821
24822 page_pde_offset = (__PAGE_OFFSET >> 20);
24823@@ -240,8 +311,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
24824 movl %eax, pa(max_pfn_mapped)
24825
24826 /* Do early initialization of the fixmap area */
24827- movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
24828- movl %eax,pa(initial_page_table+0xffc)
24829+#ifdef CONFIG_COMPAT_VDSO
24830+ movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
24831+#else
24832+ movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
24833+#endif
24834 #endif
24835
24836 #ifdef CONFIG_PARAVIRT
24837@@ -255,9 +329,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
24838 cmpl $num_subarch_entries, %eax
24839 jae bad_subarch
24840
24841- movl pa(subarch_entries)(,%eax,4), %eax
24842- subl $__PAGE_OFFSET, %eax
24843- jmp *%eax
24844+ jmp *pa(subarch_entries)(,%eax,4)
24845
24846 bad_subarch:
24847 WEAK(lguest_entry)
24848@@ -269,10 +341,10 @@ WEAK(xen_entry)
24849 __INITDATA
24850
24851 subarch_entries:
24852- .long default_entry /* normal x86/PC */
24853- .long lguest_entry /* lguest hypervisor */
24854- .long xen_entry /* Xen hypervisor */
24855- .long default_entry /* Moorestown MID */
24856+ .long ta(default_entry) /* normal x86/PC */
24857+ .long ta(lguest_entry) /* lguest hypervisor */
24858+ .long ta(xen_entry) /* Xen hypervisor */
24859+ .long ta(default_entry) /* Moorestown MID */
24860 num_subarch_entries = (. - subarch_entries) / 4
24861 .previous
24862 #else
24863@@ -362,6 +434,7 @@ default_entry:
24864 movl pa(mmu_cr4_features),%eax
24865 movl %eax,%cr4
24866
24867+#ifdef CONFIG_X86_PAE
24868 testb $X86_CR4_PAE, %al # check if PAE is enabled
24869 jz enable_paging
24870
24871@@ -390,6 +463,9 @@ default_entry:
24872 /* Make changes effective */
24873 wrmsr
24874
24875+ btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
24876+#endif
24877+
24878 enable_paging:
24879
24880 /*
24881@@ -457,14 +533,20 @@ is486:
24882 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
24883 movl %eax,%ss # after changing gdt.
24884
24885- movl $(__USER_DS),%eax # DS/ES contains default USER segment
24886+# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
24887 movl %eax,%ds
24888 movl %eax,%es
24889
24890 movl $(__KERNEL_PERCPU), %eax
24891 movl %eax,%fs # set this cpu's percpu
24892
24893+#ifdef CONFIG_CC_STACKPROTECTOR
24894 movl $(__KERNEL_STACK_CANARY),%eax
24895+#elif defined(CONFIG_PAX_MEMORY_UDEREF)
24896+ movl $(__USER_DS),%eax
24897+#else
24898+ xorl %eax,%eax
24899+#endif
24900 movl %eax,%gs
24901
24902 xorl %eax,%eax # Clear LDT
24903@@ -521,8 +603,11 @@ setup_once:
24904 * relocation. Manually set base address in stack canary
24905 * segment descriptor.
24906 */
24907- movl $gdt_page,%eax
24908+ movl $cpu_gdt_table,%eax
24909 movl $stack_canary,%ecx
24910+#ifdef CONFIG_SMP
24911+ addl $__per_cpu_load,%ecx
24912+#endif
24913 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
24914 shrl $16, %ecx
24915 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
24916@@ -559,7 +644,7 @@ early_idt_handler_common:
24917 cmpl $2,(%esp) # X86_TRAP_NMI
24918 je is_nmi # Ignore NMI
24919
24920- cmpl $2,%ss:early_recursion_flag
24921+ cmpl $1,%ss:early_recursion_flag
24922 je hlt_loop
24923 incl %ss:early_recursion_flag
24924
24925@@ -597,8 +682,8 @@ early_idt_handler_common:
24926 pushl (20+6*4)(%esp) /* trapno */
24927 pushl $fault_msg
24928 call printk
24929-#endif
24930 call dump_stack
24931+#endif
24932 hlt_loop:
24933 hlt
24934 jmp hlt_loop
24935@@ -618,8 +703,11 @@ ENDPROC(early_idt_handler_common)
24936 /* This is the default interrupt "handler" :-) */
24937 ALIGN
24938 ignore_int:
24939- cld
24940 #ifdef CONFIG_PRINTK
24941+ cmpl $2,%ss:early_recursion_flag
24942+ je hlt_loop
24943+ incl %ss:early_recursion_flag
24944+ cld
24945 pushl %eax
24946 pushl %ecx
24947 pushl %edx
24948@@ -628,9 +716,6 @@ ignore_int:
24949 movl $(__KERNEL_DS),%eax
24950 movl %eax,%ds
24951 movl %eax,%es
24952- cmpl $2,early_recursion_flag
24953- je hlt_loop
24954- incl early_recursion_flag
24955 pushl 16(%esp)
24956 pushl 24(%esp)
24957 pushl 32(%esp)
24958@@ -664,29 +749,34 @@ ENTRY(setup_once_ref)
24959 /*
24960 * BSS section
24961 */
24962-__PAGE_ALIGNED_BSS
24963- .align PAGE_SIZE
24964 #ifdef CONFIG_X86_PAE
24965+.section .initial_pg_pmd,"a",@progbits
24966 initial_pg_pmd:
24967 .fill 1024*KPMDS,4,0
24968 #else
24969+.section .initial_page_table,"a",@progbits
24970 ENTRY(initial_page_table)
24971 .fill 1024,4,0
24972 #endif
24973+.section .initial_pg_fixmap,"a",@progbits
24974 initial_pg_fixmap:
24975 .fill 1024,4,0
24976+.section .empty_zero_page,"a",@progbits
24977 ENTRY(empty_zero_page)
24978 .fill 4096,1,0
24979+.section .swapper_pg_dir,"a",@progbits
24980 ENTRY(swapper_pg_dir)
24981+#ifdef CONFIG_X86_PAE
24982+ .fill 4,8,0
24983+#else
24984 .fill 1024,4,0
24985+#endif
24986
24987 /*
24988 * This starts the data section.
24989 */
24990 #ifdef CONFIG_X86_PAE
24991-__PAGE_ALIGNED_DATA
24992- /* Page-aligned for the benefit of paravirt? */
24993- .align PAGE_SIZE
24994+.section .initial_page_table,"a",@progbits
24995 ENTRY(initial_page_table)
24996 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
24997 # if KPMDS == 3
24998@@ -705,12 +795,20 @@ ENTRY(initial_page_table)
24999 # error "Kernel PMDs should be 1, 2 or 3"
25000 # endif
25001 .align PAGE_SIZE /* needs to be page-sized too */
25002+
25003+#ifdef CONFIG_PAX_PER_CPU_PGD
25004+ENTRY(cpu_pgd)
25005+ .rept 2*NR_CPUS
25006+ .fill 4,8,0
25007+ .endr
25008+#endif
25009+
25010 #endif
25011
25012 .data
25013 .balign 4
25014 ENTRY(stack_start)
25015- .long init_thread_union+THREAD_SIZE
25016+ .long init_thread_union+THREAD_SIZE-8
25017
25018 __INITRODATA
25019 int_msg:
25020@@ -738,7 +836,7 @@ fault_msg:
25021 * segment size, and 32-bit linear address value:
25022 */
25023
25024- .data
25025+.section .rodata,"a",@progbits
25026 .globl boot_gdt_descr
25027 .globl idt_descr
25028
25029@@ -747,7 +845,7 @@ fault_msg:
25030 .word 0 # 32 bit align gdt_desc.address
25031 boot_gdt_descr:
25032 .word __BOOT_DS+7
25033- .long boot_gdt - __PAGE_OFFSET
25034+ .long pa(boot_gdt)
25035
25036 .word 0 # 32-bit align idt_desc.address
25037 idt_descr:
25038@@ -758,7 +856,7 @@ idt_descr:
25039 .word 0 # 32 bit align gdt_desc.address
25040 ENTRY(early_gdt_descr)
25041 .word GDT_ENTRIES*8-1
25042- .long gdt_page /* Overwritten for secondary CPUs */
25043+ .long cpu_gdt_table /* Overwritten for secondary CPUs */
25044
25045 /*
25046 * The boot_gdt must mirror the equivalent in setup.S and is
25047@@ -767,5 +865,65 @@ ENTRY(early_gdt_descr)
25048 .align L1_CACHE_BYTES
25049 ENTRY(boot_gdt)
25050 .fill GDT_ENTRY_BOOT_CS,8,0
25051- .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
25052- .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
25053+ .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
25054+ .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
25055+
25056+ .align PAGE_SIZE_asm
25057+ENTRY(cpu_gdt_table)
25058+ .rept NR_CPUS
25059+ .quad 0x0000000000000000 /* NULL descriptor */
25060+ .quad 0x0000000000000000 /* 0x0b reserved */
25061+ .quad 0x0000000000000000 /* 0x13 reserved */
25062+ .quad 0x0000000000000000 /* 0x1b reserved */
25063+
25064+#ifdef CONFIG_PAX_KERNEXEC
25065+ .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
25066+#else
25067+ .quad 0x0000000000000000 /* 0x20 unused */
25068+#endif
25069+
25070+ .quad 0x0000000000000000 /* 0x28 unused */
25071+ .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
25072+ .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
25073+ .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
25074+ .quad 0x0000000000000000 /* 0x4b reserved */
25075+ .quad 0x0000000000000000 /* 0x53 reserved */
25076+ .quad 0x0000000000000000 /* 0x5b reserved */
25077+
25078+ .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
25079+ .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
25080+ .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
25081+ .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
25082+
25083+ .quad 0x0000000000000000 /* 0x80 TSS descriptor */
25084+ .quad 0x0000000000000000 /* 0x88 LDT descriptor */
25085+
25086+ /*
25087+ * Segments used for calling PnP BIOS have byte granularity.
25088+ * The code segments and data segments have fixed 64k limits,
25089+ * the transfer segment sizes are set at run time.
25090+ */
25091+ .quad 0x00409b000000ffff /* 0x90 32-bit code */
25092+ .quad 0x00009b000000ffff /* 0x98 16-bit code */
25093+ .quad 0x000093000000ffff /* 0xa0 16-bit data */
25094+ .quad 0x0000930000000000 /* 0xa8 16-bit data */
25095+ .quad 0x0000930000000000 /* 0xb0 16-bit data */
25096+
25097+ /*
25098+ * The APM segments have byte granularity and their bases
25099+ * are set at run time. All have 64k limits.
25100+ */
25101+ .quad 0x00409b000000ffff /* 0xb8 APM CS code */
25102+ .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
25103+ .quad 0x004093000000ffff /* 0xc8 APM DS data */
25104+
25105+ .quad 0x00c093000000ffff /* 0xd0 - ESPFIX SS */
25106+ .quad 0x0040930000000000 /* 0xd8 - PERCPU */
25107+ .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
25108+ .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
25109+ .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
25110+ .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
25111+
25112+ /* Be sure this is zeroed to avoid false validations in Xen */
25113+ .fill PAGE_SIZE_asm - GDT_SIZE,1,0
25114+ .endr
25115diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
25116index df7e780..e97a497 100644
25117--- a/arch/x86/kernel/head_64.S
25118+++ b/arch/x86/kernel/head_64.S
25119@@ -20,6 +20,8 @@
25120 #include <asm/processor-flags.h>
25121 #include <asm/percpu.h>
25122 #include <asm/nops.h>
25123+#include <asm/cpufeature.h>
25124+#include <asm/alternative-asm.h>
25125
25126 #ifdef CONFIG_PARAVIRT
25127 #include <asm/asm-offsets.h>
25128@@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
25129 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
25130 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
25131 L3_START_KERNEL = pud_index(__START_KERNEL_map)
25132+L4_VMALLOC_START = pgd_index(VMALLOC_START)
25133+L3_VMALLOC_START = pud_index(VMALLOC_START)
25134+L4_VMALLOC_END = pgd_index(VMALLOC_END)
25135+L3_VMALLOC_END = pud_index(VMALLOC_END)
25136+L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
25137+L3_VMEMMAP_START = pud_index(VMEMMAP_START)
25138
25139 .text
25140 __HEAD
25141@@ -89,11 +97,26 @@ startup_64:
25142 * Fixup the physical addresses in the page table
25143 */
25144 addq %rbp, early_level4_pgt + (L4_START_KERNEL*8)(%rip)
25145+ addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
25146+ addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
25147+ addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
25148+ addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
25149+ addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
25150
25151- addq %rbp, level3_kernel_pgt + (510*8)(%rip)
25152- addq %rbp, level3_kernel_pgt + (511*8)(%rip)
25153+ addq %rbp, level3_ident_pgt + (0*8)(%rip)
25154+#ifndef CONFIG_XEN
25155+ addq %rbp, level3_ident_pgt + (1*8)(%rip)
25156+#endif
25157
25158+ addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
25159+
25160+ addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
25161+ addq %rbp, level3_kernel_pgt + ((L3_START_KERNEL+1)*8)(%rip)
25162+
25163+ addq %rbp, level2_fixmap_pgt + (504*8)(%rip)
25164+ addq %rbp, level2_fixmap_pgt + (505*8)(%rip)
25165 addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
25166+ addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
25167
25168 /*
25169 * Set up the identity mapping for the switchover. These
25170@@ -174,11 +197,12 @@ ENTRY(secondary_startup_64)
25171 * after the boot processor executes this code.
25172 */
25173
25174+ orq $-1, %rbp
25175 movq $(init_level4_pgt - __START_KERNEL_map), %rax
25176 1:
25177
25178- /* Enable PAE mode and PGE */
25179- movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx
25180+ /* Enable PAE mode and PSE/PGE */
25181+ movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %ecx
25182 movq %rcx, %cr4
25183
25184 /* Setup early boot stage 4 level pagetables. */
25185@@ -199,10 +223,21 @@ ENTRY(secondary_startup_64)
25186 movl $MSR_EFER, %ecx
25187 rdmsr
25188 btsl $_EFER_SCE, %eax /* Enable System Call */
25189- btl $20,%edi /* No Execute supported? */
25190+ btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
25191 jnc 1f
25192 btsl $_EFER_NX, %eax
25193+ cmpq $-1, %rbp
25194+ je 1f
25195 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
25196+ btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_PAGE_OFFSET(%rip)
25197+ btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_VMALLOC_START(%rip)
25198+ btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_VMALLOC_END(%rip)
25199+ btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_VMEMMAP_START(%rip)
25200+ btsq $_PAGE_BIT_NX, level2_fixmap_pgt + 8*504(%rip)
25201+ btsq $_PAGE_BIT_NX, level2_fixmap_pgt + 8*505(%rip)
25202+ btsq $_PAGE_BIT_NX, level2_fixmap_pgt + 8*506(%rip)
25203+ btsq $_PAGE_BIT_NX, level2_fixmap_pgt + 8*507(%rip)
25204+ btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
25205 1: wrmsr /* Make changes effective */
25206
25207 /* Setup cr0 */
25208@@ -282,6 +317,7 @@ ENTRY(secondary_startup_64)
25209 * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
25210 * address given in m16:64.
25211 */
25212+ pax_set_fptr_mask
25213 movq initial_code(%rip),%rax
25214 pushq $0 # fake return address to stop unwinder
25215 pushq $__KERNEL_CS # set correct cs
25216@@ -313,7 +349,7 @@ ENDPROC(start_cpu0)
25217 .quad INIT_PER_CPU_VAR(irq_stack_union)
25218
25219 GLOBAL(stack_start)
25220- .quad init_thread_union+THREAD_SIZE-8
25221+ .quad init_thread_union+THREAD_SIZE-16
25222 .word 0
25223 __FINITDATA
25224
25225@@ -393,7 +429,7 @@ early_idt_handler_common:
25226 call dump_stack
25227 #ifdef CONFIG_KALLSYMS
25228 leaq early_idt_ripmsg(%rip),%rdi
25229- movq 40(%rsp),%rsi # %rip again
25230+ movq 88(%rsp),%rsi # %rip again
25231 call __print_symbol
25232 #endif
25233 #endif /* EARLY_PRINTK */
25234@@ -422,6 +458,7 @@ ENDPROC(early_idt_handler_common)
25235 early_recursion_flag:
25236 .long 0
25237
25238+ .section .rodata,"a",@progbits
25239 #ifdef CONFIG_EARLY_PRINTK
25240 early_idt_msg:
25241 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
25242@@ -449,29 +486,52 @@ NEXT_PAGE(early_level4_pgt)
25243 NEXT_PAGE(early_dynamic_pgts)
25244 .fill 512*EARLY_DYNAMIC_PAGE_TABLES,8,0
25245
25246- .data
25247+ .section .rodata,"a",@progbits
25248
25249-#ifndef CONFIG_XEN
25250 NEXT_PAGE(init_level4_pgt)
25251- .fill 512,8,0
25252-#else
25253-NEXT_PAGE(init_level4_pgt)
25254- .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
25255 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
25256 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
25257+ .org init_level4_pgt + L4_VMALLOC_START*8, 0
25258+ .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
25259+ .org init_level4_pgt + L4_VMALLOC_END*8, 0
25260+ .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
25261+ .org init_level4_pgt + L4_VMEMMAP_START*8, 0
25262+ .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
25263 .org init_level4_pgt + L4_START_KERNEL*8, 0
25264 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
25265 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
25266
25267+#ifdef CONFIG_PAX_PER_CPU_PGD
25268+NEXT_PAGE(cpu_pgd)
25269+ .rept 2*NR_CPUS
25270+ .fill 512,8,0
25271+ .endr
25272+#endif
25273+
25274 NEXT_PAGE(level3_ident_pgt)
25275 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
25276+#ifdef CONFIG_XEN
25277 .fill 511, 8, 0
25278+#else
25279+ .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
25280+ .fill 510,8,0
25281+#endif
25282+
25283+NEXT_PAGE(level3_vmalloc_start_pgt)
25284+ .fill 512,8,0
25285+
25286+NEXT_PAGE(level3_vmalloc_end_pgt)
25287+ .fill 512,8,0
25288+
25289+NEXT_PAGE(level3_vmemmap_pgt)
25290+ .fill L3_VMEMMAP_START,8,0
25291+ .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
25292+
25293 NEXT_PAGE(level2_ident_pgt)
25294- /* Since I easily can, map the first 1G.
25295+ /* Since I easily can, map the first 2G.
25296 * Don't set NX because code runs from these pages.
25297 */
25298- PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
25299-#endif
25300+ PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
25301
25302 NEXT_PAGE(level3_kernel_pgt)
25303 .fill L3_START_KERNEL,8,0
25304@@ -479,6 +539,9 @@ NEXT_PAGE(level3_kernel_pgt)
25305 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
25306 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
25307
25308+NEXT_PAGE(level2_vmemmap_pgt)
25309+ .fill 512,8,0
25310+
25311 NEXT_PAGE(level2_kernel_pgt)
25312 /*
25313 * 512 MB kernel mapping. We spend a full page on this pagetable
25314@@ -494,23 +557,61 @@ NEXT_PAGE(level2_kernel_pgt)
25315 KERNEL_IMAGE_SIZE/PMD_SIZE)
25316
25317 NEXT_PAGE(level2_fixmap_pgt)
25318- .fill 506,8,0
25319- .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
25320- /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
25321- .fill 5,8,0
25322+ .fill 504,8,0
25323+ .quad level1_fixmap_pgt - __START_KERNEL_map + 0 * PAGE_SIZE + _PAGE_TABLE
25324+ .quad level1_fixmap_pgt - __START_KERNEL_map + 1 * PAGE_SIZE + _PAGE_TABLE
25325+ .quad level1_fixmap_pgt - __START_KERNEL_map + 2 * PAGE_SIZE + _PAGE_TABLE
25326+ .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
25327+ /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
25328+ .fill 4,8,0
25329
25330 NEXT_PAGE(level1_fixmap_pgt)
25331+ .fill 3*512,8,0
25332+
25333+NEXT_PAGE(level1_vsyscall_pgt)
25334 .fill 512,8,0
25335
25336 #undef PMDS
25337
25338- .data
25339+ .align PAGE_SIZE
25340+ENTRY(cpu_gdt_table)
25341+ .rept NR_CPUS
25342+ .quad 0x0000000000000000 /* NULL descriptor */
25343+ .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
25344+ .quad 0x00af9b000000ffff /* __KERNEL_CS */
25345+ .quad 0x00cf93000000ffff /* __KERNEL_DS */
25346+ .quad 0x00cffb000000ffff /* __USER32_CS */
25347+ .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
25348+ .quad 0x00affb000000ffff /* __USER_CS */
25349+
25350+#ifdef CONFIG_PAX_KERNEXEC
25351+ .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
25352+#else
25353+ .quad 0x0 /* unused */
25354+#endif
25355+
25356+ .quad 0,0 /* TSS */
25357+ .quad 0,0 /* LDT */
25358+ .quad 0,0,0 /* three TLS descriptors */
25359+ .quad 0x0000f40000000000 /* node/CPU stored in limit */
25360+ /* asm/segment.h:GDT_ENTRIES must match this */
25361+
25362+#ifdef CONFIG_PAX_MEMORY_UDEREF
25363+ .quad 0x00cf93000000ffff /* __UDEREF_KERNEL_DS */
25364+#else
25365+ .quad 0x0 /* unused */
25366+#endif
25367+
25368+ /* zero the remaining page */
25369+ .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
25370+ .endr
25371+
25372 .align 16
25373 .globl early_gdt_descr
25374 early_gdt_descr:
25375 .word GDT_ENTRIES*8-1
25376 early_gdt_descr_base:
25377- .quad INIT_PER_CPU_VAR(gdt_page)
25378+ .quad cpu_gdt_table
25379
25380 ENTRY(phys_base)
25381 /* This must match the first entry in level2_kernel_pgt */
25382@@ -534,8 +635,8 @@ NEXT_PAGE(kasan_zero_pud)
25383
25384
25385 #include "../../x86/xen/xen-head.S"
25386-
25387- __PAGE_ALIGNED_BSS
25388+
25389+ .section .rodata,"a",@progbits
25390 NEXT_PAGE(empty_zero_page)
25391 .skip PAGE_SIZE
25392
25393diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
25394index 05fd74f..c3548b1 100644
25395--- a/arch/x86/kernel/i386_ksyms_32.c
25396+++ b/arch/x86/kernel/i386_ksyms_32.c
25397@@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
25398 EXPORT_SYMBOL(cmpxchg8b_emu);
25399 #endif
25400
25401+EXPORT_SYMBOL_GPL(cpu_gdt_table);
25402+
25403 /* Networking helper routines. */
25404 EXPORT_SYMBOL(csum_partial_copy_generic);
25405+EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
25406+EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
25407
25408 EXPORT_SYMBOL(__get_user_1);
25409 EXPORT_SYMBOL(__get_user_2);
25410@@ -44,3 +48,11 @@ EXPORT_SYMBOL(___preempt_schedule);
25411 EXPORT_SYMBOL(___preempt_schedule_context);
25412 #endif
25413 #endif
25414+
25415+#ifdef CONFIG_PAX_KERNEXEC
25416+EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
25417+#endif
25418+
25419+#ifdef CONFIG_PAX_PER_CPU_PGD
25420+EXPORT_SYMBOL(cpu_pgd);
25421+#endif
25422diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
25423index e7cc537..67d7372 100644
25424--- a/arch/x86/kernel/i8259.c
25425+++ b/arch/x86/kernel/i8259.c
25426@@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
25427 static void make_8259A_irq(unsigned int irq)
25428 {
25429 disable_irq_nosync(irq);
25430- io_apic_irqs &= ~(1<<irq);
25431+ io_apic_irqs &= ~(1UL<<irq);
25432 irq_set_chip_and_handler(irq, &i8259A_chip, handle_level_irq);
25433 enable_irq(irq);
25434 }
25435@@ -208,7 +208,7 @@ spurious_8259A_irq:
25436 "spurious 8259A interrupt: IRQ%d.\n", irq);
25437 spurious_irq_mask |= irqmask;
25438 }
25439- atomic_inc(&irq_err_count);
25440+ atomic_inc_unchecked(&irq_err_count);
25441 /*
25442 * Theoretically we do not have to handle this IRQ,
25443 * but in Linux this does not cause problems and is
25444@@ -349,14 +349,16 @@ static void init_8259A(int auto_eoi)
25445 /* (slave's support for AEOI in flat mode is to be investigated) */
25446 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
25447
25448+ pax_open_kernel();
25449 if (auto_eoi)
25450 /*
25451 * In AEOI mode we just have to mask the interrupt
25452 * when acking.
25453 */
25454- i8259A_chip.irq_mask_ack = disable_8259A_irq;
25455+ *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
25456 else
25457- i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
25458+ *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
25459+ pax_close_kernel();
25460
25461 udelay(100); /* wait for 8259A to initialize */
25462
25463diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
25464index a979b5b..1d6db75 100644
25465--- a/arch/x86/kernel/io_delay.c
25466+++ b/arch/x86/kernel/io_delay.c
25467@@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
25468 * Quirk table for systems that misbehave (lock up, etc.) if port
25469 * 0x80 is used:
25470 */
25471-static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
25472+static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
25473 {
25474 .callback = dmi_io_delay_0xed_port,
25475 .ident = "Compaq Presario V6000",
25476diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
25477index 37dae79..620dd84 100644
25478--- a/arch/x86/kernel/ioport.c
25479+++ b/arch/x86/kernel/ioport.c
25480@@ -6,6 +6,7 @@
25481 #include <linux/sched.h>
25482 #include <linux/kernel.h>
25483 #include <linux/capability.h>
25484+#include <linux/security.h>
25485 #include <linux/errno.h>
25486 #include <linux/types.h>
25487 #include <linux/ioport.h>
25488@@ -30,6 +31,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
25489 return -EINVAL;
25490 if (turn_on && !capable(CAP_SYS_RAWIO))
25491 return -EPERM;
25492+#ifdef CONFIG_GRKERNSEC_IO
25493+ if (turn_on && grsec_disable_privio) {
25494+ gr_handle_ioperm();
25495+ return -ENODEV;
25496+ }
25497+#endif
25498
25499 /*
25500 * If it's the first ioperm() call in this thread's lifetime, set the
25501@@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
25502 * because the ->io_bitmap_max value must match the bitmap
25503 * contents:
25504 */
25505- tss = &per_cpu(cpu_tss, get_cpu());
25506+ tss = cpu_tss + get_cpu();
25507
25508 if (turn_on)
25509 bitmap_clear(t->io_bitmap_ptr, from, num);
25510@@ -105,6 +112,12 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
25511 if (level > old) {
25512 if (!capable(CAP_SYS_RAWIO))
25513 return -EPERM;
25514+#ifdef CONFIG_GRKERNSEC_IO
25515+ if (grsec_disable_privio) {
25516+ gr_handle_iopl();
25517+ return -ENODEV;
25518+ }
25519+#endif
25520 }
25521 regs->flags = (regs->flags & ~X86_EFLAGS_IOPL) | (level << 12);
25522 t->iopl = level << 12;
25523diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
25524index e5952c2..11c3a54 100644
25525--- a/arch/x86/kernel/irq.c
25526+++ b/arch/x86/kernel/irq.c
25527@@ -22,7 +22,7 @@
25528 #define CREATE_TRACE_POINTS
25529 #include <asm/trace/irq_vectors.h>
25530
25531-atomic_t irq_err_count;
25532+atomic_unchecked_t irq_err_count;
25533
25534 /* Function pointer for generic interrupt vector handling */
25535 void (*x86_platform_ipi_callback)(void) = NULL;
25536@@ -132,9 +132,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
25537 seq_printf(p, "%10u ", irq_stats(j)->irq_hv_callback_count);
25538 seq_puts(p, " Hypervisor callback interrupts\n");
25539 #endif
25540- seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
25541+ seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
25542 #if defined(CONFIG_X86_IO_APIC)
25543- seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
25544+ seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
25545 #endif
25546 return 0;
25547 }
25548@@ -174,7 +174,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
25549
25550 u64 arch_irq_stat(void)
25551 {
25552- u64 sum = atomic_read(&irq_err_count);
25553+ u64 sum = atomic_read_unchecked(&irq_err_count);
25554 return sum;
25555 }
25556
25557diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
25558index f9fd86a..e6cc9ae 100644
25559--- a/arch/x86/kernel/irq_32.c
25560+++ b/arch/x86/kernel/irq_32.c
25561@@ -29,6 +29,8 @@ EXPORT_PER_CPU_SYMBOL(irq_regs);
25562
25563 #ifdef CONFIG_DEBUG_STACKOVERFLOW
25564
25565+extern void gr_handle_kernel_exploit(void);
25566+
25567 int sysctl_panic_on_stackoverflow __read_mostly;
25568
25569 /* Debugging check for stack overflow: is there less than 1KB free? */
25570@@ -39,13 +41,14 @@ static int check_stack_overflow(void)
25571 __asm__ __volatile__("andl %%esp,%0" :
25572 "=r" (sp) : "0" (THREAD_SIZE - 1));
25573
25574- return sp < (sizeof(struct thread_info) + STACK_WARN);
25575+ return sp < STACK_WARN;
25576 }
25577
25578 static void print_stack_overflow(void)
25579 {
25580 printk(KERN_WARNING "low stack detected by irq handler\n");
25581 dump_stack();
25582+ gr_handle_kernel_exploit();
25583 if (sysctl_panic_on_stackoverflow)
25584 panic("low stack detected by irq handler - check messages\n");
25585 }
25586@@ -77,10 +80,9 @@ static inline void *current_stack(void)
25587 static inline int
25588 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
25589 {
25590- struct irq_stack *curstk, *irqstk;
25591+ struct irq_stack *irqstk;
25592 u32 *isp, *prev_esp, arg1, arg2;
25593
25594- curstk = (struct irq_stack *) current_stack();
25595 irqstk = __this_cpu_read(hardirq_stack);
25596
25597 /*
25598@@ -89,15 +91,19 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
25599 * handler) we can't do that and just have to keep using the
25600 * current stack (which is the irq stack already after all)
25601 */
25602- if (unlikely(curstk == irqstk))
25603+ if (unlikely((void *)current_stack_pointer - (void *)irqstk < THREAD_SIZE))
25604 return 0;
25605
25606- isp = (u32 *) ((char *)irqstk + sizeof(*irqstk));
25607+ isp = (u32 *) ((char *)irqstk + sizeof(*irqstk) - 8);
25608
25609 /* Save the next esp at the bottom of the stack */
25610 prev_esp = (u32 *)irqstk;
25611 *prev_esp = current_stack_pointer();
25612
25613+#ifdef CONFIG_PAX_MEMORY_UDEREF
25614+ __set_fs(MAKE_MM_SEG(0));
25615+#endif
25616+
25617 if (unlikely(overflow))
25618 call_on_stack(print_stack_overflow, isp);
25619
25620@@ -108,6 +114,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
25621 : "0" (irq), "1" (desc), "2" (isp),
25622 "D" (desc->handle_irq)
25623 : "memory", "cc", "ecx");
25624+
25625+#ifdef CONFIG_PAX_MEMORY_UDEREF
25626+ __set_fs(current_thread_info()->addr_limit);
25627+#endif
25628+
25629 return 1;
25630 }
25631
25632@@ -116,32 +127,18 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
25633 */
25634 void irq_ctx_init(int cpu)
25635 {
25636- struct irq_stack *irqstk;
25637-
25638 if (per_cpu(hardirq_stack, cpu))
25639 return;
25640
25641- irqstk = page_address(alloc_pages_node(cpu_to_node(cpu),
25642- THREADINFO_GFP,
25643- THREAD_SIZE_ORDER));
25644- per_cpu(hardirq_stack, cpu) = irqstk;
25645-
25646- irqstk = page_address(alloc_pages_node(cpu_to_node(cpu),
25647- THREADINFO_GFP,
25648- THREAD_SIZE_ORDER));
25649- per_cpu(softirq_stack, cpu) = irqstk;
25650-
25651- printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
25652- cpu, per_cpu(hardirq_stack, cpu), per_cpu(softirq_stack, cpu));
25653+ per_cpu(hardirq_stack, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
25654+ per_cpu(softirq_stack, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
25655 }
25656
25657 void do_softirq_own_stack(void)
25658 {
25659- struct thread_info *curstk;
25660 struct irq_stack *irqstk;
25661 u32 *isp, *prev_esp;
25662
25663- curstk = current_stack();
25664 irqstk = __this_cpu_read(softirq_stack);
25665
25666 /* build the stack frame on the softirq stack */
25667@@ -151,7 +148,16 @@ void do_softirq_own_stack(void)
25668 prev_esp = (u32 *)irqstk;
25669 *prev_esp = current_stack_pointer();
25670
25671+#ifdef CONFIG_PAX_MEMORY_UDEREF
25672+ __set_fs(MAKE_MM_SEG(0));
25673+#endif
25674+
25675 call_on_stack(__do_softirq, isp);
25676+
25677+#ifdef CONFIG_PAX_MEMORY_UDEREF
25678+ __set_fs(current_thread_info()->addr_limit);
25679+#endif
25680+
25681 }
25682
25683 bool handle_irq(unsigned irq, struct pt_regs *regs)
25684diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
25685index 394e643..824fce8 100644
25686--- a/arch/x86/kernel/irq_64.c
25687+++ b/arch/x86/kernel/irq_64.c
25688@@ -26,6 +26,8 @@ EXPORT_PER_CPU_SYMBOL(irq_stat);
25689 DEFINE_PER_CPU(struct pt_regs *, irq_regs);
25690 EXPORT_PER_CPU_SYMBOL(irq_regs);
25691
25692+extern void gr_handle_kernel_exploit(void);
25693+
25694 int sysctl_panic_on_stackoverflow;
25695
25696 /*
25697@@ -69,6 +71,8 @@ static inline void stack_overflow_check(struct pt_regs *regs)
25698 irq_stack_top, irq_stack_bottom,
25699 estack_top, estack_bottom);
25700
25701+ gr_handle_kernel_exploit();
25702+
25703 if (sysctl_panic_on_stackoverflow)
25704 panic("low stack detected by irq handler - check messages\n");
25705 #endif
25706diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c
25707index 26d5a55..a01160a 100644
25708--- a/arch/x86/kernel/jump_label.c
25709+++ b/arch/x86/kernel/jump_label.c
25710@@ -51,7 +51,7 @@ static void __jump_label_transform(struct jump_entry *entry,
25711 * Jump label is enabled for the first time.
25712 * So we expect a default_nop...
25713 */
25714- if (unlikely(memcmp((void *)entry->code, default_nop, 5)
25715+ if (unlikely(memcmp((void *)ktla_ktva(entry->code), default_nop, 5)
25716 != 0))
25717 bug_at((void *)entry->code, __LINE__);
25718 } else {
25719@@ -59,7 +59,7 @@ static void __jump_label_transform(struct jump_entry *entry,
25720 * ...otherwise expect an ideal_nop. Otherwise
25721 * something went horribly wrong.
25722 */
25723- if (unlikely(memcmp((void *)entry->code, ideal_nop, 5)
25724+ if (unlikely(memcmp((void *)ktla_ktva(entry->code), ideal_nop, 5)
25725 != 0))
25726 bug_at((void *)entry->code, __LINE__);
25727 }
25728@@ -75,13 +75,13 @@ static void __jump_label_transform(struct jump_entry *entry,
25729 * are converting the default nop to the ideal nop.
25730 */
25731 if (init) {
25732- if (unlikely(memcmp((void *)entry->code, default_nop, 5) != 0))
25733+ if (unlikely(memcmp((void *)ktla_ktva(entry->code), default_nop, 5) != 0))
25734 bug_at((void *)entry->code, __LINE__);
25735 } else {
25736 code.jump = 0xe9;
25737 code.offset = entry->target -
25738 (entry->code + JUMP_LABEL_NOP_SIZE);
25739- if (unlikely(memcmp((void *)entry->code, &code, 5) != 0))
25740+ if (unlikely(memcmp((void *)ktla_ktva(entry->code), &code, 5) != 0))
25741 bug_at((void *)entry->code, __LINE__);
25742 }
25743 memcpy(&code, ideal_nops[NOP_ATOMIC5], JUMP_LABEL_NOP_SIZE);
25744diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
25745index d6178d9..e12482f 100644
25746--- a/arch/x86/kernel/kgdb.c
25747+++ b/arch/x86/kernel/kgdb.c
25748@@ -228,7 +228,10 @@ static void kgdb_correct_hw_break(void)
25749 bp->attr.bp_addr = breakinfo[breakno].addr;
25750 bp->attr.bp_len = breakinfo[breakno].len;
25751 bp->attr.bp_type = breakinfo[breakno].type;
25752- info->address = breakinfo[breakno].addr;
25753+ if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
25754+ info->address = ktla_ktva(breakinfo[breakno].addr);
25755+ else
25756+ info->address = breakinfo[breakno].addr;
25757 info->len = breakinfo[breakno].len;
25758 info->type = breakinfo[breakno].type;
25759 val = arch_install_hw_breakpoint(bp);
25760@@ -475,12 +478,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
25761 case 'k':
25762 /* clear the trace bit */
25763 linux_regs->flags &= ~X86_EFLAGS_TF;
25764- atomic_set(&kgdb_cpu_doing_single_step, -1);
25765+ atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
25766
25767 /* set the trace bit if we're stepping */
25768 if (remcomInBuffer[0] == 's') {
25769 linux_regs->flags |= X86_EFLAGS_TF;
25770- atomic_set(&kgdb_cpu_doing_single_step,
25771+ atomic_set_unchecked(&kgdb_cpu_doing_single_step,
25772 raw_smp_processor_id());
25773 }
25774
25775@@ -545,7 +548,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
25776
25777 switch (cmd) {
25778 case DIE_DEBUG:
25779- if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
25780+ if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
25781 if (user_mode(regs))
25782 return single_step_cont(regs, args);
25783 break;
25784@@ -750,11 +753,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
25785 #endif /* CONFIG_DEBUG_RODATA */
25786
25787 bpt->type = BP_BREAKPOINT;
25788- err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
25789+ err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
25790 BREAK_INSTR_SIZE);
25791 if (err)
25792 return err;
25793- err = probe_kernel_write((char *)bpt->bpt_addr,
25794+ err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
25795 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
25796 #ifdef CONFIG_DEBUG_RODATA
25797 if (!err)
25798@@ -767,7 +770,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
25799 return -EBUSY;
25800 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
25801 BREAK_INSTR_SIZE);
25802- err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
25803+ err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
25804 if (err)
25805 return err;
25806 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
25807@@ -792,13 +795,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
25808 if (mutex_is_locked(&text_mutex))
25809 goto knl_write;
25810 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
25811- err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
25812+ err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
25813 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
25814 goto knl_write;
25815 return err;
25816 knl_write:
25817 #endif /* CONFIG_DEBUG_RODATA */
25818- return probe_kernel_write((char *)bpt->bpt_addr,
25819+ return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
25820 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
25821 }
25822
25823diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
25824index 1deffe6..4705700 100644
25825--- a/arch/x86/kernel/kprobes/core.c
25826+++ b/arch/x86/kernel/kprobes/core.c
25827@@ -120,9 +120,12 @@ __synthesize_relative_insn(void *from, void *to, u8 op)
25828 s32 raddr;
25829 } __packed *insn;
25830
25831- insn = (struct __arch_relative_insn *)from;
25832+ insn = (struct __arch_relative_insn *)ktla_ktva(from);
25833+
25834+ pax_open_kernel();
25835 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
25836 insn->op = op;
25837+ pax_close_kernel();
25838 }
25839
25840 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
25841@@ -168,7 +171,7 @@ int can_boost(kprobe_opcode_t *opcodes)
25842 kprobe_opcode_t opcode;
25843 kprobe_opcode_t *orig_opcodes = opcodes;
25844
25845- if (search_exception_tables((unsigned long)opcodes))
25846+ if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
25847 return 0; /* Page fault may occur on this address. */
25848
25849 retry:
25850@@ -260,12 +263,12 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
25851 * Fortunately, we know that the original code is the ideal 5-byte
25852 * long NOP.
25853 */
25854- memcpy(buf, (void *)addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
25855+ memcpy(buf, (void *)ktla_ktva(addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
25856 if (faddr)
25857 memcpy(buf, ideal_nops[NOP_ATOMIC5], 5);
25858 else
25859 buf[0] = kp->opcode;
25860- return (unsigned long)buf;
25861+ return ktva_ktla((unsigned long)buf);
25862 }
25863
25864 /*
25865@@ -367,7 +370,9 @@ int __copy_instruction(u8 *dest, u8 *src)
25866 /* Another subsystem puts a breakpoint, failed to recover */
25867 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
25868 return 0;
25869+ pax_open_kernel();
25870 memcpy(dest, insn.kaddr, length);
25871+ pax_close_kernel();
25872
25873 #ifdef CONFIG_X86_64
25874 if (insn_rip_relative(&insn)) {
25875@@ -394,7 +399,9 @@ int __copy_instruction(u8 *dest, u8 *src)
25876 return 0;
25877 }
25878 disp = (u8 *) dest + insn_offset_displacement(&insn);
25879+ pax_open_kernel();
25880 *(s32 *) disp = (s32) newdisp;
25881+ pax_close_kernel();
25882 }
25883 #endif
25884 return length;
25885@@ -536,7 +543,7 @@ static void setup_singlestep(struct kprobe *p, struct pt_regs *regs,
25886 * nor set current_kprobe, because it doesn't use single
25887 * stepping.
25888 */
25889- regs->ip = (unsigned long)p->ainsn.insn;
25890+ regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
25891 preempt_enable_no_resched();
25892 return;
25893 }
25894@@ -553,9 +560,9 @@ static void setup_singlestep(struct kprobe *p, struct pt_regs *regs,
25895 regs->flags &= ~X86_EFLAGS_IF;
25896 /* single step inline if the instruction is an int3 */
25897 if (p->opcode == BREAKPOINT_INSTRUCTION)
25898- regs->ip = (unsigned long)p->addr;
25899+ regs->ip = ktla_ktva((unsigned long)p->addr);
25900 else
25901- regs->ip = (unsigned long)p->ainsn.insn;
25902+ regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
25903 }
25904 NOKPROBE_SYMBOL(setup_singlestep);
25905
25906@@ -640,7 +647,7 @@ int kprobe_int3_handler(struct pt_regs *regs)
25907 setup_singlestep(p, regs, kcb, 0);
25908 return 1;
25909 }
25910- } else if (*addr != BREAKPOINT_INSTRUCTION) {
25911+ } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
25912 /*
25913 * The breakpoint instruction was removed right
25914 * after we hit it. Another cpu has removed
25915@@ -687,6 +694,9 @@ static void __used kretprobe_trampoline_holder(void)
25916 " movq %rax, 152(%rsp)\n"
25917 RESTORE_REGS_STRING
25918 " popfq\n"
25919+#ifdef KERNEXEC_PLUGIN
25920+ " btsq $63,(%rsp)\n"
25921+#endif
25922 #else
25923 " pushf\n"
25924 SAVE_REGS_STRING
25925@@ -827,7 +837,7 @@ static void resume_execution(struct kprobe *p, struct pt_regs *regs,
25926 struct kprobe_ctlblk *kcb)
25927 {
25928 unsigned long *tos = stack_addr(regs);
25929- unsigned long copy_ip = (unsigned long)p->ainsn.insn;
25930+ unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
25931 unsigned long orig_ip = (unsigned long)p->addr;
25932 kprobe_opcode_t *insn = p->ainsn.insn;
25933
25934diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
25935index 7b3b9d1..e2478b91 100644
25936--- a/arch/x86/kernel/kprobes/opt.c
25937+++ b/arch/x86/kernel/kprobes/opt.c
25938@@ -79,6 +79,7 @@ found:
25939 /* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
25940 static void synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
25941 {
25942+ pax_open_kernel();
25943 #ifdef CONFIG_X86_64
25944 *addr++ = 0x48;
25945 *addr++ = 0xbf;
25946@@ -86,6 +87,7 @@ static void synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
25947 *addr++ = 0xb8;
25948 #endif
25949 *(unsigned long *)addr = val;
25950+ pax_close_kernel();
25951 }
25952
25953 asm (
25954@@ -342,7 +344,7 @@ int arch_prepare_optimized_kprobe(struct optimized_kprobe *op,
25955 * Verify if the address gap is in 2GB range, because this uses
25956 * a relative jump.
25957 */
25958- rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
25959+ rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
25960 if (abs(rel) > 0x7fffffff) {
25961 __arch_remove_optimized_kprobe(op, 0);
25962 return -ERANGE;
25963@@ -359,16 +361,18 @@ int arch_prepare_optimized_kprobe(struct optimized_kprobe *op,
25964 op->optinsn.size = ret;
25965
25966 /* Copy arch-dep-instance from template */
25967- memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
25968+ pax_open_kernel();
25969+ memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
25970+ pax_close_kernel();
25971
25972 /* Set probe information */
25973 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
25974
25975 /* Set probe function call */
25976- synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
25977+ synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
25978
25979 /* Set returning jmp instruction at the tail of out-of-line buffer */
25980- synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
25981+ synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
25982 (u8 *)op->kp.addr + op->optinsn.size);
25983
25984 flush_icache_range((unsigned long) buf,
25985@@ -393,7 +397,7 @@ void arch_optimize_kprobes(struct list_head *oplist)
25986 WARN_ON(kprobe_disabled(&op->kp));
25987
25988 /* Backup instructions which will be replaced by jump address */
25989- memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
25990+ memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
25991 RELATIVE_ADDR_SIZE);
25992
25993 insn_buf[0] = RELATIVEJUMP_OPCODE;
25994@@ -441,7 +445,7 @@ int setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
25995 /* This kprobe is really able to run optimized path. */
25996 op = container_of(p, struct optimized_kprobe, kp);
25997 /* Detour through copied instructions */
25998- regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
25999+ regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
26000 if (!reenter)
26001 reset_current_kprobe();
26002 preempt_enable_no_resched();
26003diff --git a/arch/x86/kernel/ksysfs.c b/arch/x86/kernel/ksysfs.c
26004index c2bedae..25e7ab60 100644
26005--- a/arch/x86/kernel/ksysfs.c
26006+++ b/arch/x86/kernel/ksysfs.c
26007@@ -184,7 +184,7 @@ out:
26008
26009 static struct kobj_attribute type_attr = __ATTR_RO(type);
26010
26011-static struct bin_attribute data_attr = {
26012+static bin_attribute_no_const data_attr __read_only = {
26013 .attr = {
26014 .name = "data",
26015 .mode = S_IRUGO,
26016diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
26017index c37886d..f43b63d 100644
26018--- a/arch/x86/kernel/ldt.c
26019+++ b/arch/x86/kernel/ldt.c
26020@@ -11,6 +11,7 @@
26021 #include <linux/sched.h>
26022 #include <linux/string.h>
26023 #include <linux/mm.h>
26024+#include <linux/ratelimit.h>
26025 #include <linux/smp.h>
26026 #include <linux/vmalloc.h>
26027 #include <linux/uaccess.h>
26028@@ -20,6 +21,14 @@
26029 #include <asm/mmu_context.h>
26030 #include <asm/syscalls.h>
26031
26032+#ifdef CONFIG_GRKERNSEC
26033+int sysctl_modify_ldt __read_only = 0;
26034+#elif defined(CONFIG_DEFAULT_MODIFY_LDT_SYSCALL)
26035+int sysctl_modify_ldt __read_only = 1;
26036+#else
26037+int sysctl_modify_ldt __read_only = 0;
26038+#endif
26039+
26040 #ifdef CONFIG_SMP
26041 static void flush_ldt(void *current_mm)
26042 {
26043@@ -66,13 +75,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
26044 if (reload) {
26045 #ifdef CONFIG_SMP
26046 preempt_disable();
26047- load_LDT(pc);
26048+ load_LDT_nolock(pc);
26049 if (!cpumask_equal(mm_cpumask(current->mm),
26050 cpumask_of(smp_processor_id())))
26051 smp_call_function(flush_ldt, current->mm, 1);
26052 preempt_enable();
26053 #else
26054- load_LDT(pc);
26055+ load_LDT_nolock(pc);
26056 #endif
26057 }
26058 if (oldsize) {
26059@@ -94,7 +103,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
26060 return err;
26061
26062 for (i = 0; i < old->size; i++)
26063- write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
26064+ write_ldt_entry(new->ldt, i, old->ldt + i);
26065 return 0;
26066 }
26067
26068@@ -115,6 +124,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
26069 retval = copy_ldt(&mm->context, &old_mm->context);
26070 mutex_unlock(&old_mm->context.lock);
26071 }
26072+
26073+ if (tsk == current) {
26074+ mm->context.vdso = 0;
26075+
26076+#ifdef CONFIG_X86_32
26077+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
26078+ mm->context.user_cs_base = 0UL;
26079+ mm->context.user_cs_limit = ~0UL;
26080+
26081+#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
26082+ cpumask_clear(&mm->context.cpu_user_cs_mask);
26083+#endif
26084+
26085+#endif
26086+#endif
26087+
26088+ }
26089+
26090 return retval;
26091 }
26092
26093@@ -229,6 +256,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
26094 }
26095 }
26096
26097+#ifdef CONFIG_PAX_SEGMEXEC
26098+ if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
26099+ error = -EINVAL;
26100+ goto out_unlock;
26101+ }
26102+#endif
26103+
26104 if (!IS_ENABLED(CONFIG_X86_16BIT) && !ldt_info.seg_32bit) {
26105 error = -EINVAL;
26106 goto out_unlock;
26107@@ -254,6 +288,15 @@ asmlinkage int sys_modify_ldt(int func, void __user *ptr,
26108 {
26109 int ret = -ENOSYS;
26110
26111+ if (!sysctl_modify_ldt) {
26112+ printk_ratelimited(KERN_INFO
26113+ "Denied a call to modify_ldt() from %s[%d] (uid: %d)."
26114+ " Adjust sysctl if this was not an exploit attempt.\n",
26115+ current->comm, task_pid_nr(current),
26116+ from_kuid_munged(current_user_ns(), current_uid()));
26117+ return ret;
26118+ }
26119+
26120 switch (func) {
26121 case 0:
26122 ret = read_ldt(ptr, bytecount);
26123diff --git a/arch/x86/kernel/livepatch.c b/arch/x86/kernel/livepatch.c
26124index ff3c3101d..d7c0cd8 100644
26125--- a/arch/x86/kernel/livepatch.c
26126+++ b/arch/x86/kernel/livepatch.c
26127@@ -41,9 +41,10 @@ int klp_write_module_reloc(struct module *mod, unsigned long type,
26128 int ret, numpages, size = 4;
26129 bool readonly;
26130 unsigned long val;
26131- unsigned long core = (unsigned long)mod->module_core;
26132- unsigned long core_ro_size = mod->core_ro_size;
26133- unsigned long core_size = mod->core_size;
26134+ unsigned long core_rx = (unsigned long)mod->module_core_rx;
26135+ unsigned long core_rw = (unsigned long)mod->module_core_rw;
26136+ unsigned long core_size_rx = mod->core_size_rx;
26137+ unsigned long core_size_rw = mod->core_size_rw;
26138
26139 switch (type) {
26140 case R_X86_64_NONE:
26141@@ -66,11 +67,12 @@ int klp_write_module_reloc(struct module *mod, unsigned long type,
26142 return -EINVAL;
26143 }
26144
26145- if (loc < core || loc >= core + core_size)
26146+ if ((loc < core_rx || loc >= core_rx + core_size_rx) &&
26147+ (loc < core_rw || loc >= core_rw + core_size_rw))
26148 /* loc does not point to any symbol inside the module */
26149 return -EINVAL;
26150
26151- if (loc < core + core_ro_size)
26152+ if (loc < core_rx + core_size_rx)
26153 readonly = true;
26154 else
26155 readonly = false;
26156diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
26157index 469b23d..5449cfe 100644
26158--- a/arch/x86/kernel/machine_kexec_32.c
26159+++ b/arch/x86/kernel/machine_kexec_32.c
26160@@ -26,7 +26,7 @@
26161 #include <asm/cacheflush.h>
26162 #include <asm/debugreg.h>
26163
26164-static void set_idt(void *newidt, __u16 limit)
26165+static void set_idt(struct desc_struct *newidt, __u16 limit)
26166 {
26167 struct desc_ptr curidt;
26168
26169@@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
26170 }
26171
26172
26173-static void set_gdt(void *newgdt, __u16 limit)
26174+static void set_gdt(struct desc_struct *newgdt, __u16 limit)
26175 {
26176 struct desc_ptr curgdt;
26177
26178@@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
26179 }
26180
26181 control_page = page_address(image->control_code_page);
26182- memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
26183+ memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
26184
26185 relocate_kernel_ptr = control_page;
26186 page_list[PA_CONTROL_PAGE] = __pa(control_page);
26187diff --git a/arch/x86/kernel/mcount_64.S b/arch/x86/kernel/mcount_64.S
26188index 94ea120..4154cea 100644
26189--- a/arch/x86/kernel/mcount_64.S
26190+++ b/arch/x86/kernel/mcount_64.S
26191@@ -7,7 +7,7 @@
26192 #include <linux/linkage.h>
26193 #include <asm/ptrace.h>
26194 #include <asm/ftrace.h>
26195-
26196+#include <asm/alternative-asm.h>
26197
26198 .code64
26199 .section .entry.text, "ax"
26200@@ -148,8 +148,9 @@
26201 #ifdef CONFIG_DYNAMIC_FTRACE
26202
26203 ENTRY(function_hook)
26204+ pax_force_retaddr
26205 retq
26206-END(function_hook)
26207+ENDPROC(function_hook)
26208
26209 ENTRY(ftrace_caller)
26210 /* save_mcount_regs fills in first two parameters */
26211@@ -181,8 +182,9 @@ GLOBAL(ftrace_graph_call)
26212 #endif
26213
26214 GLOBAL(ftrace_stub)
26215+ pax_force_retaddr
26216 retq
26217-END(ftrace_caller)
26218+ENDPROC(ftrace_caller)
26219
26220 ENTRY(ftrace_regs_caller)
26221 /* Save the current flags before any operations that can change them */
26222@@ -253,7 +255,7 @@ GLOBAL(ftrace_regs_caller_end)
26223
26224 jmp ftrace_return
26225
26226-END(ftrace_regs_caller)
26227+ENDPROC(ftrace_regs_caller)
26228
26229
26230 #else /* ! CONFIG_DYNAMIC_FTRACE */
26231@@ -272,18 +274,20 @@ fgraph_trace:
26232 #endif
26233
26234 GLOBAL(ftrace_stub)
26235+ pax_force_retaddr
26236 retq
26237
26238 trace:
26239 /* save_mcount_regs fills in first two parameters */
26240 save_mcount_regs
26241
26242+ pax_force_fptr ftrace_trace_function
26243 call *ftrace_trace_function
26244
26245 restore_mcount_regs
26246
26247 jmp fgraph_trace
26248-END(function_hook)
26249+ENDPROC(function_hook)
26250 #endif /* CONFIG_DYNAMIC_FTRACE */
26251 #endif /* CONFIG_FUNCTION_TRACER */
26252
26253@@ -305,8 +309,9 @@ ENTRY(ftrace_graph_caller)
26254
26255 restore_mcount_regs
26256
26257+ pax_force_retaddr
26258 retq
26259-END(ftrace_graph_caller)
26260+ENDPROC(ftrace_graph_caller)
26261
26262 GLOBAL(return_to_handler)
26263 subq $24, %rsp
26264@@ -322,5 +327,7 @@ GLOBAL(return_to_handler)
26265 movq 8(%rsp), %rdx
26266 movq (%rsp), %rax
26267 addq $24, %rsp
26268+ pax_force_fptr %rdi
26269 jmp *%rdi
26270+ENDPROC(return_to_handler)
26271 #endif
26272diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
26273index 005c03e..2f440cd 100644
26274--- a/arch/x86/kernel/module.c
26275+++ b/arch/x86/kernel/module.c
26276@@ -75,17 +75,17 @@ static unsigned long int get_module_load_offset(void)
26277 }
26278 #endif
26279
26280-void *module_alloc(unsigned long size)
26281+static inline void *__module_alloc(unsigned long size, pgprot_t prot)
26282 {
26283 void *p;
26284
26285- if (PAGE_ALIGN(size) > MODULES_LEN)
26286+ if (!size || PAGE_ALIGN(size) > MODULES_LEN)
26287 return NULL;
26288
26289 p = __vmalloc_node_range(size, MODULE_ALIGN,
26290 MODULES_VADDR + get_module_load_offset(),
26291- MODULES_END, GFP_KERNEL | __GFP_HIGHMEM,
26292- PAGE_KERNEL_EXEC, 0, NUMA_NO_NODE,
26293+ MODULES_END, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO,
26294+ prot, 0, NUMA_NO_NODE,
26295 __builtin_return_address(0));
26296 if (p && (kasan_module_alloc(p, size) < 0)) {
26297 vfree(p);
26298@@ -95,6 +95,51 @@ void *module_alloc(unsigned long size)
26299 return p;
26300 }
26301
26302+void *module_alloc(unsigned long size)
26303+{
26304+
26305+#ifdef CONFIG_PAX_KERNEXEC
26306+ return __module_alloc(size, PAGE_KERNEL);
26307+#else
26308+ return __module_alloc(size, PAGE_KERNEL_EXEC);
26309+#endif
26310+
26311+}
26312+
26313+#ifdef CONFIG_PAX_KERNEXEC
26314+#ifdef CONFIG_X86_32
26315+void *module_alloc_exec(unsigned long size)
26316+{
26317+ struct vm_struct *area;
26318+
26319+ if (size == 0)
26320+ return NULL;
26321+
26322+ area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
26323+return area ? area->addr : NULL;
26324+}
26325+EXPORT_SYMBOL(module_alloc_exec);
26326+
26327+void module_memfree_exec(void *module_region)
26328+{
26329+ vunmap(module_region);
26330+}
26331+EXPORT_SYMBOL(module_memfree_exec);
26332+#else
26333+void module_memfree_exec(void *module_region)
26334+{
26335+ module_memfree(module_region);
26336+}
26337+EXPORT_SYMBOL(module_memfree_exec);
26338+
26339+void *module_alloc_exec(unsigned long size)
26340+{
26341+ return __module_alloc(size, PAGE_KERNEL_RX);
26342+}
26343+EXPORT_SYMBOL(module_alloc_exec);
26344+#endif
26345+#endif
26346+
26347 #ifdef CONFIG_X86_32
26348 int apply_relocate(Elf32_Shdr *sechdrs,
26349 const char *strtab,
26350@@ -105,14 +150,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
26351 unsigned int i;
26352 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
26353 Elf32_Sym *sym;
26354- uint32_t *location;
26355+ uint32_t *plocation, location;
26356
26357 DEBUGP("Applying relocate section %u to %u\n",
26358 relsec, sechdrs[relsec].sh_info);
26359 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
26360 /* This is where to make the change */
26361- location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
26362- + rel[i].r_offset;
26363+ plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
26364+ location = (uint32_t)plocation;
26365+ if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
26366+ plocation = ktla_ktva((void *)plocation);
26367 /* This is the symbol it is referring to. Note that all
26368 undefined symbols have been resolved. */
26369 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
26370@@ -121,11 +168,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
26371 switch (ELF32_R_TYPE(rel[i].r_info)) {
26372 case R_386_32:
26373 /* We add the value into the location given */
26374- *location += sym->st_value;
26375+ pax_open_kernel();
26376+ *plocation += sym->st_value;
26377+ pax_close_kernel();
26378 break;
26379 case R_386_PC32:
26380 /* Add the value, subtract its position */
26381- *location += sym->st_value - (uint32_t)location;
26382+ pax_open_kernel();
26383+ *plocation += sym->st_value - location;
26384+ pax_close_kernel();
26385 break;
26386 default:
26387 pr_err("%s: Unknown relocation: %u\n",
26388@@ -170,21 +221,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
26389 case R_X86_64_NONE:
26390 break;
26391 case R_X86_64_64:
26392+ pax_open_kernel();
26393 *(u64 *)loc = val;
26394+ pax_close_kernel();
26395 break;
26396 case R_X86_64_32:
26397+ pax_open_kernel();
26398 *(u32 *)loc = val;
26399+ pax_close_kernel();
26400 if (val != *(u32 *)loc)
26401 goto overflow;
26402 break;
26403 case R_X86_64_32S:
26404+ pax_open_kernel();
26405 *(s32 *)loc = val;
26406+ pax_close_kernel();
26407 if ((s64)val != *(s32 *)loc)
26408 goto overflow;
26409 break;
26410 case R_X86_64_PC32:
26411 val -= (u64)loc;
26412+ pax_open_kernel();
26413 *(u32 *)loc = val;
26414+ pax_close_kernel();
26415+
26416 #if 0
26417 if ((s64)val != *(s32 *)loc)
26418 goto overflow;
26419diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
26420index 113e707..0a690e1 100644
26421--- a/arch/x86/kernel/msr.c
26422+++ b/arch/x86/kernel/msr.c
26423@@ -39,6 +39,7 @@
26424 #include <linux/notifier.h>
26425 #include <linux/uaccess.h>
26426 #include <linux/gfp.h>
26427+#include <linux/grsecurity.h>
26428
26429 #include <asm/processor.h>
26430 #include <asm/msr.h>
26431@@ -105,6 +106,11 @@ static ssize_t msr_write(struct file *file, const char __user *buf,
26432 int err = 0;
26433 ssize_t bytes = 0;
26434
26435+#ifdef CONFIG_GRKERNSEC_KMEM
26436+ gr_handle_msr_write();
26437+ return -EPERM;
26438+#endif
26439+
26440 if (count % 8)
26441 return -EINVAL; /* Invalid chunk size */
26442
26443@@ -152,6 +158,10 @@ static long msr_ioctl(struct file *file, unsigned int ioc, unsigned long arg)
26444 err = -EBADF;
26445 break;
26446 }
26447+#ifdef CONFIG_GRKERNSEC_KMEM
26448+ gr_handle_msr_write();
26449+ return -EPERM;
26450+#endif
26451 if (copy_from_user(&regs, uregs, sizeof regs)) {
26452 err = -EFAULT;
26453 break;
26454@@ -235,7 +245,7 @@ static int msr_class_cpu_callback(struct notifier_block *nfb,
26455 return notifier_from_errno(err);
26456 }
26457
26458-static struct notifier_block __refdata msr_class_cpu_notifier = {
26459+static struct notifier_block msr_class_cpu_notifier = {
26460 .notifier_call = msr_class_cpu_callback,
26461 };
26462
26463diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
26464index c3e985d..f690edd 100644
26465--- a/arch/x86/kernel/nmi.c
26466+++ b/arch/x86/kernel/nmi.c
26467@@ -98,16 +98,16 @@ fs_initcall(nmi_warning_debugfs);
26468
26469 static void nmi_max_handler(struct irq_work *w)
26470 {
26471- struct nmiaction *a = container_of(w, struct nmiaction, irq_work);
26472+ struct nmiwork *n = container_of(w, struct nmiwork, irq_work);
26473 int remainder_ns, decimal_msecs;
26474- u64 whole_msecs = ACCESS_ONCE(a->max_duration);
26475+ u64 whole_msecs = ACCESS_ONCE(n->max_duration);
26476
26477 remainder_ns = do_div(whole_msecs, (1000 * 1000));
26478 decimal_msecs = remainder_ns / 1000;
26479
26480 printk_ratelimited(KERN_INFO
26481 "INFO: NMI handler (%ps) took too long to run: %lld.%03d msecs\n",
26482- a->handler, whole_msecs, decimal_msecs);
26483+ n->action->handler, whole_msecs, decimal_msecs);
26484 }
26485
26486 static int nmi_handle(unsigned int type, struct pt_regs *regs, bool b2b)
26487@@ -134,11 +134,11 @@ static int nmi_handle(unsigned int type, struct pt_regs *regs, bool b2b)
26488 delta = sched_clock() - delta;
26489 trace_nmi_handler(a->handler, (int)delta, thishandled);
26490
26491- if (delta < nmi_longest_ns || delta < a->max_duration)
26492+ if (delta < nmi_longest_ns || delta < a->work->max_duration)
26493 continue;
26494
26495- a->max_duration = delta;
26496- irq_work_queue(&a->irq_work);
26497+ a->work->max_duration = delta;
26498+ irq_work_queue(&a->work->irq_work);
26499 }
26500
26501 rcu_read_unlock();
26502@@ -148,7 +148,7 @@ static int nmi_handle(unsigned int type, struct pt_regs *regs, bool b2b)
26503 }
26504 NOKPROBE_SYMBOL(nmi_handle);
26505
26506-int __register_nmi_handler(unsigned int type, struct nmiaction *action)
26507+int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
26508 {
26509 struct nmi_desc *desc = nmi_to_desc(type);
26510 unsigned long flags;
26511@@ -156,7 +156,8 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
26512 if (!action->handler)
26513 return -EINVAL;
26514
26515- init_irq_work(&action->irq_work, nmi_max_handler);
26516+ action->work->action = action;
26517+ init_irq_work(&action->work->irq_work, nmi_max_handler);
26518
26519 spin_lock_irqsave(&desc->lock, flags);
26520
26521@@ -174,9 +175,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
26522 * event confuses some handlers (kdump uses this flag)
26523 */
26524 if (action->flags & NMI_FLAG_FIRST)
26525- list_add_rcu(&action->list, &desc->head);
26526+ pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
26527 else
26528- list_add_tail_rcu(&action->list, &desc->head);
26529+ pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
26530
26531 spin_unlock_irqrestore(&desc->lock, flags);
26532 return 0;
26533@@ -199,7 +200,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
26534 if (!strcmp(n->name, name)) {
26535 WARN(in_nmi(),
26536 "Trying to free NMI (%s) from NMI context!\n", n->name);
26537- list_del_rcu(&n->list);
26538+ pax_list_del_rcu((struct list_head *)&n->list);
26539 break;
26540 }
26541 }
26542@@ -408,15 +409,15 @@ static void default_do_nmi(struct pt_regs *regs)
26543 NOKPROBE_SYMBOL(default_do_nmi);
26544
26545 /*
26546- * NMIs can hit breakpoints which will cause it to lose its
26547- * NMI context with the CPU when the breakpoint does an iret.
26548- */
26549-#ifdef CONFIG_X86_32
26550-/*
26551- * For i386, NMIs use the same stack as the kernel, and we can
26552- * add a workaround to the iret problem in C (preventing nested
26553- * NMIs if an NMI takes a trap). Simply have 3 states the NMI
26554- * can be in:
26555+ * NMIs can page fault or hit breakpoints which will cause it to lose
26556+ * its NMI context with the CPU when the breakpoint or page fault does an IRET.
26557+ *
26558+ * As a result, NMIs can nest if NMIs get unmasked due an IRET during
26559+ * NMI processing. On x86_64, the asm glue protects us from nested NMIs
26560+ * if the outer NMI came from kernel mode, but we can still nest if the
26561+ * outer NMI came from user mode.
26562+ *
26563+ * To handle these nested NMIs, we have three states:
26564 *
26565 * 1) not running
26566 * 2) executing
26567@@ -430,15 +431,14 @@ NOKPROBE_SYMBOL(default_do_nmi);
26568 * (Note, the latch is binary, thus multiple NMIs triggering,
26569 * when one is running, are ignored. Only one NMI is restarted.)
26570 *
26571- * If an NMI hits a breakpoint that executes an iret, another
26572- * NMI can preempt it. We do not want to allow this new NMI
26573- * to run, but we want to execute it when the first one finishes.
26574- * We set the state to "latched", and the exit of the first NMI will
26575- * perform a dec_return, if the result is zero (NOT_RUNNING), then
26576- * it will simply exit the NMI handler. If not, the dec_return
26577- * would have set the state to NMI_EXECUTING (what we want it to
26578- * be when we are running). In this case, we simply jump back
26579- * to rerun the NMI handler again, and restart the 'latched' NMI.
26580+ * If an NMI executes an iret, another NMI can preempt it. We do not
26581+ * want to allow this new NMI to run, but we want to execute it when the
26582+ * first one finishes. We set the state to "latched", and the exit of
26583+ * the first NMI will perform a dec_return, if the result is zero
26584+ * (NOT_RUNNING), then it will simply exit the NMI handler. If not, the
26585+ * dec_return would have set the state to NMI_EXECUTING (what we want it
26586+ * to be when we are running). In this case, we simply jump back to
26587+ * rerun the NMI handler again, and restart the 'latched' NMI.
26588 *
26589 * No trap (breakpoint or page fault) should be hit before nmi_restart,
26590 * thus there is no race between the first check of state for NOT_RUNNING
26591@@ -461,49 +461,47 @@ enum nmi_states {
26592 static DEFINE_PER_CPU(enum nmi_states, nmi_state);
26593 static DEFINE_PER_CPU(unsigned long, nmi_cr2);
26594
26595-#define nmi_nesting_preprocess(regs) \
26596- do { \
26597- if (this_cpu_read(nmi_state) != NMI_NOT_RUNNING) { \
26598- this_cpu_write(nmi_state, NMI_LATCHED); \
26599- return; \
26600- } \
26601- this_cpu_write(nmi_state, NMI_EXECUTING); \
26602- this_cpu_write(nmi_cr2, read_cr2()); \
26603- } while (0); \
26604- nmi_restart:
26605-
26606-#define nmi_nesting_postprocess() \
26607- do { \
26608- if (unlikely(this_cpu_read(nmi_cr2) != read_cr2())) \
26609- write_cr2(this_cpu_read(nmi_cr2)); \
26610- if (this_cpu_dec_return(nmi_state)) \
26611- goto nmi_restart; \
26612- } while (0)
26613-#else /* x86_64 */
26614+#ifdef CONFIG_X86_64
26615 /*
26616- * In x86_64 things are a bit more difficult. This has the same problem
26617- * where an NMI hitting a breakpoint that calls iret will remove the
26618- * NMI context, allowing a nested NMI to enter. What makes this more
26619- * difficult is that both NMIs and breakpoints have their own stack.
26620- * When a new NMI or breakpoint is executed, the stack is set to a fixed
26621- * point. If an NMI is nested, it will have its stack set at that same
26622- * fixed address that the first NMI had, and will start corrupting the
26623- * stack. This is handled in entry_64.S, but the same problem exists with
26624- * the breakpoint stack.
26625+ * In x86_64, we need to handle breakpoint -> NMI -> breakpoint. Without
26626+ * some care, the inner breakpoint will clobber the outer breakpoint's
26627+ * stack.
26628 *
26629- * If a breakpoint is being processed, and the debug stack is being used,
26630- * if an NMI comes in and also hits a breakpoint, the stack pointer
26631- * will be set to the same fixed address as the breakpoint that was
26632- * interrupted, causing that stack to be corrupted. To handle this case,
26633- * check if the stack that was interrupted is the debug stack, and if
26634- * so, change the IDT so that new breakpoints will use the current stack
26635- * and not switch to the fixed address. On return of the NMI, switch back
26636- * to the original IDT.
26637+ * If a breakpoint is being processed, and the debug stack is being
26638+ * used, if an NMI comes in and also hits a breakpoint, the stack
26639+ * pointer will be set to the same fixed address as the breakpoint that
26640+ * was interrupted, causing that stack to be corrupted. To handle this
26641+ * case, check if the stack that was interrupted is the debug stack, and
26642+ * if so, change the IDT so that new breakpoints will use the current
26643+ * stack and not switch to the fixed address. On return of the NMI,
26644+ * switch back to the original IDT.
26645 */
26646 static DEFINE_PER_CPU(int, update_debug_stack);
26647+#endif
26648
26649-static inline void nmi_nesting_preprocess(struct pt_regs *regs)
26650+dotraplinkage notrace void
26651+do_nmi(struct pt_regs *regs, long error_code)
26652 {
26653+
26654+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26655+ if (!user_mode(regs)) {
26656+ unsigned long cs = regs->cs & 0xFFFF;
26657+ unsigned long ip = ktva_ktla(regs->ip);
26658+
26659+ if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
26660+ regs->ip = ip;
26661+ }
26662+#endif
26663+
26664+ if (this_cpu_read(nmi_state) != NMI_NOT_RUNNING) {
26665+ this_cpu_write(nmi_state, NMI_LATCHED);
26666+ return;
26667+ }
26668+ this_cpu_write(nmi_state, NMI_EXECUTING);
26669+ this_cpu_write(nmi_cr2, read_cr2());
26670+nmi_restart:
26671+
26672+#ifdef CONFIG_X86_64
26673 /*
26674 * If we interrupted a breakpoint, it is possible that
26675 * the nmi handler will have breakpoints too. We need to
26676@@ -514,22 +512,8 @@ static inline void nmi_nesting_preprocess(struct pt_regs *regs)
26677 debug_stack_set_zero();
26678 this_cpu_write(update_debug_stack, 1);
26679 }
26680-}
26681-
26682-static inline void nmi_nesting_postprocess(void)
26683-{
26684- if (unlikely(this_cpu_read(update_debug_stack))) {
26685- debug_stack_reset();
26686- this_cpu_write(update_debug_stack, 0);
26687- }
26688-}
26689 #endif
26690
26691-dotraplinkage notrace void
26692-do_nmi(struct pt_regs *regs, long error_code)
26693-{
26694- nmi_nesting_preprocess(regs);
26695-
26696 nmi_enter();
26697
26698 inc_irq_stat(__nmi_count);
26699@@ -539,8 +523,17 @@ do_nmi(struct pt_regs *regs, long error_code)
26700
26701 nmi_exit();
26702
26703- /* On i386, may loop back to preprocess */
26704- nmi_nesting_postprocess();
26705+#ifdef CONFIG_X86_64
26706+ if (unlikely(this_cpu_read(update_debug_stack))) {
26707+ debug_stack_reset();
26708+ this_cpu_write(update_debug_stack, 0);
26709+ }
26710+#endif
26711+
26712+ if (unlikely(this_cpu_read(nmi_cr2) != read_cr2()))
26713+ write_cr2(this_cpu_read(nmi_cr2));
26714+ if (this_cpu_dec_return(nmi_state))
26715+ goto nmi_restart;
26716 }
26717 NOKPROBE_SYMBOL(do_nmi);
26718
26719diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
26720index 6d9582e..f746287 100644
26721--- a/arch/x86/kernel/nmi_selftest.c
26722+++ b/arch/x86/kernel/nmi_selftest.c
26723@@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
26724 {
26725 /* trap all the unknown NMIs we may generate */
26726 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
26727- __initdata);
26728+ __initconst);
26729 }
26730
26731 static void __init cleanup_nmi_testsuite(void)
26732@@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
26733 unsigned long timeout;
26734
26735 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
26736- NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
26737+ NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
26738 nmi_fail = FAILURE;
26739 return;
26740 }
26741diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
26742index bbb6c73..24a58ef 100644
26743--- a/arch/x86/kernel/paravirt-spinlocks.c
26744+++ b/arch/x86/kernel/paravirt-spinlocks.c
26745@@ -8,7 +8,7 @@
26746
26747 #include <asm/paravirt.h>
26748
26749-struct pv_lock_ops pv_lock_ops = {
26750+struct pv_lock_ops pv_lock_ops __read_only = {
26751 #ifdef CONFIG_SMP
26752 .lock_spinning = __PV_IS_CALLEE_SAVE(paravirt_nop),
26753 .unlock_kick = paravirt_nop,
26754diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
26755index c614dd4..9ad659e 100644
26756--- a/arch/x86/kernel/paravirt.c
26757+++ b/arch/x86/kernel/paravirt.c
26758@@ -56,6 +56,9 @@ u64 _paravirt_ident_64(u64 x)
26759 {
26760 return x;
26761 }
26762+#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
26763+PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
26764+#endif
26765
26766 void __init default_banner(void)
26767 {
26768@@ -142,16 +145,20 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
26769
26770 if (opfunc == NULL)
26771 /* If there's no function, patch it with a ud2a (BUG) */
26772- ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
26773- else if (opfunc == _paravirt_nop)
26774+ ret = paravirt_patch_insns(insnbuf, len, ktva_ktla(ud2a), ud2a+sizeof(ud2a));
26775+ else if (opfunc == (void *)_paravirt_nop)
26776 /* If the operation is a nop, then nop the callsite */
26777 ret = paravirt_patch_nop();
26778
26779 /* identity functions just return their single argument */
26780- else if (opfunc == _paravirt_ident_32)
26781+ else if (opfunc == (void *)_paravirt_ident_32)
26782 ret = paravirt_patch_ident_32(insnbuf, len);
26783- else if (opfunc == _paravirt_ident_64)
26784+ else if (opfunc == (void *)_paravirt_ident_64)
26785 ret = paravirt_patch_ident_64(insnbuf, len);
26786+#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
26787+ else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
26788+ ret = paravirt_patch_ident_64(insnbuf, len);
26789+#endif
26790
26791 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
26792 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
26793@@ -176,7 +183,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
26794 if (insn_len > len || start == NULL)
26795 insn_len = len;
26796 else
26797- memcpy(insnbuf, start, insn_len);
26798+ memcpy(insnbuf, ktla_ktva(start), insn_len);
26799
26800 return insn_len;
26801 }
26802@@ -300,7 +307,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
26803 return this_cpu_read(paravirt_lazy_mode);
26804 }
26805
26806-struct pv_info pv_info = {
26807+struct pv_info pv_info __read_only = {
26808 .name = "bare hardware",
26809 .paravirt_enabled = 0,
26810 .kernel_rpl = 0,
26811@@ -311,16 +318,16 @@ struct pv_info pv_info = {
26812 #endif
26813 };
26814
26815-struct pv_init_ops pv_init_ops = {
26816+struct pv_init_ops pv_init_ops __read_only = {
26817 .patch = native_patch,
26818 };
26819
26820-struct pv_time_ops pv_time_ops = {
26821+struct pv_time_ops pv_time_ops __read_only = {
26822 .sched_clock = native_sched_clock,
26823 .steal_clock = native_steal_clock,
26824 };
26825
26826-__visible struct pv_irq_ops pv_irq_ops = {
26827+__visible struct pv_irq_ops pv_irq_ops __read_only = {
26828 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
26829 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
26830 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
26831@@ -332,7 +339,7 @@ __visible struct pv_irq_ops pv_irq_ops = {
26832 #endif
26833 };
26834
26835-__visible struct pv_cpu_ops pv_cpu_ops = {
26836+__visible struct pv_cpu_ops pv_cpu_ops __read_only = {
26837 .cpuid = native_cpuid,
26838 .get_debugreg = native_get_debugreg,
26839 .set_debugreg = native_set_debugreg,
26840@@ -395,21 +402,26 @@ NOKPROBE_SYMBOL(native_get_debugreg);
26841 NOKPROBE_SYMBOL(native_set_debugreg);
26842 NOKPROBE_SYMBOL(native_load_idt);
26843
26844-struct pv_apic_ops pv_apic_ops = {
26845+struct pv_apic_ops pv_apic_ops __read_only= {
26846 #ifdef CONFIG_X86_LOCAL_APIC
26847 .startup_ipi_hook = paravirt_nop,
26848 #endif
26849 };
26850
26851-#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
26852+#ifdef CONFIG_X86_32
26853+#ifdef CONFIG_X86_PAE
26854+/* 64-bit pagetable entries */
26855+#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
26856+#else
26857 /* 32-bit pagetable entries */
26858 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
26859+#endif
26860 #else
26861 /* 64-bit pagetable entries */
26862 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
26863 #endif
26864
26865-struct pv_mmu_ops pv_mmu_ops = {
26866+struct pv_mmu_ops pv_mmu_ops __read_only = {
26867
26868 .read_cr2 = native_read_cr2,
26869 .write_cr2 = native_write_cr2,
26870@@ -459,6 +471,7 @@ struct pv_mmu_ops pv_mmu_ops = {
26871 .make_pud = PTE_IDENT,
26872
26873 .set_pgd = native_set_pgd,
26874+ .set_pgd_batched = native_set_pgd_batched,
26875 #endif
26876 #endif /* CONFIG_PGTABLE_LEVELS >= 3 */
26877
26878@@ -479,6 +492,12 @@ struct pv_mmu_ops pv_mmu_ops = {
26879 },
26880
26881 .set_fixmap = native_set_fixmap,
26882+
26883+#ifdef CONFIG_PAX_KERNEXEC
26884+ .pax_open_kernel = native_pax_open_kernel,
26885+ .pax_close_kernel = native_pax_close_kernel,
26886+#endif
26887+
26888 };
26889
26890 EXPORT_SYMBOL_GPL(pv_time_ops);
26891diff --git a/arch/x86/kernel/paravirt_patch_64.c b/arch/x86/kernel/paravirt_patch_64.c
26892index a1da673..b6f5831 100644
26893--- a/arch/x86/kernel/paravirt_patch_64.c
26894+++ b/arch/x86/kernel/paravirt_patch_64.c
26895@@ -9,7 +9,11 @@ DEF_NATIVE(pv_irq_ops, save_fl, "pushfq; popq %rax");
26896 DEF_NATIVE(pv_mmu_ops, read_cr2, "movq %cr2, %rax");
26897 DEF_NATIVE(pv_mmu_ops, read_cr3, "movq %cr3, %rax");
26898 DEF_NATIVE(pv_mmu_ops, write_cr3, "movq %rdi, %cr3");
26899+
26900+#ifndef CONFIG_PAX_MEMORY_UDEREF
26901 DEF_NATIVE(pv_mmu_ops, flush_tlb_single, "invlpg (%rdi)");
26902+#endif
26903+
26904 DEF_NATIVE(pv_cpu_ops, clts, "clts");
26905 DEF_NATIVE(pv_cpu_ops, wbinvd, "wbinvd");
26906
26907@@ -57,7 +61,11 @@ unsigned native_patch(u8 type, u16 clobbers, void *ibuf,
26908 PATCH_SITE(pv_mmu_ops, read_cr3);
26909 PATCH_SITE(pv_mmu_ops, write_cr3);
26910 PATCH_SITE(pv_cpu_ops, clts);
26911+
26912+#ifndef CONFIG_PAX_MEMORY_UDEREF
26913 PATCH_SITE(pv_mmu_ops, flush_tlb_single);
26914+#endif
26915+
26916 PATCH_SITE(pv_cpu_ops, wbinvd);
26917
26918 patch_site:
26919diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
26920index 0497f71..7186c0d 100644
26921--- a/arch/x86/kernel/pci-calgary_64.c
26922+++ b/arch/x86/kernel/pci-calgary_64.c
26923@@ -1347,7 +1347,7 @@ static void __init get_tce_space_from_tar(void)
26924 tce_space = be64_to_cpu(readq(target));
26925 tce_space = tce_space & TAR_SW_BITS;
26926
26927- tce_space = tce_space & (~specified_table_size);
26928+ tce_space = tce_space & (~(unsigned long)specified_table_size);
26929 info->tce_space = (u64 *)__va(tce_space);
26930 }
26931 }
26932diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
26933index 35ccf75..7a15747 100644
26934--- a/arch/x86/kernel/pci-iommu_table.c
26935+++ b/arch/x86/kernel/pci-iommu_table.c
26936@@ -2,7 +2,7 @@
26937 #include <asm/iommu_table.h>
26938 #include <linux/string.h>
26939 #include <linux/kallsyms.h>
26940-
26941+#include <linux/sched.h>
26942
26943 #define DEBUG 1
26944
26945diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
26946index 77dd0ad..9ec4723 100644
26947--- a/arch/x86/kernel/pci-swiotlb.c
26948+++ b/arch/x86/kernel/pci-swiotlb.c
26949@@ -33,7 +33,7 @@ void x86_swiotlb_free_coherent(struct device *dev, size_t size,
26950 struct dma_attrs *attrs)
26951 {
26952 if (is_swiotlb_buffer(dma_to_phys(dev, dma_addr)))
26953- swiotlb_free_coherent(dev, size, vaddr, dma_addr);
26954+ swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
26955 else
26956 dma_generic_free_coherent(dev, size, vaddr, dma_addr, attrs);
26957 }
26958diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
26959index 6e338e3..82f946e 100644
26960--- a/arch/x86/kernel/process.c
26961+++ b/arch/x86/kernel/process.c
26962@@ -38,7 +38,8 @@
26963 * section. Since TSS's are completely CPU-local, we want them
26964 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
26965 */
26966-__visible DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, cpu_tss) = {
26967+struct tss_struct cpu_tss[NR_CPUS] __visible ____cacheline_internodealigned_in_smp = {
26968+ [0 ... NR_CPUS-1] = {
26969 .x86_tss = {
26970 .sp0 = TOP_OF_INIT_STACK,
26971 #ifdef CONFIG_X86_32
26972@@ -56,6 +57,7 @@ __visible DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, cpu_tss) = {
26973 */
26974 .io_bitmap = { [0 ... IO_BITMAP_LONGS] = ~0 },
26975 #endif
26976+}
26977 };
26978 EXPORT_PER_CPU_SYMBOL(cpu_tss);
26979
26980@@ -115,7 +117,7 @@ void arch_task_cache_init(void)
26981 task_xstate_cachep =
26982 kmem_cache_create("task_xstate", xstate_size,
26983 __alignof__(union thread_xstate),
26984- SLAB_PANIC | SLAB_NOTRACK, NULL);
26985+ SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
26986 setup_xstate_comp();
26987 }
26988
26989@@ -129,7 +131,7 @@ void exit_thread(void)
26990 unsigned long *bp = t->io_bitmap_ptr;
26991
26992 if (bp) {
26993- struct tss_struct *tss = &per_cpu(cpu_tss, get_cpu());
26994+ struct tss_struct *tss = cpu_tss + get_cpu();
26995
26996 t->io_bitmap_ptr = NULL;
26997 clear_thread_flag(TIF_IO_BITMAP);
26998@@ -149,6 +151,9 @@ void flush_thread(void)
26999 {
27000 struct task_struct *tsk = current;
27001
27002+#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
27003+ loadsegment(gs, 0);
27004+#endif
27005 flush_ptrace_hw_breakpoint(tsk);
27006 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
27007
27008@@ -302,7 +307,7 @@ static void __exit_idle(void)
27009 void exit_idle(void)
27010 {
27011 /* idle loop has pid 0 */
27012- if (current->pid)
27013+ if (task_pid_nr(current))
27014 return;
27015 __exit_idle();
27016 }
27017@@ -355,7 +360,7 @@ bool xen_set_default_idle(void)
27018 return ret;
27019 }
27020 #endif
27021-void stop_this_cpu(void *dummy)
27022+__noreturn void stop_this_cpu(void *dummy)
27023 {
27024 local_irq_disable();
27025 /*
27026@@ -531,16 +536,43 @@ static int __init idle_setup(char *str)
27027 }
27028 early_param("idle", idle_setup);
27029
27030-unsigned long arch_align_stack(unsigned long sp)
27031-{
27032- if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
27033- sp -= get_random_int() % 8192;
27034- return sp & ~0xf;
27035-}
27036-
27037 unsigned long arch_randomize_brk(struct mm_struct *mm)
27038 {
27039 unsigned long range_end = mm->brk + 0x02000000;
27040 return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
27041 }
27042
27043+#ifdef CONFIG_PAX_RANDKSTACK
27044+void pax_randomize_kstack(struct pt_regs *regs)
27045+{
27046+ struct thread_struct *thread = &current->thread;
27047+ unsigned long time;
27048+
27049+ if (!randomize_va_space)
27050+ return;
27051+
27052+ if (v8086_mode(regs))
27053+ return;
27054+
27055+ rdtscl(time);
27056+
27057+ /* P4 seems to return a 0 LSB, ignore it */
27058+#ifdef CONFIG_MPENTIUM4
27059+ time &= 0x3EUL;
27060+ time <<= 2;
27061+#elif defined(CONFIG_X86_64)
27062+ time &= 0xFUL;
27063+ time <<= 4;
27064+#else
27065+ time &= 0x1FUL;
27066+ time <<= 3;
27067+#endif
27068+
27069+ thread->sp0 ^= time;
27070+ load_sp0(cpu_tss + smp_processor_id(), thread);
27071+
27072+#ifdef CONFIG_X86_64
27073+ this_cpu_write(kernel_stack, thread->sp0);
27074+#endif
27075+}
27076+#endif
27077diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
27078index 8ed2106..1345704 100644
27079--- a/arch/x86/kernel/process_32.c
27080+++ b/arch/x86/kernel/process_32.c
27081@@ -64,6 +64,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
27082 unsigned long thread_saved_pc(struct task_struct *tsk)
27083 {
27084 return ((unsigned long *)tsk->thread.sp)[3];
27085+//XXX return tsk->thread.eip;
27086 }
27087
27088 void __show_regs(struct pt_regs *regs, int all)
27089@@ -76,16 +77,15 @@ void __show_regs(struct pt_regs *regs, int all)
27090 if (user_mode(regs)) {
27091 sp = regs->sp;
27092 ss = regs->ss & 0xffff;
27093- gs = get_user_gs(regs);
27094 } else {
27095 sp = kernel_stack_pointer(regs);
27096 savesegment(ss, ss);
27097- savesegment(gs, gs);
27098 }
27099+ gs = get_user_gs(regs);
27100
27101 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
27102 (u16)regs->cs, regs->ip, regs->flags,
27103- smp_processor_id());
27104+ raw_smp_processor_id());
27105 print_symbol("EIP is at %s\n", regs->ip);
27106
27107 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
27108@@ -132,21 +132,22 @@ void release_thread(struct task_struct *dead_task)
27109 int copy_thread(unsigned long clone_flags, unsigned long sp,
27110 unsigned long arg, struct task_struct *p)
27111 {
27112- struct pt_regs *childregs = task_pt_regs(p);
27113+ struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
27114 struct task_struct *tsk;
27115 int err;
27116
27117 p->thread.sp = (unsigned long) childregs;
27118 p->thread.sp0 = (unsigned long) (childregs+1);
27119+ p->tinfo.lowest_stack = (unsigned long)task_stack_page(p) + 2 * sizeof(unsigned long);
27120 memset(p->thread.ptrace_bps, 0, sizeof(p->thread.ptrace_bps));
27121
27122 if (unlikely(p->flags & PF_KTHREAD)) {
27123 /* kernel thread */
27124 memset(childregs, 0, sizeof(struct pt_regs));
27125 p->thread.ip = (unsigned long) ret_from_kernel_thread;
27126- task_user_gs(p) = __KERNEL_STACK_CANARY;
27127- childregs->ds = __USER_DS;
27128- childregs->es = __USER_DS;
27129+ savesegment(gs, childregs->gs);
27130+ childregs->ds = __KERNEL_DS;
27131+ childregs->es = __KERNEL_DS;
27132 childregs->fs = __KERNEL_PERCPU;
27133 childregs->bx = sp; /* function */
27134 childregs->bp = arg;
27135@@ -244,7 +245,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
27136 struct thread_struct *prev = &prev_p->thread,
27137 *next = &next_p->thread;
27138 int cpu = smp_processor_id();
27139- struct tss_struct *tss = &per_cpu(cpu_tss, cpu);
27140+ struct tss_struct *tss = cpu_tss + cpu;
27141 fpu_switch_t fpu;
27142
27143 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
27144@@ -263,6 +264,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
27145 */
27146 lazy_save_gs(prev->gs);
27147
27148+#ifdef CONFIG_PAX_MEMORY_UDEREF
27149+ __set_fs(task_thread_info(next_p)->addr_limit);
27150+#endif
27151+
27152 /*
27153 * Load the per-thread Thread-Local Storage descriptor.
27154 */
27155@@ -306,12 +311,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
27156 * current_thread_info().
27157 */
27158 load_sp0(tss, next);
27159- this_cpu_write(kernel_stack,
27160- (unsigned long)task_stack_page(next_p) +
27161- THREAD_SIZE);
27162- this_cpu_write(cpu_current_top_of_stack,
27163- (unsigned long)task_stack_page(next_p) +
27164- THREAD_SIZE);
27165+ this_cpu_write(current_task, next_p);
27166+ this_cpu_write(current_tinfo, &next_p->tinfo);
27167+ this_cpu_write(kernel_stack, next->sp0);
27168+ this_cpu_write(cpu_current_top_of_stack, next->sp0);
27169
27170 /*
27171 * Restore %gs if needed (which is common)
27172@@ -321,8 +324,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
27173
27174 switch_fpu_finish(next_p, fpu);
27175
27176- this_cpu_write(current_task, next_p);
27177-
27178 return prev_p;
27179 }
27180
27181@@ -352,4 +353,3 @@ unsigned long get_wchan(struct task_struct *p)
27182 } while (count++ < 16);
27183 return 0;
27184 }
27185-
27186diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
27187index ddfdbf7..625417c 100644
27188--- a/arch/x86/kernel/process_64.c
27189+++ b/arch/x86/kernel/process_64.c
27190@@ -158,9 +158,10 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
27191 struct pt_regs *childregs;
27192 struct task_struct *me = current;
27193
27194- p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
27195+ p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
27196 childregs = task_pt_regs(p);
27197 p->thread.sp = (unsigned long) childregs;
27198+ p->tinfo.lowest_stack = (unsigned long)task_stack_page(p) + 2 * sizeof(unsigned long);
27199 set_tsk_thread_flag(p, TIF_FORK);
27200 p->thread.io_bitmap_ptr = NULL;
27201
27202@@ -170,6 +171,8 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
27203 p->thread.fs = p->thread.fsindex ? 0 : me->thread.fs;
27204 savesegment(es, p->thread.es);
27205 savesegment(ds, p->thread.ds);
27206+ savesegment(ss, p->thread.ss);
27207+ BUG_ON(p->thread.ss == __UDEREF_KERNEL_DS);
27208 memset(p->thread.ptrace_bps, 0, sizeof(p->thread.ptrace_bps));
27209
27210 if (unlikely(p->flags & PF_KTHREAD)) {
27211@@ -275,7 +278,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
27212 struct thread_struct *prev = &prev_p->thread;
27213 struct thread_struct *next = &next_p->thread;
27214 int cpu = smp_processor_id();
27215- struct tss_struct *tss = &per_cpu(cpu_tss, cpu);
27216+ struct tss_struct *tss = cpu_tss + cpu;
27217 unsigned fsindex, gsindex;
27218 fpu_switch_t fpu;
27219
27220@@ -326,6 +329,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
27221 if (unlikely(next->ds | prev->ds))
27222 loadsegment(ds, next->ds);
27223
27224+ savesegment(ss, prev->ss);
27225+ if (unlikely(next->ss != prev->ss))
27226+ loadsegment(ss, next->ss);
27227+
27228 /*
27229 * Switch FS and GS.
27230 *
27231@@ -397,6 +404,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
27232 * Switch the PDA and FPU contexts.
27233 */
27234 this_cpu_write(current_task, next_p);
27235+ this_cpu_write(current_tinfo, &next_p->tinfo);
27236
27237 /*
27238 * If it were not for PREEMPT_ACTIVE we could guarantee that the
27239@@ -409,8 +417,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
27240 /* Reload esp0 and ss1. This changes current_thread_info(). */
27241 load_sp0(tss, next);
27242
27243- this_cpu_write(kernel_stack,
27244- (unsigned long)task_stack_page(next_p) + THREAD_SIZE);
27245+ this_cpu_write(kernel_stack, next->sp0);
27246
27247 /*
27248 * Now maybe reload the debug registers and handle I/O bitmaps
27249@@ -508,12 +515,11 @@ unsigned long get_wchan(struct task_struct *p)
27250 if (!p || p == current || p->state == TASK_RUNNING)
27251 return 0;
27252 stack = (unsigned long)task_stack_page(p);
27253- if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
27254+ if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
27255 return 0;
27256 fp = *(u64 *)(p->thread.sp);
27257 do {
27258- if (fp < (unsigned long)stack ||
27259- fp >= (unsigned long)stack+THREAD_SIZE)
27260+ if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
27261 return 0;
27262 ip = *(u64 *)(fp+8);
27263 if (!in_sched_functions(ip))
27264diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
27265index a7bc794..094ee8e 100644
27266--- a/arch/x86/kernel/ptrace.c
27267+++ b/arch/x86/kernel/ptrace.c
27268@@ -186,10 +186,10 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
27269 unsigned long sp = (unsigned long)&regs->sp;
27270 u32 *prev_esp;
27271
27272- if (context == (sp & ~(THREAD_SIZE - 1)))
27273+ if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
27274 return sp;
27275
27276- prev_esp = (u32 *)(context);
27277+ prev_esp = *(u32 **)(context);
27278 if (prev_esp)
27279 return (unsigned long)prev_esp;
27280
27281@@ -446,6 +446,20 @@ static int putreg(struct task_struct *child,
27282 if (child->thread.gs != value)
27283 return do_arch_prctl(child, ARCH_SET_GS, value);
27284 return 0;
27285+
27286+ case offsetof(struct user_regs_struct,ip):
27287+ /*
27288+ * Protect against any attempt to set ip to an
27289+ * impossible address. There are dragons lurking if the
27290+ * address is noncanonical. (This explicitly allows
27291+ * setting ip to TASK_SIZE_MAX, because user code can do
27292+ * that all by itself by running off the end of its
27293+ * address space.
27294+ */
27295+ if (value > TASK_SIZE_MAX)
27296+ return -EIO;
27297+ break;
27298+
27299 #endif
27300 }
27301
27302@@ -582,7 +596,7 @@ static void ptrace_triggered(struct perf_event *bp,
27303 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
27304 {
27305 int i;
27306- int dr7 = 0;
27307+ unsigned long dr7 = 0;
27308 struct arch_hw_breakpoint *info;
27309
27310 for (i = 0; i < HBP_NUM; i++) {
27311@@ -816,7 +830,7 @@ long arch_ptrace(struct task_struct *child, long request,
27312 unsigned long addr, unsigned long data)
27313 {
27314 int ret;
27315- unsigned long __user *datap = (unsigned long __user *)data;
27316+ unsigned long __user *datap = (__force unsigned long __user *)data;
27317
27318 switch (request) {
27319 /* read the word at location addr in the USER area. */
27320@@ -901,14 +915,14 @@ long arch_ptrace(struct task_struct *child, long request,
27321 if ((int) addr < 0)
27322 return -EIO;
27323 ret = do_get_thread_area(child, addr,
27324- (struct user_desc __user *)data);
27325+ (__force struct user_desc __user *) data);
27326 break;
27327
27328 case PTRACE_SET_THREAD_AREA:
27329 if ((int) addr < 0)
27330 return -EIO;
27331 ret = do_set_thread_area(child, addr,
27332- (struct user_desc __user *)data, 0);
27333+ (__force struct user_desc __user *) data, 0);
27334 break;
27335 #endif
27336
27337@@ -1286,7 +1300,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
27338
27339 #ifdef CONFIG_X86_64
27340
27341-static struct user_regset x86_64_regsets[] __read_mostly = {
27342+static user_regset_no_const x86_64_regsets[] __read_only = {
27343 [REGSET_GENERAL] = {
27344 .core_note_type = NT_PRSTATUS,
27345 .n = sizeof(struct user_regs_struct) / sizeof(long),
27346@@ -1327,7 +1341,7 @@ static const struct user_regset_view user_x86_64_view = {
27347 #endif /* CONFIG_X86_64 */
27348
27349 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
27350-static struct user_regset x86_32_regsets[] __read_mostly = {
27351+static user_regset_no_const x86_32_regsets[] __read_only = {
27352 [REGSET_GENERAL] = {
27353 .core_note_type = NT_PRSTATUS,
27354 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
27355@@ -1380,7 +1394,7 @@ static const struct user_regset_view user_x86_32_view = {
27356 */
27357 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
27358
27359-void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
27360+void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
27361 {
27362 #ifdef CONFIG_X86_64
27363 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
27364@@ -1415,7 +1429,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
27365 memset(info, 0, sizeof(*info));
27366 info->si_signo = SIGTRAP;
27367 info->si_code = si_code;
27368- info->si_addr = user_mode(regs) ? (void __user *)regs->ip : NULL;
27369+ info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
27370 }
27371
27372 void user_single_step_siginfo(struct task_struct *tsk,
27373@@ -1449,6 +1463,10 @@ static void do_audit_syscall_entry(struct pt_regs *regs, u32 arch)
27374 }
27375 }
27376
27377+#ifdef CONFIG_GRKERNSEC_SETXID
27378+extern void gr_delayed_cred_worker(void);
27379+#endif
27380+
27381 /*
27382 * We can return 0 to resume the syscall or anything else to go to phase
27383 * 2. If we resume the syscall, we need to put something appropriate in
27384@@ -1556,6 +1574,11 @@ long syscall_trace_enter_phase2(struct pt_regs *regs, u32 arch,
27385
27386 BUG_ON(regs != task_pt_regs(current));
27387
27388+#ifdef CONFIG_GRKERNSEC_SETXID
27389+ if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
27390+ gr_delayed_cred_worker();
27391+#endif
27392+
27393 /*
27394 * If we stepped into a sysenter/syscall insn, it trapped in
27395 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
27396@@ -1614,6 +1637,11 @@ void syscall_trace_leave(struct pt_regs *regs)
27397 */
27398 user_exit();
27399
27400+#ifdef CONFIG_GRKERNSEC_SETXID
27401+ if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
27402+ gr_delayed_cred_worker();
27403+#endif
27404+
27405 audit_syscall_exit(regs);
27406
27407 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
27408diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
27409index 2f355d2..e75ed0a 100644
27410--- a/arch/x86/kernel/pvclock.c
27411+++ b/arch/x86/kernel/pvclock.c
27412@@ -51,11 +51,11 @@ void pvclock_touch_watchdogs(void)
27413 reset_hung_task_detector();
27414 }
27415
27416-static atomic64_t last_value = ATOMIC64_INIT(0);
27417+static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
27418
27419 void pvclock_resume(void)
27420 {
27421- atomic64_set(&last_value, 0);
27422+ atomic64_set_unchecked(&last_value, 0);
27423 }
27424
27425 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
27426@@ -105,11 +105,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
27427 * updating at the same time, and one of them could be slightly behind,
27428 * making the assumption that last_value always go forward fail to hold.
27429 */
27430- last = atomic64_read(&last_value);
27431+ last = atomic64_read_unchecked(&last_value);
27432 do {
27433 if (ret < last)
27434 return last;
27435- last = atomic64_cmpxchg(&last_value, last, ret);
27436+ last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
27437 } while (unlikely(last != ret));
27438
27439 return ret;
27440diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
27441index 86db4bc..a50a54a 100644
27442--- a/arch/x86/kernel/reboot.c
27443+++ b/arch/x86/kernel/reboot.c
27444@@ -70,6 +70,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
27445
27446 void __noreturn machine_real_restart(unsigned int type)
27447 {
27448+
27449+#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
27450+ struct desc_struct *gdt;
27451+#endif
27452+
27453 local_irq_disable();
27454
27455 /*
27456@@ -97,7 +102,29 @@ void __noreturn machine_real_restart(unsigned int type)
27457
27458 /* Jump to the identity-mapped low memory code */
27459 #ifdef CONFIG_X86_32
27460- asm volatile("jmpl *%0" : :
27461+
27462+#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
27463+ gdt = get_cpu_gdt_table(smp_processor_id());
27464+ pax_open_kernel();
27465+#ifdef CONFIG_PAX_MEMORY_UDEREF
27466+ gdt[GDT_ENTRY_KERNEL_DS].type = 3;
27467+ gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
27468+ loadsegment(ds, __KERNEL_DS);
27469+ loadsegment(es, __KERNEL_DS);
27470+ loadsegment(ss, __KERNEL_DS);
27471+#endif
27472+#ifdef CONFIG_PAX_KERNEXEC
27473+ gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
27474+ gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
27475+ gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
27476+ gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
27477+ gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
27478+ gdt[GDT_ENTRY_KERNEL_CS].g = 1;
27479+#endif
27480+ pax_close_kernel();
27481+#endif
27482+
27483+ asm volatile("ljmpl *%0" : :
27484 "rm" (real_mode_header->machine_real_restart_asm),
27485 "a" (type));
27486 #else
27487@@ -137,7 +164,7 @@ static int __init set_kbd_reboot(const struct dmi_system_id *d)
27488 /*
27489 * This is a single dmi_table handling all reboot quirks.
27490 */
27491-static struct dmi_system_id __initdata reboot_dmi_table[] = {
27492+static const struct dmi_system_id __initconst reboot_dmi_table[] = {
27493
27494 /* Acer */
27495 { /* Handle reboot issue on Acer Aspire one */
27496@@ -511,7 +538,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
27497 * This means that this function can never return, it can misbehave
27498 * by not rebooting properly and hanging.
27499 */
27500-static void native_machine_emergency_restart(void)
27501+static void __noreturn native_machine_emergency_restart(void)
27502 {
27503 int i;
27504 int attempt = 0;
27505@@ -631,13 +658,13 @@ void native_machine_shutdown(void)
27506 #endif
27507 }
27508
27509-static void __machine_emergency_restart(int emergency)
27510+static void __noreturn __machine_emergency_restart(int emergency)
27511 {
27512 reboot_emergency = emergency;
27513 machine_ops.emergency_restart();
27514 }
27515
27516-static void native_machine_restart(char *__unused)
27517+static void __noreturn native_machine_restart(char *__unused)
27518 {
27519 pr_notice("machine restart\n");
27520
27521@@ -646,7 +673,7 @@ static void native_machine_restart(char *__unused)
27522 __machine_emergency_restart(0);
27523 }
27524
27525-static void native_machine_halt(void)
27526+static void __noreturn native_machine_halt(void)
27527 {
27528 /* Stop other cpus and apics */
27529 machine_shutdown();
27530@@ -656,7 +683,7 @@ static void native_machine_halt(void)
27531 stop_this_cpu(NULL);
27532 }
27533
27534-static void native_machine_power_off(void)
27535+static void __noreturn native_machine_power_off(void)
27536 {
27537 if (pm_power_off) {
27538 if (!reboot_force)
27539@@ -665,9 +692,10 @@ static void native_machine_power_off(void)
27540 }
27541 /* A fallback in case there is no PM info available */
27542 tboot_shutdown(TB_SHUTDOWN_HALT);
27543+ unreachable();
27544 }
27545
27546-struct machine_ops machine_ops = {
27547+struct machine_ops machine_ops __read_only = {
27548 .power_off = native_machine_power_off,
27549 .shutdown = native_machine_shutdown,
27550 .emergency_restart = native_machine_emergency_restart,
27551diff --git a/arch/x86/kernel/reboot_fixups_32.c b/arch/x86/kernel/reboot_fixups_32.c
27552index c8e41e9..64049ef 100644
27553--- a/arch/x86/kernel/reboot_fixups_32.c
27554+++ b/arch/x86/kernel/reboot_fixups_32.c
27555@@ -57,7 +57,7 @@ struct device_fixup {
27556 unsigned int vendor;
27557 unsigned int device;
27558 void (*reboot_fixup)(struct pci_dev *);
27559-};
27560+} __do_const;
27561
27562 /*
27563 * PCI ids solely used for fixups_table go here
27564diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
27565index 98111b3..73ca125 100644
27566--- a/arch/x86/kernel/relocate_kernel_64.S
27567+++ b/arch/x86/kernel/relocate_kernel_64.S
27568@@ -96,8 +96,7 @@ relocate_kernel:
27569
27570 /* jump to identity mapped page */
27571 addq $(identity_mapped - relocate_kernel), %r8
27572- pushq %r8
27573- ret
27574+ jmp *%r8
27575
27576 identity_mapped:
27577 /* set return address to 0 if not preserving context */
27578diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
27579index d74ac33..d9efe04 100644
27580--- a/arch/x86/kernel/setup.c
27581+++ b/arch/x86/kernel/setup.c
27582@@ -111,6 +111,7 @@
27583 #include <asm/mce.h>
27584 #include <asm/alternative.h>
27585 #include <asm/prom.h>
27586+#include <asm/boot.h>
27587
27588 /*
27589 * max_low_pfn_mapped: highest direct mapped pfn under 4GB
27590@@ -206,10 +207,12 @@ EXPORT_SYMBOL(boot_cpu_data);
27591 #endif
27592
27593
27594-#if !defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64)
27595-__visible unsigned long mmu_cr4_features;
27596+#ifdef CONFIG_X86_64
27597+__visible unsigned long mmu_cr4_features __read_only = X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE;
27598+#elif defined(CONFIG_X86_PAE)
27599+__visible unsigned long mmu_cr4_features __read_only = X86_CR4_PAE;
27600 #else
27601-__visible unsigned long mmu_cr4_features = X86_CR4_PAE;
27602+__visible unsigned long mmu_cr4_features __read_only;
27603 #endif
27604
27605 /* Boot loader ID and version as integers, for the benefit of proc_dointvec */
27606@@ -771,7 +774,7 @@ static void __init trim_bios_range(void)
27607 * area (640->1Mb) as ram even though it is not.
27608 * take them out.
27609 */
27610- e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
27611+ e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
27612
27613 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
27614 }
27615@@ -779,7 +782,7 @@ static void __init trim_bios_range(void)
27616 /* called before trim_bios_range() to spare extra sanitize */
27617 static void __init e820_add_kernel_range(void)
27618 {
27619- u64 start = __pa_symbol(_text);
27620+ u64 start = __pa_symbol(ktla_ktva(_text));
27621 u64 size = __pa_symbol(_end) - start;
27622
27623 /*
27624@@ -860,8 +863,12 @@ dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p)
27625
27626 void __init setup_arch(char **cmdline_p)
27627 {
27628+#ifdef CONFIG_X86_32
27629+ memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(__bss_stop) - LOAD_PHYSICAL_ADDR);
27630+#else
27631 memblock_reserve(__pa_symbol(_text),
27632 (unsigned long)__bss_stop - (unsigned long)_text);
27633+#endif
27634
27635 early_reserve_initrd();
27636
27637@@ -959,16 +966,16 @@ void __init setup_arch(char **cmdline_p)
27638
27639 if (!boot_params.hdr.root_flags)
27640 root_mountflags &= ~MS_RDONLY;
27641- init_mm.start_code = (unsigned long) _text;
27642- init_mm.end_code = (unsigned long) _etext;
27643+ init_mm.start_code = ktla_ktva((unsigned long) _text);
27644+ init_mm.end_code = ktla_ktva((unsigned long) _etext);
27645 init_mm.end_data = (unsigned long) _edata;
27646 init_mm.brk = _brk_end;
27647
27648 mpx_mm_init(&init_mm);
27649
27650- code_resource.start = __pa_symbol(_text);
27651- code_resource.end = __pa_symbol(_etext)-1;
27652- data_resource.start = __pa_symbol(_etext);
27653+ code_resource.start = __pa_symbol(ktla_ktva(_text));
27654+ code_resource.end = __pa_symbol(ktla_ktva(_etext))-1;
27655+ data_resource.start = __pa_symbol(_sdata);
27656 data_resource.end = __pa_symbol(_edata)-1;
27657 bss_resource.start = __pa_symbol(__bss_start);
27658 bss_resource.end = __pa_symbol(__bss_stop)-1;
27659diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
27660index e4fcb87..9c06c55 100644
27661--- a/arch/x86/kernel/setup_percpu.c
27662+++ b/arch/x86/kernel/setup_percpu.c
27663@@ -21,19 +21,17 @@
27664 #include <asm/cpu.h>
27665 #include <asm/stackprotector.h>
27666
27667-DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
27668+#ifdef CONFIG_SMP
27669+DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
27670 EXPORT_PER_CPU_SYMBOL(cpu_number);
27671+#endif
27672
27673-#ifdef CONFIG_X86_64
27674 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
27675-#else
27676-#define BOOT_PERCPU_OFFSET 0
27677-#endif
27678
27679 DEFINE_PER_CPU_READ_MOSTLY(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
27680 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
27681
27682-unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
27683+unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
27684 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
27685 };
27686 EXPORT_SYMBOL(__per_cpu_offset);
27687@@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
27688 {
27689 #ifdef CONFIG_NEED_MULTIPLE_NODES
27690 pg_data_t *last = NULL;
27691- unsigned int cpu;
27692+ int cpu;
27693
27694 for_each_possible_cpu(cpu) {
27695 int node = early_cpu_to_node(cpu);
27696@@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
27697 {
27698 #ifdef CONFIG_X86_32
27699 struct desc_struct gdt;
27700+ unsigned long base = per_cpu_offset(cpu);
27701
27702- pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
27703- 0x2 | DESCTYPE_S, 0x8);
27704- gdt.s = 1;
27705+ pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
27706+ 0x83 | DESCTYPE_S, 0xC);
27707 write_gdt_entry(get_cpu_gdt_table(cpu),
27708 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
27709 #endif
27710@@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
27711 /* alrighty, percpu areas up and running */
27712 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
27713 for_each_possible_cpu(cpu) {
27714+#ifdef CONFIG_CC_STACKPROTECTOR
27715+#ifdef CONFIG_X86_32
27716+ unsigned long canary = per_cpu(stack_canary.canary, cpu);
27717+#endif
27718+#endif
27719 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
27720 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
27721 per_cpu(cpu_number, cpu) = cpu;
27722@@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
27723 */
27724 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
27725 #endif
27726+#ifdef CONFIG_CC_STACKPROTECTOR
27727+#ifdef CONFIG_X86_32
27728+ if (!cpu)
27729+ per_cpu(stack_canary.canary, cpu) = canary;
27730+#endif
27731+#endif
27732 /*
27733 * Up to this point, the boot CPU has been using .init.data
27734 * area. Reload any changed state for the boot CPU.
27735diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
27736index 1ea14fd..b16147f 100644
27737--- a/arch/x86/kernel/signal.c
27738+++ b/arch/x86/kernel/signal.c
27739@@ -183,7 +183,7 @@ static unsigned long align_sigframe(unsigned long sp)
27740 * Align the stack pointer according to the i386 ABI,
27741 * i.e. so that on function entry ((sp + 4) & 15) == 0.
27742 */
27743- sp = ((sp + 4) & -16ul) - 4;
27744+ sp = ((sp - 12) & -16ul) - 4;
27745 #else /* !CONFIG_X86_32 */
27746 sp = round_down(sp, 16) - 8;
27747 #endif
27748@@ -291,10 +291,9 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
27749 }
27750
27751 if (current->mm->context.vdso)
27752- restorer = current->mm->context.vdso +
27753- selected_vdso32->sym___kernel_sigreturn;
27754+ restorer = (void __force_user *)(current->mm->context.vdso + selected_vdso32->sym___kernel_sigreturn);
27755 else
27756- restorer = &frame->retcode;
27757+ restorer = (void __user *)&frame->retcode;
27758 if (ksig->ka.sa.sa_flags & SA_RESTORER)
27759 restorer = ksig->ka.sa.sa_restorer;
27760
27761@@ -308,7 +307,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
27762 * reasons and because gdb uses it as a signature to notice
27763 * signal handler stack frames.
27764 */
27765- err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
27766+ err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
27767
27768 if (err)
27769 return -EFAULT;
27770@@ -355,8 +354,10 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
27771 save_altstack_ex(&frame->uc.uc_stack, regs->sp);
27772
27773 /* Set up to return from userspace. */
27774- restorer = current->mm->context.vdso +
27775- selected_vdso32->sym___kernel_rt_sigreturn;
27776+ if (current->mm->context.vdso)
27777+ restorer = (void __force_user *)(current->mm->context.vdso + selected_vdso32->sym___kernel_rt_sigreturn);
27778+ else
27779+ restorer = (void __user *)&frame->retcode;
27780 if (ksig->ka.sa.sa_flags & SA_RESTORER)
27781 restorer = ksig->ka.sa.sa_restorer;
27782 put_user_ex(restorer, &frame->pretcode);
27783@@ -368,7 +369,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
27784 * reasons and because gdb uses it as a signature to notice
27785 * signal handler stack frames.
27786 */
27787- put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
27788+ put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
27789 } put_user_catch(err);
27790
27791 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
27792@@ -598,7 +599,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
27793 {
27794 int usig = ksig->sig;
27795 sigset_t *set = sigmask_to_save();
27796- compat_sigset_t *cset = (compat_sigset_t *) set;
27797+ sigset_t sigcopy;
27798+ compat_sigset_t *cset;
27799+
27800+ sigcopy = *set;
27801+
27802+ cset = (compat_sigset_t *) &sigcopy;
27803
27804 /* Set up the stack frame */
27805 if (is_ia32_frame()) {
27806@@ -609,7 +615,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
27807 } else if (is_x32_frame()) {
27808 return x32_setup_rt_frame(ksig, cset, regs);
27809 } else {
27810- return __setup_rt_frame(ksig->sig, ksig, set, regs);
27811+ return __setup_rt_frame(ksig->sig, ksig, &sigcopy, regs);
27812 }
27813 }
27814
27815diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
27816index be8e1bd..a3d93fa 100644
27817--- a/arch/x86/kernel/smp.c
27818+++ b/arch/x86/kernel/smp.c
27819@@ -341,7 +341,7 @@ static int __init nonmi_ipi_setup(char *str)
27820
27821 __setup("nonmi_ipi", nonmi_ipi_setup);
27822
27823-struct smp_ops smp_ops = {
27824+struct smp_ops smp_ops __read_only = {
27825 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
27826 .smp_prepare_cpus = native_smp_prepare_cpus,
27827 .smp_cpus_done = native_smp_cpus_done,
27828diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
27829index 50e547e..d59d06a 100644
27830--- a/arch/x86/kernel/smpboot.c
27831+++ b/arch/x86/kernel/smpboot.c
27832@@ -226,14 +226,17 @@ static void notrace start_secondary(void *unused)
27833
27834 enable_start_cpu0 = 0;
27835
27836-#ifdef CONFIG_X86_32
27837+ /* otherwise gcc will move up smp_processor_id before the cpu_init */
27838+ barrier();
27839+
27840 /* switch away from the initial page table */
27841+#ifdef CONFIG_PAX_PER_CPU_PGD
27842+ load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
27843+#else
27844 load_cr3(swapper_pg_dir);
27845+#endif
27846 __flush_tlb_all();
27847-#endif
27848
27849- /* otherwise gcc will move up smp_processor_id before the cpu_init */
27850- barrier();
27851 /*
27852 * Check TSC synchronization with the BP:
27853 */
27854@@ -782,18 +785,17 @@ void common_cpu_up(unsigned int cpu, struct task_struct *idle)
27855 alternatives_enable_smp();
27856
27857 per_cpu(current_task, cpu) = idle;
27858+ per_cpu(current_tinfo, cpu) = &idle->tinfo;
27859
27860 #ifdef CONFIG_X86_32
27861 /* Stack for startup_32 can be just as for start_secondary onwards */
27862 irq_ctx_init(cpu);
27863- per_cpu(cpu_current_top_of_stack, cpu) =
27864- (unsigned long)task_stack_page(idle) + THREAD_SIZE;
27865+ per_cpu(cpu_current_top_of_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
27866 #else
27867 clear_tsk_thread_flag(idle, TIF_FORK);
27868 initial_gs = per_cpu_offset(cpu);
27869 #endif
27870- per_cpu(kernel_stack, cpu) =
27871- (unsigned long)task_stack_page(idle) + THREAD_SIZE;
27872+ per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
27873 }
27874
27875 /*
27876@@ -814,9 +816,11 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
27877 unsigned long timeout;
27878
27879 idle->thread.sp = (unsigned long) (((struct pt_regs *)
27880- (THREAD_SIZE + task_stack_page(idle))) - 1);
27881+ (THREAD_SIZE - 16 + task_stack_page(idle))) - 1);
27882
27883+ pax_open_kernel();
27884 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
27885+ pax_close_kernel();
27886 initial_code = (unsigned long)start_secondary;
27887 stack_start = idle->thread.sp;
27888
27889@@ -961,6 +965,15 @@ int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
27890
27891 common_cpu_up(cpu, tidle);
27892
27893+#ifdef CONFIG_PAX_PER_CPU_PGD
27894+ clone_pgd_range(get_cpu_pgd(cpu, kernel) + KERNEL_PGD_BOUNDARY,
27895+ swapper_pg_dir + KERNEL_PGD_BOUNDARY,
27896+ KERNEL_PGD_PTRS);
27897+ clone_pgd_range(get_cpu_pgd(cpu, user) + KERNEL_PGD_BOUNDARY,
27898+ swapper_pg_dir + KERNEL_PGD_BOUNDARY,
27899+ KERNEL_PGD_PTRS);
27900+#endif
27901+
27902 err = do_boot_cpu(apicid, cpu, tidle);
27903 if (err) {
27904 pr_err("do_boot_cpu failed(%d) to wakeup CPU#%u\n", err, cpu);
27905diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
27906index 9b4d51d..5d28b58 100644
27907--- a/arch/x86/kernel/step.c
27908+++ b/arch/x86/kernel/step.c
27909@@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
27910 struct desc_struct *desc;
27911 unsigned long base;
27912
27913- seg &= ~7UL;
27914+ seg >>= 3;
27915
27916 mutex_lock(&child->mm->context.lock);
27917- if (unlikely((seg >> 3) >= child->mm->context.size))
27918+ if (unlikely(seg >= child->mm->context.size))
27919 addr = -1L; /* bogus selector, access would fault */
27920 else {
27921 desc = child->mm->context.ldt + seg;
27922@@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
27923 addr += base;
27924 }
27925 mutex_unlock(&child->mm->context.lock);
27926- }
27927+ } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
27928+ addr = ktla_ktva(addr);
27929
27930 return addr;
27931 }
27932@@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
27933 unsigned char opcode[15];
27934 unsigned long addr = convert_ip_to_linear(child, regs);
27935
27936+ if (addr == -EINVAL)
27937+ return 0;
27938+
27939 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
27940 for (i = 0; i < copied; i++) {
27941 switch (opcode[i]) {
27942diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
27943new file mode 100644
27944index 0000000..5877189
27945--- /dev/null
27946+++ b/arch/x86/kernel/sys_i386_32.c
27947@@ -0,0 +1,189 @@
27948+/*
27949+ * This file contains various random system calls that
27950+ * have a non-standard calling sequence on the Linux/i386
27951+ * platform.
27952+ */
27953+
27954+#include <linux/errno.h>
27955+#include <linux/sched.h>
27956+#include <linux/mm.h>
27957+#include <linux/fs.h>
27958+#include <linux/smp.h>
27959+#include <linux/sem.h>
27960+#include <linux/msg.h>
27961+#include <linux/shm.h>
27962+#include <linux/stat.h>
27963+#include <linux/syscalls.h>
27964+#include <linux/mman.h>
27965+#include <linux/file.h>
27966+#include <linux/utsname.h>
27967+#include <linux/ipc.h>
27968+#include <linux/elf.h>
27969+
27970+#include <linux/uaccess.h>
27971+#include <linux/unistd.h>
27972+
27973+#include <asm/syscalls.h>
27974+
27975+int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
27976+{
27977+ unsigned long pax_task_size = TASK_SIZE;
27978+
27979+#ifdef CONFIG_PAX_SEGMEXEC
27980+ if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
27981+ pax_task_size = SEGMEXEC_TASK_SIZE;
27982+#endif
27983+
27984+ if (flags & MAP_FIXED)
27985+ if (len > pax_task_size || addr > pax_task_size - len)
27986+ return -EINVAL;
27987+
27988+ return 0;
27989+}
27990+
27991+/*
27992+ * Align a virtual address to avoid aliasing in the I$ on AMD F15h.
27993+ */
27994+static unsigned long get_align_mask(void)
27995+{
27996+ if (va_align.flags < 0 || !(va_align.flags & ALIGN_VA_32))
27997+ return 0;
27998+
27999+ if (!(current->flags & PF_RANDOMIZE))
28000+ return 0;
28001+
28002+ return va_align.mask;
28003+}
28004+
28005+unsigned long
28006+arch_get_unmapped_area(struct file *filp, unsigned long addr,
28007+ unsigned long len, unsigned long pgoff, unsigned long flags)
28008+{
28009+ struct mm_struct *mm = current->mm;
28010+ struct vm_area_struct *vma;
28011+ unsigned long pax_task_size = TASK_SIZE;
28012+ struct vm_unmapped_area_info info;
28013+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
28014+
28015+#ifdef CONFIG_PAX_SEGMEXEC
28016+ if (mm->pax_flags & MF_PAX_SEGMEXEC)
28017+ pax_task_size = SEGMEXEC_TASK_SIZE;
28018+#endif
28019+
28020+ pax_task_size -= PAGE_SIZE;
28021+
28022+ if (len > pax_task_size)
28023+ return -ENOMEM;
28024+
28025+ if (flags & MAP_FIXED)
28026+ return addr;
28027+
28028+#ifdef CONFIG_PAX_RANDMMAP
28029+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
28030+#endif
28031+
28032+ if (addr) {
28033+ addr = PAGE_ALIGN(addr);
28034+ if (pax_task_size - len >= addr) {
28035+ vma = find_vma(mm, addr);
28036+ if (check_heap_stack_gap(vma, addr, len, offset))
28037+ return addr;
28038+ }
28039+ }
28040+
28041+ info.flags = 0;
28042+ info.length = len;
28043+ info.align_mask = filp ? get_align_mask() : 0;
28044+ info.align_offset = pgoff << PAGE_SHIFT;
28045+ info.threadstack_offset = offset;
28046+
28047+#ifdef CONFIG_PAX_PAGEEXEC
28048+ if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE)) {
28049+ info.low_limit = 0x00110000UL;
28050+ info.high_limit = mm->start_code;
28051+
28052+#ifdef CONFIG_PAX_RANDMMAP
28053+ if (mm->pax_flags & MF_PAX_RANDMMAP)
28054+ info.low_limit += mm->delta_mmap & 0x03FFF000UL;
28055+#endif
28056+
28057+ if (info.low_limit < info.high_limit) {
28058+ addr = vm_unmapped_area(&info);
28059+ if (!IS_ERR_VALUE(addr))
28060+ return addr;
28061+ }
28062+ } else
28063+#endif
28064+
28065+ info.low_limit = mm->mmap_base;
28066+ info.high_limit = pax_task_size;
28067+
28068+ return vm_unmapped_area(&info);
28069+}
28070+
28071+unsigned long
28072+arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
28073+ const unsigned long len, const unsigned long pgoff,
28074+ const unsigned long flags)
28075+{
28076+ struct vm_area_struct *vma;
28077+ struct mm_struct *mm = current->mm;
28078+ unsigned long addr = addr0, pax_task_size = TASK_SIZE;
28079+ struct vm_unmapped_area_info info;
28080+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
28081+
28082+#ifdef CONFIG_PAX_SEGMEXEC
28083+ if (mm->pax_flags & MF_PAX_SEGMEXEC)
28084+ pax_task_size = SEGMEXEC_TASK_SIZE;
28085+#endif
28086+
28087+ pax_task_size -= PAGE_SIZE;
28088+
28089+ /* requested length too big for entire address space */
28090+ if (len > pax_task_size)
28091+ return -ENOMEM;
28092+
28093+ if (flags & MAP_FIXED)
28094+ return addr;
28095+
28096+#ifdef CONFIG_PAX_PAGEEXEC
28097+ if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
28098+ goto bottomup;
28099+#endif
28100+
28101+#ifdef CONFIG_PAX_RANDMMAP
28102+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
28103+#endif
28104+
28105+ /* requesting a specific address */
28106+ if (addr) {
28107+ addr = PAGE_ALIGN(addr);
28108+ if (pax_task_size - len >= addr) {
28109+ vma = find_vma(mm, addr);
28110+ if (check_heap_stack_gap(vma, addr, len, offset))
28111+ return addr;
28112+ }
28113+ }
28114+
28115+ info.flags = VM_UNMAPPED_AREA_TOPDOWN;
28116+ info.length = len;
28117+ info.low_limit = PAGE_SIZE;
28118+ info.high_limit = mm->mmap_base;
28119+ info.align_mask = filp ? get_align_mask() : 0;
28120+ info.align_offset = pgoff << PAGE_SHIFT;
28121+ info.threadstack_offset = offset;
28122+
28123+ addr = vm_unmapped_area(&info);
28124+ if (!(addr & ~PAGE_MASK))
28125+ return addr;
28126+ VM_BUG_ON(addr != -ENOMEM);
28127+
28128+bottomup:
28129+ /*
28130+ * A failed mmap() very likely causes application failure,
28131+ * so fall back to the bottom-up function here. This scenario
28132+ * can happen with large stack limits and large mmap()
28133+ * allocations.
28134+ */
28135+ return arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
28136+}
28137diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
28138index 10e0272..b4bb9a7 100644
28139--- a/arch/x86/kernel/sys_x86_64.c
28140+++ b/arch/x86/kernel/sys_x86_64.c
28141@@ -97,8 +97,8 @@ out:
28142 return error;
28143 }
28144
28145-static void find_start_end(unsigned long flags, unsigned long *begin,
28146- unsigned long *end)
28147+static void find_start_end(struct mm_struct *mm, unsigned long flags,
28148+ unsigned long *begin, unsigned long *end)
28149 {
28150 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
28151 unsigned long new_begin;
28152@@ -117,7 +117,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
28153 *begin = new_begin;
28154 }
28155 } else {
28156- *begin = current->mm->mmap_legacy_base;
28157+ *begin = mm->mmap_legacy_base;
28158 *end = TASK_SIZE;
28159 }
28160 }
28161@@ -130,20 +130,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
28162 struct vm_area_struct *vma;
28163 struct vm_unmapped_area_info info;
28164 unsigned long begin, end;
28165+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
28166
28167 if (flags & MAP_FIXED)
28168 return addr;
28169
28170- find_start_end(flags, &begin, &end);
28171+ find_start_end(mm, flags, &begin, &end);
28172
28173 if (len > end)
28174 return -ENOMEM;
28175
28176+#ifdef CONFIG_PAX_RANDMMAP
28177+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
28178+#endif
28179+
28180 if (addr) {
28181 addr = PAGE_ALIGN(addr);
28182 vma = find_vma(mm, addr);
28183- if (end - len >= addr &&
28184- (!vma || addr + len <= vma->vm_start))
28185+ if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
28186 return addr;
28187 }
28188
28189@@ -157,6 +161,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
28190 info.align_mask = get_align_mask();
28191 info.align_offset += get_align_bits();
28192 }
28193+ info.threadstack_offset = offset;
28194 return vm_unmapped_area(&info);
28195 }
28196
28197@@ -169,6 +174,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
28198 struct mm_struct *mm = current->mm;
28199 unsigned long addr = addr0;
28200 struct vm_unmapped_area_info info;
28201+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
28202
28203 /* requested length too big for entire address space */
28204 if (len > TASK_SIZE)
28205@@ -181,12 +187,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
28206 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
28207 goto bottomup;
28208
28209+#ifdef CONFIG_PAX_RANDMMAP
28210+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
28211+#endif
28212+
28213 /* requesting a specific address */
28214 if (addr) {
28215 addr = PAGE_ALIGN(addr);
28216 vma = find_vma(mm, addr);
28217- if (TASK_SIZE - len >= addr &&
28218- (!vma || addr + len <= vma->vm_start))
28219+ if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
28220 return addr;
28221 }
28222
28223@@ -200,6 +209,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
28224 info.align_mask = get_align_mask();
28225 info.align_offset += get_align_bits();
28226 }
28227+ info.threadstack_offset = offset;
28228 addr = vm_unmapped_area(&info);
28229 if (!(addr & ~PAGE_MASK))
28230 return addr;
28231diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
28232index 91a4496..42fc304 100644
28233--- a/arch/x86/kernel/tboot.c
28234+++ b/arch/x86/kernel/tboot.c
28235@@ -44,6 +44,7 @@
28236 #include <asm/setup.h>
28237 #include <asm/e820.h>
28238 #include <asm/io.h>
28239+#include <asm/tlbflush.h>
28240
28241 #include "../realmode/rm/wakeup.h"
28242
28243@@ -221,7 +222,7 @@ static int tboot_setup_sleep(void)
28244
28245 void tboot_shutdown(u32 shutdown_type)
28246 {
28247- void (*shutdown)(void);
28248+ void (* __noreturn shutdown)(void);
28249
28250 if (!tboot_enabled())
28251 return;
28252@@ -242,8 +243,9 @@ void tboot_shutdown(u32 shutdown_type)
28253 tboot->shutdown_type = shutdown_type;
28254
28255 switch_to_tboot_pt();
28256+ cr4_clear_bits(X86_CR4_PCIDE);
28257
28258- shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
28259+ shutdown = (void *)(unsigned long)tboot->shutdown_entry;
28260 shutdown();
28261
28262 /* should not reach here */
28263@@ -310,7 +312,7 @@ static int tboot_extended_sleep(u8 sleep_state, u32 val_a, u32 val_b)
28264 return -ENODEV;
28265 }
28266
28267-static atomic_t ap_wfs_count;
28268+static atomic_unchecked_t ap_wfs_count;
28269
28270 static int tboot_wait_for_aps(int num_aps)
28271 {
28272@@ -334,9 +336,9 @@ static int tboot_cpu_callback(struct notifier_block *nfb, unsigned long action,
28273 {
28274 switch (action) {
28275 case CPU_DYING:
28276- atomic_inc(&ap_wfs_count);
28277+ atomic_inc_unchecked(&ap_wfs_count);
28278 if (num_online_cpus() == 1)
28279- if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
28280+ if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
28281 return NOTIFY_BAD;
28282 break;
28283 }
28284@@ -422,7 +424,7 @@ static __init int tboot_late_init(void)
28285
28286 tboot_create_trampoline();
28287
28288- atomic_set(&ap_wfs_count, 0);
28289+ atomic_set_unchecked(&ap_wfs_count, 0);
28290 register_hotcpu_notifier(&tboot_cpu_notifier);
28291
28292 #ifdef CONFIG_DEBUG_FS
28293diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
28294index d39c091..1df4349 100644
28295--- a/arch/x86/kernel/time.c
28296+++ b/arch/x86/kernel/time.c
28297@@ -32,7 +32,7 @@ unsigned long profile_pc(struct pt_regs *regs)
28298
28299 if (!user_mode(regs) && in_lock_functions(pc)) {
28300 #ifdef CONFIG_FRAME_POINTER
28301- return *(unsigned long *)(regs->bp + sizeof(long));
28302+ return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
28303 #else
28304 unsigned long *sp =
28305 (unsigned long *)kernel_stack_pointer(regs);
28306@@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
28307 * or above a saved flags. Eflags has bits 22-31 zero,
28308 * kernel addresses don't.
28309 */
28310+
28311+#ifdef CONFIG_PAX_KERNEXEC
28312+ return ktla_ktva(sp[0]);
28313+#else
28314 if (sp[0] >> 22)
28315 return sp[0];
28316 if (sp[1] >> 22)
28317 return sp[1];
28318 #endif
28319+
28320+#endif
28321 }
28322 return pc;
28323 }
28324diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
28325index 7fc5e84..c6e445a 100644
28326--- a/arch/x86/kernel/tls.c
28327+++ b/arch/x86/kernel/tls.c
28328@@ -139,6 +139,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
28329 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
28330 return -EINVAL;
28331
28332+#ifdef CONFIG_PAX_SEGMEXEC
28333+ if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
28334+ return -EINVAL;
28335+#endif
28336+
28337 set_tls_desc(p, idx, &info, 1);
28338
28339 return 0;
28340@@ -256,7 +261,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
28341
28342 if (kbuf)
28343 info = kbuf;
28344- else if (__copy_from_user(infobuf, ubuf, count))
28345+ else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
28346 return -EFAULT;
28347 else
28348 info = infobuf;
28349diff --git a/arch/x86/kernel/tracepoint.c b/arch/x86/kernel/tracepoint.c
28350index 1c113db..287b42e 100644
28351--- a/arch/x86/kernel/tracepoint.c
28352+++ b/arch/x86/kernel/tracepoint.c
28353@@ -9,11 +9,11 @@
28354 #include <linux/atomic.h>
28355
28356 atomic_t trace_idt_ctr = ATOMIC_INIT(0);
28357-struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
28358+const struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
28359 (unsigned long) trace_idt_table };
28360
28361 /* No need to be aligned, but done to keep all IDTs defined the same way. */
28362-gate_desc trace_idt_table[NR_VECTORS] __page_aligned_bss;
28363+gate_desc trace_idt_table[NR_VECTORS] __page_aligned_rodata;
28364
28365 static int trace_irq_vector_refcount;
28366 static DEFINE_MUTEX(irq_vector_mutex);
28367diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
28368index 324ab52..0cfd2d05 100644
28369--- a/arch/x86/kernel/traps.c
28370+++ b/arch/x86/kernel/traps.c
28371@@ -68,7 +68,7 @@
28372 #include <asm/proto.h>
28373
28374 /* No need to be aligned, but done to keep all IDTs defined the same way. */
28375-gate_desc debug_idt_table[NR_VECTORS] __page_aligned_bss;
28376+gate_desc debug_idt_table[NR_VECTORS] __page_aligned_rodata;
28377 #else
28378 #include <asm/processor-flags.h>
28379 #include <asm/setup.h>
28380@@ -77,7 +77,7 @@ asmlinkage int system_call(void);
28381 #endif
28382
28383 /* Must be page-aligned because the real IDT is used in a fixmap. */
28384-gate_desc idt_table[NR_VECTORS] __page_aligned_bss;
28385+gate_desc idt_table[NR_VECTORS] __page_aligned_rodata;
28386
28387 DECLARE_BITMAP(used_vectors, NR_VECTORS);
28388 EXPORT_SYMBOL_GPL(used_vectors);
28389@@ -174,7 +174,7 @@ void ist_begin_non_atomic(struct pt_regs *regs)
28390 * will catch asm bugs and any attempt to use ist_preempt_enable
28391 * from double_fault.
28392 */
28393- BUG_ON((unsigned long)(current_top_of_stack() -
28394+ BUG_ON((unsigned long)(current_top_of_stack(smp_processor_id()) -
28395 current_stack_pointer()) >= THREAD_SIZE);
28396
28397 preempt_count_sub(HARDIRQ_OFFSET);
28398@@ -191,7 +191,7 @@ void ist_end_non_atomic(void)
28399 }
28400
28401 static nokprobe_inline int
28402-do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
28403+do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
28404 struct pt_regs *regs, long error_code)
28405 {
28406 if (v8086_mode(regs)) {
28407@@ -211,8 +211,20 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
28408 if (!fixup_exception(regs)) {
28409 tsk->thread.error_code = error_code;
28410 tsk->thread.trap_nr = trapnr;
28411+
28412+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
28413+ if (trapnr == X86_TRAP_SS && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
28414+ str = "PAX: suspicious stack segment fault";
28415+#endif
28416+
28417 die(str, regs, error_code);
28418 }
28419+
28420+#ifdef CONFIG_PAX_REFCOUNT
28421+ if (trapnr == X86_TRAP_OF)
28422+ pax_report_refcount_overflow(regs);
28423+#endif
28424+
28425 return 0;
28426 }
28427
28428@@ -251,7 +263,7 @@ static siginfo_t *fill_trap_info(struct pt_regs *regs, int signr, int trapnr,
28429 }
28430
28431 static void
28432-do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
28433+do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
28434 long error_code, siginfo_t *info)
28435 {
28436 struct task_struct *tsk = current;
28437@@ -275,7 +287,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
28438 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
28439 printk_ratelimit()) {
28440 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
28441- tsk->comm, tsk->pid, str,
28442+ tsk->comm, task_pid_nr(tsk), str,
28443 regs->ip, regs->sp, error_code);
28444 print_vma_addr(" in ", regs->ip);
28445 pr_cont("\n");
28446@@ -357,6 +369,11 @@ dotraplinkage void do_double_fault(struct pt_regs *regs, long error_code)
28447 tsk->thread.error_code = error_code;
28448 tsk->thread.trap_nr = X86_TRAP_DF;
28449
28450+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
28451+ if ((unsigned long)tsk->stack - regs->sp <= PAGE_SIZE)
28452+ die("grsec: kernel stack overflow detected", regs, error_code);
28453+#endif
28454+
28455 #ifdef CONFIG_DOUBLEFAULT
28456 df_debug(regs, error_code);
28457 #endif
28458@@ -475,11 +492,35 @@ do_general_protection(struct pt_regs *regs, long error_code)
28459 tsk->thread.error_code = error_code;
28460 tsk->thread.trap_nr = X86_TRAP_GP;
28461 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
28462- X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
28463+ X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
28464+
28465+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
28466+ if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
28467+ die("PAX: suspicious general protection fault", regs, error_code);
28468+ else
28469+#endif
28470+
28471 die("general protection fault", regs, error_code);
28472+ }
28473 goto exit;
28474 }
28475
28476+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
28477+ if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
28478+ struct mm_struct *mm = tsk->mm;
28479+ unsigned long limit;
28480+
28481+ down_write(&mm->mmap_sem);
28482+ limit = mm->context.user_cs_limit;
28483+ if (limit < TASK_SIZE) {
28484+ track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
28485+ up_write(&mm->mmap_sem);
28486+ return;
28487+ }
28488+ up_write(&mm->mmap_sem);
28489+ }
28490+#endif
28491+
28492 tsk->thread.error_code = error_code;
28493 tsk->thread.trap_nr = X86_TRAP_GP;
28494
28495@@ -578,6 +619,9 @@ struct bad_iret_stack *fixup_bad_iret(struct bad_iret_stack *s)
28496 container_of(task_pt_regs(current),
28497 struct bad_iret_stack, regs);
28498
28499+ if ((current->thread.sp0 ^ (unsigned long)s) < THREAD_SIZE)
28500+ new_stack = s;
28501+
28502 /* Copy the IRET target to the new stack. */
28503 memmove(&new_stack->regs.ip, (void *)s->regs.sp, 5*8);
28504
28505diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
28506index 5054497..139f8f8 100644
28507--- a/arch/x86/kernel/tsc.c
28508+++ b/arch/x86/kernel/tsc.c
28509@@ -150,7 +150,7 @@ static void cyc2ns_write_end(int cpu, struct cyc2ns_data *data)
28510 */
28511 smp_wmb();
28512
28513- ACCESS_ONCE(c2n->head) = data;
28514+ ACCESS_ONCE_RW(c2n->head) = data;
28515 }
28516
28517 /*
28518diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
28519index 0b81ad6..fff670e 100644
28520--- a/arch/x86/kernel/uprobes.c
28521+++ b/arch/x86/kernel/uprobes.c
28522@@ -986,7 +986,7 @@ arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regs
28523
28524 if (nleft != rasize) {
28525 pr_err("uprobe: return address clobbered: pid=%d, %%sp=%#lx, "
28526- "%%ip=%#lx\n", current->pid, regs->sp, regs->ip);
28527+ "%%ip=%#lx\n", task_pid_nr(current), regs->sp, regs->ip);
28528
28529 force_sig_info(SIGSEGV, SEND_SIG_FORCED, current);
28530 }
28531diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
28532index b9242ba..50c5edd 100644
28533--- a/arch/x86/kernel/verify_cpu.S
28534+++ b/arch/x86/kernel/verify_cpu.S
28535@@ -20,6 +20,7 @@
28536 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
28537 * arch/x86/kernel/trampoline_64.S: secondary processor verification
28538 * arch/x86/kernel/head_32.S: processor startup
28539+ * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
28540 *
28541 * verify_cpu, returns the status of longmode and SSE in register %eax.
28542 * 0: Success 1: Failure
28543diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
28544index fc9db6e..2c5865d 100644
28545--- a/arch/x86/kernel/vm86_32.c
28546+++ b/arch/x86/kernel/vm86_32.c
28547@@ -44,6 +44,7 @@
28548 #include <linux/ptrace.h>
28549 #include <linux/audit.h>
28550 #include <linux/stddef.h>
28551+#include <linux/grsecurity.h>
28552
28553 #include <asm/uaccess.h>
28554 #include <asm/io.h>
28555@@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
28556 do_exit(SIGSEGV);
28557 }
28558
28559- tss = &per_cpu(cpu_tss, get_cpu());
28560+ tss = cpu_tss + get_cpu();
28561 current->thread.sp0 = current->thread.saved_sp0;
28562 current->thread.sysenter_cs = __KERNEL_CS;
28563 load_sp0(tss, &current->thread);
28564@@ -214,6 +215,14 @@ SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
28565
28566 if (tsk->thread.saved_sp0)
28567 return -EPERM;
28568+
28569+#ifdef CONFIG_GRKERNSEC_VM86
28570+ if (!capable(CAP_SYS_RAWIO)) {
28571+ gr_handle_vm86();
28572+ return -EPERM;
28573+ }
28574+#endif
28575+
28576 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
28577 offsetof(struct kernel_vm86_struct, vm86plus) -
28578 sizeof(info.regs));
28579@@ -238,6 +247,13 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
28580 int tmp;
28581 struct vm86plus_struct __user *v86;
28582
28583+#ifdef CONFIG_GRKERNSEC_VM86
28584+ if (!capable(CAP_SYS_RAWIO)) {
28585+ gr_handle_vm86();
28586+ return -EPERM;
28587+ }
28588+#endif
28589+
28590 tsk = current;
28591 switch (cmd) {
28592 case VM86_REQUEST_IRQ:
28593@@ -318,7 +334,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
28594 tsk->thread.saved_fs = info->regs32->fs;
28595 tsk->thread.saved_gs = get_user_gs(info->regs32);
28596
28597- tss = &per_cpu(cpu_tss, get_cpu());
28598+ tss = cpu_tss + get_cpu();
28599 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
28600 if (cpu_has_sep)
28601 tsk->thread.sysenter_cs = 0;
28602@@ -525,7 +541,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
28603 goto cannot_handle;
28604 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
28605 goto cannot_handle;
28606- intr_ptr = (unsigned long __user *) (i << 2);
28607+ intr_ptr = (__force unsigned long __user *) (i << 2);
28608 if (get_user(segoffs, intr_ptr))
28609 goto cannot_handle;
28610 if ((segoffs >> 16) == BIOSSEG)
28611diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
28612index 00bf300..129df8e 100644
28613--- a/arch/x86/kernel/vmlinux.lds.S
28614+++ b/arch/x86/kernel/vmlinux.lds.S
28615@@ -26,6 +26,13 @@
28616 #include <asm/page_types.h>
28617 #include <asm/cache.h>
28618 #include <asm/boot.h>
28619+#include <asm/segment.h>
28620+
28621+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
28622+#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
28623+#else
28624+#define __KERNEL_TEXT_OFFSET 0
28625+#endif
28626
28627 #undef i386 /* in case the preprocessor is a 32bit one */
28628
28629@@ -69,30 +76,43 @@ jiffies_64 = jiffies;
28630
28631 PHDRS {
28632 text PT_LOAD FLAGS(5); /* R_E */
28633+#ifdef CONFIG_X86_32
28634+ module PT_LOAD FLAGS(5); /* R_E */
28635+#endif
28636+#ifdef CONFIG_XEN
28637+ rodata PT_LOAD FLAGS(5); /* R_E */
28638+#else
28639+ rodata PT_LOAD FLAGS(4); /* R__ */
28640+#endif
28641 data PT_LOAD FLAGS(6); /* RW_ */
28642-#ifdef CONFIG_X86_64
28643+ init.begin PT_LOAD FLAGS(6); /* RW_ */
28644 #ifdef CONFIG_SMP
28645 percpu PT_LOAD FLAGS(6); /* RW_ */
28646 #endif
28647+ text.init PT_LOAD FLAGS(5); /* R_E */
28648+ text.exit PT_LOAD FLAGS(5); /* R_E */
28649 init PT_LOAD FLAGS(7); /* RWE */
28650-#endif
28651 note PT_NOTE FLAGS(0); /* ___ */
28652 }
28653
28654 SECTIONS
28655 {
28656 #ifdef CONFIG_X86_32
28657- . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
28658- phys_startup_32 = startup_32 - LOAD_OFFSET;
28659+ . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
28660 #else
28661- . = __START_KERNEL;
28662- phys_startup_64 = startup_64 - LOAD_OFFSET;
28663+ . = __START_KERNEL;
28664 #endif
28665
28666 /* Text and read-only data */
28667- .text : AT(ADDR(.text) - LOAD_OFFSET) {
28668- _text = .;
28669+ .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
28670 /* bootstrapping code */
28671+#ifdef CONFIG_X86_32
28672+ phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
28673+#else
28674+ phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
28675+#endif
28676+ __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
28677+ _text = .;
28678 HEAD_TEXT
28679 . = ALIGN(8);
28680 _stext = .;
28681@@ -104,13 +124,47 @@ SECTIONS
28682 IRQENTRY_TEXT
28683 *(.fixup)
28684 *(.gnu.warning)
28685- /* End of text section */
28686- _etext = .;
28687 } :text = 0x9090
28688
28689- NOTES :text :note
28690+ . += __KERNEL_TEXT_OFFSET;
28691
28692- EXCEPTION_TABLE(16) :text = 0x9090
28693+#ifdef CONFIG_X86_32
28694+ . = ALIGN(PAGE_SIZE);
28695+ .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
28696+
28697+#ifdef CONFIG_PAX_KERNEXEC
28698+ MODULES_EXEC_VADDR = .;
28699+ BYTE(0)
28700+ . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
28701+ . = ALIGN(HPAGE_SIZE) - 1;
28702+ MODULES_EXEC_END = .;
28703+#endif
28704+
28705+ } :module
28706+#endif
28707+
28708+ .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
28709+ /* End of text section */
28710+ BYTE(0)
28711+ _etext = . - __KERNEL_TEXT_OFFSET;
28712+ }
28713+
28714+#ifdef CONFIG_X86_32
28715+ . = ALIGN(PAGE_SIZE);
28716+ .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
28717+ . = ALIGN(PAGE_SIZE);
28718+ *(.empty_zero_page)
28719+ *(.initial_pg_fixmap)
28720+ *(.initial_pg_pmd)
28721+ *(.initial_page_table)
28722+ *(.swapper_pg_dir)
28723+ } :rodata
28724+#endif
28725+
28726+ . = ALIGN(PAGE_SIZE);
28727+ NOTES :rodata :note
28728+
28729+ EXCEPTION_TABLE(16) :rodata
28730
28731 #if defined(CONFIG_DEBUG_RODATA)
28732 /* .text should occupy whole number of pages */
28733@@ -122,16 +176,20 @@ SECTIONS
28734
28735 /* Data */
28736 .data : AT(ADDR(.data) - LOAD_OFFSET) {
28737+
28738+#ifdef CONFIG_PAX_KERNEXEC
28739+ . = ALIGN(HPAGE_SIZE);
28740+#else
28741+ . = ALIGN(PAGE_SIZE);
28742+#endif
28743+
28744 /* Start of data section */
28745 _sdata = .;
28746
28747 /* init_task */
28748 INIT_TASK_DATA(THREAD_SIZE)
28749
28750-#ifdef CONFIG_X86_32
28751- /* 32 bit has nosave before _edata */
28752 NOSAVE_DATA
28753-#endif
28754
28755 PAGE_ALIGNED_DATA(PAGE_SIZE)
28756
28757@@ -174,12 +232,19 @@ SECTIONS
28758 . = ALIGN(__vvar_page + PAGE_SIZE, PAGE_SIZE);
28759
28760 /* Init code and data - will be freed after init */
28761- . = ALIGN(PAGE_SIZE);
28762 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
28763+ BYTE(0)
28764+
28765+#ifdef CONFIG_PAX_KERNEXEC
28766+ . = ALIGN(HPAGE_SIZE);
28767+#else
28768+ . = ALIGN(PAGE_SIZE);
28769+#endif
28770+
28771 __init_begin = .; /* paired with __init_end */
28772- }
28773+ } :init.begin
28774
28775-#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
28776+#ifdef CONFIG_SMP
28777 /*
28778 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
28779 * output PHDR, so the next output section - .init.text - should
28780@@ -190,12 +255,27 @@ SECTIONS
28781 "per-CPU data too large - increase CONFIG_PHYSICAL_START")
28782 #endif
28783
28784- INIT_TEXT_SECTION(PAGE_SIZE)
28785-#ifdef CONFIG_X86_64
28786- :init
28787-#endif
28788+ . = ALIGN(PAGE_SIZE);
28789+ init_begin = .;
28790+ .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
28791+ VMLINUX_SYMBOL(_sinittext) = .;
28792+ INIT_TEXT
28793+ . = ALIGN(PAGE_SIZE);
28794+ } :text.init
28795
28796- INIT_DATA_SECTION(16)
28797+ /*
28798+ * .exit.text is discard at runtime, not link time, to deal with
28799+ * references from .altinstructions and .eh_frame
28800+ */
28801+ .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
28802+ EXIT_TEXT
28803+ VMLINUX_SYMBOL(_einittext) = .;
28804+ . = ALIGN(16);
28805+ } :text.exit
28806+ . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
28807+
28808+ . = ALIGN(PAGE_SIZE);
28809+ INIT_DATA_SECTION(16) :init
28810
28811 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
28812 __x86_cpu_dev_start = .;
28813@@ -266,19 +346,12 @@ SECTIONS
28814 }
28815
28816 . = ALIGN(8);
28817- /*
28818- * .exit.text is discard at runtime, not link time, to deal with
28819- * references from .altinstructions and .eh_frame
28820- */
28821- .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
28822- EXIT_TEXT
28823- }
28824
28825 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
28826 EXIT_DATA
28827 }
28828
28829-#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
28830+#ifndef CONFIG_SMP
28831 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
28832 #endif
28833
28834@@ -297,16 +370,10 @@ SECTIONS
28835 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
28836 __smp_locks = .;
28837 *(.smp_locks)
28838- . = ALIGN(PAGE_SIZE);
28839 __smp_locks_end = .;
28840+ . = ALIGN(PAGE_SIZE);
28841 }
28842
28843-#ifdef CONFIG_X86_64
28844- .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
28845- NOSAVE_DATA
28846- }
28847-#endif
28848-
28849 /* BSS */
28850 . = ALIGN(PAGE_SIZE);
28851 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
28852@@ -322,6 +389,7 @@ SECTIONS
28853 __brk_base = .;
28854 . += 64 * 1024; /* 64k alignment slop space */
28855 *(.brk_reservation) /* areas brk users have reserved */
28856+ . = ALIGN(HPAGE_SIZE);
28857 __brk_limit = .;
28858 }
28859
28860@@ -348,13 +416,12 @@ SECTIONS
28861 * for the boot processor.
28862 */
28863 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
28864-INIT_PER_CPU(gdt_page);
28865 INIT_PER_CPU(irq_stack_union);
28866
28867 /*
28868 * Build-time check on the image size:
28869 */
28870-. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
28871+. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
28872 "kernel image bigger than KERNEL_IMAGE_SIZE");
28873
28874 #ifdef CONFIG_SMP
28875diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
28876index 2dcc6ff..082dc7a 100644
28877--- a/arch/x86/kernel/vsyscall_64.c
28878+++ b/arch/x86/kernel/vsyscall_64.c
28879@@ -38,15 +38,13 @@
28880 #define CREATE_TRACE_POINTS
28881 #include "vsyscall_trace.h"
28882
28883-static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
28884+static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
28885
28886 static int __init vsyscall_setup(char *str)
28887 {
28888 if (str) {
28889 if (!strcmp("emulate", str))
28890 vsyscall_mode = EMULATE;
28891- else if (!strcmp("native", str))
28892- vsyscall_mode = NATIVE;
28893 else if (!strcmp("none", str))
28894 vsyscall_mode = NONE;
28895 else
28896@@ -264,8 +262,7 @@ do_ret:
28897 return true;
28898
28899 sigsegv:
28900- force_sig(SIGSEGV, current);
28901- return true;
28902+ do_group_exit(SIGKILL);
28903 }
28904
28905 /*
28906@@ -283,8 +280,8 @@ static struct vm_operations_struct gate_vma_ops = {
28907 static struct vm_area_struct gate_vma = {
28908 .vm_start = VSYSCALL_ADDR,
28909 .vm_end = VSYSCALL_ADDR + PAGE_SIZE,
28910- .vm_page_prot = PAGE_READONLY_EXEC,
28911- .vm_flags = VM_READ | VM_EXEC,
28912+ .vm_page_prot = PAGE_READONLY,
28913+ .vm_flags = VM_READ,
28914 .vm_ops = &gate_vma_ops,
28915 };
28916
28917@@ -325,10 +322,7 @@ void __init map_vsyscall(void)
28918 unsigned long physaddr_vsyscall = __pa_symbol(&__vsyscall_page);
28919
28920 if (vsyscall_mode != NONE)
28921- __set_fixmap(VSYSCALL_PAGE, physaddr_vsyscall,
28922- vsyscall_mode == NATIVE
28923- ? PAGE_KERNEL_VSYSCALL
28924- : PAGE_KERNEL_VVAR);
28925+ __set_fixmap(VSYSCALL_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
28926
28927 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_PAGE) !=
28928 (unsigned long)VSYSCALL_ADDR);
28929diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
28930index 37d8fa4..66e319a 100644
28931--- a/arch/x86/kernel/x8664_ksyms_64.c
28932+++ b/arch/x86/kernel/x8664_ksyms_64.c
28933@@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
28934 EXPORT_SYMBOL(copy_user_generic_unrolled);
28935 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
28936 EXPORT_SYMBOL(__copy_user_nocache);
28937-EXPORT_SYMBOL(_copy_from_user);
28938-EXPORT_SYMBOL(_copy_to_user);
28939
28940 EXPORT_SYMBOL(copy_page);
28941 EXPORT_SYMBOL(clear_page);
28942@@ -79,3 +77,7 @@ EXPORT_SYMBOL(___preempt_schedule);
28943 EXPORT_SYMBOL(___preempt_schedule_context);
28944 #endif
28945 #endif
28946+
28947+#ifdef CONFIG_PAX_PER_CPU_PGD
28948+EXPORT_SYMBOL(cpu_pgd);
28949+#endif
28950diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
28951index 234b072..b7ab191 100644
28952--- a/arch/x86/kernel/x86_init.c
28953+++ b/arch/x86/kernel/x86_init.c
28954@@ -93,7 +93,7 @@ struct x86_cpuinit_ops x86_cpuinit = {
28955 static void default_nmi_init(void) { };
28956 static int default_i8042_detect(void) { return 1; };
28957
28958-struct x86_platform_ops x86_platform = {
28959+struct x86_platform_ops x86_platform __read_only = {
28960 .calibrate_tsc = native_calibrate_tsc,
28961 .get_wallclock = mach_get_cmos_time,
28962 .set_wallclock = mach_set_rtc_mmss,
28963@@ -109,7 +109,7 @@ struct x86_platform_ops x86_platform = {
28964 EXPORT_SYMBOL_GPL(x86_platform);
28965
28966 #if defined(CONFIG_PCI_MSI)
28967-struct x86_msi_ops x86_msi = {
28968+struct x86_msi_ops x86_msi __read_only = {
28969 .setup_msi_irqs = native_setup_msi_irqs,
28970 .compose_msi_msg = native_compose_msi_msg,
28971 .teardown_msi_irq = native_teardown_msi_irq,
28972@@ -140,7 +140,7 @@ void arch_restore_msi_irqs(struct pci_dev *dev)
28973 }
28974 #endif
28975
28976-struct x86_io_apic_ops x86_io_apic_ops = {
28977+struct x86_io_apic_ops x86_io_apic_ops __read_only = {
28978 .init = native_io_apic_init_mappings,
28979 .read = native_io_apic_read,
28980 .write = native_io_apic_write,
28981diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
28982index 87a815b..727dbe6 100644
28983--- a/arch/x86/kernel/xsave.c
28984+++ b/arch/x86/kernel/xsave.c
28985@@ -168,18 +168,18 @@ static inline int save_xstate_epilog(void __user *buf, int ia32_frame)
28986
28987 /* Setup the bytes not touched by the [f]xsave and reserved for SW. */
28988 sw_bytes = ia32_frame ? &fx_sw_reserved_ia32 : &fx_sw_reserved;
28989- err = __copy_to_user(&x->i387.sw_reserved, sw_bytes, sizeof(*sw_bytes));
28990+ err = __copy_to_user(x->i387.sw_reserved, sw_bytes, sizeof(*sw_bytes));
28991
28992 if (!use_xsave())
28993 return err;
28994
28995- err |= __put_user(FP_XSTATE_MAGIC2, (__u32 *)(buf + xstate_size));
28996+ err |= __put_user(FP_XSTATE_MAGIC2, (__u32 __user *)(buf + xstate_size));
28997
28998 /*
28999 * Read the xstate_bv which we copied (directly from the cpu or
29000 * from the state in task struct) to the user buffers.
29001 */
29002- err |= __get_user(xstate_bv, (__u32 *)&x->xsave_hdr.xstate_bv);
29003+ err |= __get_user(xstate_bv, (__u32 __user *)&x->xsave_hdr.xstate_bv);
29004
29005 /*
29006 * For legacy compatible, we always set FP/SSE bits in the bit
29007@@ -194,7 +194,7 @@ static inline int save_xstate_epilog(void __user *buf, int ia32_frame)
29008 */
29009 xstate_bv |= XSTATE_FPSSE;
29010
29011- err |= __put_user(xstate_bv, (__u32 *)&x->xsave_hdr.xstate_bv);
29012+ err |= __put_user(xstate_bv, (__u32 __user *)&x->xsave_hdr.xstate_bv);
29013
29014 return err;
29015 }
29016@@ -203,6 +203,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
29017 {
29018 int err;
29019
29020+ buf = (struct xsave_struct __user *)____m(buf);
29021 if (use_xsave())
29022 err = xsave_user(buf);
29023 else if (use_fxsr())
29024@@ -313,6 +314,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
29025 */
29026 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
29027 {
29028+ buf = (void __user *)____m(buf);
29029 if (use_xsave()) {
29030 if ((unsigned long)buf % 64 || fx_only) {
29031 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
29032diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
29033index 1d08ad3..c6a4faf 100644
29034--- a/arch/x86/kvm/cpuid.c
29035+++ b/arch/x86/kvm/cpuid.c
29036@@ -204,15 +204,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
29037 struct kvm_cpuid2 *cpuid,
29038 struct kvm_cpuid_entry2 __user *entries)
29039 {
29040- int r;
29041+ int r, i;
29042
29043 r = -E2BIG;
29044 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
29045 goto out;
29046 r = -EFAULT;
29047- if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
29048- cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
29049+ if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
29050 goto out;
29051+ for (i = 0; i < cpuid->nent; ++i) {
29052+ struct kvm_cpuid_entry2 cpuid_entry;
29053+ if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
29054+ goto out;
29055+ vcpu->arch.cpuid_entries[i] = cpuid_entry;
29056+ }
29057 vcpu->arch.cpuid_nent = cpuid->nent;
29058 kvm_apic_set_version(vcpu);
29059 kvm_x86_ops->cpuid_update(vcpu);
29060@@ -225,15 +230,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
29061 struct kvm_cpuid2 *cpuid,
29062 struct kvm_cpuid_entry2 __user *entries)
29063 {
29064- int r;
29065+ int r, i;
29066
29067 r = -E2BIG;
29068 if (cpuid->nent < vcpu->arch.cpuid_nent)
29069 goto out;
29070 r = -EFAULT;
29071- if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
29072- vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
29073+ if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
29074 goto out;
29075+ for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
29076+ struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
29077+ if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
29078+ goto out;
29079+ }
29080 return 0;
29081
29082 out:
29083diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
29084index 630bcb0..a7f6d9e 100644
29085--- a/arch/x86/kvm/emulate.c
29086+++ b/arch/x86/kvm/emulate.c
29087@@ -3569,7 +3569,7 @@ static int check_cr_write(struct x86_emulate_ctxt *ctxt)
29088 int cr = ctxt->modrm_reg;
29089 u64 efer = 0;
29090
29091- static u64 cr_reserved_bits[] = {
29092+ static const u64 cr_reserved_bits[] = {
29093 0xffffffff00000000ULL,
29094 0, 0, 0, /* CR3 checked later */
29095 CR4_RESERVED_BITS,
29096diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
29097index 67d07e0..10769d5 100644
29098--- a/arch/x86/kvm/lapic.c
29099+++ b/arch/x86/kvm/lapic.c
29100@@ -56,7 +56,7 @@
29101 #define APIC_BUS_CYCLE_NS 1
29102
29103 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
29104-#define apic_debug(fmt, arg...)
29105+#define apic_debug(fmt, arg...) do {} while (0)
29106
29107 #define APIC_LVT_NUM 6
29108 /* 14 is the version for Xeon and Pentium 8.4.8*/
29109diff --git a/arch/x86/kvm/lapic.h b/arch/x86/kvm/lapic.h
29110index 9d28383..c4ea87e 100644
29111--- a/arch/x86/kvm/lapic.h
29112+++ b/arch/x86/kvm/lapic.h
29113@@ -150,7 +150,7 @@ static inline bool kvm_apic_vid_enabled(struct kvm *kvm)
29114
29115 static inline bool kvm_apic_has_events(struct kvm_vcpu *vcpu)
29116 {
29117- return vcpu->arch.apic->pending_events;
29118+ return kvm_vcpu_has_lapic(vcpu) && vcpu->arch.apic->pending_events;
29119 }
29120
29121 bool kvm_apic_pending_eoi(struct kvm_vcpu *vcpu, int vector);
29122diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
29123index 6e6d115..43fecbf 100644
29124--- a/arch/x86/kvm/paging_tmpl.h
29125+++ b/arch/x86/kvm/paging_tmpl.h
29126@@ -343,7 +343,7 @@ retry_walk:
29127 if (unlikely(kvm_is_error_hva(host_addr)))
29128 goto error;
29129
29130- ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
29131+ ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
29132 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
29133 goto error;
29134 walker->ptep_user[walker->level - 1] = ptep_user;
29135diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
29136index 4911bf1..e7d3ed2 100644
29137--- a/arch/x86/kvm/svm.c
29138+++ b/arch/x86/kvm/svm.c
29139@@ -3577,7 +3577,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
29140 int cpu = raw_smp_processor_id();
29141
29142 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
29143+
29144+ pax_open_kernel();
29145 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
29146+ pax_close_kernel();
29147+
29148 load_TR_desc();
29149 }
29150
29151@@ -3973,6 +3977,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
29152 #endif
29153 #endif
29154
29155+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
29156+ __set_fs(current_thread_info()->addr_limit);
29157+#endif
29158+
29159 reload_tss(vcpu);
29160
29161 local_irq_disable();
29162diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
29163index 2d73807..84a0e59 100644
29164--- a/arch/x86/kvm/vmx.c
29165+++ b/arch/x86/kvm/vmx.c
29166@@ -1440,12 +1440,12 @@ static void vmcs_write64(unsigned long field, u64 value)
29167 #endif
29168 }
29169
29170-static void vmcs_clear_bits(unsigned long field, u32 mask)
29171+static void vmcs_clear_bits(unsigned long field, unsigned long mask)
29172 {
29173 vmcs_writel(field, vmcs_readl(field) & ~mask);
29174 }
29175
29176-static void vmcs_set_bits(unsigned long field, u32 mask)
29177+static void vmcs_set_bits(unsigned long field, unsigned long mask)
29178 {
29179 vmcs_writel(field, vmcs_readl(field) | mask);
29180 }
29181@@ -1705,7 +1705,11 @@ static void reload_tss(void)
29182 struct desc_struct *descs;
29183
29184 descs = (void *)gdt->address;
29185+
29186+ pax_open_kernel();
29187 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
29188+ pax_close_kernel();
29189+
29190 load_TR_desc();
29191 }
29192
29193@@ -1941,6 +1945,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
29194 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
29195 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
29196
29197+#ifdef CONFIG_PAX_PER_CPU_PGD
29198+ vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
29199+#endif
29200+
29201 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
29202 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
29203 vmx->loaded_vmcs->cpu = cpu;
29204@@ -2233,7 +2241,7 @@ static void setup_msrs(struct vcpu_vmx *vmx)
29205 * reads and returns guest's timestamp counter "register"
29206 * guest_tsc = host_tsc + tsc_offset -- 21.3
29207 */
29208-static u64 guest_read_tsc(void)
29209+static u64 __intentional_overflow(-1) guest_read_tsc(void)
29210 {
29211 u64 host_tsc, tsc_offset;
29212
29213@@ -4467,7 +4475,10 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
29214 unsigned long cr4;
29215
29216 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
29217+
29218+#ifndef CONFIG_PAX_PER_CPU_PGD
29219 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
29220+#endif
29221
29222 /* Save the most likely value for this task's CR4 in the VMCS. */
29223 cr4 = cr4_read_shadow();
29224@@ -4494,7 +4505,7 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
29225 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
29226 vmx->host_idt_base = dt.address;
29227
29228- vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
29229+ vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
29230
29231 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
29232 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
29233@@ -6107,11 +6118,17 @@ static __init int hardware_setup(void)
29234 * page upon invalidation. No need to do anything if not
29235 * using the APIC_ACCESS_ADDR VMCS field.
29236 */
29237- if (!flexpriority_enabled)
29238- kvm_x86_ops->set_apic_access_page_addr = NULL;
29239+ if (!flexpriority_enabled) {
29240+ pax_open_kernel();
29241+ *(void **)&kvm_x86_ops->set_apic_access_page_addr = NULL;
29242+ pax_close_kernel();
29243+ }
29244
29245- if (!cpu_has_vmx_tpr_shadow())
29246- kvm_x86_ops->update_cr8_intercept = NULL;
29247+ if (!cpu_has_vmx_tpr_shadow()) {
29248+ pax_open_kernel();
29249+ *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
29250+ pax_close_kernel();
29251+ }
29252
29253 if (enable_ept && !cpu_has_vmx_ept_2m_page())
29254 kvm_disable_largepages();
29255@@ -6122,14 +6139,16 @@ static __init int hardware_setup(void)
29256 if (!cpu_has_vmx_apicv())
29257 enable_apicv = 0;
29258
29259+ pax_open_kernel();
29260 if (enable_apicv)
29261- kvm_x86_ops->update_cr8_intercept = NULL;
29262+ *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
29263 else {
29264- kvm_x86_ops->hwapic_irr_update = NULL;
29265- kvm_x86_ops->hwapic_isr_update = NULL;
29266- kvm_x86_ops->deliver_posted_interrupt = NULL;
29267- kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
29268+ *(void **)&kvm_x86_ops->hwapic_irr_update = NULL;
29269+ *(void **)&kvm_x86_ops->hwapic_isr_update = NULL;
29270+ *(void **)&kvm_x86_ops->deliver_posted_interrupt = NULL;
29271+ *(void **)&kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
29272 }
29273+ pax_close_kernel();
29274
29275 vmx_disable_intercept_for_msr(MSR_FS_BASE, false);
29276 vmx_disable_intercept_for_msr(MSR_GS_BASE, false);
29277@@ -6182,10 +6201,12 @@ static __init int hardware_setup(void)
29278 enable_pml = 0;
29279
29280 if (!enable_pml) {
29281- kvm_x86_ops->slot_enable_log_dirty = NULL;
29282- kvm_x86_ops->slot_disable_log_dirty = NULL;
29283- kvm_x86_ops->flush_log_dirty = NULL;
29284- kvm_x86_ops->enable_log_dirty_pt_masked = NULL;
29285+ pax_open_kernel();
29286+ *(void **)&kvm_x86_ops->slot_enable_log_dirty = NULL;
29287+ *(void **)&kvm_x86_ops->slot_disable_log_dirty = NULL;
29288+ *(void **)&kvm_x86_ops->flush_log_dirty = NULL;
29289+ *(void **)&kvm_x86_ops->enable_log_dirty_pt_masked = NULL;
29290+ pax_close_kernel();
29291 }
29292
29293 return alloc_kvm_area();
29294@@ -8230,6 +8251,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
29295 "jmp 2f \n\t"
29296 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
29297 "2: "
29298+
29299+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29300+ "ljmp %[cs],$3f\n\t"
29301+ "3: "
29302+#endif
29303+
29304 /* Save guest registers, load host registers, keep flags */
29305 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
29306 "pop %0 \n\t"
29307@@ -8282,6 +8309,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
29308 #endif
29309 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
29310 [wordsize]"i"(sizeof(ulong))
29311+
29312+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29313+ ,[cs]"i"(__KERNEL_CS)
29314+#endif
29315+
29316 : "cc", "memory"
29317 #ifdef CONFIG_X86_64
29318 , "rax", "rbx", "rdi", "rsi"
29319@@ -8295,7 +8327,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
29320 if (debugctlmsr)
29321 update_debugctlmsr(debugctlmsr);
29322
29323-#ifndef CONFIG_X86_64
29324+#ifdef CONFIG_X86_32
29325 /*
29326 * The sysexit path does not restore ds/es, so we must set them to
29327 * a reasonable value ourselves.
29328@@ -8304,8 +8336,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
29329 * may be executed in interrupt context, which saves and restore segments
29330 * around it, nullifying its effect.
29331 */
29332- loadsegment(ds, __USER_DS);
29333- loadsegment(es, __USER_DS);
29334+ loadsegment(ds, __KERNEL_DS);
29335+ loadsegment(es, __KERNEL_DS);
29336+ loadsegment(ss, __KERNEL_DS);
29337+
29338+#ifdef CONFIG_PAX_KERNEXEC
29339+ loadsegment(fs, __KERNEL_PERCPU);
29340+#endif
29341+
29342+#ifdef CONFIG_PAX_MEMORY_UDEREF
29343+ __set_fs(current_thread_info()->addr_limit);
29344+#endif
29345+
29346 #endif
29347
29348 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
29349diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
29350index ea306ad..669f42d 100644
29351--- a/arch/x86/kvm/x86.c
29352+++ b/arch/x86/kvm/x86.c
29353@@ -1929,8 +1929,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
29354 {
29355 struct kvm *kvm = vcpu->kvm;
29356 int lm = is_long_mode(vcpu);
29357- u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
29358- : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
29359+ u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
29360+ : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
29361 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
29362 : kvm->arch.xen_hvm_config.blob_size_32;
29363 u32 page_num = data & ~PAGE_MASK;
29364@@ -2867,6 +2867,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
29365 if (n < msr_list.nmsrs)
29366 goto out;
29367 r = -EFAULT;
29368+ if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
29369+ goto out;
29370 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
29371 num_msrs_to_save * sizeof(u32)))
29372 goto out;
29373@@ -5784,7 +5786,7 @@ static struct notifier_block pvclock_gtod_notifier = {
29374 };
29375 #endif
29376
29377-int kvm_arch_init(void *opaque)
29378+int kvm_arch_init(const void *opaque)
29379 {
29380 int r;
29381 struct kvm_x86_ops *ops = opaque;
29382diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
29383index 8f9a133..3c7694b 100644
29384--- a/arch/x86/lguest/boot.c
29385+++ b/arch/x86/lguest/boot.c
29386@@ -1341,9 +1341,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
29387 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
29388 * Launcher to reboot us.
29389 */
29390-static void lguest_restart(char *reason)
29391+static __noreturn void lguest_restart(char *reason)
29392 {
29393 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
29394+ BUG();
29395 }
29396
29397 /*G:050
29398diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
29399index 00933d5..3a64af9 100644
29400--- a/arch/x86/lib/atomic64_386_32.S
29401+++ b/arch/x86/lib/atomic64_386_32.S
29402@@ -48,6 +48,10 @@ BEGIN(read)
29403 movl (v), %eax
29404 movl 4(v), %edx
29405 RET_ENDP
29406+BEGIN(read_unchecked)
29407+ movl (v), %eax
29408+ movl 4(v), %edx
29409+RET_ENDP
29410 #undef v
29411
29412 #define v %esi
29413@@ -55,6 +59,10 @@ BEGIN(set)
29414 movl %ebx, (v)
29415 movl %ecx, 4(v)
29416 RET_ENDP
29417+BEGIN(set_unchecked)
29418+ movl %ebx, (v)
29419+ movl %ecx, 4(v)
29420+RET_ENDP
29421 #undef v
29422
29423 #define v %esi
29424@@ -70,6 +78,20 @@ RET_ENDP
29425 BEGIN(add)
29426 addl %eax, (v)
29427 adcl %edx, 4(v)
29428+
29429+#ifdef CONFIG_PAX_REFCOUNT
29430+ jno 0f
29431+ subl %eax, (v)
29432+ sbbl %edx, 4(v)
29433+ int $4
29434+0:
29435+ _ASM_EXTABLE(0b, 0b)
29436+#endif
29437+
29438+RET_ENDP
29439+BEGIN(add_unchecked)
29440+ addl %eax, (v)
29441+ adcl %edx, 4(v)
29442 RET_ENDP
29443 #undef v
29444
29445@@ -77,6 +99,24 @@ RET_ENDP
29446 BEGIN(add_return)
29447 addl (v), %eax
29448 adcl 4(v), %edx
29449+
29450+#ifdef CONFIG_PAX_REFCOUNT
29451+ into
29452+1234:
29453+ _ASM_EXTABLE(1234b, 2f)
29454+#endif
29455+
29456+ movl %eax, (v)
29457+ movl %edx, 4(v)
29458+
29459+#ifdef CONFIG_PAX_REFCOUNT
29460+2:
29461+#endif
29462+
29463+RET_ENDP
29464+BEGIN(add_return_unchecked)
29465+ addl (v), %eax
29466+ adcl 4(v), %edx
29467 movl %eax, (v)
29468 movl %edx, 4(v)
29469 RET_ENDP
29470@@ -86,6 +126,20 @@ RET_ENDP
29471 BEGIN(sub)
29472 subl %eax, (v)
29473 sbbl %edx, 4(v)
29474+
29475+#ifdef CONFIG_PAX_REFCOUNT
29476+ jno 0f
29477+ addl %eax, (v)
29478+ adcl %edx, 4(v)
29479+ int $4
29480+0:
29481+ _ASM_EXTABLE(0b, 0b)
29482+#endif
29483+
29484+RET_ENDP
29485+BEGIN(sub_unchecked)
29486+ subl %eax, (v)
29487+ sbbl %edx, 4(v)
29488 RET_ENDP
29489 #undef v
29490
29491@@ -96,6 +150,27 @@ BEGIN(sub_return)
29492 sbbl $0, %edx
29493 addl (v), %eax
29494 adcl 4(v), %edx
29495+
29496+#ifdef CONFIG_PAX_REFCOUNT
29497+ into
29498+1234:
29499+ _ASM_EXTABLE(1234b, 2f)
29500+#endif
29501+
29502+ movl %eax, (v)
29503+ movl %edx, 4(v)
29504+
29505+#ifdef CONFIG_PAX_REFCOUNT
29506+2:
29507+#endif
29508+
29509+RET_ENDP
29510+BEGIN(sub_return_unchecked)
29511+ negl %edx
29512+ negl %eax
29513+ sbbl $0, %edx
29514+ addl (v), %eax
29515+ adcl 4(v), %edx
29516 movl %eax, (v)
29517 movl %edx, 4(v)
29518 RET_ENDP
29519@@ -105,6 +180,20 @@ RET_ENDP
29520 BEGIN(inc)
29521 addl $1, (v)
29522 adcl $0, 4(v)
29523+
29524+#ifdef CONFIG_PAX_REFCOUNT
29525+ jno 0f
29526+ subl $1, (v)
29527+ sbbl $0, 4(v)
29528+ int $4
29529+0:
29530+ _ASM_EXTABLE(0b, 0b)
29531+#endif
29532+
29533+RET_ENDP
29534+BEGIN(inc_unchecked)
29535+ addl $1, (v)
29536+ adcl $0, 4(v)
29537 RET_ENDP
29538 #undef v
29539
29540@@ -114,6 +203,26 @@ BEGIN(inc_return)
29541 movl 4(v), %edx
29542 addl $1, %eax
29543 adcl $0, %edx
29544+
29545+#ifdef CONFIG_PAX_REFCOUNT
29546+ into
29547+1234:
29548+ _ASM_EXTABLE(1234b, 2f)
29549+#endif
29550+
29551+ movl %eax, (v)
29552+ movl %edx, 4(v)
29553+
29554+#ifdef CONFIG_PAX_REFCOUNT
29555+2:
29556+#endif
29557+
29558+RET_ENDP
29559+BEGIN(inc_return_unchecked)
29560+ movl (v), %eax
29561+ movl 4(v), %edx
29562+ addl $1, %eax
29563+ adcl $0, %edx
29564 movl %eax, (v)
29565 movl %edx, 4(v)
29566 RET_ENDP
29567@@ -123,6 +232,20 @@ RET_ENDP
29568 BEGIN(dec)
29569 subl $1, (v)
29570 sbbl $0, 4(v)
29571+
29572+#ifdef CONFIG_PAX_REFCOUNT
29573+ jno 0f
29574+ addl $1, (v)
29575+ adcl $0, 4(v)
29576+ int $4
29577+0:
29578+ _ASM_EXTABLE(0b, 0b)
29579+#endif
29580+
29581+RET_ENDP
29582+BEGIN(dec_unchecked)
29583+ subl $1, (v)
29584+ sbbl $0, 4(v)
29585 RET_ENDP
29586 #undef v
29587
29588@@ -132,6 +255,26 @@ BEGIN(dec_return)
29589 movl 4(v), %edx
29590 subl $1, %eax
29591 sbbl $0, %edx
29592+
29593+#ifdef CONFIG_PAX_REFCOUNT
29594+ into
29595+1234:
29596+ _ASM_EXTABLE(1234b, 2f)
29597+#endif
29598+
29599+ movl %eax, (v)
29600+ movl %edx, 4(v)
29601+
29602+#ifdef CONFIG_PAX_REFCOUNT
29603+2:
29604+#endif
29605+
29606+RET_ENDP
29607+BEGIN(dec_return_unchecked)
29608+ movl (v), %eax
29609+ movl 4(v), %edx
29610+ subl $1, %eax
29611+ sbbl $0, %edx
29612 movl %eax, (v)
29613 movl %edx, 4(v)
29614 RET_ENDP
29615@@ -143,6 +286,13 @@ BEGIN(add_unless)
29616 adcl %edx, %edi
29617 addl (v), %eax
29618 adcl 4(v), %edx
29619+
29620+#ifdef CONFIG_PAX_REFCOUNT
29621+ into
29622+1234:
29623+ _ASM_EXTABLE(1234b, 2f)
29624+#endif
29625+
29626 cmpl %eax, %ecx
29627 je 3f
29628 1:
29629@@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
29630 1:
29631 addl $1, %eax
29632 adcl $0, %edx
29633+
29634+#ifdef CONFIG_PAX_REFCOUNT
29635+ into
29636+1234:
29637+ _ASM_EXTABLE(1234b, 2f)
29638+#endif
29639+
29640 movl %eax, (v)
29641 movl %edx, 4(v)
29642 movl $1, %eax
29643@@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
29644 movl 4(v), %edx
29645 subl $1, %eax
29646 sbbl $0, %edx
29647+
29648+#ifdef CONFIG_PAX_REFCOUNT
29649+ into
29650+1234:
29651+ _ASM_EXTABLE(1234b, 1f)
29652+#endif
29653+
29654 js 1f
29655 movl %eax, (v)
29656 movl %edx, 4(v)
29657diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
29658index 082a851..6a963bc 100644
29659--- a/arch/x86/lib/atomic64_cx8_32.S
29660+++ b/arch/x86/lib/atomic64_cx8_32.S
29661@@ -25,10 +25,20 @@ ENTRY(atomic64_read_cx8)
29662 CFI_STARTPROC
29663
29664 read64 %ecx
29665+ pax_force_retaddr
29666 ret
29667 CFI_ENDPROC
29668 ENDPROC(atomic64_read_cx8)
29669
29670+ENTRY(atomic64_read_unchecked_cx8)
29671+ CFI_STARTPROC
29672+
29673+ read64 %ecx
29674+ pax_force_retaddr
29675+ ret
29676+ CFI_ENDPROC
29677+ENDPROC(atomic64_read_unchecked_cx8)
29678+
29679 ENTRY(atomic64_set_cx8)
29680 CFI_STARTPROC
29681
29682@@ -38,10 +48,25 @@ ENTRY(atomic64_set_cx8)
29683 cmpxchg8b (%esi)
29684 jne 1b
29685
29686+ pax_force_retaddr
29687 ret
29688 CFI_ENDPROC
29689 ENDPROC(atomic64_set_cx8)
29690
29691+ENTRY(atomic64_set_unchecked_cx8)
29692+ CFI_STARTPROC
29693+
29694+1:
29695+/* we don't need LOCK_PREFIX since aligned 64-bit writes
29696+ * are atomic on 586 and newer */
29697+ cmpxchg8b (%esi)
29698+ jne 1b
29699+
29700+ pax_force_retaddr
29701+ ret
29702+ CFI_ENDPROC
29703+ENDPROC(atomic64_set_unchecked_cx8)
29704+
29705 ENTRY(atomic64_xchg_cx8)
29706 CFI_STARTPROC
29707
29708@@ -50,12 +75,13 @@ ENTRY(atomic64_xchg_cx8)
29709 cmpxchg8b (%esi)
29710 jne 1b
29711
29712+ pax_force_retaddr
29713 ret
29714 CFI_ENDPROC
29715 ENDPROC(atomic64_xchg_cx8)
29716
29717-.macro addsub_return func ins insc
29718-ENTRY(atomic64_\func\()_return_cx8)
29719+.macro addsub_return func ins insc unchecked=""
29720+ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
29721 CFI_STARTPROC
29722 pushl_cfi_reg ebp
29723 pushl_cfi_reg ebx
29724@@ -72,27 +98,44 @@ ENTRY(atomic64_\func\()_return_cx8)
29725 movl %edx, %ecx
29726 \ins\()l %esi, %ebx
29727 \insc\()l %edi, %ecx
29728+
29729+.ifb \unchecked
29730+#ifdef CONFIG_PAX_REFCOUNT
29731+ into
29732+2:
29733+ _ASM_EXTABLE(2b, 3f)
29734+#endif
29735+.endif
29736+
29737 LOCK_PREFIX
29738 cmpxchg8b (%ebp)
29739 jne 1b
29740-
29741-10:
29742 movl %ebx, %eax
29743 movl %ecx, %edx
29744+
29745+.ifb \unchecked
29746+#ifdef CONFIG_PAX_REFCOUNT
29747+3:
29748+#endif
29749+.endif
29750+
29751 popl_cfi_reg edi
29752 popl_cfi_reg esi
29753 popl_cfi_reg ebx
29754 popl_cfi_reg ebp
29755+ pax_force_retaddr
29756 ret
29757 CFI_ENDPROC
29758-ENDPROC(atomic64_\func\()_return_cx8)
29759+ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
29760 .endm
29761
29762 addsub_return add add adc
29763 addsub_return sub sub sbb
29764+addsub_return add add adc _unchecked
29765+addsub_return sub sub sbb _unchecked
29766
29767-.macro incdec_return func ins insc
29768-ENTRY(atomic64_\func\()_return_cx8)
29769+.macro incdec_return func ins insc unchecked=""
29770+ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
29771 CFI_STARTPROC
29772 pushl_cfi_reg ebx
29773
29774@@ -102,21 +145,38 @@ ENTRY(atomic64_\func\()_return_cx8)
29775 movl %edx, %ecx
29776 \ins\()l $1, %ebx
29777 \insc\()l $0, %ecx
29778+
29779+.ifb \unchecked
29780+#ifdef CONFIG_PAX_REFCOUNT
29781+ into
29782+2:
29783+ _ASM_EXTABLE(2b, 3f)
29784+#endif
29785+.endif
29786+
29787 LOCK_PREFIX
29788 cmpxchg8b (%esi)
29789 jne 1b
29790-
29791-10:
29792 movl %ebx, %eax
29793 movl %ecx, %edx
29794+
29795+.ifb \unchecked
29796+#ifdef CONFIG_PAX_REFCOUNT
29797+3:
29798+#endif
29799+.endif
29800+
29801 popl_cfi_reg ebx
29802+ pax_force_retaddr
29803 ret
29804 CFI_ENDPROC
29805-ENDPROC(atomic64_\func\()_return_cx8)
29806+ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
29807 .endm
29808
29809 incdec_return inc add adc
29810 incdec_return dec sub sbb
29811+incdec_return inc add adc _unchecked
29812+incdec_return dec sub sbb _unchecked
29813
29814 ENTRY(atomic64_dec_if_positive_cx8)
29815 CFI_STARTPROC
29816@@ -128,6 +188,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
29817 movl %edx, %ecx
29818 subl $1, %ebx
29819 sbb $0, %ecx
29820+
29821+#ifdef CONFIG_PAX_REFCOUNT
29822+ into
29823+1234:
29824+ _ASM_EXTABLE(1234b, 2f)
29825+#endif
29826+
29827 js 2f
29828 LOCK_PREFIX
29829 cmpxchg8b (%esi)
29830@@ -137,6 +204,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
29831 movl %ebx, %eax
29832 movl %ecx, %edx
29833 popl_cfi_reg ebx
29834+ pax_force_retaddr
29835 ret
29836 CFI_ENDPROC
29837 ENDPROC(atomic64_dec_if_positive_cx8)
29838@@ -161,6 +229,13 @@ ENTRY(atomic64_add_unless_cx8)
29839 movl %edx, %ecx
29840 addl %ebp, %ebx
29841 adcl %edi, %ecx
29842+
29843+#ifdef CONFIG_PAX_REFCOUNT
29844+ into
29845+1234:
29846+ _ASM_EXTABLE(1234b, 3f)
29847+#endif
29848+
29849 LOCK_PREFIX
29850 cmpxchg8b (%esi)
29851 jne 1b
29852@@ -171,6 +246,7 @@ ENTRY(atomic64_add_unless_cx8)
29853 CFI_ADJUST_CFA_OFFSET -8
29854 popl_cfi_reg ebx
29855 popl_cfi_reg ebp
29856+ pax_force_retaddr
29857 ret
29858 4:
29859 cmpl %edx, 4(%esp)
29860@@ -193,6 +269,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
29861 xorl %ecx, %ecx
29862 addl $1, %ebx
29863 adcl %edx, %ecx
29864+
29865+#ifdef CONFIG_PAX_REFCOUNT
29866+ into
29867+1234:
29868+ _ASM_EXTABLE(1234b, 3f)
29869+#endif
29870+
29871 LOCK_PREFIX
29872 cmpxchg8b (%esi)
29873 jne 1b
29874@@ -200,6 +283,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
29875 movl $1, %eax
29876 3:
29877 popl_cfi_reg ebx
29878+ pax_force_retaddr
29879 ret
29880 CFI_ENDPROC
29881 ENDPROC(atomic64_inc_not_zero_cx8)
29882diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
29883index 9bc944a..e52be6c 100644
29884--- a/arch/x86/lib/checksum_32.S
29885+++ b/arch/x86/lib/checksum_32.S
29886@@ -29,7 +29,8 @@
29887 #include <asm/dwarf2.h>
29888 #include <asm/errno.h>
29889 #include <asm/asm.h>
29890-
29891+#include <asm/segment.h>
29892+
29893 /*
29894 * computes a partial checksum, e.g. for TCP/UDP fragments
29895 */
29896@@ -285,9 +286,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
29897
29898 #define ARGBASE 16
29899 #define FP 12
29900-
29901-ENTRY(csum_partial_copy_generic)
29902+
29903+ENTRY(csum_partial_copy_generic_to_user)
29904 CFI_STARTPROC
29905+
29906+#ifdef CONFIG_PAX_MEMORY_UDEREF
29907+ pushl_cfi %gs
29908+ popl_cfi %es
29909+ jmp csum_partial_copy_generic
29910+#endif
29911+
29912+ENTRY(csum_partial_copy_generic_from_user)
29913+
29914+#ifdef CONFIG_PAX_MEMORY_UDEREF
29915+ pushl_cfi %gs
29916+ popl_cfi %ds
29917+#endif
29918+
29919+ENTRY(csum_partial_copy_generic)
29920 subl $4,%esp
29921 CFI_ADJUST_CFA_OFFSET 4
29922 pushl_cfi_reg edi
29923@@ -306,7 +322,7 @@ ENTRY(csum_partial_copy_generic)
29924 jmp 4f
29925 SRC(1: movw (%esi), %bx )
29926 addl $2, %esi
29927-DST( movw %bx, (%edi) )
29928+DST( movw %bx, %es:(%edi) )
29929 addl $2, %edi
29930 addw %bx, %ax
29931 adcl $0, %eax
29932@@ -318,30 +334,30 @@ DST( movw %bx, (%edi) )
29933 SRC(1: movl (%esi), %ebx )
29934 SRC( movl 4(%esi), %edx )
29935 adcl %ebx, %eax
29936-DST( movl %ebx, (%edi) )
29937+DST( movl %ebx, %es:(%edi) )
29938 adcl %edx, %eax
29939-DST( movl %edx, 4(%edi) )
29940+DST( movl %edx, %es:4(%edi) )
29941
29942 SRC( movl 8(%esi), %ebx )
29943 SRC( movl 12(%esi), %edx )
29944 adcl %ebx, %eax
29945-DST( movl %ebx, 8(%edi) )
29946+DST( movl %ebx, %es:8(%edi) )
29947 adcl %edx, %eax
29948-DST( movl %edx, 12(%edi) )
29949+DST( movl %edx, %es:12(%edi) )
29950
29951 SRC( movl 16(%esi), %ebx )
29952 SRC( movl 20(%esi), %edx )
29953 adcl %ebx, %eax
29954-DST( movl %ebx, 16(%edi) )
29955+DST( movl %ebx, %es:16(%edi) )
29956 adcl %edx, %eax
29957-DST( movl %edx, 20(%edi) )
29958+DST( movl %edx, %es:20(%edi) )
29959
29960 SRC( movl 24(%esi), %ebx )
29961 SRC( movl 28(%esi), %edx )
29962 adcl %ebx, %eax
29963-DST( movl %ebx, 24(%edi) )
29964+DST( movl %ebx, %es:24(%edi) )
29965 adcl %edx, %eax
29966-DST( movl %edx, 28(%edi) )
29967+DST( movl %edx, %es:28(%edi) )
29968
29969 lea 32(%esi), %esi
29970 lea 32(%edi), %edi
29971@@ -355,7 +371,7 @@ DST( movl %edx, 28(%edi) )
29972 shrl $2, %edx # This clears CF
29973 SRC(3: movl (%esi), %ebx )
29974 adcl %ebx, %eax
29975-DST( movl %ebx, (%edi) )
29976+DST( movl %ebx, %es:(%edi) )
29977 lea 4(%esi), %esi
29978 lea 4(%edi), %edi
29979 dec %edx
29980@@ -367,12 +383,12 @@ DST( movl %ebx, (%edi) )
29981 jb 5f
29982 SRC( movw (%esi), %cx )
29983 leal 2(%esi), %esi
29984-DST( movw %cx, (%edi) )
29985+DST( movw %cx, %es:(%edi) )
29986 leal 2(%edi), %edi
29987 je 6f
29988 shll $16,%ecx
29989 SRC(5: movb (%esi), %cl )
29990-DST( movb %cl, (%edi) )
29991+DST( movb %cl, %es:(%edi) )
29992 6: addl %ecx, %eax
29993 adcl $0, %eax
29994 7:
29995@@ -383,7 +399,7 @@ DST( movb %cl, (%edi) )
29996
29997 6001:
29998 movl ARGBASE+20(%esp), %ebx # src_err_ptr
29999- movl $-EFAULT, (%ebx)
30000+ movl $-EFAULT, %ss:(%ebx)
30001
30002 # zero the complete destination - computing the rest
30003 # is too much work
30004@@ -396,37 +412,58 @@ DST( movb %cl, (%edi) )
30005
30006 6002:
30007 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
30008- movl $-EFAULT,(%ebx)
30009+ movl $-EFAULT,%ss:(%ebx)
30010 jmp 5000b
30011
30012 .previous
30013
30014+ pushl_cfi %ss
30015+ popl_cfi %ds
30016+ pushl_cfi %ss
30017+ popl_cfi %es
30018 popl_cfi_reg ebx
30019 popl_cfi_reg esi
30020 popl_cfi_reg edi
30021 popl_cfi %ecx # equivalent to addl $4,%esp
30022 ret
30023 CFI_ENDPROC
30024-ENDPROC(csum_partial_copy_generic)
30025+ENDPROC(csum_partial_copy_generic_to_user)
30026
30027 #else
30028
30029 /* Version for PentiumII/PPro */
30030
30031 #define ROUND1(x) \
30032+ nop; nop; nop; \
30033 SRC(movl x(%esi), %ebx ) ; \
30034 addl %ebx, %eax ; \
30035- DST(movl %ebx, x(%edi) ) ;
30036+ DST(movl %ebx, %es:x(%edi)) ;
30037
30038 #define ROUND(x) \
30039+ nop; nop; nop; \
30040 SRC(movl x(%esi), %ebx ) ; \
30041 adcl %ebx, %eax ; \
30042- DST(movl %ebx, x(%edi) ) ;
30043+ DST(movl %ebx, %es:x(%edi)) ;
30044
30045 #define ARGBASE 12
30046-
30047-ENTRY(csum_partial_copy_generic)
30048+
30049+ENTRY(csum_partial_copy_generic_to_user)
30050 CFI_STARTPROC
30051+
30052+#ifdef CONFIG_PAX_MEMORY_UDEREF
30053+ pushl_cfi %gs
30054+ popl_cfi %es
30055+ jmp csum_partial_copy_generic
30056+#endif
30057+
30058+ENTRY(csum_partial_copy_generic_from_user)
30059+
30060+#ifdef CONFIG_PAX_MEMORY_UDEREF
30061+ pushl_cfi %gs
30062+ popl_cfi %ds
30063+#endif
30064+
30065+ENTRY(csum_partial_copy_generic)
30066 pushl_cfi_reg ebx
30067 pushl_cfi_reg edi
30068 pushl_cfi_reg esi
30069@@ -444,7 +481,7 @@ ENTRY(csum_partial_copy_generic)
30070 subl %ebx, %edi
30071 lea -1(%esi),%edx
30072 andl $-32,%edx
30073- lea 3f(%ebx,%ebx), %ebx
30074+ lea 3f(%ebx,%ebx,2), %ebx
30075 testl %esi, %esi
30076 jmp *%ebx
30077 1: addl $64,%esi
30078@@ -465,19 +502,19 @@ ENTRY(csum_partial_copy_generic)
30079 jb 5f
30080 SRC( movw (%esi), %dx )
30081 leal 2(%esi), %esi
30082-DST( movw %dx, (%edi) )
30083+DST( movw %dx, %es:(%edi) )
30084 leal 2(%edi), %edi
30085 je 6f
30086 shll $16,%edx
30087 5:
30088 SRC( movb (%esi), %dl )
30089-DST( movb %dl, (%edi) )
30090+DST( movb %dl, %es:(%edi) )
30091 6: addl %edx, %eax
30092 adcl $0, %eax
30093 7:
30094 .section .fixup, "ax"
30095 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
30096- movl $-EFAULT, (%ebx)
30097+ movl $-EFAULT, %ss:(%ebx)
30098 # zero the complete destination (computing the rest is too much work)
30099 movl ARGBASE+8(%esp),%edi # dst
30100 movl ARGBASE+12(%esp),%ecx # len
30101@@ -485,16 +522,23 @@ DST( movb %dl, (%edi) )
30102 rep; stosb
30103 jmp 7b
30104 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
30105- movl $-EFAULT, (%ebx)
30106+ movl $-EFAULT, %ss:(%ebx)
30107 jmp 7b
30108 .previous
30109
30110+#ifdef CONFIG_PAX_MEMORY_UDEREF
30111+ pushl_cfi %ss
30112+ popl_cfi %ds
30113+ pushl_cfi %ss
30114+ popl_cfi %es
30115+#endif
30116+
30117 popl_cfi_reg esi
30118 popl_cfi_reg edi
30119 popl_cfi_reg ebx
30120 ret
30121 CFI_ENDPROC
30122-ENDPROC(csum_partial_copy_generic)
30123+ENDPROC(csum_partial_copy_generic_to_user)
30124
30125 #undef ROUND
30126 #undef ROUND1
30127diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
30128index e67e579..4782449 100644
30129--- a/arch/x86/lib/clear_page_64.S
30130+++ b/arch/x86/lib/clear_page_64.S
30131@@ -23,6 +23,7 @@ ENTRY(clear_page)
30132 movl $4096/8,%ecx
30133 xorl %eax,%eax
30134 rep stosq
30135+ pax_force_retaddr
30136 ret
30137 CFI_ENDPROC
30138 ENDPROC(clear_page)
30139@@ -47,6 +48,7 @@ ENTRY(clear_page_orig)
30140 leaq 64(%rdi),%rdi
30141 jnz .Lloop
30142 nop
30143+ pax_force_retaddr
30144 ret
30145 CFI_ENDPROC
30146 ENDPROC(clear_page_orig)
30147@@ -56,6 +58,7 @@ ENTRY(clear_page_c_e)
30148 movl $4096,%ecx
30149 xorl %eax,%eax
30150 rep stosb
30151+ pax_force_retaddr
30152 ret
30153 CFI_ENDPROC
30154 ENDPROC(clear_page_c_e)
30155diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
30156index 40a1725..5d12ac4 100644
30157--- a/arch/x86/lib/cmpxchg16b_emu.S
30158+++ b/arch/x86/lib/cmpxchg16b_emu.S
30159@@ -8,6 +8,7 @@
30160 #include <linux/linkage.h>
30161 #include <asm/dwarf2.h>
30162 #include <asm/percpu.h>
30163+#include <asm/alternative-asm.h>
30164
30165 .text
30166
30167@@ -46,12 +47,14 @@ CFI_STARTPROC
30168 CFI_REMEMBER_STATE
30169 popfq_cfi
30170 mov $1, %al
30171+ pax_force_retaddr
30172 ret
30173
30174 CFI_RESTORE_STATE
30175 .Lnot_same:
30176 popfq_cfi
30177 xor %al,%al
30178+ pax_force_retaddr
30179 ret
30180
30181 CFI_ENDPROC
30182diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
30183index 8239dbc..e714d2a 100644
30184--- a/arch/x86/lib/copy_page_64.S
30185+++ b/arch/x86/lib/copy_page_64.S
30186@@ -17,6 +17,7 @@ ENTRY(copy_page)
30187 ALTERNATIVE "jmp copy_page_regs", "", X86_FEATURE_REP_GOOD
30188 movl $4096/8, %ecx
30189 rep movsq
30190+ pax_force_retaddr
30191 ret
30192 CFI_ENDPROC
30193 ENDPROC(copy_page)
30194@@ -27,8 +28,8 @@ ENTRY(copy_page_regs)
30195 CFI_ADJUST_CFA_OFFSET 2*8
30196 movq %rbx, (%rsp)
30197 CFI_REL_OFFSET rbx, 0
30198- movq %r12, 1*8(%rsp)
30199- CFI_REL_OFFSET r12, 1*8
30200+ movq %r13, 1*8(%rsp)
30201+ CFI_REL_OFFSET r13, 1*8
30202
30203 movl $(4096/64)-5, %ecx
30204 .p2align 4
30205@@ -41,7 +42,7 @@ ENTRY(copy_page_regs)
30206 movq 0x8*4(%rsi), %r9
30207 movq 0x8*5(%rsi), %r10
30208 movq 0x8*6(%rsi), %r11
30209- movq 0x8*7(%rsi), %r12
30210+ movq 0x8*7(%rsi), %r13
30211
30212 prefetcht0 5*64(%rsi)
30213
30214@@ -52,7 +53,7 @@ ENTRY(copy_page_regs)
30215 movq %r9, 0x8*4(%rdi)
30216 movq %r10, 0x8*5(%rdi)
30217 movq %r11, 0x8*6(%rdi)
30218- movq %r12, 0x8*7(%rdi)
30219+ movq %r13, 0x8*7(%rdi)
30220
30221 leaq 64 (%rsi), %rsi
30222 leaq 64 (%rdi), %rdi
30223@@ -71,7 +72,7 @@ ENTRY(copy_page_regs)
30224 movq 0x8*4(%rsi), %r9
30225 movq 0x8*5(%rsi), %r10
30226 movq 0x8*6(%rsi), %r11
30227- movq 0x8*7(%rsi), %r12
30228+ movq 0x8*7(%rsi), %r13
30229
30230 movq %rax, 0x8*0(%rdi)
30231 movq %rbx, 0x8*1(%rdi)
30232@@ -80,7 +81,7 @@ ENTRY(copy_page_regs)
30233 movq %r9, 0x8*4(%rdi)
30234 movq %r10, 0x8*5(%rdi)
30235 movq %r11, 0x8*6(%rdi)
30236- movq %r12, 0x8*7(%rdi)
30237+ movq %r13, 0x8*7(%rdi)
30238
30239 leaq 64(%rdi), %rdi
30240 leaq 64(%rsi), %rsi
30241@@ -88,10 +89,11 @@ ENTRY(copy_page_regs)
30242
30243 movq (%rsp), %rbx
30244 CFI_RESTORE rbx
30245- movq 1*8(%rsp), %r12
30246- CFI_RESTORE r12
30247+ movq 1*8(%rsp), %r13
30248+ CFI_RESTORE r13
30249 addq $2*8, %rsp
30250 CFI_ADJUST_CFA_OFFSET -2*8
30251+ pax_force_retaddr
30252 ret
30253 CFI_ENDPROC
30254 ENDPROC(copy_page_regs)
30255diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
30256index fa997df..060ab18 100644
30257--- a/arch/x86/lib/copy_user_64.S
30258+++ b/arch/x86/lib/copy_user_64.S
30259@@ -15,6 +15,7 @@
30260 #include <asm/alternative-asm.h>
30261 #include <asm/asm.h>
30262 #include <asm/smap.h>
30263+#include <asm/pgtable.h>
30264
30265 .macro ALIGN_DESTINATION
30266 /* check for bad alignment of destination */
30267@@ -40,56 +41,6 @@
30268 _ASM_EXTABLE(101b,103b)
30269 .endm
30270
30271-/* Standard copy_to_user with segment limit checking */
30272-ENTRY(_copy_to_user)
30273- CFI_STARTPROC
30274- GET_THREAD_INFO(%rax)
30275- movq %rdi,%rcx
30276- addq %rdx,%rcx
30277- jc bad_to_user
30278- cmpq TI_addr_limit(%rax),%rcx
30279- ja bad_to_user
30280- ALTERNATIVE_2 "jmp copy_user_generic_unrolled", \
30281- "jmp copy_user_generic_string", \
30282- X86_FEATURE_REP_GOOD, \
30283- "jmp copy_user_enhanced_fast_string", \
30284- X86_FEATURE_ERMS
30285- CFI_ENDPROC
30286-ENDPROC(_copy_to_user)
30287-
30288-/* Standard copy_from_user with segment limit checking */
30289-ENTRY(_copy_from_user)
30290- CFI_STARTPROC
30291- GET_THREAD_INFO(%rax)
30292- movq %rsi,%rcx
30293- addq %rdx,%rcx
30294- jc bad_from_user
30295- cmpq TI_addr_limit(%rax),%rcx
30296- ja bad_from_user
30297- ALTERNATIVE_2 "jmp copy_user_generic_unrolled", \
30298- "jmp copy_user_generic_string", \
30299- X86_FEATURE_REP_GOOD, \
30300- "jmp copy_user_enhanced_fast_string", \
30301- X86_FEATURE_ERMS
30302- CFI_ENDPROC
30303-ENDPROC(_copy_from_user)
30304-
30305- .section .fixup,"ax"
30306- /* must zero dest */
30307-ENTRY(bad_from_user)
30308-bad_from_user:
30309- CFI_STARTPROC
30310- movl %edx,%ecx
30311- xorl %eax,%eax
30312- rep
30313- stosb
30314-bad_to_user:
30315- movl %edx,%eax
30316- ret
30317- CFI_ENDPROC
30318-ENDPROC(bad_from_user)
30319- .previous
30320-
30321 /*
30322 * copy_user_generic_unrolled - memory copy with exception handling.
30323 * This version is for CPUs like P4 that don't have efficient micro
30324@@ -105,6 +56,7 @@ ENDPROC(bad_from_user)
30325 */
30326 ENTRY(copy_user_generic_unrolled)
30327 CFI_STARTPROC
30328+ ASM_PAX_OPEN_USERLAND
30329 ASM_STAC
30330 cmpl $8,%edx
30331 jb 20f /* less then 8 bytes, go to byte copy loop */
30332@@ -154,6 +106,8 @@ ENTRY(copy_user_generic_unrolled)
30333 jnz 21b
30334 23: xor %eax,%eax
30335 ASM_CLAC
30336+ ASM_PAX_CLOSE_USERLAND
30337+ pax_force_retaddr
30338 ret
30339
30340 .section .fixup,"ax"
30341@@ -209,6 +163,7 @@ ENDPROC(copy_user_generic_unrolled)
30342 */
30343 ENTRY(copy_user_generic_string)
30344 CFI_STARTPROC
30345+ ASM_PAX_OPEN_USERLAND
30346 ASM_STAC
30347 cmpl $8,%edx
30348 jb 2f /* less than 8 bytes, go to byte copy loop */
30349@@ -223,6 +178,8 @@ ENTRY(copy_user_generic_string)
30350 movsb
30351 xorl %eax,%eax
30352 ASM_CLAC
30353+ ASM_PAX_CLOSE_USERLAND
30354+ pax_force_retaddr
30355 ret
30356
30357 .section .fixup,"ax"
30358@@ -250,12 +207,15 @@ ENDPROC(copy_user_generic_string)
30359 */
30360 ENTRY(copy_user_enhanced_fast_string)
30361 CFI_STARTPROC
30362+ ASM_PAX_OPEN_USERLAND
30363 ASM_STAC
30364 movl %edx,%ecx
30365 1: rep
30366 movsb
30367 xorl %eax,%eax
30368 ASM_CLAC
30369+ ASM_PAX_CLOSE_USERLAND
30370+ pax_force_retaddr
30371 ret
30372
30373 .section .fixup,"ax"
30374diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
30375index 6a4f43c..c70fb52 100644
30376--- a/arch/x86/lib/copy_user_nocache_64.S
30377+++ b/arch/x86/lib/copy_user_nocache_64.S
30378@@ -8,6 +8,7 @@
30379
30380 #include <linux/linkage.h>
30381 #include <asm/dwarf2.h>
30382+#include <asm/alternative-asm.h>
30383
30384 #define FIX_ALIGNMENT 1
30385
30386@@ -16,6 +17,7 @@
30387 #include <asm/thread_info.h>
30388 #include <asm/asm.h>
30389 #include <asm/smap.h>
30390+#include <asm/pgtable.h>
30391
30392 .macro ALIGN_DESTINATION
30393 #ifdef FIX_ALIGNMENT
30394@@ -49,6 +51,16 @@
30395 */
30396 ENTRY(__copy_user_nocache)
30397 CFI_STARTPROC
30398+
30399+#ifdef CONFIG_PAX_MEMORY_UDEREF
30400+ mov pax_user_shadow_base,%rcx
30401+ cmp %rcx,%rsi
30402+ jae 1f
30403+ add %rcx,%rsi
30404+1:
30405+#endif
30406+
30407+ ASM_PAX_OPEN_USERLAND
30408 ASM_STAC
30409 cmpl $8,%edx
30410 jb 20f /* less then 8 bytes, go to byte copy loop */
30411@@ -98,7 +110,9 @@ ENTRY(__copy_user_nocache)
30412 jnz 21b
30413 23: xorl %eax,%eax
30414 ASM_CLAC
30415+ ASM_PAX_CLOSE_USERLAND
30416 sfence
30417+ pax_force_retaddr
30418 ret
30419
30420 .section .fixup,"ax"
30421diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
30422index 9734182..dbee61c 100644
30423--- a/arch/x86/lib/csum-copy_64.S
30424+++ b/arch/x86/lib/csum-copy_64.S
30425@@ -9,6 +9,7 @@
30426 #include <asm/dwarf2.h>
30427 #include <asm/errno.h>
30428 #include <asm/asm.h>
30429+#include <asm/alternative-asm.h>
30430
30431 /*
30432 * Checksum copy with exception handling.
30433@@ -56,8 +57,8 @@ ENTRY(csum_partial_copy_generic)
30434 CFI_ADJUST_CFA_OFFSET 7*8
30435 movq %rbx, 2*8(%rsp)
30436 CFI_REL_OFFSET rbx, 2*8
30437- movq %r12, 3*8(%rsp)
30438- CFI_REL_OFFSET r12, 3*8
30439+ movq %r15, 3*8(%rsp)
30440+ CFI_REL_OFFSET r15, 3*8
30441 movq %r14, 4*8(%rsp)
30442 CFI_REL_OFFSET r14, 4*8
30443 movq %r13, 5*8(%rsp)
30444@@ -72,16 +73,16 @@ ENTRY(csum_partial_copy_generic)
30445 movl %edx, %ecx
30446
30447 xorl %r9d, %r9d
30448- movq %rcx, %r12
30449+ movq %rcx, %r15
30450
30451- shrq $6, %r12
30452+ shrq $6, %r15
30453 jz .Lhandle_tail /* < 64 */
30454
30455 clc
30456
30457 /* main loop. clear in 64 byte blocks */
30458 /* r9: zero, r8: temp2, rbx: temp1, rax: sum, rcx: saved length */
30459- /* r11: temp3, rdx: temp4, r12 loopcnt */
30460+ /* r11: temp3, rdx: temp4, r15 loopcnt */
30461 /* r10: temp5, rbp: temp6, r14 temp7, r13 temp8 */
30462 .p2align 4
30463 .Lloop:
30464@@ -115,7 +116,7 @@ ENTRY(csum_partial_copy_generic)
30465 adcq %r14, %rax
30466 adcq %r13, %rax
30467
30468- decl %r12d
30469+ decl %r15d
30470
30471 dest
30472 movq %rbx, (%rsi)
30473@@ -210,8 +211,8 @@ ENTRY(csum_partial_copy_generic)
30474 .Lende:
30475 movq 2*8(%rsp), %rbx
30476 CFI_RESTORE rbx
30477- movq 3*8(%rsp), %r12
30478- CFI_RESTORE r12
30479+ movq 3*8(%rsp), %r15
30480+ CFI_RESTORE r15
30481 movq 4*8(%rsp), %r14
30482 CFI_RESTORE r14
30483 movq 5*8(%rsp), %r13
30484@@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
30485 CFI_RESTORE rbp
30486 addq $7*8, %rsp
30487 CFI_ADJUST_CFA_OFFSET -7*8
30488+ pax_force_retaddr
30489 ret
30490 CFI_RESTORE_STATE
30491
30492diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
30493index 1318f75..44c30fd 100644
30494--- a/arch/x86/lib/csum-wrappers_64.c
30495+++ b/arch/x86/lib/csum-wrappers_64.c
30496@@ -52,10 +52,12 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
30497 len -= 2;
30498 }
30499 }
30500+ pax_open_userland();
30501 stac();
30502- isum = csum_partial_copy_generic((__force const void *)src,
30503+ isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
30504 dst, len, isum, errp, NULL);
30505 clac();
30506+ pax_close_userland();
30507 if (unlikely(*errp))
30508 goto out_err;
30509
30510@@ -109,10 +111,12 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
30511 }
30512
30513 *errp = 0;
30514+ pax_open_userland();
30515 stac();
30516- ret = csum_partial_copy_generic(src, (void __force *)dst,
30517+ ret = csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
30518 len, isum, NULL, errp);
30519 clac();
30520+ pax_close_userland();
30521 return ret;
30522 }
30523 EXPORT_SYMBOL(csum_partial_copy_to_user);
30524diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
30525index a451235..a74bfa3 100644
30526--- a/arch/x86/lib/getuser.S
30527+++ b/arch/x86/lib/getuser.S
30528@@ -33,17 +33,40 @@
30529 #include <asm/thread_info.h>
30530 #include <asm/asm.h>
30531 #include <asm/smap.h>
30532+#include <asm/segment.h>
30533+#include <asm/pgtable.h>
30534+#include <asm/alternative-asm.h>
30535+
30536+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
30537+#define __copyuser_seg gs;
30538+#else
30539+#define __copyuser_seg
30540+#endif
30541
30542 .text
30543 ENTRY(__get_user_1)
30544 CFI_STARTPROC
30545+
30546+#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
30547 GET_THREAD_INFO(%_ASM_DX)
30548 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
30549 jae bad_get_user
30550+
30551+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
30552+ mov pax_user_shadow_base,%_ASM_DX
30553+ cmp %_ASM_DX,%_ASM_AX
30554+ jae 1234f
30555+ add %_ASM_DX,%_ASM_AX
30556+1234:
30557+#endif
30558+
30559+#endif
30560+
30561 ASM_STAC
30562-1: movzbl (%_ASM_AX),%edx
30563+1: __copyuser_seg movzbl (%_ASM_AX),%edx
30564 xor %eax,%eax
30565 ASM_CLAC
30566+ pax_force_retaddr
30567 ret
30568 CFI_ENDPROC
30569 ENDPROC(__get_user_1)
30570@@ -51,14 +74,28 @@ ENDPROC(__get_user_1)
30571 ENTRY(__get_user_2)
30572 CFI_STARTPROC
30573 add $1,%_ASM_AX
30574+
30575+#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
30576 jc bad_get_user
30577 GET_THREAD_INFO(%_ASM_DX)
30578 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
30579 jae bad_get_user
30580+
30581+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
30582+ mov pax_user_shadow_base,%_ASM_DX
30583+ cmp %_ASM_DX,%_ASM_AX
30584+ jae 1234f
30585+ add %_ASM_DX,%_ASM_AX
30586+1234:
30587+#endif
30588+
30589+#endif
30590+
30591 ASM_STAC
30592-2: movzwl -1(%_ASM_AX),%edx
30593+2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
30594 xor %eax,%eax
30595 ASM_CLAC
30596+ pax_force_retaddr
30597 ret
30598 CFI_ENDPROC
30599 ENDPROC(__get_user_2)
30600@@ -66,14 +103,28 @@ ENDPROC(__get_user_2)
30601 ENTRY(__get_user_4)
30602 CFI_STARTPROC
30603 add $3,%_ASM_AX
30604+
30605+#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
30606 jc bad_get_user
30607 GET_THREAD_INFO(%_ASM_DX)
30608 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
30609 jae bad_get_user
30610+
30611+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
30612+ mov pax_user_shadow_base,%_ASM_DX
30613+ cmp %_ASM_DX,%_ASM_AX
30614+ jae 1234f
30615+ add %_ASM_DX,%_ASM_AX
30616+1234:
30617+#endif
30618+
30619+#endif
30620+
30621 ASM_STAC
30622-3: movl -3(%_ASM_AX),%edx
30623+3: __copyuser_seg movl -3(%_ASM_AX),%edx
30624 xor %eax,%eax
30625 ASM_CLAC
30626+ pax_force_retaddr
30627 ret
30628 CFI_ENDPROC
30629 ENDPROC(__get_user_4)
30630@@ -86,10 +137,20 @@ ENTRY(__get_user_8)
30631 GET_THREAD_INFO(%_ASM_DX)
30632 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
30633 jae bad_get_user
30634+
30635+#ifdef CONFIG_PAX_MEMORY_UDEREF
30636+ mov pax_user_shadow_base,%_ASM_DX
30637+ cmp %_ASM_DX,%_ASM_AX
30638+ jae 1234f
30639+ add %_ASM_DX,%_ASM_AX
30640+1234:
30641+#endif
30642+
30643 ASM_STAC
30644 4: movq -7(%_ASM_AX),%rdx
30645 xor %eax,%eax
30646 ASM_CLAC
30647+ pax_force_retaddr
30648 ret
30649 #else
30650 add $7,%_ASM_AX
30651@@ -98,10 +159,11 @@ ENTRY(__get_user_8)
30652 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
30653 jae bad_get_user_8
30654 ASM_STAC
30655-4: movl -7(%_ASM_AX),%edx
30656-5: movl -3(%_ASM_AX),%ecx
30657+4: __copyuser_seg movl -7(%_ASM_AX),%edx
30658+5: __copyuser_seg movl -3(%_ASM_AX),%ecx
30659 xor %eax,%eax
30660 ASM_CLAC
30661+ pax_force_retaddr
30662 ret
30663 #endif
30664 CFI_ENDPROC
30665@@ -113,6 +175,7 @@ bad_get_user:
30666 xor %edx,%edx
30667 mov $(-EFAULT),%_ASM_AX
30668 ASM_CLAC
30669+ pax_force_retaddr
30670 ret
30671 CFI_ENDPROC
30672 END(bad_get_user)
30673@@ -124,6 +187,7 @@ bad_get_user_8:
30674 xor %ecx,%ecx
30675 mov $(-EFAULT),%_ASM_AX
30676 ASM_CLAC
30677+ pax_force_retaddr
30678 ret
30679 CFI_ENDPROC
30680 END(bad_get_user_8)
30681diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
30682index 8f72b33..a43d9969 100644
30683--- a/arch/x86/lib/insn.c
30684+++ b/arch/x86/lib/insn.c
30685@@ -20,8 +20,10 @@
30686
30687 #ifdef __KERNEL__
30688 #include <linux/string.h>
30689+#include <asm/pgtable_types.h>
30690 #else
30691 #include <string.h>
30692+#define ktla_ktva(addr) addr
30693 #endif
30694 #include <asm/inat.h>
30695 #include <asm/insn.h>
30696@@ -60,9 +62,9 @@ void insn_init(struct insn *insn, const void *kaddr, int buf_len, int x86_64)
30697 buf_len = MAX_INSN_SIZE;
30698
30699 memset(insn, 0, sizeof(*insn));
30700- insn->kaddr = kaddr;
30701- insn->end_kaddr = kaddr + buf_len;
30702- insn->next_byte = kaddr;
30703+ insn->kaddr = ktla_ktva(kaddr);
30704+ insn->end_kaddr = insn->kaddr + buf_len;
30705+ insn->next_byte = insn->kaddr;
30706 insn->x86_64 = x86_64 ? 1 : 0;
30707 insn->opnd_bytes = 4;
30708 if (x86_64)
30709diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
30710index 05a95e7..326f2fa 100644
30711--- a/arch/x86/lib/iomap_copy_64.S
30712+++ b/arch/x86/lib/iomap_copy_64.S
30713@@ -17,6 +17,7 @@
30714
30715 #include <linux/linkage.h>
30716 #include <asm/dwarf2.h>
30717+#include <asm/alternative-asm.h>
30718
30719 /*
30720 * override generic version in lib/iomap_copy.c
30721@@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
30722 CFI_STARTPROC
30723 movl %edx,%ecx
30724 rep movsd
30725+ pax_force_retaddr
30726 ret
30727 CFI_ENDPROC
30728 ENDPROC(__iowrite32_copy)
30729diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
30730index b046664..dec9465 100644
30731--- a/arch/x86/lib/memcpy_64.S
30732+++ b/arch/x86/lib/memcpy_64.S
30733@@ -37,6 +37,7 @@ ENTRY(memcpy)
30734 rep movsq
30735 movl %edx, %ecx
30736 rep movsb
30737+ pax_force_retaddr
30738 ret
30739 ENDPROC(memcpy)
30740 ENDPROC(__memcpy)
30741@@ -49,6 +50,7 @@ ENTRY(memcpy_erms)
30742 movq %rdi, %rax
30743 movq %rdx, %rcx
30744 rep movsb
30745+ pax_force_retaddr
30746 ret
30747 ENDPROC(memcpy_erms)
30748
30749@@ -134,6 +136,7 @@ ENTRY(memcpy_orig)
30750 movq %r9, 1*8(%rdi)
30751 movq %r10, -2*8(%rdi, %rdx)
30752 movq %r11, -1*8(%rdi, %rdx)
30753+ pax_force_retaddr
30754 retq
30755 .p2align 4
30756 .Lless_16bytes:
30757@@ -146,6 +149,7 @@ ENTRY(memcpy_orig)
30758 movq -1*8(%rsi, %rdx), %r9
30759 movq %r8, 0*8(%rdi)
30760 movq %r9, -1*8(%rdi, %rdx)
30761+ pax_force_retaddr
30762 retq
30763 .p2align 4
30764 .Lless_8bytes:
30765@@ -159,6 +163,7 @@ ENTRY(memcpy_orig)
30766 movl -4(%rsi, %rdx), %r8d
30767 movl %ecx, (%rdi)
30768 movl %r8d, -4(%rdi, %rdx)
30769+ pax_force_retaddr
30770 retq
30771 .p2align 4
30772 .Lless_3bytes:
30773@@ -177,6 +182,7 @@ ENTRY(memcpy_orig)
30774 movb %cl, (%rdi)
30775
30776 .Lend:
30777+ pax_force_retaddr
30778 retq
30779 CFI_ENDPROC
30780 ENDPROC(memcpy_orig)
30781diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
30782index 0f8a0d0..f6e0ea4 100644
30783--- a/arch/x86/lib/memmove_64.S
30784+++ b/arch/x86/lib/memmove_64.S
30785@@ -43,7 +43,7 @@ ENTRY(__memmove)
30786 jg 2f
30787
30788 .Lmemmove_begin_forward:
30789- ALTERNATIVE "", "movq %rdx, %rcx; rep movsb; retq", X86_FEATURE_ERMS
30790+ ALTERNATIVE "", "movq %rdx, %rcx; rep movsb; pax_force_retaddr; retq", X86_FEATURE_ERMS
30791
30792 /*
30793 * movsq instruction have many startup latency
30794@@ -206,6 +206,7 @@ ENTRY(__memmove)
30795 movb (%rsi), %r11b
30796 movb %r11b, (%rdi)
30797 13:
30798+ pax_force_retaddr
30799 retq
30800 CFI_ENDPROC
30801 ENDPROC(__memmove)
30802diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
30803index 93118fb..386ed2a 100644
30804--- a/arch/x86/lib/memset_64.S
30805+++ b/arch/x86/lib/memset_64.S
30806@@ -41,6 +41,7 @@ ENTRY(__memset)
30807 movl %edx,%ecx
30808 rep stosb
30809 movq %r9,%rax
30810+ pax_force_retaddr
30811 ret
30812 ENDPROC(memset)
30813 ENDPROC(__memset)
30814@@ -62,6 +63,7 @@ ENTRY(memset_erms)
30815 movq %rdx,%rcx
30816 rep stosb
30817 movq %r9,%rax
30818+ pax_force_retaddr
30819 ret
30820 ENDPROC(memset_erms)
30821
30822@@ -126,6 +128,7 @@ ENTRY(memset_orig)
30823
30824 .Lende:
30825 movq %r10,%rax
30826+ pax_force_retaddr
30827 ret
30828
30829 CFI_RESTORE_STATE
30830diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
30831index c9f2d9b..e7fd2c0 100644
30832--- a/arch/x86/lib/mmx_32.c
30833+++ b/arch/x86/lib/mmx_32.c
30834@@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
30835 {
30836 void *p;
30837 int i;
30838+ unsigned long cr0;
30839
30840 if (unlikely(in_interrupt()))
30841 return __memcpy(to, from, len);
30842@@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
30843 kernel_fpu_begin();
30844
30845 __asm__ __volatile__ (
30846- "1: prefetch (%0)\n" /* This set is 28 bytes */
30847- " prefetch 64(%0)\n"
30848- " prefetch 128(%0)\n"
30849- " prefetch 192(%0)\n"
30850- " prefetch 256(%0)\n"
30851+ "1: prefetch (%1)\n" /* This set is 28 bytes */
30852+ " prefetch 64(%1)\n"
30853+ " prefetch 128(%1)\n"
30854+ " prefetch 192(%1)\n"
30855+ " prefetch 256(%1)\n"
30856 "2: \n"
30857 ".section .fixup, \"ax\"\n"
30858- "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
30859+ "3: \n"
30860+
30861+#ifdef CONFIG_PAX_KERNEXEC
30862+ " movl %%cr0, %0\n"
30863+ " movl %0, %%eax\n"
30864+ " andl $0xFFFEFFFF, %%eax\n"
30865+ " movl %%eax, %%cr0\n"
30866+#endif
30867+
30868+ " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
30869+
30870+#ifdef CONFIG_PAX_KERNEXEC
30871+ " movl %0, %%cr0\n"
30872+#endif
30873+
30874 " jmp 2b\n"
30875 ".previous\n"
30876 _ASM_EXTABLE(1b, 3b)
30877- : : "r" (from));
30878+ : "=&r" (cr0) : "r" (from) : "ax");
30879
30880 for ( ; i > 5; i--) {
30881 __asm__ __volatile__ (
30882- "1: prefetch 320(%0)\n"
30883- "2: movq (%0), %%mm0\n"
30884- " movq 8(%0), %%mm1\n"
30885- " movq 16(%0), %%mm2\n"
30886- " movq 24(%0), %%mm3\n"
30887- " movq %%mm0, (%1)\n"
30888- " movq %%mm1, 8(%1)\n"
30889- " movq %%mm2, 16(%1)\n"
30890- " movq %%mm3, 24(%1)\n"
30891- " movq 32(%0), %%mm0\n"
30892- " movq 40(%0), %%mm1\n"
30893- " movq 48(%0), %%mm2\n"
30894- " movq 56(%0), %%mm3\n"
30895- " movq %%mm0, 32(%1)\n"
30896- " movq %%mm1, 40(%1)\n"
30897- " movq %%mm2, 48(%1)\n"
30898- " movq %%mm3, 56(%1)\n"
30899+ "1: prefetch 320(%1)\n"
30900+ "2: movq (%1), %%mm0\n"
30901+ " movq 8(%1), %%mm1\n"
30902+ " movq 16(%1), %%mm2\n"
30903+ " movq 24(%1), %%mm3\n"
30904+ " movq %%mm0, (%2)\n"
30905+ " movq %%mm1, 8(%2)\n"
30906+ " movq %%mm2, 16(%2)\n"
30907+ " movq %%mm3, 24(%2)\n"
30908+ " movq 32(%1), %%mm0\n"
30909+ " movq 40(%1), %%mm1\n"
30910+ " movq 48(%1), %%mm2\n"
30911+ " movq 56(%1), %%mm3\n"
30912+ " movq %%mm0, 32(%2)\n"
30913+ " movq %%mm1, 40(%2)\n"
30914+ " movq %%mm2, 48(%2)\n"
30915+ " movq %%mm3, 56(%2)\n"
30916 ".section .fixup, \"ax\"\n"
30917- "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
30918+ "3:\n"
30919+
30920+#ifdef CONFIG_PAX_KERNEXEC
30921+ " movl %%cr0, %0\n"
30922+ " movl %0, %%eax\n"
30923+ " andl $0xFFFEFFFF, %%eax\n"
30924+ " movl %%eax, %%cr0\n"
30925+#endif
30926+
30927+ " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
30928+
30929+#ifdef CONFIG_PAX_KERNEXEC
30930+ " movl %0, %%cr0\n"
30931+#endif
30932+
30933 " jmp 2b\n"
30934 ".previous\n"
30935 _ASM_EXTABLE(1b, 3b)
30936- : : "r" (from), "r" (to) : "memory");
30937+ : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
30938
30939 from += 64;
30940 to += 64;
30941@@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
30942 static void fast_copy_page(void *to, void *from)
30943 {
30944 int i;
30945+ unsigned long cr0;
30946
30947 kernel_fpu_begin();
30948
30949@@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
30950 * but that is for later. -AV
30951 */
30952 __asm__ __volatile__(
30953- "1: prefetch (%0)\n"
30954- " prefetch 64(%0)\n"
30955- " prefetch 128(%0)\n"
30956- " prefetch 192(%0)\n"
30957- " prefetch 256(%0)\n"
30958+ "1: prefetch (%1)\n"
30959+ " prefetch 64(%1)\n"
30960+ " prefetch 128(%1)\n"
30961+ " prefetch 192(%1)\n"
30962+ " prefetch 256(%1)\n"
30963 "2: \n"
30964 ".section .fixup, \"ax\"\n"
30965- "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
30966+ "3: \n"
30967+
30968+#ifdef CONFIG_PAX_KERNEXEC
30969+ " movl %%cr0, %0\n"
30970+ " movl %0, %%eax\n"
30971+ " andl $0xFFFEFFFF, %%eax\n"
30972+ " movl %%eax, %%cr0\n"
30973+#endif
30974+
30975+ " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
30976+
30977+#ifdef CONFIG_PAX_KERNEXEC
30978+ " movl %0, %%cr0\n"
30979+#endif
30980+
30981 " jmp 2b\n"
30982 ".previous\n"
30983- _ASM_EXTABLE(1b, 3b) : : "r" (from));
30984+ _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
30985
30986 for (i = 0; i < (4096-320)/64; i++) {
30987 __asm__ __volatile__ (
30988- "1: prefetch 320(%0)\n"
30989- "2: movq (%0), %%mm0\n"
30990- " movntq %%mm0, (%1)\n"
30991- " movq 8(%0), %%mm1\n"
30992- " movntq %%mm1, 8(%1)\n"
30993- " movq 16(%0), %%mm2\n"
30994- " movntq %%mm2, 16(%1)\n"
30995- " movq 24(%0), %%mm3\n"
30996- " movntq %%mm3, 24(%1)\n"
30997- " movq 32(%0), %%mm4\n"
30998- " movntq %%mm4, 32(%1)\n"
30999- " movq 40(%0), %%mm5\n"
31000- " movntq %%mm5, 40(%1)\n"
31001- " movq 48(%0), %%mm6\n"
31002- " movntq %%mm6, 48(%1)\n"
31003- " movq 56(%0), %%mm7\n"
31004- " movntq %%mm7, 56(%1)\n"
31005+ "1: prefetch 320(%1)\n"
31006+ "2: movq (%1), %%mm0\n"
31007+ " movntq %%mm0, (%2)\n"
31008+ " movq 8(%1), %%mm1\n"
31009+ " movntq %%mm1, 8(%2)\n"
31010+ " movq 16(%1), %%mm2\n"
31011+ " movntq %%mm2, 16(%2)\n"
31012+ " movq 24(%1), %%mm3\n"
31013+ " movntq %%mm3, 24(%2)\n"
31014+ " movq 32(%1), %%mm4\n"
31015+ " movntq %%mm4, 32(%2)\n"
31016+ " movq 40(%1), %%mm5\n"
31017+ " movntq %%mm5, 40(%2)\n"
31018+ " movq 48(%1), %%mm6\n"
31019+ " movntq %%mm6, 48(%2)\n"
31020+ " movq 56(%1), %%mm7\n"
31021+ " movntq %%mm7, 56(%2)\n"
31022 ".section .fixup, \"ax\"\n"
31023- "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
31024+ "3:\n"
31025+
31026+#ifdef CONFIG_PAX_KERNEXEC
31027+ " movl %%cr0, %0\n"
31028+ " movl %0, %%eax\n"
31029+ " andl $0xFFFEFFFF, %%eax\n"
31030+ " movl %%eax, %%cr0\n"
31031+#endif
31032+
31033+ " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
31034+
31035+#ifdef CONFIG_PAX_KERNEXEC
31036+ " movl %0, %%cr0\n"
31037+#endif
31038+
31039 " jmp 2b\n"
31040 ".previous\n"
31041- _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
31042+ _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
31043
31044 from += 64;
31045 to += 64;
31046@@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
31047 static void fast_copy_page(void *to, void *from)
31048 {
31049 int i;
31050+ unsigned long cr0;
31051
31052 kernel_fpu_begin();
31053
31054 __asm__ __volatile__ (
31055- "1: prefetch (%0)\n"
31056- " prefetch 64(%0)\n"
31057- " prefetch 128(%0)\n"
31058- " prefetch 192(%0)\n"
31059- " prefetch 256(%0)\n"
31060+ "1: prefetch (%1)\n"
31061+ " prefetch 64(%1)\n"
31062+ " prefetch 128(%1)\n"
31063+ " prefetch 192(%1)\n"
31064+ " prefetch 256(%1)\n"
31065 "2: \n"
31066 ".section .fixup, \"ax\"\n"
31067- "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
31068+ "3: \n"
31069+
31070+#ifdef CONFIG_PAX_KERNEXEC
31071+ " movl %%cr0, %0\n"
31072+ " movl %0, %%eax\n"
31073+ " andl $0xFFFEFFFF, %%eax\n"
31074+ " movl %%eax, %%cr0\n"
31075+#endif
31076+
31077+ " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
31078+
31079+#ifdef CONFIG_PAX_KERNEXEC
31080+ " movl %0, %%cr0\n"
31081+#endif
31082+
31083 " jmp 2b\n"
31084 ".previous\n"
31085- _ASM_EXTABLE(1b, 3b) : : "r" (from));
31086+ _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
31087
31088 for (i = 0; i < 4096/64; i++) {
31089 __asm__ __volatile__ (
31090- "1: prefetch 320(%0)\n"
31091- "2: movq (%0), %%mm0\n"
31092- " movq 8(%0), %%mm1\n"
31093- " movq 16(%0), %%mm2\n"
31094- " movq 24(%0), %%mm3\n"
31095- " movq %%mm0, (%1)\n"
31096- " movq %%mm1, 8(%1)\n"
31097- " movq %%mm2, 16(%1)\n"
31098- " movq %%mm3, 24(%1)\n"
31099- " movq 32(%0), %%mm0\n"
31100- " movq 40(%0), %%mm1\n"
31101- " movq 48(%0), %%mm2\n"
31102- " movq 56(%0), %%mm3\n"
31103- " movq %%mm0, 32(%1)\n"
31104- " movq %%mm1, 40(%1)\n"
31105- " movq %%mm2, 48(%1)\n"
31106- " movq %%mm3, 56(%1)\n"
31107+ "1: prefetch 320(%1)\n"
31108+ "2: movq (%1), %%mm0\n"
31109+ " movq 8(%1), %%mm1\n"
31110+ " movq 16(%1), %%mm2\n"
31111+ " movq 24(%1), %%mm3\n"
31112+ " movq %%mm0, (%2)\n"
31113+ " movq %%mm1, 8(%2)\n"
31114+ " movq %%mm2, 16(%2)\n"
31115+ " movq %%mm3, 24(%2)\n"
31116+ " movq 32(%1), %%mm0\n"
31117+ " movq 40(%1), %%mm1\n"
31118+ " movq 48(%1), %%mm2\n"
31119+ " movq 56(%1), %%mm3\n"
31120+ " movq %%mm0, 32(%2)\n"
31121+ " movq %%mm1, 40(%2)\n"
31122+ " movq %%mm2, 48(%2)\n"
31123+ " movq %%mm3, 56(%2)\n"
31124 ".section .fixup, \"ax\"\n"
31125- "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
31126+ "3:\n"
31127+
31128+#ifdef CONFIG_PAX_KERNEXEC
31129+ " movl %%cr0, %0\n"
31130+ " movl %0, %%eax\n"
31131+ " andl $0xFFFEFFFF, %%eax\n"
31132+ " movl %%eax, %%cr0\n"
31133+#endif
31134+
31135+ " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
31136+
31137+#ifdef CONFIG_PAX_KERNEXEC
31138+ " movl %0, %%cr0\n"
31139+#endif
31140+
31141 " jmp 2b\n"
31142 ".previous\n"
31143 _ASM_EXTABLE(1b, 3b)
31144- : : "r" (from), "r" (to) : "memory");
31145+ : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
31146
31147 from += 64;
31148 to += 64;
31149diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
31150index 3ca5218..c2ae6bc 100644
31151--- a/arch/x86/lib/msr-reg.S
31152+++ b/arch/x86/lib/msr-reg.S
31153@@ -3,6 +3,7 @@
31154 #include <asm/dwarf2.h>
31155 #include <asm/asm.h>
31156 #include <asm/msr.h>
31157+#include <asm/alternative-asm.h>
31158
31159 #ifdef CONFIG_X86_64
31160 /*
31161@@ -37,6 +38,7 @@ ENTRY(\op\()_safe_regs)
31162 movl %edi, 28(%r10)
31163 popq_cfi_reg rbp
31164 popq_cfi_reg rbx
31165+ pax_force_retaddr
31166 ret
31167 3:
31168 CFI_RESTORE_STATE
31169diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
31170index fc6ba17..14ad9a5 100644
31171--- a/arch/x86/lib/putuser.S
31172+++ b/arch/x86/lib/putuser.S
31173@@ -16,7 +16,9 @@
31174 #include <asm/errno.h>
31175 #include <asm/asm.h>
31176 #include <asm/smap.h>
31177-
31178+#include <asm/segment.h>
31179+#include <asm/pgtable.h>
31180+#include <asm/alternative-asm.h>
31181
31182 /*
31183 * __put_user_X
31184@@ -30,57 +32,125 @@
31185 * as they get called from within inline assembly.
31186 */
31187
31188-#define ENTER CFI_STARTPROC ; \
31189- GET_THREAD_INFO(%_ASM_BX)
31190-#define EXIT ASM_CLAC ; \
31191- ret ; \
31192+#define ENTER CFI_STARTPROC
31193+#define EXIT ASM_CLAC ; \
31194+ pax_force_retaddr ; \
31195+ ret ; \
31196 CFI_ENDPROC
31197
31198+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31199+#define _DEST %_ASM_CX,%_ASM_BX
31200+#else
31201+#define _DEST %_ASM_CX
31202+#endif
31203+
31204+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
31205+#define __copyuser_seg gs;
31206+#else
31207+#define __copyuser_seg
31208+#endif
31209+
31210 .text
31211 ENTRY(__put_user_1)
31212 ENTER
31213+
31214+#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
31215+ GET_THREAD_INFO(%_ASM_BX)
31216 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
31217 jae bad_put_user
31218+
31219+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31220+ mov pax_user_shadow_base,%_ASM_BX
31221+ cmp %_ASM_BX,%_ASM_CX
31222+ jb 1234f
31223+ xor %ebx,%ebx
31224+1234:
31225+#endif
31226+
31227+#endif
31228+
31229 ASM_STAC
31230-1: movb %al,(%_ASM_CX)
31231+1: __copyuser_seg movb %al,(_DEST)
31232 xor %eax,%eax
31233 EXIT
31234 ENDPROC(__put_user_1)
31235
31236 ENTRY(__put_user_2)
31237 ENTER
31238+
31239+#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
31240+ GET_THREAD_INFO(%_ASM_BX)
31241 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
31242 sub $1,%_ASM_BX
31243 cmp %_ASM_BX,%_ASM_CX
31244 jae bad_put_user
31245+
31246+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31247+ mov pax_user_shadow_base,%_ASM_BX
31248+ cmp %_ASM_BX,%_ASM_CX
31249+ jb 1234f
31250+ xor %ebx,%ebx
31251+1234:
31252+#endif
31253+
31254+#endif
31255+
31256 ASM_STAC
31257-2: movw %ax,(%_ASM_CX)
31258+2: __copyuser_seg movw %ax,(_DEST)
31259 xor %eax,%eax
31260 EXIT
31261 ENDPROC(__put_user_2)
31262
31263 ENTRY(__put_user_4)
31264 ENTER
31265+
31266+#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
31267+ GET_THREAD_INFO(%_ASM_BX)
31268 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
31269 sub $3,%_ASM_BX
31270 cmp %_ASM_BX,%_ASM_CX
31271 jae bad_put_user
31272+
31273+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31274+ mov pax_user_shadow_base,%_ASM_BX
31275+ cmp %_ASM_BX,%_ASM_CX
31276+ jb 1234f
31277+ xor %ebx,%ebx
31278+1234:
31279+#endif
31280+
31281+#endif
31282+
31283 ASM_STAC
31284-3: movl %eax,(%_ASM_CX)
31285+3: __copyuser_seg movl %eax,(_DEST)
31286 xor %eax,%eax
31287 EXIT
31288 ENDPROC(__put_user_4)
31289
31290 ENTRY(__put_user_8)
31291 ENTER
31292+
31293+#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
31294+ GET_THREAD_INFO(%_ASM_BX)
31295 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
31296 sub $7,%_ASM_BX
31297 cmp %_ASM_BX,%_ASM_CX
31298 jae bad_put_user
31299+
31300+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31301+ mov pax_user_shadow_base,%_ASM_BX
31302+ cmp %_ASM_BX,%_ASM_CX
31303+ jb 1234f
31304+ xor %ebx,%ebx
31305+1234:
31306+#endif
31307+
31308+#endif
31309+
31310 ASM_STAC
31311-4: mov %_ASM_AX,(%_ASM_CX)
31312+4: __copyuser_seg mov %_ASM_AX,(_DEST)
31313 #ifdef CONFIG_X86_32
31314-5: movl %edx,4(%_ASM_CX)
31315+5: __copyuser_seg movl %edx,4(_DEST)
31316 #endif
31317 xor %eax,%eax
31318 EXIT
31319diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
31320index 2322abe..1e78a75 100644
31321--- a/arch/x86/lib/rwsem.S
31322+++ b/arch/x86/lib/rwsem.S
31323@@ -92,6 +92,7 @@ ENTRY(call_rwsem_down_read_failed)
31324 call rwsem_down_read_failed
31325 __ASM_SIZE(pop,_cfi_reg) __ASM_REG(dx)
31326 restore_common_regs
31327+ pax_force_retaddr
31328 ret
31329 CFI_ENDPROC
31330 ENDPROC(call_rwsem_down_read_failed)
31331@@ -102,6 +103,7 @@ ENTRY(call_rwsem_down_write_failed)
31332 movq %rax,%rdi
31333 call rwsem_down_write_failed
31334 restore_common_regs
31335+ pax_force_retaddr
31336 ret
31337 CFI_ENDPROC
31338 ENDPROC(call_rwsem_down_write_failed)
31339@@ -115,7 +117,8 @@ ENTRY(call_rwsem_wake)
31340 movq %rax,%rdi
31341 call rwsem_wake
31342 restore_common_regs
31343-1: ret
31344+1: pax_force_retaddr
31345+ ret
31346 CFI_ENDPROC
31347 ENDPROC(call_rwsem_wake)
31348
31349@@ -127,6 +130,7 @@ ENTRY(call_rwsem_downgrade_wake)
31350 call rwsem_downgrade_wake
31351 __ASM_SIZE(pop,_cfi_reg) __ASM_REG(dx)
31352 restore_common_regs
31353+ pax_force_retaddr
31354 ret
31355 CFI_ENDPROC
31356 ENDPROC(call_rwsem_downgrade_wake)
31357diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
31358index f89ba4e9..512b2de 100644
31359--- a/arch/x86/lib/thunk_64.S
31360+++ b/arch/x86/lib/thunk_64.S
31361@@ -9,6 +9,7 @@
31362 #include <asm/dwarf2.h>
31363 #include <asm/calling.h>
31364 #include <asm/asm.h>
31365+#include <asm/alternative-asm.h>
31366
31367 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
31368 .macro THUNK name, func, put_ret_addr_in_rdi=0
31369@@ -69,6 +70,7 @@ restore:
31370 popq_cfi_reg rdx
31371 popq_cfi_reg rsi
31372 popq_cfi_reg rdi
31373+ pax_force_retaddr
31374 ret
31375 CFI_ENDPROC
31376 _ASM_NOKPROBE(restore)
31377diff --git a/arch/x86/lib/usercopy.c b/arch/x86/lib/usercopy.c
31378index ddf9ecb..e342586 100644
31379--- a/arch/x86/lib/usercopy.c
31380+++ b/arch/x86/lib/usercopy.c
31381@@ -20,7 +20,7 @@ copy_from_user_nmi(void *to, const void __user *from, unsigned long n)
31382 unsigned long ret;
31383
31384 if (__range_not_ok(from, n, TASK_SIZE))
31385- return 0;
31386+ return n;
31387
31388 /*
31389 * Even though this function is typically called from NMI/IRQ context
31390diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
31391index e2f5e21..4b22130 100644
31392--- a/arch/x86/lib/usercopy_32.c
31393+++ b/arch/x86/lib/usercopy_32.c
31394@@ -42,11 +42,13 @@ do { \
31395 int __d0; \
31396 might_fault(); \
31397 __asm__ __volatile__( \
31398+ __COPYUSER_SET_ES \
31399 ASM_STAC "\n" \
31400 "0: rep; stosl\n" \
31401 " movl %2,%0\n" \
31402 "1: rep; stosb\n" \
31403 "2: " ASM_CLAC "\n" \
31404+ __COPYUSER_RESTORE_ES \
31405 ".section .fixup,\"ax\"\n" \
31406 "3: lea 0(%2,%0,4),%0\n" \
31407 " jmp 2b\n" \
31408@@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
31409
31410 #ifdef CONFIG_X86_INTEL_USERCOPY
31411 static unsigned long
31412-__copy_user_intel(void __user *to, const void *from, unsigned long size)
31413+__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
31414 {
31415 int d0, d1;
31416 __asm__ __volatile__(
31417@@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
31418 " .align 2,0x90\n"
31419 "3: movl 0(%4), %%eax\n"
31420 "4: movl 4(%4), %%edx\n"
31421- "5: movl %%eax, 0(%3)\n"
31422- "6: movl %%edx, 4(%3)\n"
31423+ "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
31424+ "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
31425 "7: movl 8(%4), %%eax\n"
31426 "8: movl 12(%4),%%edx\n"
31427- "9: movl %%eax, 8(%3)\n"
31428- "10: movl %%edx, 12(%3)\n"
31429+ "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
31430+ "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
31431 "11: movl 16(%4), %%eax\n"
31432 "12: movl 20(%4), %%edx\n"
31433- "13: movl %%eax, 16(%3)\n"
31434- "14: movl %%edx, 20(%3)\n"
31435+ "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
31436+ "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
31437 "15: movl 24(%4), %%eax\n"
31438 "16: movl 28(%4), %%edx\n"
31439- "17: movl %%eax, 24(%3)\n"
31440- "18: movl %%edx, 28(%3)\n"
31441+ "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
31442+ "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
31443 "19: movl 32(%4), %%eax\n"
31444 "20: movl 36(%4), %%edx\n"
31445- "21: movl %%eax, 32(%3)\n"
31446- "22: movl %%edx, 36(%3)\n"
31447+ "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
31448+ "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
31449 "23: movl 40(%4), %%eax\n"
31450 "24: movl 44(%4), %%edx\n"
31451- "25: movl %%eax, 40(%3)\n"
31452- "26: movl %%edx, 44(%3)\n"
31453+ "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
31454+ "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
31455 "27: movl 48(%4), %%eax\n"
31456 "28: movl 52(%4), %%edx\n"
31457- "29: movl %%eax, 48(%3)\n"
31458- "30: movl %%edx, 52(%3)\n"
31459+ "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
31460+ "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
31461 "31: movl 56(%4), %%eax\n"
31462 "32: movl 60(%4), %%edx\n"
31463- "33: movl %%eax, 56(%3)\n"
31464- "34: movl %%edx, 60(%3)\n"
31465+ "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
31466+ "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
31467 " addl $-64, %0\n"
31468 " addl $64, %4\n"
31469 " addl $64, %3\n"
31470@@ -149,10 +151,116 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
31471 " shrl $2, %0\n"
31472 " andl $3, %%eax\n"
31473 " cld\n"
31474+ __COPYUSER_SET_ES
31475 "99: rep; movsl\n"
31476 "36: movl %%eax, %0\n"
31477 "37: rep; movsb\n"
31478 "100:\n"
31479+ __COPYUSER_RESTORE_ES
31480+ ".section .fixup,\"ax\"\n"
31481+ "101: lea 0(%%eax,%0,4),%0\n"
31482+ " jmp 100b\n"
31483+ ".previous\n"
31484+ _ASM_EXTABLE(1b,100b)
31485+ _ASM_EXTABLE(2b,100b)
31486+ _ASM_EXTABLE(3b,100b)
31487+ _ASM_EXTABLE(4b,100b)
31488+ _ASM_EXTABLE(5b,100b)
31489+ _ASM_EXTABLE(6b,100b)
31490+ _ASM_EXTABLE(7b,100b)
31491+ _ASM_EXTABLE(8b,100b)
31492+ _ASM_EXTABLE(9b,100b)
31493+ _ASM_EXTABLE(10b,100b)
31494+ _ASM_EXTABLE(11b,100b)
31495+ _ASM_EXTABLE(12b,100b)
31496+ _ASM_EXTABLE(13b,100b)
31497+ _ASM_EXTABLE(14b,100b)
31498+ _ASM_EXTABLE(15b,100b)
31499+ _ASM_EXTABLE(16b,100b)
31500+ _ASM_EXTABLE(17b,100b)
31501+ _ASM_EXTABLE(18b,100b)
31502+ _ASM_EXTABLE(19b,100b)
31503+ _ASM_EXTABLE(20b,100b)
31504+ _ASM_EXTABLE(21b,100b)
31505+ _ASM_EXTABLE(22b,100b)
31506+ _ASM_EXTABLE(23b,100b)
31507+ _ASM_EXTABLE(24b,100b)
31508+ _ASM_EXTABLE(25b,100b)
31509+ _ASM_EXTABLE(26b,100b)
31510+ _ASM_EXTABLE(27b,100b)
31511+ _ASM_EXTABLE(28b,100b)
31512+ _ASM_EXTABLE(29b,100b)
31513+ _ASM_EXTABLE(30b,100b)
31514+ _ASM_EXTABLE(31b,100b)
31515+ _ASM_EXTABLE(32b,100b)
31516+ _ASM_EXTABLE(33b,100b)
31517+ _ASM_EXTABLE(34b,100b)
31518+ _ASM_EXTABLE(35b,100b)
31519+ _ASM_EXTABLE(36b,100b)
31520+ _ASM_EXTABLE(37b,100b)
31521+ _ASM_EXTABLE(99b,101b)
31522+ : "=&c"(size), "=&D" (d0), "=&S" (d1)
31523+ : "1"(to), "2"(from), "0"(size)
31524+ : "eax", "edx", "memory");
31525+ return size;
31526+}
31527+
31528+static unsigned long
31529+__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
31530+{
31531+ int d0, d1;
31532+ __asm__ __volatile__(
31533+ " .align 2,0x90\n"
31534+ "1: "__copyuser_seg" movl 32(%4), %%eax\n"
31535+ " cmpl $67, %0\n"
31536+ " jbe 3f\n"
31537+ "2: "__copyuser_seg" movl 64(%4), %%eax\n"
31538+ " .align 2,0x90\n"
31539+ "3: "__copyuser_seg" movl 0(%4), %%eax\n"
31540+ "4: "__copyuser_seg" movl 4(%4), %%edx\n"
31541+ "5: movl %%eax, 0(%3)\n"
31542+ "6: movl %%edx, 4(%3)\n"
31543+ "7: "__copyuser_seg" movl 8(%4), %%eax\n"
31544+ "8: "__copyuser_seg" movl 12(%4),%%edx\n"
31545+ "9: movl %%eax, 8(%3)\n"
31546+ "10: movl %%edx, 12(%3)\n"
31547+ "11: "__copyuser_seg" movl 16(%4), %%eax\n"
31548+ "12: "__copyuser_seg" movl 20(%4), %%edx\n"
31549+ "13: movl %%eax, 16(%3)\n"
31550+ "14: movl %%edx, 20(%3)\n"
31551+ "15: "__copyuser_seg" movl 24(%4), %%eax\n"
31552+ "16: "__copyuser_seg" movl 28(%4), %%edx\n"
31553+ "17: movl %%eax, 24(%3)\n"
31554+ "18: movl %%edx, 28(%3)\n"
31555+ "19: "__copyuser_seg" movl 32(%4), %%eax\n"
31556+ "20: "__copyuser_seg" movl 36(%4), %%edx\n"
31557+ "21: movl %%eax, 32(%3)\n"
31558+ "22: movl %%edx, 36(%3)\n"
31559+ "23: "__copyuser_seg" movl 40(%4), %%eax\n"
31560+ "24: "__copyuser_seg" movl 44(%4), %%edx\n"
31561+ "25: movl %%eax, 40(%3)\n"
31562+ "26: movl %%edx, 44(%3)\n"
31563+ "27: "__copyuser_seg" movl 48(%4), %%eax\n"
31564+ "28: "__copyuser_seg" movl 52(%4), %%edx\n"
31565+ "29: movl %%eax, 48(%3)\n"
31566+ "30: movl %%edx, 52(%3)\n"
31567+ "31: "__copyuser_seg" movl 56(%4), %%eax\n"
31568+ "32: "__copyuser_seg" movl 60(%4), %%edx\n"
31569+ "33: movl %%eax, 56(%3)\n"
31570+ "34: movl %%edx, 60(%3)\n"
31571+ " addl $-64, %0\n"
31572+ " addl $64, %4\n"
31573+ " addl $64, %3\n"
31574+ " cmpl $63, %0\n"
31575+ " ja 1b\n"
31576+ "35: movl %0, %%eax\n"
31577+ " shrl $2, %0\n"
31578+ " andl $3, %%eax\n"
31579+ " cld\n"
31580+ "99: rep; "__copyuser_seg" movsl\n"
31581+ "36: movl %%eax, %0\n"
31582+ "37: rep; "__copyuser_seg" movsb\n"
31583+ "100:\n"
31584 ".section .fixup,\"ax\"\n"
31585 "101: lea 0(%%eax,%0,4),%0\n"
31586 " jmp 100b\n"
31587@@ -207,41 +315,41 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
31588 int d0, d1;
31589 __asm__ __volatile__(
31590 " .align 2,0x90\n"
31591- "0: movl 32(%4), %%eax\n"
31592+ "0: "__copyuser_seg" movl 32(%4), %%eax\n"
31593 " cmpl $67, %0\n"
31594 " jbe 2f\n"
31595- "1: movl 64(%4), %%eax\n"
31596+ "1: "__copyuser_seg" movl 64(%4), %%eax\n"
31597 " .align 2,0x90\n"
31598- "2: movl 0(%4), %%eax\n"
31599- "21: movl 4(%4), %%edx\n"
31600+ "2: "__copyuser_seg" movl 0(%4), %%eax\n"
31601+ "21: "__copyuser_seg" movl 4(%4), %%edx\n"
31602 " movl %%eax, 0(%3)\n"
31603 " movl %%edx, 4(%3)\n"
31604- "3: movl 8(%4), %%eax\n"
31605- "31: movl 12(%4),%%edx\n"
31606+ "3: "__copyuser_seg" movl 8(%4), %%eax\n"
31607+ "31: "__copyuser_seg" movl 12(%4),%%edx\n"
31608 " movl %%eax, 8(%3)\n"
31609 " movl %%edx, 12(%3)\n"
31610- "4: movl 16(%4), %%eax\n"
31611- "41: movl 20(%4), %%edx\n"
31612+ "4: "__copyuser_seg" movl 16(%4), %%eax\n"
31613+ "41: "__copyuser_seg" movl 20(%4), %%edx\n"
31614 " movl %%eax, 16(%3)\n"
31615 " movl %%edx, 20(%3)\n"
31616- "10: movl 24(%4), %%eax\n"
31617- "51: movl 28(%4), %%edx\n"
31618+ "10: "__copyuser_seg" movl 24(%4), %%eax\n"
31619+ "51: "__copyuser_seg" movl 28(%4), %%edx\n"
31620 " movl %%eax, 24(%3)\n"
31621 " movl %%edx, 28(%3)\n"
31622- "11: movl 32(%4), %%eax\n"
31623- "61: movl 36(%4), %%edx\n"
31624+ "11: "__copyuser_seg" movl 32(%4), %%eax\n"
31625+ "61: "__copyuser_seg" movl 36(%4), %%edx\n"
31626 " movl %%eax, 32(%3)\n"
31627 " movl %%edx, 36(%3)\n"
31628- "12: movl 40(%4), %%eax\n"
31629- "71: movl 44(%4), %%edx\n"
31630+ "12: "__copyuser_seg" movl 40(%4), %%eax\n"
31631+ "71: "__copyuser_seg" movl 44(%4), %%edx\n"
31632 " movl %%eax, 40(%3)\n"
31633 " movl %%edx, 44(%3)\n"
31634- "13: movl 48(%4), %%eax\n"
31635- "81: movl 52(%4), %%edx\n"
31636+ "13: "__copyuser_seg" movl 48(%4), %%eax\n"
31637+ "81: "__copyuser_seg" movl 52(%4), %%edx\n"
31638 " movl %%eax, 48(%3)\n"
31639 " movl %%edx, 52(%3)\n"
31640- "14: movl 56(%4), %%eax\n"
31641- "91: movl 60(%4), %%edx\n"
31642+ "14: "__copyuser_seg" movl 56(%4), %%eax\n"
31643+ "91: "__copyuser_seg" movl 60(%4), %%edx\n"
31644 " movl %%eax, 56(%3)\n"
31645 " movl %%edx, 60(%3)\n"
31646 " addl $-64, %0\n"
31647@@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
31648 " shrl $2, %0\n"
31649 " andl $3, %%eax\n"
31650 " cld\n"
31651- "6: rep; movsl\n"
31652+ "6: rep; "__copyuser_seg" movsl\n"
31653 " movl %%eax,%0\n"
31654- "7: rep; movsb\n"
31655+ "7: rep; "__copyuser_seg" movsb\n"
31656 "8:\n"
31657 ".section .fixup,\"ax\"\n"
31658 "9: lea 0(%%eax,%0,4),%0\n"
31659@@ -305,41 +413,41 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
31660
31661 __asm__ __volatile__(
31662 " .align 2,0x90\n"
31663- "0: movl 32(%4), %%eax\n"
31664+ "0: "__copyuser_seg" movl 32(%4), %%eax\n"
31665 " cmpl $67, %0\n"
31666 " jbe 2f\n"
31667- "1: movl 64(%4), %%eax\n"
31668+ "1: "__copyuser_seg" movl 64(%4), %%eax\n"
31669 " .align 2,0x90\n"
31670- "2: movl 0(%4), %%eax\n"
31671- "21: movl 4(%4), %%edx\n"
31672+ "2: "__copyuser_seg" movl 0(%4), %%eax\n"
31673+ "21: "__copyuser_seg" movl 4(%4), %%edx\n"
31674 " movnti %%eax, 0(%3)\n"
31675 " movnti %%edx, 4(%3)\n"
31676- "3: movl 8(%4), %%eax\n"
31677- "31: movl 12(%4),%%edx\n"
31678+ "3: "__copyuser_seg" movl 8(%4), %%eax\n"
31679+ "31: "__copyuser_seg" movl 12(%4),%%edx\n"
31680 " movnti %%eax, 8(%3)\n"
31681 " movnti %%edx, 12(%3)\n"
31682- "4: movl 16(%4), %%eax\n"
31683- "41: movl 20(%4), %%edx\n"
31684+ "4: "__copyuser_seg" movl 16(%4), %%eax\n"
31685+ "41: "__copyuser_seg" movl 20(%4), %%edx\n"
31686 " movnti %%eax, 16(%3)\n"
31687 " movnti %%edx, 20(%3)\n"
31688- "10: movl 24(%4), %%eax\n"
31689- "51: movl 28(%4), %%edx\n"
31690+ "10: "__copyuser_seg" movl 24(%4), %%eax\n"
31691+ "51: "__copyuser_seg" movl 28(%4), %%edx\n"
31692 " movnti %%eax, 24(%3)\n"
31693 " movnti %%edx, 28(%3)\n"
31694- "11: movl 32(%4), %%eax\n"
31695- "61: movl 36(%4), %%edx\n"
31696+ "11: "__copyuser_seg" movl 32(%4), %%eax\n"
31697+ "61: "__copyuser_seg" movl 36(%4), %%edx\n"
31698 " movnti %%eax, 32(%3)\n"
31699 " movnti %%edx, 36(%3)\n"
31700- "12: movl 40(%4), %%eax\n"
31701- "71: movl 44(%4), %%edx\n"
31702+ "12: "__copyuser_seg" movl 40(%4), %%eax\n"
31703+ "71: "__copyuser_seg" movl 44(%4), %%edx\n"
31704 " movnti %%eax, 40(%3)\n"
31705 " movnti %%edx, 44(%3)\n"
31706- "13: movl 48(%4), %%eax\n"
31707- "81: movl 52(%4), %%edx\n"
31708+ "13: "__copyuser_seg" movl 48(%4), %%eax\n"
31709+ "81: "__copyuser_seg" movl 52(%4), %%edx\n"
31710 " movnti %%eax, 48(%3)\n"
31711 " movnti %%edx, 52(%3)\n"
31712- "14: movl 56(%4), %%eax\n"
31713- "91: movl 60(%4), %%edx\n"
31714+ "14: "__copyuser_seg" movl 56(%4), %%eax\n"
31715+ "91: "__copyuser_seg" movl 60(%4), %%edx\n"
31716 " movnti %%eax, 56(%3)\n"
31717 " movnti %%edx, 60(%3)\n"
31718 " addl $-64, %0\n"
31719@@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
31720 " shrl $2, %0\n"
31721 " andl $3, %%eax\n"
31722 " cld\n"
31723- "6: rep; movsl\n"
31724+ "6: rep; "__copyuser_seg" movsl\n"
31725 " movl %%eax,%0\n"
31726- "7: rep; movsb\n"
31727+ "7: rep; "__copyuser_seg" movsb\n"
31728 "8:\n"
31729 ".section .fixup,\"ax\"\n"
31730 "9: lea 0(%%eax,%0,4),%0\n"
31731@@ -399,41 +507,41 @@ static unsigned long __copy_user_intel_nocache(void *to,
31732
31733 __asm__ __volatile__(
31734 " .align 2,0x90\n"
31735- "0: movl 32(%4), %%eax\n"
31736+ "0: "__copyuser_seg" movl 32(%4), %%eax\n"
31737 " cmpl $67, %0\n"
31738 " jbe 2f\n"
31739- "1: movl 64(%4), %%eax\n"
31740+ "1: "__copyuser_seg" movl 64(%4), %%eax\n"
31741 " .align 2,0x90\n"
31742- "2: movl 0(%4), %%eax\n"
31743- "21: movl 4(%4), %%edx\n"
31744+ "2: "__copyuser_seg" movl 0(%4), %%eax\n"
31745+ "21: "__copyuser_seg" movl 4(%4), %%edx\n"
31746 " movnti %%eax, 0(%3)\n"
31747 " movnti %%edx, 4(%3)\n"
31748- "3: movl 8(%4), %%eax\n"
31749- "31: movl 12(%4),%%edx\n"
31750+ "3: "__copyuser_seg" movl 8(%4), %%eax\n"
31751+ "31: "__copyuser_seg" movl 12(%4),%%edx\n"
31752 " movnti %%eax, 8(%3)\n"
31753 " movnti %%edx, 12(%3)\n"
31754- "4: movl 16(%4), %%eax\n"
31755- "41: movl 20(%4), %%edx\n"
31756+ "4: "__copyuser_seg" movl 16(%4), %%eax\n"
31757+ "41: "__copyuser_seg" movl 20(%4), %%edx\n"
31758 " movnti %%eax, 16(%3)\n"
31759 " movnti %%edx, 20(%3)\n"
31760- "10: movl 24(%4), %%eax\n"
31761- "51: movl 28(%4), %%edx\n"
31762+ "10: "__copyuser_seg" movl 24(%4), %%eax\n"
31763+ "51: "__copyuser_seg" movl 28(%4), %%edx\n"
31764 " movnti %%eax, 24(%3)\n"
31765 " movnti %%edx, 28(%3)\n"
31766- "11: movl 32(%4), %%eax\n"
31767- "61: movl 36(%4), %%edx\n"
31768+ "11: "__copyuser_seg" movl 32(%4), %%eax\n"
31769+ "61: "__copyuser_seg" movl 36(%4), %%edx\n"
31770 " movnti %%eax, 32(%3)\n"
31771 " movnti %%edx, 36(%3)\n"
31772- "12: movl 40(%4), %%eax\n"
31773- "71: movl 44(%4), %%edx\n"
31774+ "12: "__copyuser_seg" movl 40(%4), %%eax\n"
31775+ "71: "__copyuser_seg" movl 44(%4), %%edx\n"
31776 " movnti %%eax, 40(%3)\n"
31777 " movnti %%edx, 44(%3)\n"
31778- "13: movl 48(%4), %%eax\n"
31779- "81: movl 52(%4), %%edx\n"
31780+ "13: "__copyuser_seg" movl 48(%4), %%eax\n"
31781+ "81: "__copyuser_seg" movl 52(%4), %%edx\n"
31782 " movnti %%eax, 48(%3)\n"
31783 " movnti %%edx, 52(%3)\n"
31784- "14: movl 56(%4), %%eax\n"
31785- "91: movl 60(%4), %%edx\n"
31786+ "14: "__copyuser_seg" movl 56(%4), %%eax\n"
31787+ "91: "__copyuser_seg" movl 60(%4), %%edx\n"
31788 " movnti %%eax, 56(%3)\n"
31789 " movnti %%edx, 60(%3)\n"
31790 " addl $-64, %0\n"
31791@@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
31792 " shrl $2, %0\n"
31793 " andl $3, %%eax\n"
31794 " cld\n"
31795- "6: rep; movsl\n"
31796+ "6: rep; "__copyuser_seg" movsl\n"
31797 " movl %%eax,%0\n"
31798- "7: rep; movsb\n"
31799+ "7: rep; "__copyuser_seg" movsb\n"
31800 "8:\n"
31801 ".section .fixup,\"ax\"\n"
31802 "9: lea 0(%%eax,%0,4),%0\n"
31803@@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
31804 */
31805 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
31806 unsigned long size);
31807-unsigned long __copy_user_intel(void __user *to, const void *from,
31808+unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
31809+ unsigned long size);
31810+unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
31811 unsigned long size);
31812 unsigned long __copy_user_zeroing_intel_nocache(void *to,
31813 const void __user *from, unsigned long size);
31814 #endif /* CONFIG_X86_INTEL_USERCOPY */
31815
31816 /* Generic arbitrary sized copy. */
31817-#define __copy_user(to, from, size) \
31818+#define __copy_user(to, from, size, prefix, set, restore) \
31819 do { \
31820 int __d0, __d1, __d2; \
31821 __asm__ __volatile__( \
31822+ set \
31823 " cmp $7,%0\n" \
31824 " jbe 1f\n" \
31825 " movl %1,%0\n" \
31826 " negl %0\n" \
31827 " andl $7,%0\n" \
31828 " subl %0,%3\n" \
31829- "4: rep; movsb\n" \
31830+ "4: rep; "prefix"movsb\n" \
31831 " movl %3,%0\n" \
31832 " shrl $2,%0\n" \
31833 " andl $3,%3\n" \
31834 " .align 2,0x90\n" \
31835- "0: rep; movsl\n" \
31836+ "0: rep; "prefix"movsl\n" \
31837 " movl %3,%0\n" \
31838- "1: rep; movsb\n" \
31839+ "1: rep; "prefix"movsb\n" \
31840 "2:\n" \
31841+ restore \
31842 ".section .fixup,\"ax\"\n" \
31843 "5: addl %3,%0\n" \
31844 " jmp 2b\n" \
31845@@ -538,14 +650,14 @@ do { \
31846 " negl %0\n" \
31847 " andl $7,%0\n" \
31848 " subl %0,%3\n" \
31849- "4: rep; movsb\n" \
31850+ "4: rep; "__copyuser_seg"movsb\n" \
31851 " movl %3,%0\n" \
31852 " shrl $2,%0\n" \
31853 " andl $3,%3\n" \
31854 " .align 2,0x90\n" \
31855- "0: rep; movsl\n" \
31856+ "0: rep; "__copyuser_seg"movsl\n" \
31857 " movl %3,%0\n" \
31858- "1: rep; movsb\n" \
31859+ "1: rep; "__copyuser_seg"movsb\n" \
31860 "2:\n" \
31861 ".section .fixup,\"ax\"\n" \
31862 "5: addl %3,%0\n" \
31863@@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
31864 {
31865 stac();
31866 if (movsl_is_ok(to, from, n))
31867- __copy_user(to, from, n);
31868+ __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
31869 else
31870- n = __copy_user_intel(to, from, n);
31871+ n = __generic_copy_to_user_intel(to, from, n);
31872 clac();
31873 return n;
31874 }
31875@@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
31876 {
31877 stac();
31878 if (movsl_is_ok(to, from, n))
31879- __copy_user(to, from, n);
31880+ __copy_user(to, from, n, __copyuser_seg, "", "");
31881 else
31882- n = __copy_user_intel((void __user *)to,
31883- (const void *)from, n);
31884+ n = __generic_copy_from_user_intel(to, from, n);
31885 clac();
31886 return n;
31887 }
31888@@ -632,58 +743,38 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
31889 if (n > 64 && cpu_has_xmm2)
31890 n = __copy_user_intel_nocache(to, from, n);
31891 else
31892- __copy_user(to, from, n);
31893+ __copy_user(to, from, n, __copyuser_seg, "", "");
31894 #else
31895- __copy_user(to, from, n);
31896+ __copy_user(to, from, n, __copyuser_seg, "", "");
31897 #endif
31898 clac();
31899 return n;
31900 }
31901 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
31902
31903-/**
31904- * copy_to_user: - Copy a block of data into user space.
31905- * @to: Destination address, in user space.
31906- * @from: Source address, in kernel space.
31907- * @n: Number of bytes to copy.
31908- *
31909- * Context: User context only. This function may sleep.
31910- *
31911- * Copy data from kernel space to user space.
31912- *
31913- * Returns number of bytes that could not be copied.
31914- * On success, this will be zero.
31915- */
31916-unsigned long _copy_to_user(void __user *to, const void *from, unsigned n)
31917+#ifdef CONFIG_PAX_MEMORY_UDEREF
31918+void __set_fs(mm_segment_t x)
31919 {
31920- if (access_ok(VERIFY_WRITE, to, n))
31921- n = __copy_to_user(to, from, n);
31922- return n;
31923+ switch (x.seg) {
31924+ case 0:
31925+ loadsegment(gs, 0);
31926+ break;
31927+ case TASK_SIZE_MAX:
31928+ loadsegment(gs, __USER_DS);
31929+ break;
31930+ case -1UL:
31931+ loadsegment(gs, __KERNEL_DS);
31932+ break;
31933+ default:
31934+ BUG();
31935+ }
31936 }
31937-EXPORT_SYMBOL(_copy_to_user);
31938+EXPORT_SYMBOL(__set_fs);
31939
31940-/**
31941- * copy_from_user: - Copy a block of data from user space.
31942- * @to: Destination address, in kernel space.
31943- * @from: Source address, in user space.
31944- * @n: Number of bytes to copy.
31945- *
31946- * Context: User context only. This function may sleep.
31947- *
31948- * Copy data from user space to kernel space.
31949- *
31950- * Returns number of bytes that could not be copied.
31951- * On success, this will be zero.
31952- *
31953- * If some data could not be copied, this function will pad the copied
31954- * data to the requested size using zero bytes.
31955- */
31956-unsigned long _copy_from_user(void *to, const void __user *from, unsigned n)
31957+void set_fs(mm_segment_t x)
31958 {
31959- if (access_ok(VERIFY_READ, from, n))
31960- n = __copy_from_user(to, from, n);
31961- else
31962- memset(to, 0, n);
31963- return n;
31964+ current_thread_info()->addr_limit = x;
31965+ __set_fs(x);
31966 }
31967-EXPORT_SYMBOL(_copy_from_user);
31968+EXPORT_SYMBOL(set_fs);
31969+#endif
31970diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
31971index 0a42327..7a82465 100644
31972--- a/arch/x86/lib/usercopy_64.c
31973+++ b/arch/x86/lib/usercopy_64.c
31974@@ -18,6 +18,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
31975 might_fault();
31976 /* no memory constraint because it doesn't change any memory gcc knows
31977 about */
31978+ pax_open_userland();
31979 stac();
31980 asm volatile(
31981 " testq %[size8],%[size8]\n"
31982@@ -39,9 +40,10 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
31983 _ASM_EXTABLE(0b,3b)
31984 _ASM_EXTABLE(1b,2b)
31985 : [size8] "=&c"(size), [dst] "=&D" (__d0)
31986- : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
31987+ : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
31988 [zero] "r" (0UL), [eight] "r" (8UL));
31989 clac();
31990+ pax_close_userland();
31991 return size;
31992 }
31993 EXPORT_SYMBOL(__clear_user);
31994@@ -54,12 +56,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
31995 }
31996 EXPORT_SYMBOL(clear_user);
31997
31998-unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
31999+unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
32000 {
32001- if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
32002- return copy_user_generic((__force void *)to, (__force void *)from, len);
32003- }
32004- return len;
32005+ if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
32006+ return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
32007+ return len;
32008 }
32009 EXPORT_SYMBOL(copy_in_user);
32010
32011@@ -69,8 +70,10 @@ EXPORT_SYMBOL(copy_in_user);
32012 * it is not necessary to optimize tail handling.
32013 */
32014 __visible unsigned long
32015-copy_user_handle_tail(char *to, char *from, unsigned len)
32016+copy_user_handle_tail(char __user *to, char __user *from, unsigned long len)
32017 {
32018+ clac();
32019+ pax_close_userland();
32020 for (; len; --len, to++) {
32021 char c;
32022
32023@@ -79,10 +82,9 @@ copy_user_handle_tail(char *to, char *from, unsigned len)
32024 if (__put_user_nocheck(c, to, sizeof(char)))
32025 break;
32026 }
32027- clac();
32028
32029 /* If the destination is a kernel buffer, we always clear the end */
32030- if (!__addr_ok(to))
32031+ if (!__addr_ok(to) && (unsigned long)to >= TASK_SIZE_MAX + pax_user_shadow_base)
32032 memset(to, 0, len);
32033 return len;
32034 }
32035diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile
32036index a482d10..1a6edb5 100644
32037--- a/arch/x86/mm/Makefile
32038+++ b/arch/x86/mm/Makefile
32039@@ -33,3 +33,7 @@ obj-$(CONFIG_ACPI_NUMA) += srat.o
32040 obj-$(CONFIG_NUMA_EMU) += numa_emulation.o
32041
32042 obj-$(CONFIG_X86_INTEL_MPX) += mpx.o
32043+
32044+quote:="
32045+obj-$(CONFIG_X86_64) += uderef_64.o
32046+CFLAGS_uderef_64.o := $(subst $(quote),,$(CONFIG_ARCH_HWEIGHT_CFLAGS)) -fcall-saved-rax
32047diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
32048index 903ec1e..c4166b2 100644
32049--- a/arch/x86/mm/extable.c
32050+++ b/arch/x86/mm/extable.c
32051@@ -6,12 +6,24 @@
32052 static inline unsigned long
32053 ex_insn_addr(const struct exception_table_entry *x)
32054 {
32055- return (unsigned long)&x->insn + x->insn;
32056+ unsigned long reloc = 0;
32057+
32058+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
32059+ reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
32060+#endif
32061+
32062+ return (unsigned long)&x->insn + x->insn + reloc;
32063 }
32064 static inline unsigned long
32065 ex_fixup_addr(const struct exception_table_entry *x)
32066 {
32067- return (unsigned long)&x->fixup + x->fixup;
32068+ unsigned long reloc = 0;
32069+
32070+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
32071+ reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
32072+#endif
32073+
32074+ return (unsigned long)&x->fixup + x->fixup + reloc;
32075 }
32076
32077 int fixup_exception(struct pt_regs *regs)
32078@@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
32079 unsigned long new_ip;
32080
32081 #ifdef CONFIG_PNPBIOS
32082- if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
32083+ if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
32084 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
32085 extern u32 pnp_bios_is_utter_crap;
32086 pnp_bios_is_utter_crap = 1;
32087@@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
32088 i += 4;
32089 p->fixup -= i;
32090 i += 4;
32091+
32092+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
32093+ BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
32094+ p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
32095+ p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
32096+#endif
32097+
32098 }
32099 }
32100
32101diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
32102index 181c53b..d336596 100644
32103--- a/arch/x86/mm/fault.c
32104+++ b/arch/x86/mm/fault.c
32105@@ -13,12 +13,19 @@
32106 #include <linux/hugetlb.h> /* hstate_index_to_shift */
32107 #include <linux/prefetch.h> /* prefetchw */
32108 #include <linux/context_tracking.h> /* exception_enter(), ... */
32109+#include <linux/unistd.h>
32110+#include <linux/compiler.h>
32111
32112 #include <asm/traps.h> /* dotraplinkage, ... */
32113 #include <asm/pgalloc.h> /* pgd_*(), ... */
32114 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
32115 #include <asm/fixmap.h> /* VSYSCALL_ADDR */
32116 #include <asm/vsyscall.h> /* emulate_vsyscall */
32117+#include <asm/tlbflush.h>
32118+
32119+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
32120+#include <asm/stacktrace.h>
32121+#endif
32122
32123 #define CREATE_TRACE_POINTS
32124 #include <asm/trace/exceptions.h>
32125@@ -120,7 +127,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
32126 return !instr_lo || (instr_lo>>1) == 1;
32127 case 0x00:
32128 /* Prefetch instruction is 0x0F0D or 0x0F18 */
32129- if (probe_kernel_address(instr, opcode))
32130+ if (user_mode(regs)) {
32131+ if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
32132+ return 0;
32133+ } else if (probe_kernel_address(instr, opcode))
32134 return 0;
32135
32136 *prefetch = (instr_lo == 0xF) &&
32137@@ -154,7 +164,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
32138 while (instr < max_instr) {
32139 unsigned char opcode;
32140
32141- if (probe_kernel_address(instr, opcode))
32142+ if (user_mode(regs)) {
32143+ if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
32144+ break;
32145+ } else if (probe_kernel_address(instr, opcode))
32146 break;
32147
32148 instr++;
32149@@ -185,6 +198,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
32150 force_sig_info(si_signo, &info, tsk);
32151 }
32152
32153+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
32154+static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
32155+#endif
32156+
32157+#ifdef CONFIG_PAX_EMUTRAMP
32158+static int pax_handle_fetch_fault(struct pt_regs *regs);
32159+#endif
32160+
32161+#ifdef CONFIG_PAX_PAGEEXEC
32162+static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
32163+{
32164+ pgd_t *pgd;
32165+ pud_t *pud;
32166+ pmd_t *pmd;
32167+
32168+ pgd = pgd_offset(mm, address);
32169+ if (!pgd_present(*pgd))
32170+ return NULL;
32171+ pud = pud_offset(pgd, address);
32172+ if (!pud_present(*pud))
32173+ return NULL;
32174+ pmd = pmd_offset(pud, address);
32175+ if (!pmd_present(*pmd))
32176+ return NULL;
32177+ return pmd;
32178+}
32179+#endif
32180+
32181 DEFINE_SPINLOCK(pgd_lock);
32182 LIST_HEAD(pgd_list);
32183
32184@@ -235,10 +276,27 @@ void vmalloc_sync_all(void)
32185 for (address = VMALLOC_START & PMD_MASK;
32186 address >= TASK_SIZE && address < FIXADDR_TOP;
32187 address += PMD_SIZE) {
32188+
32189+#ifdef CONFIG_PAX_PER_CPU_PGD
32190+ unsigned long cpu;
32191+#else
32192 struct page *page;
32193+#endif
32194
32195 spin_lock(&pgd_lock);
32196+
32197+#ifdef CONFIG_PAX_PER_CPU_PGD
32198+ for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
32199+ pgd_t *pgd = get_cpu_pgd(cpu, user);
32200+ pmd_t *ret;
32201+
32202+ ret = vmalloc_sync_one(pgd, address);
32203+ if (!ret)
32204+ break;
32205+ pgd = get_cpu_pgd(cpu, kernel);
32206+#else
32207 list_for_each_entry(page, &pgd_list, lru) {
32208+ pgd_t *pgd;
32209 spinlock_t *pgt_lock;
32210 pmd_t *ret;
32211
32212@@ -246,8 +304,14 @@ void vmalloc_sync_all(void)
32213 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
32214
32215 spin_lock(pgt_lock);
32216- ret = vmalloc_sync_one(page_address(page), address);
32217+ pgd = page_address(page);
32218+#endif
32219+
32220+ ret = vmalloc_sync_one(pgd, address);
32221+
32222+#ifndef CONFIG_PAX_PER_CPU_PGD
32223 spin_unlock(pgt_lock);
32224+#endif
32225
32226 if (!ret)
32227 break;
32228@@ -281,6 +345,12 @@ static noinline int vmalloc_fault(unsigned long address)
32229 * an interrupt in the middle of a task switch..
32230 */
32231 pgd_paddr = read_cr3();
32232+
32233+#ifdef CONFIG_PAX_PER_CPU_PGD
32234+ BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (pgd_paddr & __PHYSICAL_MASK));
32235+ vmalloc_sync_one(__va(pgd_paddr + PAGE_SIZE), address);
32236+#endif
32237+
32238 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
32239 if (!pmd_k)
32240 return -1;
32241@@ -377,11 +447,25 @@ static noinline int vmalloc_fault(unsigned long address)
32242 * happen within a race in page table update. In the later
32243 * case just flush:
32244 */
32245- pgd = pgd_offset(current->active_mm, address);
32246+
32247 pgd_ref = pgd_offset_k(address);
32248 if (pgd_none(*pgd_ref))
32249 return -1;
32250
32251+#ifdef CONFIG_PAX_PER_CPU_PGD
32252+ BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (read_cr3() & __PHYSICAL_MASK));
32253+ pgd = pgd_offset_cpu(smp_processor_id(), user, address);
32254+ if (pgd_none(*pgd)) {
32255+ set_pgd(pgd, *pgd_ref);
32256+ arch_flush_lazy_mmu_mode();
32257+ } else {
32258+ BUG_ON(pgd_page_vaddr(*pgd) != pgd_page_vaddr(*pgd_ref));
32259+ }
32260+ pgd = pgd_offset_cpu(smp_processor_id(), kernel, address);
32261+#else
32262+ pgd = pgd_offset(current->active_mm, address);
32263+#endif
32264+
32265 if (pgd_none(*pgd)) {
32266 set_pgd(pgd, *pgd_ref);
32267 arch_flush_lazy_mmu_mode();
32268@@ -548,7 +632,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
32269 static int is_errata100(struct pt_regs *regs, unsigned long address)
32270 {
32271 #ifdef CONFIG_X86_64
32272- if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
32273+ if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
32274 return 1;
32275 #endif
32276 return 0;
32277@@ -575,9 +659,9 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
32278 }
32279
32280 static const char nx_warning[] = KERN_CRIT
32281-"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
32282+"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
32283 static const char smep_warning[] = KERN_CRIT
32284-"unable to execute userspace code (SMEP?) (uid: %d)\n";
32285+"unable to execute userspace code (SMEP?) (uid: %d, task: %s, pid: %d)\n";
32286
32287 static void
32288 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
32289@@ -586,7 +670,7 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
32290 if (!oops_may_print())
32291 return;
32292
32293- if (error_code & PF_INSTR) {
32294+ if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
32295 unsigned int level;
32296 pgd_t *pgd;
32297 pte_t *pte;
32298@@ -597,13 +681,25 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
32299 pte = lookup_address_in_pgd(pgd, address, &level);
32300
32301 if (pte && pte_present(*pte) && !pte_exec(*pte))
32302- printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
32303+ printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
32304 if (pte && pte_present(*pte) && pte_exec(*pte) &&
32305 (pgd_flags(*pgd) & _PAGE_USER) &&
32306 (__read_cr4() & X86_CR4_SMEP))
32307- printk(smep_warning, from_kuid(&init_user_ns, current_uid()));
32308+ printk(smep_warning, from_kuid(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
32309 }
32310
32311+#ifdef CONFIG_PAX_KERNEXEC
32312+ if (init_mm.start_code <= address && address < init_mm.end_code) {
32313+ if (current->signal->curr_ip)
32314+ printk(KERN_EMERG "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
32315+ &current->signal->curr_ip, current->comm, task_pid_nr(current),
32316+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
32317+ else
32318+ printk(KERN_EMERG "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
32319+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
32320+ }
32321+#endif
32322+
32323 printk(KERN_ALERT "BUG: unable to handle kernel ");
32324 if (address < PAGE_SIZE)
32325 printk(KERN_CONT "NULL pointer dereference");
32326@@ -782,6 +878,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
32327 return;
32328 }
32329 #endif
32330+
32331+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
32332+ if (pax_is_fetch_fault(regs, error_code, address)) {
32333+
32334+#ifdef CONFIG_PAX_EMUTRAMP
32335+ switch (pax_handle_fetch_fault(regs)) {
32336+ case 2:
32337+ return;
32338+ }
32339+#endif
32340+
32341+ pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
32342+ do_group_exit(SIGKILL);
32343+ }
32344+#endif
32345+
32346 /* Kernel addresses are always protection faults: */
32347 if (address >= TASK_SIZE)
32348 error_code |= PF_PROT;
32349@@ -864,7 +976,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
32350 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
32351 printk(KERN_ERR
32352 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
32353- tsk->comm, tsk->pid, address);
32354+ tsk->comm, task_pid_nr(tsk), address);
32355 code = BUS_MCEERR_AR;
32356 }
32357 #endif
32358@@ -916,6 +1028,107 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
32359 return 1;
32360 }
32361
32362+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
32363+static inline unsigned long get_limit(unsigned long segment)
32364+{
32365+ unsigned long __limit;
32366+
32367+ asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
32368+ return __limit + 1;
32369+}
32370+
32371+static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
32372+{
32373+ pte_t *pte;
32374+ pmd_t *pmd;
32375+ spinlock_t *ptl;
32376+ unsigned char pte_mask;
32377+
32378+ if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
32379+ !(mm->pax_flags & MF_PAX_PAGEEXEC))
32380+ return 0;
32381+
32382+ /* PaX: it's our fault, let's handle it if we can */
32383+
32384+ /* PaX: take a look at read faults before acquiring any locks */
32385+ if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
32386+ /* instruction fetch attempt from a protected page in user mode */
32387+ up_read(&mm->mmap_sem);
32388+
32389+#ifdef CONFIG_PAX_EMUTRAMP
32390+ switch (pax_handle_fetch_fault(regs)) {
32391+ case 2:
32392+ return 1;
32393+ }
32394+#endif
32395+
32396+ pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
32397+ do_group_exit(SIGKILL);
32398+ }
32399+
32400+ pmd = pax_get_pmd(mm, address);
32401+ if (unlikely(!pmd))
32402+ return 0;
32403+
32404+ pte = pte_offset_map_lock(mm, pmd, address, &ptl);
32405+ if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
32406+ pte_unmap_unlock(pte, ptl);
32407+ return 0;
32408+ }
32409+
32410+ if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
32411+ /* write attempt to a protected page in user mode */
32412+ pte_unmap_unlock(pte, ptl);
32413+ return 0;
32414+ }
32415+
32416+#ifdef CONFIG_SMP
32417+ if (likely(address > get_limit(regs->cs) && cpumask_test_cpu(smp_processor_id(), &mm->context.cpu_user_cs_mask)))
32418+#else
32419+ if (likely(address > get_limit(regs->cs)))
32420+#endif
32421+ {
32422+ set_pte(pte, pte_mkread(*pte));
32423+ __flush_tlb_one(address);
32424+ pte_unmap_unlock(pte, ptl);
32425+ up_read(&mm->mmap_sem);
32426+ return 1;
32427+ }
32428+
32429+ pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
32430+
32431+ /*
32432+ * PaX: fill DTLB with user rights and retry
32433+ */
32434+ __asm__ __volatile__ (
32435+ "orb %2,(%1)\n"
32436+#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
32437+/*
32438+ * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
32439+ * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
32440+ * page fault when examined during a TLB load attempt. this is true not only
32441+ * for PTEs holding a non-present entry but also present entries that will
32442+ * raise a page fault (such as those set up by PaX, or the copy-on-write
32443+ * mechanism). in effect it means that we do *not* need to flush the TLBs
32444+ * for our target pages since their PTEs are simply not in the TLBs at all.
32445+
32446+ * the best thing in omitting it is that we gain around 15-20% speed in the
32447+ * fast path of the page fault handler and can get rid of tracing since we
32448+ * can no longer flush unintended entries.
32449+ */
32450+ "invlpg (%0)\n"
32451+#endif
32452+ __copyuser_seg"testb $0,(%0)\n"
32453+ "xorb %3,(%1)\n"
32454+ :
32455+ : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
32456+ : "memory", "cc");
32457+ pte_unmap_unlock(pte, ptl);
32458+ up_read(&mm->mmap_sem);
32459+ return 1;
32460+}
32461+#endif
32462+
32463 /*
32464 * Handle a spurious fault caused by a stale TLB entry.
32465 *
32466@@ -1001,6 +1214,9 @@ int show_unhandled_signals = 1;
32467 static inline int
32468 access_error(unsigned long error_code, struct vm_area_struct *vma)
32469 {
32470+ if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
32471+ return 1;
32472+
32473 if (error_code & PF_WRITE) {
32474 /* write, present and write, not present: */
32475 if (unlikely(!(vma->vm_flags & VM_WRITE)))
32476@@ -1063,6 +1279,22 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code,
32477 tsk = current;
32478 mm = tsk->mm;
32479
32480+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
32481+ if (!user_mode(regs) && address < 2 * pax_user_shadow_base) {
32482+ if (!search_exception_tables(regs->ip)) {
32483+ printk(KERN_EMERG "PAX: please report this to pageexec@freemail.hu\n");
32484+ bad_area_nosemaphore(regs, error_code, address);
32485+ return;
32486+ }
32487+ if (address < pax_user_shadow_base) {
32488+ printk(KERN_EMERG "PAX: please report this to pageexec@freemail.hu\n");
32489+ printk(KERN_EMERG "PAX: faulting IP: %pS\n", (void *)regs->ip);
32490+ show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_EMERG);
32491+ } else
32492+ address -= pax_user_shadow_base;
32493+ }
32494+#endif
32495+
32496 /*
32497 * Detect and handle instructions that would cause a page fault for
32498 * both a tracked kernel page and a userspace page.
32499@@ -1187,6 +1419,11 @@ retry:
32500 might_sleep();
32501 }
32502
32503+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
32504+ if (pax_handle_pageexec_fault(regs, mm, address, error_code))
32505+ return;
32506+#endif
32507+
32508 vma = find_vma(mm, address);
32509 if (unlikely(!vma)) {
32510 bad_area(regs, error_code, address);
32511@@ -1198,18 +1435,24 @@ retry:
32512 bad_area(regs, error_code, address);
32513 return;
32514 }
32515- if (error_code & PF_USER) {
32516- /*
32517- * Accessing the stack below %sp is always a bug.
32518- * The large cushion allows instructions like enter
32519- * and pusha to work. ("enter $65535, $31" pushes
32520- * 32 pointers and then decrements %sp by 65535.)
32521- */
32522- if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
32523- bad_area(regs, error_code, address);
32524- return;
32525- }
32526+ /*
32527+ * Accessing the stack below %sp is always a bug.
32528+ * The large cushion allows instructions like enter
32529+ * and pusha to work. ("enter $65535, $31" pushes
32530+ * 32 pointers and then decrements %sp by 65535.)
32531+ */
32532+ if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
32533+ bad_area(regs, error_code, address);
32534+ return;
32535 }
32536+
32537+#ifdef CONFIG_PAX_SEGMEXEC
32538+ if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
32539+ bad_area(regs, error_code, address);
32540+ return;
32541+ }
32542+#endif
32543+
32544 if (unlikely(expand_stack(vma, address))) {
32545 bad_area(regs, error_code, address);
32546 return;
32547@@ -1329,3 +1572,292 @@ trace_do_page_fault(struct pt_regs *regs, unsigned long error_code)
32548 }
32549 NOKPROBE_SYMBOL(trace_do_page_fault);
32550 #endif /* CONFIG_TRACING */
32551+
32552+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
32553+static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
32554+{
32555+ struct mm_struct *mm = current->mm;
32556+ unsigned long ip = regs->ip;
32557+
32558+ if (v8086_mode(regs))
32559+ ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
32560+
32561+#ifdef CONFIG_PAX_PAGEEXEC
32562+ if (mm->pax_flags & MF_PAX_PAGEEXEC) {
32563+ if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
32564+ return true;
32565+ if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
32566+ return true;
32567+ return false;
32568+ }
32569+#endif
32570+
32571+#ifdef CONFIG_PAX_SEGMEXEC
32572+ if (mm->pax_flags & MF_PAX_SEGMEXEC) {
32573+ if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
32574+ return true;
32575+ return false;
32576+ }
32577+#endif
32578+
32579+ return false;
32580+}
32581+#endif
32582+
32583+#ifdef CONFIG_PAX_EMUTRAMP
32584+static int pax_handle_fetch_fault_32(struct pt_regs *regs)
32585+{
32586+ int err;
32587+
32588+ do { /* PaX: libffi trampoline emulation */
32589+ unsigned char mov, jmp;
32590+ unsigned int addr1, addr2;
32591+
32592+#ifdef CONFIG_X86_64
32593+ if ((regs->ip + 9) >> 32)
32594+ break;
32595+#endif
32596+
32597+ err = get_user(mov, (unsigned char __user *)regs->ip);
32598+ err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
32599+ err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
32600+ err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
32601+
32602+ if (err)
32603+ break;
32604+
32605+ if (mov == 0xB8 && jmp == 0xE9) {
32606+ regs->ax = addr1;
32607+ regs->ip = (unsigned int)(regs->ip + addr2 + 10);
32608+ return 2;
32609+ }
32610+ } while (0);
32611+
32612+ do { /* PaX: gcc trampoline emulation #1 */
32613+ unsigned char mov1, mov2;
32614+ unsigned short jmp;
32615+ unsigned int addr1, addr2;
32616+
32617+#ifdef CONFIG_X86_64
32618+ if ((regs->ip + 11) >> 32)
32619+ break;
32620+#endif
32621+
32622+ err = get_user(mov1, (unsigned char __user *)regs->ip);
32623+ err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
32624+ err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
32625+ err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
32626+ err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
32627+
32628+ if (err)
32629+ break;
32630+
32631+ if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
32632+ regs->cx = addr1;
32633+ regs->ax = addr2;
32634+ regs->ip = addr2;
32635+ return 2;
32636+ }
32637+ } while (0);
32638+
32639+ do { /* PaX: gcc trampoline emulation #2 */
32640+ unsigned char mov, jmp;
32641+ unsigned int addr1, addr2;
32642+
32643+#ifdef CONFIG_X86_64
32644+ if ((regs->ip + 9) >> 32)
32645+ break;
32646+#endif
32647+
32648+ err = get_user(mov, (unsigned char __user *)regs->ip);
32649+ err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
32650+ err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
32651+ err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
32652+
32653+ if (err)
32654+ break;
32655+
32656+ if (mov == 0xB9 && jmp == 0xE9) {
32657+ regs->cx = addr1;
32658+ regs->ip = (unsigned int)(regs->ip + addr2 + 10);
32659+ return 2;
32660+ }
32661+ } while (0);
32662+
32663+ return 1; /* PaX in action */
32664+}
32665+
32666+#ifdef CONFIG_X86_64
32667+static int pax_handle_fetch_fault_64(struct pt_regs *regs)
32668+{
32669+ int err;
32670+
32671+ do { /* PaX: libffi trampoline emulation */
32672+ unsigned short mov1, mov2, jmp1;
32673+ unsigned char stcclc, jmp2;
32674+ unsigned long addr1, addr2;
32675+
32676+ err = get_user(mov1, (unsigned short __user *)regs->ip);
32677+ err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
32678+ err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
32679+ err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
32680+ err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
32681+ err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
32682+ err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
32683+
32684+ if (err)
32685+ break;
32686+
32687+ if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
32688+ regs->r11 = addr1;
32689+ regs->r10 = addr2;
32690+ if (stcclc == 0xF8)
32691+ regs->flags &= ~X86_EFLAGS_CF;
32692+ else
32693+ regs->flags |= X86_EFLAGS_CF;
32694+ regs->ip = addr1;
32695+ return 2;
32696+ }
32697+ } while (0);
32698+
32699+ do { /* PaX: gcc trampoline emulation #1 */
32700+ unsigned short mov1, mov2, jmp1;
32701+ unsigned char jmp2;
32702+ unsigned int addr1;
32703+ unsigned long addr2;
32704+
32705+ err = get_user(mov1, (unsigned short __user *)regs->ip);
32706+ err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
32707+ err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
32708+ err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
32709+ err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
32710+ err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
32711+
32712+ if (err)
32713+ break;
32714+
32715+ if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
32716+ regs->r11 = addr1;
32717+ regs->r10 = addr2;
32718+ regs->ip = addr1;
32719+ return 2;
32720+ }
32721+ } while (0);
32722+
32723+ do { /* PaX: gcc trampoline emulation #2 */
32724+ unsigned short mov1, mov2, jmp1;
32725+ unsigned char jmp2;
32726+ unsigned long addr1, addr2;
32727+
32728+ err = get_user(mov1, (unsigned short __user *)regs->ip);
32729+ err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
32730+ err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
32731+ err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
32732+ err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
32733+ err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
32734+
32735+ if (err)
32736+ break;
32737+
32738+ if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
32739+ regs->r11 = addr1;
32740+ regs->r10 = addr2;
32741+ regs->ip = addr1;
32742+ return 2;
32743+ }
32744+ } while (0);
32745+
32746+ return 1; /* PaX in action */
32747+}
32748+#endif
32749+
32750+/*
32751+ * PaX: decide what to do with offenders (regs->ip = fault address)
32752+ *
32753+ * returns 1 when task should be killed
32754+ * 2 when gcc trampoline was detected
32755+ */
32756+static int pax_handle_fetch_fault(struct pt_regs *regs)
32757+{
32758+ if (v8086_mode(regs))
32759+ return 1;
32760+
32761+ if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
32762+ return 1;
32763+
32764+#ifdef CONFIG_X86_32
32765+ return pax_handle_fetch_fault_32(regs);
32766+#else
32767+ if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
32768+ return pax_handle_fetch_fault_32(regs);
32769+ else
32770+ return pax_handle_fetch_fault_64(regs);
32771+#endif
32772+}
32773+#endif
32774+
32775+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
32776+void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
32777+{
32778+ long i;
32779+
32780+ printk(KERN_ERR "PAX: bytes at PC: ");
32781+ for (i = 0; i < 20; i++) {
32782+ unsigned char c;
32783+ if (get_user(c, (unsigned char __force_user *)pc+i))
32784+ printk(KERN_CONT "?? ");
32785+ else
32786+ printk(KERN_CONT "%02x ", c);
32787+ }
32788+ printk("\n");
32789+
32790+ printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
32791+ for (i = -1; i < 80 / (long)sizeof(long); i++) {
32792+ unsigned long c;
32793+ if (get_user(c, (unsigned long __force_user *)sp+i)) {
32794+#ifdef CONFIG_X86_32
32795+ printk(KERN_CONT "???????? ");
32796+#else
32797+ if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
32798+ printk(KERN_CONT "???????? ???????? ");
32799+ else
32800+ printk(KERN_CONT "???????????????? ");
32801+#endif
32802+ } else {
32803+#ifdef CONFIG_X86_64
32804+ if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
32805+ printk(KERN_CONT "%08x ", (unsigned int)c);
32806+ printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
32807+ } else
32808+#endif
32809+ printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
32810+ }
32811+ }
32812+ printk("\n");
32813+}
32814+#endif
32815+
32816+/**
32817+ * probe_kernel_write(): safely attempt to write to a location
32818+ * @dst: address to write to
32819+ * @src: pointer to the data that shall be written
32820+ * @size: size of the data chunk
32821+ *
32822+ * Safely write to address @dst from the buffer at @src. If a kernel fault
32823+ * happens, handle that and return -EFAULT.
32824+ */
32825+long notrace probe_kernel_write(void *dst, const void *src, size_t size)
32826+{
32827+ long ret;
32828+ mm_segment_t old_fs = get_fs();
32829+
32830+ set_fs(KERNEL_DS);
32831+ pagefault_disable();
32832+ pax_open_kernel();
32833+ ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
32834+ pax_close_kernel();
32835+ pagefault_enable();
32836+ set_fs(old_fs);
32837+
32838+ return ret ? -EFAULT : 0;
32839+}
32840diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
32841index 81bf3d2..7ef25c2 100644
32842--- a/arch/x86/mm/gup.c
32843+++ b/arch/x86/mm/gup.c
32844@@ -268,7 +268,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
32845 addr = start;
32846 len = (unsigned long) nr_pages << PAGE_SHIFT;
32847 end = start + len;
32848- if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
32849+ if (unlikely(!access_ok_noprefault(write ? VERIFY_WRITE : VERIFY_READ,
32850 (void __user *)start, len)))
32851 return 0;
32852
32853@@ -344,6 +344,10 @@ int get_user_pages_fast(unsigned long start, int nr_pages, int write,
32854 goto slow_irqon;
32855 #endif
32856
32857+ if (unlikely(!access_ok_noprefault(write ? VERIFY_WRITE : VERIFY_READ,
32858+ (void __user *)start, len)))
32859+ return 0;
32860+
32861 /*
32862 * XXX: batch / limit 'nr', to avoid large irq off latency
32863 * needs some instrumenting to determine the common sizes used by
32864diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
32865index 4500142..53a363c 100644
32866--- a/arch/x86/mm/highmem_32.c
32867+++ b/arch/x86/mm/highmem_32.c
32868@@ -45,7 +45,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
32869 idx = type + KM_TYPE_NR*smp_processor_id();
32870 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
32871 BUG_ON(!pte_none(*(kmap_pte-idx)));
32872+
32873+ pax_open_kernel();
32874 set_pte(kmap_pte-idx, mk_pte(page, prot));
32875+ pax_close_kernel();
32876+
32877 arch_flush_lazy_mmu_mode();
32878
32879 return (void *)vaddr;
32880diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
32881index 42982b2..7168fc3 100644
32882--- a/arch/x86/mm/hugetlbpage.c
32883+++ b/arch/x86/mm/hugetlbpage.c
32884@@ -74,23 +74,24 @@ int pud_huge(pud_t pud)
32885 #ifdef CONFIG_HUGETLB_PAGE
32886 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
32887 unsigned long addr, unsigned long len,
32888- unsigned long pgoff, unsigned long flags)
32889+ unsigned long pgoff, unsigned long flags, unsigned long offset)
32890 {
32891 struct hstate *h = hstate_file(file);
32892 struct vm_unmapped_area_info info;
32893-
32894+
32895 info.flags = 0;
32896 info.length = len;
32897 info.low_limit = current->mm->mmap_legacy_base;
32898 info.high_limit = TASK_SIZE;
32899 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
32900 info.align_offset = 0;
32901+ info.threadstack_offset = offset;
32902 return vm_unmapped_area(&info);
32903 }
32904
32905 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
32906 unsigned long addr0, unsigned long len,
32907- unsigned long pgoff, unsigned long flags)
32908+ unsigned long pgoff, unsigned long flags, unsigned long offset)
32909 {
32910 struct hstate *h = hstate_file(file);
32911 struct vm_unmapped_area_info info;
32912@@ -102,6 +103,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
32913 info.high_limit = current->mm->mmap_base;
32914 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
32915 info.align_offset = 0;
32916+ info.threadstack_offset = offset;
32917 addr = vm_unmapped_area(&info);
32918
32919 /*
32920@@ -114,6 +116,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
32921 VM_BUG_ON(addr != -ENOMEM);
32922 info.flags = 0;
32923 info.low_limit = TASK_UNMAPPED_BASE;
32924+
32925+#ifdef CONFIG_PAX_RANDMMAP
32926+ if (current->mm->pax_flags & MF_PAX_RANDMMAP)
32927+ info.low_limit += current->mm->delta_mmap;
32928+#endif
32929+
32930 info.high_limit = TASK_SIZE;
32931 addr = vm_unmapped_area(&info);
32932 }
32933@@ -128,10 +136,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
32934 struct hstate *h = hstate_file(file);
32935 struct mm_struct *mm = current->mm;
32936 struct vm_area_struct *vma;
32937+ unsigned long pax_task_size = TASK_SIZE;
32938+ unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
32939
32940 if (len & ~huge_page_mask(h))
32941 return -EINVAL;
32942- if (len > TASK_SIZE)
32943+
32944+#ifdef CONFIG_PAX_SEGMEXEC
32945+ if (mm->pax_flags & MF_PAX_SEGMEXEC)
32946+ pax_task_size = SEGMEXEC_TASK_SIZE;
32947+#endif
32948+
32949+ pax_task_size -= PAGE_SIZE;
32950+
32951+ if (len > pax_task_size)
32952 return -ENOMEM;
32953
32954 if (flags & MAP_FIXED) {
32955@@ -140,19 +158,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
32956 return addr;
32957 }
32958
32959+#ifdef CONFIG_PAX_RANDMMAP
32960+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
32961+#endif
32962+
32963 if (addr) {
32964 addr = ALIGN(addr, huge_page_size(h));
32965 vma = find_vma(mm, addr);
32966- if (TASK_SIZE - len >= addr &&
32967- (!vma || addr + len <= vma->vm_start))
32968+ if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
32969 return addr;
32970 }
32971 if (mm->get_unmapped_area == arch_get_unmapped_area)
32972 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
32973- pgoff, flags);
32974+ pgoff, flags, offset);
32975 else
32976 return hugetlb_get_unmapped_area_topdown(file, addr, len,
32977- pgoff, flags);
32978+ pgoff, flags, offset);
32979 }
32980 #endif /* CONFIG_HUGETLB_PAGE */
32981
32982diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
32983index 1d55318..d58fd6a 100644
32984--- a/arch/x86/mm/init.c
32985+++ b/arch/x86/mm/init.c
32986@@ -4,6 +4,7 @@
32987 #include <linux/swap.h>
32988 #include <linux/memblock.h>
32989 #include <linux/bootmem.h> /* for max_low_pfn */
32990+#include <linux/tboot.h>
32991
32992 #include <asm/cacheflush.h>
32993 #include <asm/e820.h>
32994@@ -17,6 +18,8 @@
32995 #include <asm/proto.h>
32996 #include <asm/dma.h> /* for MAX_DMA_PFN */
32997 #include <asm/microcode.h>
32998+#include <asm/desc.h>
32999+#include <asm/bios_ebda.h>
33000
33001 /*
33002 * We need to define the tracepoints somewhere, and tlb.c
33003@@ -615,7 +618,18 @@ void __init init_mem_mapping(void)
33004 early_ioremap_page_table_range_init();
33005 #endif
33006
33007+#ifdef CONFIG_PAX_PER_CPU_PGD
33008+ clone_pgd_range(get_cpu_pgd(0, kernel) + KERNEL_PGD_BOUNDARY,
33009+ swapper_pg_dir + KERNEL_PGD_BOUNDARY,
33010+ KERNEL_PGD_PTRS);
33011+ clone_pgd_range(get_cpu_pgd(0, user) + KERNEL_PGD_BOUNDARY,
33012+ swapper_pg_dir + KERNEL_PGD_BOUNDARY,
33013+ KERNEL_PGD_PTRS);
33014+ load_cr3(get_cpu_pgd(0, kernel));
33015+#else
33016 load_cr3(swapper_pg_dir);
33017+#endif
33018+
33019 __flush_tlb_all();
33020
33021 early_memtest(0, max_pfn_mapped << PAGE_SHIFT);
33022@@ -631,10 +645,40 @@ void __init init_mem_mapping(void)
33023 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
33024 * mmio resources as well as potential bios/acpi data regions.
33025 */
33026+
33027+#ifdef CONFIG_GRKERNSEC_KMEM
33028+static unsigned int ebda_start __read_only;
33029+static unsigned int ebda_end __read_only;
33030+#endif
33031+
33032 int devmem_is_allowed(unsigned long pagenr)
33033 {
33034- if (pagenr < 256)
33035+#ifdef CONFIG_GRKERNSEC_KMEM
33036+ /* allow BDA */
33037+ if (!pagenr)
33038 return 1;
33039+ /* allow EBDA */
33040+ if (pagenr >= ebda_start && pagenr < ebda_end)
33041+ return 1;
33042+ /* if tboot is in use, allow access to its hardcoded serial log range */
33043+ if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
33044+ return 1;
33045+#else
33046+ if (!pagenr)
33047+ return 1;
33048+#ifdef CONFIG_VM86
33049+ if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
33050+ return 1;
33051+#endif
33052+#endif
33053+
33054+ if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
33055+ return 1;
33056+#ifdef CONFIG_GRKERNSEC_KMEM
33057+ /* throw out everything else below 1MB */
33058+ if (pagenr <= 256)
33059+ return 0;
33060+#endif
33061 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
33062 return 0;
33063 if (!page_is_ram(pagenr))
33064@@ -680,8 +724,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
33065 #endif
33066 }
33067
33068+#ifdef CONFIG_GRKERNSEC_KMEM
33069+static inline void gr_init_ebda(void)
33070+{
33071+ unsigned int ebda_addr;
33072+ unsigned int ebda_size = 0;
33073+
33074+ ebda_addr = get_bios_ebda();
33075+ if (ebda_addr) {
33076+ ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
33077+ ebda_size <<= 10;
33078+ }
33079+ if (ebda_addr && ebda_size) {
33080+ ebda_start = ebda_addr >> PAGE_SHIFT;
33081+ ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
33082+ } else {
33083+ ebda_start = 0x9f000 >> PAGE_SHIFT;
33084+ ebda_end = 0xa0000 >> PAGE_SHIFT;
33085+ }
33086+}
33087+#else
33088+static inline void gr_init_ebda(void) { }
33089+#endif
33090+
33091 void free_initmem(void)
33092 {
33093+#ifdef CONFIG_PAX_KERNEXEC
33094+#ifdef CONFIG_X86_32
33095+ /* PaX: limit KERNEL_CS to actual size */
33096+ unsigned long addr, limit;
33097+ struct desc_struct d;
33098+ int cpu;
33099+#else
33100+ pgd_t *pgd;
33101+ pud_t *pud;
33102+ pmd_t *pmd;
33103+ unsigned long addr, end;
33104+#endif
33105+#endif
33106+
33107+ gr_init_ebda();
33108+
33109+#ifdef CONFIG_PAX_KERNEXEC
33110+#ifdef CONFIG_X86_32
33111+ limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
33112+ limit = (limit - 1UL) >> PAGE_SHIFT;
33113+
33114+ memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
33115+ for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
33116+ pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
33117+ write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
33118+ write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
33119+ }
33120+
33121+ /* PaX: make KERNEL_CS read-only */
33122+ addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
33123+ if (!paravirt_enabled())
33124+ set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
33125+/*
33126+ for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
33127+ pgd = pgd_offset_k(addr);
33128+ pud = pud_offset(pgd, addr);
33129+ pmd = pmd_offset(pud, addr);
33130+ set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
33131+ }
33132+*/
33133+#ifdef CONFIG_X86_PAE
33134+ set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
33135+/*
33136+ for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
33137+ pgd = pgd_offset_k(addr);
33138+ pud = pud_offset(pgd, addr);
33139+ pmd = pmd_offset(pud, addr);
33140+ set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
33141+ }
33142+*/
33143+#endif
33144+
33145+#ifdef CONFIG_MODULES
33146+ set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
33147+#endif
33148+
33149+#else
33150+ /* PaX: make kernel code/rodata read-only, rest non-executable */
33151+ for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
33152+ pgd = pgd_offset_k(addr);
33153+ pud = pud_offset(pgd, addr);
33154+ pmd = pmd_offset(pud, addr);
33155+ if (!pmd_present(*pmd))
33156+ continue;
33157+ if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
33158+ set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
33159+ else
33160+ set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
33161+ }
33162+
33163+ addr = (unsigned long)__va(__pa(__START_KERNEL_map));
33164+ end = addr + KERNEL_IMAGE_SIZE;
33165+ for (; addr < end; addr += PMD_SIZE) {
33166+ pgd = pgd_offset_k(addr);
33167+ pud = pud_offset(pgd, addr);
33168+ pmd = pmd_offset(pud, addr);
33169+ if (!pmd_present(*pmd))
33170+ continue;
33171+ if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
33172+ set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
33173+ }
33174+#endif
33175+
33176+ flush_tlb_all();
33177+#endif
33178+
33179 free_init_pages("unused kernel",
33180 (unsigned long)(&__init_begin),
33181 (unsigned long)(&__init_end));
33182diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
33183index c8140e1..59257fc 100644
33184--- a/arch/x86/mm/init_32.c
33185+++ b/arch/x86/mm/init_32.c
33186@@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
33187 bool __read_mostly __vmalloc_start_set = false;
33188
33189 /*
33190- * Creates a middle page table and puts a pointer to it in the
33191- * given global directory entry. This only returns the gd entry
33192- * in non-PAE compilation mode, since the middle layer is folded.
33193- */
33194-static pmd_t * __init one_md_table_init(pgd_t *pgd)
33195-{
33196- pud_t *pud;
33197- pmd_t *pmd_table;
33198-
33199-#ifdef CONFIG_X86_PAE
33200- if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
33201- pmd_table = (pmd_t *)alloc_low_page();
33202- paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
33203- set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
33204- pud = pud_offset(pgd, 0);
33205- BUG_ON(pmd_table != pmd_offset(pud, 0));
33206-
33207- return pmd_table;
33208- }
33209-#endif
33210- pud = pud_offset(pgd, 0);
33211- pmd_table = pmd_offset(pud, 0);
33212-
33213- return pmd_table;
33214-}
33215-
33216-/*
33217 * Create a page table and place a pointer to it in a middle page
33218 * directory entry:
33219 */
33220@@ -98,13 +71,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
33221 pte_t *page_table = (pte_t *)alloc_low_page();
33222
33223 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
33224+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
33225+ set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
33226+#else
33227 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
33228+#endif
33229 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
33230 }
33231
33232 return pte_offset_kernel(pmd, 0);
33233 }
33234
33235+static pmd_t * __init one_md_table_init(pgd_t *pgd)
33236+{
33237+ pud_t *pud;
33238+ pmd_t *pmd_table;
33239+
33240+ pud = pud_offset(pgd, 0);
33241+ pmd_table = pmd_offset(pud, 0);
33242+
33243+ return pmd_table;
33244+}
33245+
33246 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
33247 {
33248 int pgd_idx = pgd_index(vaddr);
33249@@ -208,6 +196,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
33250 int pgd_idx, pmd_idx;
33251 unsigned long vaddr;
33252 pgd_t *pgd;
33253+ pud_t *pud;
33254 pmd_t *pmd;
33255 pte_t *pte = NULL;
33256 unsigned long count = page_table_range_init_count(start, end);
33257@@ -222,8 +211,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
33258 pgd = pgd_base + pgd_idx;
33259
33260 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
33261- pmd = one_md_table_init(pgd);
33262- pmd = pmd + pmd_index(vaddr);
33263+ pud = pud_offset(pgd, vaddr);
33264+ pmd = pmd_offset(pud, vaddr);
33265+
33266+#ifdef CONFIG_X86_PAE
33267+ paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
33268+#endif
33269+
33270 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
33271 pmd++, pmd_idx++) {
33272 pte = page_table_kmap_check(one_page_table_init(pmd),
33273@@ -235,11 +229,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
33274 }
33275 }
33276
33277-static inline int is_kernel_text(unsigned long addr)
33278+static inline int is_kernel_text(unsigned long start, unsigned long end)
33279 {
33280- if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
33281- return 1;
33282- return 0;
33283+ if ((start >= ktla_ktva((unsigned long)_etext) ||
33284+ end <= ktla_ktva((unsigned long)_stext)) &&
33285+ (start >= ktla_ktva((unsigned long)_einittext) ||
33286+ end <= ktla_ktva((unsigned long)_sinittext)) &&
33287+
33288+#ifdef CONFIG_ACPI_SLEEP
33289+ (start >= (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
33290+#endif
33291+
33292+ (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
33293+ return 0;
33294+ return 1;
33295 }
33296
33297 /*
33298@@ -256,9 +259,10 @@ kernel_physical_mapping_init(unsigned long start,
33299 unsigned long last_map_addr = end;
33300 unsigned long start_pfn, end_pfn;
33301 pgd_t *pgd_base = swapper_pg_dir;
33302- int pgd_idx, pmd_idx, pte_ofs;
33303+ unsigned int pgd_idx, pmd_idx, pte_ofs;
33304 unsigned long pfn;
33305 pgd_t *pgd;
33306+ pud_t *pud;
33307 pmd_t *pmd;
33308 pte_t *pte;
33309 unsigned pages_2m, pages_4k;
33310@@ -291,8 +295,13 @@ repeat:
33311 pfn = start_pfn;
33312 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
33313 pgd = pgd_base + pgd_idx;
33314- for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
33315- pmd = one_md_table_init(pgd);
33316+ for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
33317+ pud = pud_offset(pgd, 0);
33318+ pmd = pmd_offset(pud, 0);
33319+
33320+#ifdef CONFIG_X86_PAE
33321+ paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
33322+#endif
33323
33324 if (pfn >= end_pfn)
33325 continue;
33326@@ -304,14 +313,13 @@ repeat:
33327 #endif
33328 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
33329 pmd++, pmd_idx++) {
33330- unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
33331+ unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
33332
33333 /*
33334 * Map with big pages if possible, otherwise
33335 * create normal page tables:
33336 */
33337 if (use_pse) {
33338- unsigned int addr2;
33339 pgprot_t prot = PAGE_KERNEL_LARGE;
33340 /*
33341 * first pass will use the same initial
33342@@ -322,11 +330,7 @@ repeat:
33343 _PAGE_PSE);
33344
33345 pfn &= PMD_MASK >> PAGE_SHIFT;
33346- addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
33347- PAGE_OFFSET + PAGE_SIZE-1;
33348-
33349- if (is_kernel_text(addr) ||
33350- is_kernel_text(addr2))
33351+ if (is_kernel_text(address, address + PMD_SIZE))
33352 prot = PAGE_KERNEL_LARGE_EXEC;
33353
33354 pages_2m++;
33355@@ -343,7 +347,7 @@ repeat:
33356 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
33357 pte += pte_ofs;
33358 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
33359- pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
33360+ pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
33361 pgprot_t prot = PAGE_KERNEL;
33362 /*
33363 * first pass will use the same initial
33364@@ -351,7 +355,7 @@ repeat:
33365 */
33366 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
33367
33368- if (is_kernel_text(addr))
33369+ if (is_kernel_text(address, address + PAGE_SIZE))
33370 prot = PAGE_KERNEL_EXEC;
33371
33372 pages_4k++;
33373@@ -474,7 +478,7 @@ void __init native_pagetable_init(void)
33374
33375 pud = pud_offset(pgd, va);
33376 pmd = pmd_offset(pud, va);
33377- if (!pmd_present(*pmd))
33378+ if (!pmd_present(*pmd)) // PAX TODO || pmd_large(*pmd))
33379 break;
33380
33381 /* should not be large page here */
33382@@ -532,12 +536,10 @@ void __init early_ioremap_page_table_range_init(void)
33383
33384 static void __init pagetable_init(void)
33385 {
33386- pgd_t *pgd_base = swapper_pg_dir;
33387-
33388- permanent_kmaps_init(pgd_base);
33389+ permanent_kmaps_init(swapper_pg_dir);
33390 }
33391
33392-pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL);
33393+pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL);
33394 EXPORT_SYMBOL_GPL(__supported_pte_mask);
33395
33396 /* user-defined highmem size */
33397@@ -787,10 +789,10 @@ void __init mem_init(void)
33398 ((unsigned long)&__init_end -
33399 (unsigned long)&__init_begin) >> 10,
33400
33401- (unsigned long)&_etext, (unsigned long)&_edata,
33402- ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
33403+ (unsigned long)&_sdata, (unsigned long)&_edata,
33404+ ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
33405
33406- (unsigned long)&_text, (unsigned long)&_etext,
33407+ ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
33408 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
33409
33410 /*
33411@@ -884,6 +886,7 @@ void set_kernel_text_rw(void)
33412 if (!kernel_set_to_readonly)
33413 return;
33414
33415+ start = ktla_ktva(start);
33416 pr_debug("Set kernel text: %lx - %lx for read write\n",
33417 start, start+size);
33418
33419@@ -898,6 +901,7 @@ void set_kernel_text_ro(void)
33420 if (!kernel_set_to_readonly)
33421 return;
33422
33423+ start = ktla_ktva(start);
33424 pr_debug("Set kernel text: %lx - %lx for read only\n",
33425 start, start+size);
33426
33427@@ -926,6 +930,7 @@ void mark_rodata_ro(void)
33428 unsigned long start = PFN_ALIGN(_text);
33429 unsigned long size = PFN_ALIGN(_etext) - start;
33430
33431+ start = ktla_ktva(start);
33432 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
33433 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
33434 size >> 10);
33435diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
33436index 3fba623..5ee9802 100644
33437--- a/arch/x86/mm/init_64.c
33438+++ b/arch/x86/mm/init_64.c
33439@@ -136,7 +136,7 @@ int kernel_ident_mapping_init(struct x86_mapping_info *info, pgd_t *pgd_page,
33440 * around without checking the pgd every time.
33441 */
33442
33443-pteval_t __supported_pte_mask __read_mostly = ~0;
33444+pteval_t __supported_pte_mask __read_only = ~_PAGE_NX;
33445 EXPORT_SYMBOL_GPL(__supported_pte_mask);
33446
33447 int force_personality32;
33448@@ -169,7 +169,12 @@ void sync_global_pgds(unsigned long start, unsigned long end, int removed)
33449
33450 for (address = start; address <= end; address += PGDIR_SIZE) {
33451 const pgd_t *pgd_ref = pgd_offset_k(address);
33452+
33453+#ifdef CONFIG_PAX_PER_CPU_PGD
33454+ unsigned long cpu;
33455+#else
33456 struct page *page;
33457+#endif
33458
33459 /*
33460 * When it is called after memory hot remove, pgd_none()
33461@@ -180,6 +185,25 @@ void sync_global_pgds(unsigned long start, unsigned long end, int removed)
33462 continue;
33463
33464 spin_lock(&pgd_lock);
33465+
33466+#ifdef CONFIG_PAX_PER_CPU_PGD
33467+ for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
33468+ pgd_t *pgd = pgd_offset_cpu(cpu, user, address);
33469+
33470+ if (!pgd_none(*pgd_ref) && !pgd_none(*pgd))
33471+ BUG_ON(pgd_page_vaddr(*pgd)
33472+ != pgd_page_vaddr(*pgd_ref));
33473+
33474+ if (removed) {
33475+ if (pgd_none(*pgd_ref) && !pgd_none(*pgd))
33476+ pgd_clear(pgd);
33477+ } else {
33478+ if (pgd_none(*pgd))
33479+ set_pgd(pgd, *pgd_ref);
33480+ }
33481+
33482+ pgd = pgd_offset_cpu(cpu, kernel, address);
33483+#else
33484 list_for_each_entry(page, &pgd_list, lru) {
33485 pgd_t *pgd;
33486 spinlock_t *pgt_lock;
33487@@ -188,6 +212,7 @@ void sync_global_pgds(unsigned long start, unsigned long end, int removed)
33488 /* the pgt_lock only for Xen */
33489 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
33490 spin_lock(pgt_lock);
33491+#endif
33492
33493 if (!pgd_none(*pgd_ref) && !pgd_none(*pgd))
33494 BUG_ON(pgd_page_vaddr(*pgd)
33495@@ -201,7 +226,10 @@ void sync_global_pgds(unsigned long start, unsigned long end, int removed)
33496 set_pgd(pgd, *pgd_ref);
33497 }
33498
33499+#ifndef CONFIG_PAX_PER_CPU_PGD
33500 spin_unlock(pgt_lock);
33501+#endif
33502+
33503 }
33504 spin_unlock(&pgd_lock);
33505 }
33506@@ -234,7 +262,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
33507 {
33508 if (pgd_none(*pgd)) {
33509 pud_t *pud = (pud_t *)spp_getpage();
33510- pgd_populate(&init_mm, pgd, pud);
33511+ pgd_populate_kernel(&init_mm, pgd, pud);
33512 if (pud != pud_offset(pgd, 0))
33513 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
33514 pud, pud_offset(pgd, 0));
33515@@ -246,7 +274,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
33516 {
33517 if (pud_none(*pud)) {
33518 pmd_t *pmd = (pmd_t *) spp_getpage();
33519- pud_populate(&init_mm, pud, pmd);
33520+ pud_populate_kernel(&init_mm, pud, pmd);
33521 if (pmd != pmd_offset(pud, 0))
33522 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
33523 pmd, pmd_offset(pud, 0));
33524@@ -275,7 +303,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
33525 pmd = fill_pmd(pud, vaddr);
33526 pte = fill_pte(pmd, vaddr);
33527
33528+ pax_open_kernel();
33529 set_pte(pte, new_pte);
33530+ pax_close_kernel();
33531
33532 /*
33533 * It's enough to flush this one mapping.
33534@@ -337,14 +367,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
33535 pgd = pgd_offset_k((unsigned long)__va(phys));
33536 if (pgd_none(*pgd)) {
33537 pud = (pud_t *) spp_getpage();
33538- set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
33539- _PAGE_USER));
33540+ set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
33541 }
33542 pud = pud_offset(pgd, (unsigned long)__va(phys));
33543 if (pud_none(*pud)) {
33544 pmd = (pmd_t *) spp_getpage();
33545- set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
33546- _PAGE_USER));
33547+ set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
33548 }
33549 pmd = pmd_offset(pud, phys);
33550 BUG_ON(!pmd_none(*pmd));
33551@@ -585,7 +613,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
33552 prot);
33553
33554 spin_lock(&init_mm.page_table_lock);
33555- pud_populate(&init_mm, pud, pmd);
33556+ pud_populate_kernel(&init_mm, pud, pmd);
33557 spin_unlock(&init_mm.page_table_lock);
33558 }
33559 __flush_tlb_all();
33560@@ -626,7 +654,7 @@ kernel_physical_mapping_init(unsigned long start,
33561 page_size_mask);
33562
33563 spin_lock(&init_mm.page_table_lock);
33564- pgd_populate(&init_mm, pgd, pud);
33565+ pgd_populate_kernel(&init_mm, pgd, pud);
33566 spin_unlock(&init_mm.page_table_lock);
33567 pgd_changed = true;
33568 }
33569diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
33570index 9ca35fc..4b2b7b7 100644
33571--- a/arch/x86/mm/iomap_32.c
33572+++ b/arch/x86/mm/iomap_32.c
33573@@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
33574 type = kmap_atomic_idx_push();
33575 idx = type + KM_TYPE_NR * smp_processor_id();
33576 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
33577+
33578+ pax_open_kernel();
33579 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
33580+ pax_close_kernel();
33581+
33582 arch_flush_lazy_mmu_mode();
33583
33584 return (void *)vaddr;
33585diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
33586index 70e7444..e9904fd 100644
33587--- a/arch/x86/mm/ioremap.c
33588+++ b/arch/x86/mm/ioremap.c
33589@@ -56,12 +56,10 @@ static int __ioremap_check_ram(unsigned long start_pfn, unsigned long nr_pages,
33590 unsigned long i;
33591
33592 for (i = 0; i < nr_pages; ++i)
33593- if (pfn_valid(start_pfn + i) &&
33594- !PageReserved(pfn_to_page(start_pfn + i)))
33595+ if (pfn_valid(start_pfn + i) && (start_pfn + i >= 0x100 ||
33596+ !PageReserved(pfn_to_page(start_pfn + i))))
33597 return 1;
33598
33599- WARN_ONCE(1, "ioremap on RAM pfn 0x%lx\n", start_pfn);
33600-
33601 return 0;
33602 }
33603
33604@@ -91,7 +89,6 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
33605 pgprot_t prot;
33606 int retval;
33607 void __iomem *ret_addr;
33608- int ram_region;
33609
33610 /* Don't allow wraparound or zero size */
33611 last_addr = phys_addr + size - 1;
33612@@ -114,23 +111,15 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
33613 /*
33614 * Don't allow anybody to remap normal RAM that we're using..
33615 */
33616- /* First check if whole region can be identified as RAM or not */
33617- ram_region = region_is_ram(phys_addr, size);
33618- if (ram_region > 0) {
33619- WARN_ONCE(1, "ioremap on RAM at 0x%lx - 0x%lx\n",
33620- (unsigned long int)phys_addr,
33621- (unsigned long int)last_addr);
33622+ pfn = phys_addr >> PAGE_SHIFT;
33623+ last_pfn = last_addr >> PAGE_SHIFT;
33624+ if (walk_system_ram_range(pfn, last_pfn - pfn + 1, NULL,
33625+ __ioremap_check_ram) == 1) {
33626+ WARN_ONCE(1, "ioremap on RAM at 0x%llx - 0x%llx\n",
33627+ phys_addr, last_addr);
33628 return NULL;
33629 }
33630
33631- /* If could not be identified(-1), check page by page */
33632- if (ram_region < 0) {
33633- pfn = phys_addr >> PAGE_SHIFT;
33634- last_pfn = last_addr >> PAGE_SHIFT;
33635- if (walk_system_ram_range(pfn, last_pfn - pfn + 1, NULL,
33636- __ioremap_check_ram) == 1)
33637- return NULL;
33638- }
33639 /*
33640 * Mappings have to be page-aligned
33641 */
33642@@ -288,7 +277,7 @@ EXPORT_SYMBOL(ioremap_prot);
33643 *
33644 * Caller must ensure there is only one unmapping for the same pointer.
33645 */
33646-void iounmap(volatile void __iomem *addr)
33647+void iounmap(const volatile void __iomem *addr)
33648 {
33649 struct vm_struct *p, *o;
33650
33651@@ -351,32 +340,36 @@ int arch_ioremap_pmd_supported(void)
33652 */
33653 void *xlate_dev_mem_ptr(phys_addr_t phys)
33654 {
33655- unsigned long start = phys & PAGE_MASK;
33656- unsigned long offset = phys & ~PAGE_MASK;
33657- unsigned long vaddr;
33658+ phys_addr_t pfn = phys >> PAGE_SHIFT;
33659
33660- /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
33661- if (page_is_ram(start >> PAGE_SHIFT))
33662- return __va(phys);
33663+ if (page_is_ram(pfn)) {
33664+#ifdef CONFIG_HIGHMEM
33665+ if (pfn >= max_low_pfn)
33666+ return kmap_high(pfn_to_page(pfn));
33667+ else
33668+#endif
33669+ return __va(phys);
33670+ }
33671
33672- vaddr = (unsigned long)ioremap_cache(start, PAGE_SIZE);
33673- /* Only add the offset on success and return NULL if the ioremap() failed: */
33674- if (vaddr)
33675- vaddr += offset;
33676-
33677- return (void *)vaddr;
33678+ return (void __force *)ioremap_cache(phys, 1);
33679 }
33680
33681 void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr)
33682 {
33683- if (page_is_ram(phys >> PAGE_SHIFT))
33684+ phys_addr_t pfn = phys >> PAGE_SHIFT;
33685+
33686+ if (page_is_ram(pfn)) {
33687+#ifdef CONFIG_HIGHMEM
33688+ if (pfn >= max_low_pfn)
33689+ kunmap_high(pfn_to_page(pfn));
33690+#endif
33691 return;
33692+ }
33693
33694- iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
33695- return;
33696+ iounmap((void __iomem __force *)addr);
33697 }
33698
33699-static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
33700+static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
33701
33702 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
33703 {
33704@@ -412,8 +405,7 @@ void __init early_ioremap_init(void)
33705 early_ioremap_setup();
33706
33707 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
33708- memset(bm_pte, 0, sizeof(bm_pte));
33709- pmd_populate_kernel(&init_mm, pmd, bm_pte);
33710+ pmd_populate_user(&init_mm, pmd, bm_pte);
33711
33712 /*
33713 * The boot-ioremap range spans multiple pmds, for which
33714diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
33715index b4f2e7e..96c9c3e 100644
33716--- a/arch/x86/mm/kmemcheck/kmemcheck.c
33717+++ b/arch/x86/mm/kmemcheck/kmemcheck.c
33718@@ -628,9 +628,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
33719 * memory (e.g. tracked pages)? For now, we need this to avoid
33720 * invoking kmemcheck for PnP BIOS calls.
33721 */
33722- if (regs->flags & X86_VM_MASK)
33723+ if (v8086_mode(regs))
33724 return false;
33725- if (regs->cs != __KERNEL_CS)
33726+ if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
33727 return false;
33728
33729 pte = kmemcheck_pte_lookup(address);
33730diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
33731index 9d518d6..8a091f5 100644
33732--- a/arch/x86/mm/mmap.c
33733+++ b/arch/x86/mm/mmap.c
33734@@ -52,7 +52,7 @@ static unsigned long stack_maxrandom_size(void)
33735 * Leave an at least ~128 MB hole with possible stack randomization.
33736 */
33737 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
33738-#define MAX_GAP (TASK_SIZE/6*5)
33739+#define MAX_GAP (pax_task_size/6*5)
33740
33741 static int mmap_is_legacy(void)
33742 {
33743@@ -81,27 +81,40 @@ unsigned long arch_mmap_rnd(void)
33744 return rnd << PAGE_SHIFT;
33745 }
33746
33747-static unsigned long mmap_base(unsigned long rnd)
33748+static unsigned long mmap_base(struct mm_struct *mm, unsigned long rnd)
33749 {
33750 unsigned long gap = rlimit(RLIMIT_STACK);
33751+ unsigned long pax_task_size = TASK_SIZE;
33752+
33753+#ifdef CONFIG_PAX_SEGMEXEC
33754+ if (mm->pax_flags & MF_PAX_SEGMEXEC)
33755+ pax_task_size = SEGMEXEC_TASK_SIZE;
33756+#endif
33757
33758 if (gap < MIN_GAP)
33759 gap = MIN_GAP;
33760 else if (gap > MAX_GAP)
33761 gap = MAX_GAP;
33762
33763- return PAGE_ALIGN(TASK_SIZE - gap - rnd);
33764+ return PAGE_ALIGN(pax_task_size - gap - rnd);
33765 }
33766
33767 /*
33768 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
33769 * does, but not when emulating X86_32
33770 */
33771-static unsigned long mmap_legacy_base(unsigned long rnd)
33772+static unsigned long mmap_legacy_base(struct mm_struct *mm, unsigned long rnd)
33773 {
33774- if (mmap_is_ia32())
33775+ if (mmap_is_ia32()) {
33776+
33777+#ifdef CONFIG_PAX_SEGMEXEC
33778+ if (mm->pax_flags & MF_PAX_SEGMEXEC)
33779+ return SEGMEXEC_TASK_UNMAPPED_BASE;
33780+ else
33781+#endif
33782+
33783 return TASK_UNMAPPED_BASE;
33784- else
33785+ } else
33786 return TASK_UNMAPPED_BASE + rnd;
33787 }
33788
33789@@ -113,16 +126,27 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
33790 {
33791 unsigned long random_factor = 0UL;
33792
33793+#ifdef CONFIG_PAX_RANDMMAP
33794+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
33795+#endif
33796 if (current->flags & PF_RANDOMIZE)
33797 random_factor = arch_mmap_rnd();
33798
33799- mm->mmap_legacy_base = mmap_legacy_base(random_factor);
33800+ mm->mmap_legacy_base = mmap_legacy_base(mm, random_factor);
33801
33802 if (mmap_is_legacy()) {
33803 mm->mmap_base = mm->mmap_legacy_base;
33804 mm->get_unmapped_area = arch_get_unmapped_area;
33805 } else {
33806- mm->mmap_base = mmap_base(random_factor);
33807+ mm->mmap_base = mmap_base(mm, random_factor);
33808 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
33809 }
33810+
33811+#ifdef CONFIG_PAX_RANDMMAP
33812+ if (mm->pax_flags & MF_PAX_RANDMMAP) {
33813+ mm->mmap_legacy_base += mm->delta_mmap;
33814+ mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
33815+ }
33816+#endif
33817+
33818 }
33819diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
33820index 0057a7a..95c7edd 100644
33821--- a/arch/x86/mm/mmio-mod.c
33822+++ b/arch/x86/mm/mmio-mod.c
33823@@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
33824 break;
33825 default:
33826 {
33827- unsigned char *ip = (unsigned char *)instptr;
33828+ unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
33829 my_trace->opcode = MMIO_UNKNOWN_OP;
33830 my_trace->width = 0;
33831 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
33832@@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
33833 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
33834 void __iomem *addr)
33835 {
33836- static atomic_t next_id;
33837+ static atomic_unchecked_t next_id;
33838 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
33839 /* These are page-unaligned. */
33840 struct mmiotrace_map map = {
33841@@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
33842 .private = trace
33843 },
33844 .phys = offset,
33845- .id = atomic_inc_return(&next_id)
33846+ .id = atomic_inc_return_unchecked(&next_id)
33847 };
33848 map.map_id = trace->id;
33849
33850@@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
33851 ioremap_trace_core(offset, size, addr);
33852 }
33853
33854-static void iounmap_trace_core(volatile void __iomem *addr)
33855+static void iounmap_trace_core(const volatile void __iomem *addr)
33856 {
33857 struct mmiotrace_map map = {
33858 .phys = 0,
33859@@ -328,7 +328,7 @@ not_enabled:
33860 }
33861 }
33862
33863-void mmiotrace_iounmap(volatile void __iomem *addr)
33864+void mmiotrace_iounmap(const volatile void __iomem *addr)
33865 {
33866 might_sleep();
33867 if (is_enabled()) /* recheck and proper locking in *_core() */
33868diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
33869index 4053bb5..b1ad3dc 100644
33870--- a/arch/x86/mm/numa.c
33871+++ b/arch/x86/mm/numa.c
33872@@ -506,7 +506,7 @@ static void __init numa_clear_kernel_node_hotplug(void)
33873 }
33874 }
33875
33876-static int __init numa_register_memblks(struct numa_meminfo *mi)
33877+static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
33878 {
33879 unsigned long uninitialized_var(pfn_align);
33880 int i, nid;
33881diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
33882index 89af288..05381957 100644
33883--- a/arch/x86/mm/pageattr.c
33884+++ b/arch/x86/mm/pageattr.c
33885@@ -260,7 +260,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
33886 */
33887 #ifdef CONFIG_PCI_BIOS
33888 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
33889- pgprot_val(forbidden) |= _PAGE_NX;
33890+ pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
33891 #endif
33892
33893 /*
33894@@ -268,9 +268,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
33895 * Does not cover __inittext since that is gone later on. On
33896 * 64bit we do not enforce !NX on the low mapping
33897 */
33898- if (within(address, (unsigned long)_text, (unsigned long)_etext))
33899- pgprot_val(forbidden) |= _PAGE_NX;
33900+ if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
33901+ pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
33902
33903+#ifdef CONFIG_DEBUG_RODATA
33904 /*
33905 * The .rodata section needs to be read-only. Using the pfn
33906 * catches all aliases.
33907@@ -278,6 +279,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
33908 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
33909 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
33910 pgprot_val(forbidden) |= _PAGE_RW;
33911+#endif
33912
33913 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
33914 /*
33915@@ -316,6 +318,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
33916 }
33917 #endif
33918
33919+#ifdef CONFIG_PAX_KERNEXEC
33920+ if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
33921+ pgprot_val(forbidden) |= _PAGE_RW;
33922+ pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
33923+ }
33924+#endif
33925+
33926 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
33927
33928 return prot;
33929@@ -438,23 +447,37 @@ EXPORT_SYMBOL_GPL(slow_virt_to_phys);
33930 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
33931 {
33932 /* change init_mm */
33933+ pax_open_kernel();
33934 set_pte_atomic(kpte, pte);
33935+
33936 #ifdef CONFIG_X86_32
33937 if (!SHARED_KERNEL_PMD) {
33938+
33939+#ifdef CONFIG_PAX_PER_CPU_PGD
33940+ unsigned long cpu;
33941+#else
33942 struct page *page;
33943+#endif
33944
33945+#ifdef CONFIG_PAX_PER_CPU_PGD
33946+ for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
33947+ pgd_t *pgd = get_cpu_pgd(cpu, kernel);
33948+#else
33949 list_for_each_entry(page, &pgd_list, lru) {
33950- pgd_t *pgd;
33951+ pgd_t *pgd = (pgd_t *)page_address(page);
33952+#endif
33953+
33954 pud_t *pud;
33955 pmd_t *pmd;
33956
33957- pgd = (pgd_t *)page_address(page) + pgd_index(address);
33958+ pgd += pgd_index(address);
33959 pud = pud_offset(pgd, address);
33960 pmd = pmd_offset(pud, address);
33961 set_pte_atomic((pte_t *)pmd, pte);
33962 }
33963 }
33964 #endif
33965+ pax_close_kernel();
33966 }
33967
33968 static int
33969diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
33970index 35af677..e7bf11f 100644
33971--- a/arch/x86/mm/pat.c
33972+++ b/arch/x86/mm/pat.c
33973@@ -89,7 +89,7 @@ static inline enum page_cache_mode get_page_memtype(struct page *pg)
33974 unsigned long pg_flags = pg->flags & _PGMT_MASK;
33975
33976 if (pg_flags == _PGMT_DEFAULT)
33977- return -1;
33978+ return _PAGE_CACHE_MODE_NUM;
33979 else if (pg_flags == _PGMT_WC)
33980 return _PAGE_CACHE_MODE_WC;
33981 else if (pg_flags == _PGMT_UC_MINUS)
33982@@ -346,7 +346,7 @@ static int reserve_ram_pages_type(u64 start, u64 end,
33983
33984 page = pfn_to_page(pfn);
33985 type = get_page_memtype(page);
33986- if (type != -1) {
33987+ if (type != _PAGE_CACHE_MODE_NUM) {
33988 pr_info("reserve_ram_pages_type failed [mem %#010Lx-%#010Lx], track 0x%x, req 0x%x\n",
33989 start, end - 1, type, req_type);
33990 if (new_type)
33991@@ -498,7 +498,7 @@ int free_memtype(u64 start, u64 end)
33992
33993 if (!entry) {
33994 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
33995- current->comm, current->pid, start, end - 1);
33996+ current->comm, task_pid_nr(current), start, end - 1);
33997 return -EINVAL;
33998 }
33999
34000@@ -532,10 +532,10 @@ static enum page_cache_mode lookup_memtype(u64 paddr)
34001 page = pfn_to_page(paddr >> PAGE_SHIFT);
34002 rettype = get_page_memtype(page);
34003 /*
34004- * -1 from get_page_memtype() implies RAM page is in its
34005+ * _PAGE_CACHE_MODE_NUM from get_page_memtype() implies RAM page is in its
34006 * default state and not reserved, and hence of type WB
34007 */
34008- if (rettype == -1)
34009+ if (rettype == _PAGE_CACHE_MODE_NUM)
34010 rettype = _PAGE_CACHE_MODE_WB;
34011
34012 return rettype;
34013@@ -628,8 +628,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34014
34015 while (cursor < to) {
34016 if (!devmem_is_allowed(pfn)) {
34017- printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx], PAT prevents it\n",
34018- current->comm, from, to - 1);
34019+ printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx), PAT prevents it\n",
34020+ current->comm, from, to - 1, cursor);
34021 return 0;
34022 }
34023 cursor += PAGE_SIZE;
34024@@ -700,7 +700,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size,
34025 if (ioremap_change_attr((unsigned long)__va(base), id_sz, pcm) < 0) {
34026 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
34027 "for [mem %#010Lx-%#010Lx]\n",
34028- current->comm, current->pid,
34029+ current->comm, task_pid_nr(current),
34030 cattr_name(pcm),
34031 base, (unsigned long long)(base + size-1));
34032 return -EINVAL;
34033@@ -735,7 +735,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
34034 pcm = lookup_memtype(paddr);
34035 if (want_pcm != pcm) {
34036 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
34037- current->comm, current->pid,
34038+ current->comm, task_pid_nr(current),
34039 cattr_name(want_pcm),
34040 (unsigned long long)paddr,
34041 (unsigned long long)(paddr + size - 1),
34042@@ -757,7 +757,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
34043 free_memtype(paddr, paddr + size);
34044 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
34045 " for [mem %#010Lx-%#010Lx], got %s\n",
34046- current->comm, current->pid,
34047+ current->comm, task_pid_nr(current),
34048 cattr_name(want_pcm),
34049 (unsigned long long)paddr,
34050 (unsigned long long)(paddr + size - 1),
34051diff --git a/arch/x86/mm/pat_rbtree.c b/arch/x86/mm/pat_rbtree.c
34052index 6582adc..fcc5d0b 100644
34053--- a/arch/x86/mm/pat_rbtree.c
34054+++ b/arch/x86/mm/pat_rbtree.c
34055@@ -161,7 +161,7 @@ success:
34056
34057 failure:
34058 printk(KERN_INFO "%s:%d conflicting memory types "
34059- "%Lx-%Lx %s<->%s\n", current->comm, current->pid, start,
34060+ "%Lx-%Lx %s<->%s\n", current->comm, task_pid_nr(current), start,
34061 end, cattr_name(found_type), cattr_name(match->type));
34062 return -EBUSY;
34063 }
34064diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
34065index 9f0614d..92ae64a 100644
34066--- a/arch/x86/mm/pf_in.c
34067+++ b/arch/x86/mm/pf_in.c
34068@@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
34069 int i;
34070 enum reason_type rv = OTHERS;
34071
34072- p = (unsigned char *)ins_addr;
34073+ p = (unsigned char *)ktla_ktva(ins_addr);
34074 p += skip_prefix(p, &prf);
34075 p += get_opcode(p, &opcode);
34076
34077@@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
34078 struct prefix_bits prf;
34079 int i;
34080
34081- p = (unsigned char *)ins_addr;
34082+ p = (unsigned char *)ktla_ktva(ins_addr);
34083 p += skip_prefix(p, &prf);
34084 p += get_opcode(p, &opcode);
34085
34086@@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
34087 struct prefix_bits prf;
34088 int i;
34089
34090- p = (unsigned char *)ins_addr;
34091+ p = (unsigned char *)ktla_ktva(ins_addr);
34092 p += skip_prefix(p, &prf);
34093 p += get_opcode(p, &opcode);
34094
34095@@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
34096 struct prefix_bits prf;
34097 int i;
34098
34099- p = (unsigned char *)ins_addr;
34100+ p = (unsigned char *)ktla_ktva(ins_addr);
34101 p += skip_prefix(p, &prf);
34102 p += get_opcode(p, &opcode);
34103 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
34104@@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
34105 struct prefix_bits prf;
34106 int i;
34107
34108- p = (unsigned char *)ins_addr;
34109+ p = (unsigned char *)ktla_ktva(ins_addr);
34110 p += skip_prefix(p, &prf);
34111 p += get_opcode(p, &opcode);
34112 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
34113diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
34114index 0b97d2c..597bb38 100644
34115--- a/arch/x86/mm/pgtable.c
34116+++ b/arch/x86/mm/pgtable.c
34117@@ -98,10 +98,75 @@ static inline void pgd_list_del(pgd_t *pgd)
34118 list_del(&page->lru);
34119 }
34120
34121-#define UNSHARED_PTRS_PER_PGD \
34122- (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
34123+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
34124+pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
34125
34126+void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
34127+{
34128+ unsigned int count = USER_PGD_PTRS;
34129
34130+ if (!pax_user_shadow_base)
34131+ return;
34132+
34133+ while (count--)
34134+ *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
34135+}
34136+#endif
34137+
34138+#ifdef CONFIG_PAX_PER_CPU_PGD
34139+void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
34140+{
34141+ unsigned int count = USER_PGD_PTRS;
34142+
34143+ while (count--) {
34144+ pgd_t pgd;
34145+
34146+#ifdef CONFIG_X86_64
34147+ pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
34148+#else
34149+ pgd = *src++;
34150+#endif
34151+
34152+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
34153+ pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
34154+#endif
34155+
34156+ *dst++ = pgd;
34157+ }
34158+
34159+}
34160+#endif
34161+
34162+#ifdef CONFIG_X86_64
34163+#define pxd_t pud_t
34164+#define pyd_t pgd_t
34165+#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
34166+#define pgtable_pxd_page_ctor(page) true
34167+#define pgtable_pxd_page_dtor(page) do {} while (0)
34168+#define pxd_free(mm, pud) pud_free((mm), (pud))
34169+#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
34170+#define pyd_offset(mm, address) pgd_offset((mm), (address))
34171+#define PYD_SIZE PGDIR_SIZE
34172+#define mm_inc_nr_pxds(mm) do {} while (0)
34173+#define mm_dec_nr_pxds(mm) do {} while (0)
34174+#else
34175+#define pxd_t pmd_t
34176+#define pyd_t pud_t
34177+#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
34178+#define pgtable_pxd_page_ctor(page) pgtable_pmd_page_ctor(page)
34179+#define pgtable_pxd_page_dtor(page) pgtable_pmd_page_dtor(page)
34180+#define pxd_free(mm, pud) pmd_free((mm), (pud))
34181+#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
34182+#define pyd_offset(mm, address) pud_offset((mm), (address))
34183+#define PYD_SIZE PUD_SIZE
34184+#define mm_inc_nr_pxds(mm) mm_inc_nr_pmds(mm)
34185+#define mm_dec_nr_pxds(mm) mm_dec_nr_pmds(mm)
34186+#endif
34187+
34188+#ifdef CONFIG_PAX_PER_CPU_PGD
34189+static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
34190+static inline void pgd_dtor(pgd_t *pgd) {}
34191+#else
34192 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
34193 {
34194 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
34195@@ -142,6 +207,7 @@ static void pgd_dtor(pgd_t *pgd)
34196 pgd_list_del(pgd);
34197 spin_unlock(&pgd_lock);
34198 }
34199+#endif
34200
34201 /*
34202 * List of all pgd's needed for non-PAE so it can invalidate entries
34203@@ -154,7 +220,7 @@ static void pgd_dtor(pgd_t *pgd)
34204 * -- nyc
34205 */
34206
34207-#ifdef CONFIG_X86_PAE
34208+#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
34209 /*
34210 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
34211 * updating the top-level pagetable entries to guarantee the
34212@@ -166,7 +232,7 @@ static void pgd_dtor(pgd_t *pgd)
34213 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
34214 * and initialize the kernel pmds here.
34215 */
34216-#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
34217+#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
34218
34219 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
34220 {
34221@@ -184,46 +250,48 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
34222 */
34223 flush_tlb_mm(mm);
34224 }
34225+#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
34226+#define PREALLOCATED_PXDS USER_PGD_PTRS
34227 #else /* !CONFIG_X86_PAE */
34228
34229 /* No need to prepopulate any pagetable entries in non-PAE modes. */
34230-#define PREALLOCATED_PMDS 0
34231+#define PREALLOCATED_PXDS 0
34232
34233 #endif /* CONFIG_X86_PAE */
34234
34235-static void free_pmds(struct mm_struct *mm, pmd_t *pmds[])
34236+static void free_pxds(struct mm_struct *mm, pxd_t *pxds[])
34237 {
34238 int i;
34239
34240- for(i = 0; i < PREALLOCATED_PMDS; i++)
34241- if (pmds[i]) {
34242- pgtable_pmd_page_dtor(virt_to_page(pmds[i]));
34243- free_page((unsigned long)pmds[i]);
34244- mm_dec_nr_pmds(mm);
34245+ for(i = 0; i < PREALLOCATED_PXDS; i++)
34246+ if (pxds[i]) {
34247+ pgtable_pxd_page_dtor(virt_to_page(pxds[i]));
34248+ free_page((unsigned long)pxds[i]);
34249+ mm_dec_nr_pxds(mm);
34250 }
34251 }
34252
34253-static int preallocate_pmds(struct mm_struct *mm, pmd_t *pmds[])
34254+static int preallocate_pxds(struct mm_struct *mm, pxd_t *pxds[])
34255 {
34256 int i;
34257 bool failed = false;
34258
34259- for(i = 0; i < PREALLOCATED_PMDS; i++) {
34260- pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
34261- if (!pmd)
34262+ for(i = 0; i < PREALLOCATED_PXDS; i++) {
34263+ pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
34264+ if (!pxd)
34265 failed = true;
34266- if (pmd && !pgtable_pmd_page_ctor(virt_to_page(pmd))) {
34267- free_page((unsigned long)pmd);
34268- pmd = NULL;
34269+ if (pxd && !pgtable_pxd_page_ctor(virt_to_page(pxd))) {
34270+ free_page((unsigned long)pxd);
34271+ pxd = NULL;
34272 failed = true;
34273 }
34274- if (pmd)
34275- mm_inc_nr_pmds(mm);
34276- pmds[i] = pmd;
34277+ if (pxd)
34278+ mm_inc_nr_pxds(mm);
34279+ pxds[i] = pxd;
34280 }
34281
34282 if (failed) {
34283- free_pmds(mm, pmds);
34284+ free_pxds(mm, pxds);
34285 return -ENOMEM;
34286 }
34287
34288@@ -236,43 +304,47 @@ static int preallocate_pmds(struct mm_struct *mm, pmd_t *pmds[])
34289 * preallocate which never got a corresponding vma will need to be
34290 * freed manually.
34291 */
34292-static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
34293+static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
34294 {
34295 int i;
34296
34297- for(i = 0; i < PREALLOCATED_PMDS; i++) {
34298+ for(i = 0; i < PREALLOCATED_PXDS; i++) {
34299 pgd_t pgd = pgdp[i];
34300
34301 if (pgd_val(pgd) != 0) {
34302- pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
34303+ pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
34304
34305- pgdp[i] = native_make_pgd(0);
34306+ set_pgd(pgdp + i, native_make_pgd(0));
34307
34308- paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
34309- pmd_free(mm, pmd);
34310- mm_dec_nr_pmds(mm);
34311+ paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
34312+ pxd_free(mm, pxd);
34313+ mm_dec_nr_pxds(mm);
34314 }
34315 }
34316 }
34317
34318-static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
34319+static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
34320 {
34321- pud_t *pud;
34322+ pyd_t *pyd;
34323 int i;
34324
34325- if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
34326+ if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
34327 return;
34328
34329- pud = pud_offset(pgd, 0);
34330+#ifdef CONFIG_X86_64
34331+ pyd = pyd_offset(mm, 0L);
34332+#else
34333+ pyd = pyd_offset(pgd, 0L);
34334+#endif
34335
34336- for (i = 0; i < PREALLOCATED_PMDS; i++, pud++) {
34337- pmd_t *pmd = pmds[i];
34338+ for (i = 0; i < PREALLOCATED_PXDS; i++, pyd++) {
34339+ pxd_t *pxd = pxds[i];
34340
34341 if (i >= KERNEL_PGD_BOUNDARY)
34342- memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
34343- sizeof(pmd_t) * PTRS_PER_PMD);
34344+ memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
34345+ sizeof(pxd_t) * PTRS_PER_PMD);
34346
34347- pud_populate(mm, pud, pmd);
34348+ pyd_populate(mm, pyd, pxd);
34349 }
34350 }
34351
34352@@ -354,7 +426,7 @@ static inline void _pgd_free(pgd_t *pgd)
34353 pgd_t *pgd_alloc(struct mm_struct *mm)
34354 {
34355 pgd_t *pgd;
34356- pmd_t *pmds[PREALLOCATED_PMDS];
34357+ pxd_t *pxds[PREALLOCATED_PXDS];
34358
34359 pgd = _pgd_alloc();
34360
34361@@ -363,11 +435,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
34362
34363 mm->pgd = pgd;
34364
34365- if (preallocate_pmds(mm, pmds) != 0)
34366+ if (preallocate_pxds(mm, pxds) != 0)
34367 goto out_free_pgd;
34368
34369 if (paravirt_pgd_alloc(mm) != 0)
34370- goto out_free_pmds;
34371+ goto out_free_pxds;
34372
34373 /*
34374 * Make sure that pre-populating the pmds is atomic with
34375@@ -377,14 +449,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
34376 spin_lock(&pgd_lock);
34377
34378 pgd_ctor(mm, pgd);
34379- pgd_prepopulate_pmd(mm, pgd, pmds);
34380+ pgd_prepopulate_pxd(mm, pgd, pxds);
34381
34382 spin_unlock(&pgd_lock);
34383
34384 return pgd;
34385
34386-out_free_pmds:
34387- free_pmds(mm, pmds);
34388+out_free_pxds:
34389+ free_pxds(mm, pxds);
34390 out_free_pgd:
34391 _pgd_free(pgd);
34392 out:
34393@@ -393,7 +465,7 @@ out:
34394
34395 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
34396 {
34397- pgd_mop_up_pmds(mm, pgd);
34398+ pgd_mop_up_pxds(mm, pgd);
34399 pgd_dtor(pgd);
34400 paravirt_pgd_free(mm, pgd);
34401 _pgd_free(pgd);
34402diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
34403index 75cc097..79a097f 100644
34404--- a/arch/x86/mm/pgtable_32.c
34405+++ b/arch/x86/mm/pgtable_32.c
34406@@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
34407 return;
34408 }
34409 pte = pte_offset_kernel(pmd, vaddr);
34410+
34411+ pax_open_kernel();
34412 if (pte_val(pteval))
34413 set_pte_at(&init_mm, vaddr, pte, pteval);
34414 else
34415 pte_clear(&init_mm, vaddr, pte);
34416+ pax_close_kernel();
34417
34418 /*
34419 * It's enough to flush this one mapping.
34420diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
34421index e666cbb..61788c45 100644
34422--- a/arch/x86/mm/physaddr.c
34423+++ b/arch/x86/mm/physaddr.c
34424@@ -10,7 +10,7 @@
34425 #ifdef CONFIG_X86_64
34426
34427 #ifdef CONFIG_DEBUG_VIRTUAL
34428-unsigned long __phys_addr(unsigned long x)
34429+unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
34430 {
34431 unsigned long y = x - __START_KERNEL_map;
34432
34433@@ -67,7 +67,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
34434 #else
34435
34436 #ifdef CONFIG_DEBUG_VIRTUAL
34437-unsigned long __phys_addr(unsigned long x)
34438+unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
34439 {
34440 unsigned long phys_addr = x - PAGE_OFFSET;
34441 /* VMALLOC_* aren't constants */
34442diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
34443index 90555bf..f5f1828 100644
34444--- a/arch/x86/mm/setup_nx.c
34445+++ b/arch/x86/mm/setup_nx.c
34446@@ -5,8 +5,10 @@
34447 #include <asm/pgtable.h>
34448 #include <asm/proto.h>
34449
34450+#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
34451 static int disable_nx;
34452
34453+#ifndef CONFIG_PAX_PAGEEXEC
34454 /*
34455 * noexec = on|off
34456 *
34457@@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
34458 return 0;
34459 }
34460 early_param("noexec", noexec_setup);
34461+#endif
34462+
34463+#endif
34464
34465 void x86_configure_nx(void)
34466 {
34467+#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
34468 if (cpu_has_nx && !disable_nx)
34469 __supported_pte_mask |= _PAGE_NX;
34470 else
34471+#endif
34472 __supported_pte_mask &= ~_PAGE_NX;
34473 }
34474
34475diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
34476index 3250f23..4197ac2 100644
34477--- a/arch/x86/mm/tlb.c
34478+++ b/arch/x86/mm/tlb.c
34479@@ -45,7 +45,11 @@ void leave_mm(int cpu)
34480 BUG();
34481 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
34482 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
34483+
34484+#ifndef CONFIG_PAX_PER_CPU_PGD
34485 load_cr3(swapper_pg_dir);
34486+#endif
34487+
34488 /*
34489 * This gets called in the idle path where RCU
34490 * functions differently. Tracing normally
34491@@ -117,7 +121,7 @@ static void flush_tlb_func(void *info)
34492 } else {
34493 unsigned long addr;
34494 unsigned long nr_pages =
34495- f->flush_end - f->flush_start / PAGE_SIZE;
34496+ (f->flush_end - f->flush_start) / PAGE_SIZE;
34497 addr = f->flush_start;
34498 while (addr < f->flush_end) {
34499 __flush_tlb_single(addr);
34500diff --git a/arch/x86/mm/uderef_64.c b/arch/x86/mm/uderef_64.c
34501new file mode 100644
34502index 0000000..3fda3f3
34503--- /dev/null
34504+++ b/arch/x86/mm/uderef_64.c
34505@@ -0,0 +1,37 @@
34506+#include <linux/mm.h>
34507+#include <asm/pgtable.h>
34508+#include <asm/uaccess.h>
34509+
34510+#ifdef CONFIG_PAX_MEMORY_UDEREF
34511+/* PaX: due to the special call convention these functions must
34512+ * - remain leaf functions under all configurations,
34513+ * - never be called directly, only dereferenced from the wrappers.
34514+ */
34515+void __used __pax_open_userland(void)
34516+{
34517+ unsigned int cpu;
34518+
34519+ if (unlikely(!segment_eq(get_fs(), USER_DS)))
34520+ return;
34521+
34522+ cpu = raw_get_cpu();
34523+ BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_KERNEL);
34524+ write_cr3(__pa_nodebug(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
34525+ raw_put_cpu_no_resched();
34526+}
34527+EXPORT_SYMBOL(__pax_open_userland);
34528+
34529+void __used __pax_close_userland(void)
34530+{
34531+ unsigned int cpu;
34532+
34533+ if (unlikely(!segment_eq(get_fs(), USER_DS)))
34534+ return;
34535+
34536+ cpu = raw_get_cpu();
34537+ BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_USER);
34538+ write_cr3(__pa_nodebug(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
34539+ raw_put_cpu_no_resched();
34540+}
34541+EXPORT_SYMBOL(__pax_close_userland);
34542+#endif
34543diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
34544index 6440221..f84b5c7 100644
34545--- a/arch/x86/net/bpf_jit.S
34546+++ b/arch/x86/net/bpf_jit.S
34547@@ -9,6 +9,7 @@
34548 */
34549 #include <linux/linkage.h>
34550 #include <asm/dwarf2.h>
34551+#include <asm/alternative-asm.h>
34552
34553 /*
34554 * Calling convention :
34555@@ -38,6 +39,7 @@ sk_load_word_positive_offset:
34556 jle bpf_slow_path_word
34557 mov (SKBDATA,%rsi),%eax
34558 bswap %eax /* ntohl() */
34559+ pax_force_retaddr
34560 ret
34561
34562 sk_load_half:
34563@@ -55,6 +57,7 @@ sk_load_half_positive_offset:
34564 jle bpf_slow_path_half
34565 movzwl (SKBDATA,%rsi),%eax
34566 rol $8,%ax # ntohs()
34567+ pax_force_retaddr
34568 ret
34569
34570 sk_load_byte:
34571@@ -69,6 +72,7 @@ sk_load_byte_positive_offset:
34572 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
34573 jle bpf_slow_path_byte
34574 movzbl (SKBDATA,%rsi),%eax
34575+ pax_force_retaddr
34576 ret
34577
34578 /* rsi contains offset and can be scratched */
34579@@ -90,6 +94,7 @@ bpf_slow_path_word:
34580 js bpf_error
34581 mov - MAX_BPF_STACK + 32(%rbp),%eax
34582 bswap %eax
34583+ pax_force_retaddr
34584 ret
34585
34586 bpf_slow_path_half:
34587@@ -98,12 +103,14 @@ bpf_slow_path_half:
34588 mov - MAX_BPF_STACK + 32(%rbp),%ax
34589 rol $8,%ax
34590 movzwl %ax,%eax
34591+ pax_force_retaddr
34592 ret
34593
34594 bpf_slow_path_byte:
34595 bpf_slow_path_common(1)
34596 js bpf_error
34597 movzbl - MAX_BPF_STACK + 32(%rbp),%eax
34598+ pax_force_retaddr
34599 ret
34600
34601 #define sk_negative_common(SIZE) \
34602@@ -126,6 +133,7 @@ sk_load_word_negative_offset:
34603 sk_negative_common(4)
34604 mov (%rax), %eax
34605 bswap %eax
34606+ pax_force_retaddr
34607 ret
34608
34609 bpf_slow_path_half_neg:
34610@@ -137,6 +145,7 @@ sk_load_half_negative_offset:
34611 mov (%rax),%ax
34612 rol $8,%ax
34613 movzwl %ax,%eax
34614+ pax_force_retaddr
34615 ret
34616
34617 bpf_slow_path_byte_neg:
34618@@ -146,6 +155,7 @@ sk_load_byte_negative_offset:
34619 .globl sk_load_byte_negative_offset
34620 sk_negative_common(1)
34621 movzbl (%rax), %eax
34622+ pax_force_retaddr
34623 ret
34624
34625 bpf_error:
34626@@ -156,4 +166,5 @@ bpf_error:
34627 mov - MAX_BPF_STACK + 16(%rbp),%r14
34628 mov - MAX_BPF_STACK + 24(%rbp),%r15
34629 leaveq
34630+ pax_force_retaddr
34631 ret
34632diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
34633index ddeff48..877ead6 100644
34634--- a/arch/x86/net/bpf_jit_comp.c
34635+++ b/arch/x86/net/bpf_jit_comp.c
34636@@ -13,7 +13,11 @@
34637 #include <linux/if_vlan.h>
34638 #include <asm/cacheflush.h>
34639
34640+#ifdef CONFIG_GRKERNSEC_BPF_HARDEN
34641+int bpf_jit_enable __read_only;
34642+#else
34643 int bpf_jit_enable __read_mostly;
34644+#endif
34645
34646 /*
34647 * assembly code in arch/x86/net/bpf_jit.S
34648@@ -174,7 +178,9 @@ static u8 add_2reg(u8 byte, u32 dst_reg, u32 src_reg)
34649 static void jit_fill_hole(void *area, unsigned int size)
34650 {
34651 /* fill whole space with int3 instructions */
34652+ pax_open_kernel();
34653 memset(area, 0xcc, size);
34654+ pax_close_kernel();
34655 }
34656
34657 struct jit_context {
34658@@ -924,7 +930,9 @@ common_load:
34659 pr_err("bpf_jit_compile fatal error\n");
34660 return -EFAULT;
34661 }
34662+ pax_open_kernel();
34663 memcpy(image + proglen, temp, ilen);
34664+ pax_close_kernel();
34665 }
34666 proglen += ilen;
34667 addrs[i] = proglen;
34668@@ -1001,7 +1009,6 @@ void bpf_int_jit_compile(struct bpf_prog *prog)
34669
34670 if (image) {
34671 bpf_flush_icache(header, image + proglen);
34672- set_memory_ro((unsigned long)header, header->pages);
34673 prog->bpf_func = (void *)image;
34674 prog->jited = true;
34675 }
34676@@ -1014,12 +1021,8 @@ void bpf_jit_free(struct bpf_prog *fp)
34677 unsigned long addr = (unsigned long)fp->bpf_func & PAGE_MASK;
34678 struct bpf_binary_header *header = (void *)addr;
34679
34680- if (!fp->jited)
34681- goto free_filter;
34682+ if (fp->jited)
34683+ bpf_jit_binary_free(header);
34684
34685- set_memory_rw(addr, header->pages);
34686- bpf_jit_binary_free(header);
34687-
34688-free_filter:
34689 bpf_prog_unlock_free(fp);
34690 }
34691diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
34692index 4e664bd..2beeaa2 100644
34693--- a/arch/x86/oprofile/backtrace.c
34694+++ b/arch/x86/oprofile/backtrace.c
34695@@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
34696 struct stack_frame_ia32 *fp;
34697 unsigned long bytes;
34698
34699- bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
34700+ bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
34701 if (bytes != 0)
34702 return NULL;
34703
34704- fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
34705+ fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
34706
34707 oprofile_add_trace(bufhead[0].return_address);
34708
34709@@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
34710 struct stack_frame bufhead[2];
34711 unsigned long bytes;
34712
34713- bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
34714+ bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
34715 if (bytes != 0)
34716 return NULL;
34717
34718diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
34719index 1d2e639..f6ef82a 100644
34720--- a/arch/x86/oprofile/nmi_int.c
34721+++ b/arch/x86/oprofile/nmi_int.c
34722@@ -23,6 +23,7 @@
34723 #include <asm/nmi.h>
34724 #include <asm/msr.h>
34725 #include <asm/apic.h>
34726+#include <asm/pgtable.h>
34727
34728 #include "op_counter.h"
34729 #include "op_x86_model.h"
34730@@ -785,8 +786,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
34731 if (ret)
34732 return ret;
34733
34734- if (!model->num_virt_counters)
34735- model->num_virt_counters = model->num_counters;
34736+ if (!model->num_virt_counters) {
34737+ pax_open_kernel();
34738+ *(unsigned int *)&model->num_virt_counters = model->num_counters;
34739+ pax_close_kernel();
34740+ }
34741
34742 mux_init(ops);
34743
34744diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
34745index 50d86c0..7985318 100644
34746--- a/arch/x86/oprofile/op_model_amd.c
34747+++ b/arch/x86/oprofile/op_model_amd.c
34748@@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
34749 num_counters = AMD64_NUM_COUNTERS;
34750 }
34751
34752- op_amd_spec.num_counters = num_counters;
34753- op_amd_spec.num_controls = num_counters;
34754- op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
34755+ pax_open_kernel();
34756+ *(unsigned int *)&op_amd_spec.num_counters = num_counters;
34757+ *(unsigned int *)&op_amd_spec.num_controls = num_counters;
34758+ *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
34759+ pax_close_kernel();
34760
34761 return 0;
34762 }
34763diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
34764index d90528e..0127e2b 100644
34765--- a/arch/x86/oprofile/op_model_ppro.c
34766+++ b/arch/x86/oprofile/op_model_ppro.c
34767@@ -19,6 +19,7 @@
34768 #include <asm/msr.h>
34769 #include <asm/apic.h>
34770 #include <asm/nmi.h>
34771+#include <asm/pgtable.h>
34772
34773 #include "op_x86_model.h"
34774 #include "op_counter.h"
34775@@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
34776
34777 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
34778
34779- op_arch_perfmon_spec.num_counters = num_counters;
34780- op_arch_perfmon_spec.num_controls = num_counters;
34781+ pax_open_kernel();
34782+ *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
34783+ *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
34784+ pax_close_kernel();
34785 }
34786
34787 static int arch_perfmon_init(struct oprofile_operations *ignore)
34788diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
34789index 71e8a67..6a313bb 100644
34790--- a/arch/x86/oprofile/op_x86_model.h
34791+++ b/arch/x86/oprofile/op_x86_model.h
34792@@ -52,7 +52,7 @@ struct op_x86_model_spec {
34793 void (*switch_ctrl)(struct op_x86_model_spec const *model,
34794 struct op_msrs const * const msrs);
34795 #endif
34796-};
34797+} __do_const;
34798
34799 struct op_counter_config;
34800
34801diff --git a/arch/x86/pci/intel_mid_pci.c b/arch/x86/pci/intel_mid_pci.c
34802index 852aa4c..71613f2 100644
34803--- a/arch/x86/pci/intel_mid_pci.c
34804+++ b/arch/x86/pci/intel_mid_pci.c
34805@@ -258,7 +258,7 @@ int __init intel_mid_pci_init(void)
34806 pci_mmcfg_late_init();
34807 pcibios_enable_irq = intel_mid_pci_irq_enable;
34808 pcibios_disable_irq = intel_mid_pci_irq_disable;
34809- pci_root_ops = intel_mid_pci_ops;
34810+ memcpy((void *)&pci_root_ops, &intel_mid_pci_ops, sizeof pci_root_ops);
34811 pci_soc_mode = 1;
34812 /* Continue with standard init */
34813 return 1;
34814diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
34815index 5dc6ca5..25c03f5 100644
34816--- a/arch/x86/pci/irq.c
34817+++ b/arch/x86/pci/irq.c
34818@@ -51,7 +51,7 @@ struct irq_router {
34819 struct irq_router_handler {
34820 u16 vendor;
34821 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
34822-};
34823+} __do_const;
34824
34825 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
34826 void (*pcibios_disable_irq)(struct pci_dev *dev) = pirq_disable_irq;
34827@@ -791,7 +791,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
34828 return 0;
34829 }
34830
34831-static __initdata struct irq_router_handler pirq_routers[] = {
34832+static __initconst const struct irq_router_handler pirq_routers[] = {
34833 { PCI_VENDOR_ID_INTEL, intel_router_probe },
34834 { PCI_VENDOR_ID_AL, ali_router_probe },
34835 { PCI_VENDOR_ID_ITE, ite_router_probe },
34836@@ -818,7 +818,7 @@ static struct pci_dev *pirq_router_dev;
34837 static void __init pirq_find_router(struct irq_router *r)
34838 {
34839 struct irq_routing_table *rt = pirq_table;
34840- struct irq_router_handler *h;
34841+ const struct irq_router_handler *h;
34842
34843 #ifdef CONFIG_PCI_BIOS
34844 if (!rt->signature) {
34845@@ -1091,7 +1091,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
34846 return 0;
34847 }
34848
34849-static struct dmi_system_id __initdata pciirq_dmi_table[] = {
34850+static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
34851 {
34852 .callback = fix_broken_hp_bios_irq9,
34853 .ident = "HP Pavilion N5400 Series Laptop",
34854diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
34855index 9b83b90..4112152 100644
34856--- a/arch/x86/pci/pcbios.c
34857+++ b/arch/x86/pci/pcbios.c
34858@@ -79,7 +79,7 @@ union bios32 {
34859 static struct {
34860 unsigned long address;
34861 unsigned short segment;
34862-} bios32_indirect __initdata = { 0, __KERNEL_CS };
34863+} bios32_indirect __initconst = { 0, __PCIBIOS_CS };
34864
34865 /*
34866 * Returns the entry point for the given service, NULL on error
34867@@ -92,37 +92,80 @@ static unsigned long __init bios32_service(unsigned long service)
34868 unsigned long length; /* %ecx */
34869 unsigned long entry; /* %edx */
34870 unsigned long flags;
34871+ struct desc_struct d, *gdt;
34872
34873 local_irq_save(flags);
34874- __asm__("lcall *(%%edi); cld"
34875+
34876+ gdt = get_cpu_gdt_table(smp_processor_id());
34877+
34878+ pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
34879+ write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
34880+ pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
34881+ write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
34882+
34883+ __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
34884 : "=a" (return_code),
34885 "=b" (address),
34886 "=c" (length),
34887 "=d" (entry)
34888 : "0" (service),
34889 "1" (0),
34890- "D" (&bios32_indirect));
34891+ "D" (&bios32_indirect),
34892+ "r"(__PCIBIOS_DS)
34893+ : "memory");
34894+
34895+ pax_open_kernel();
34896+ gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
34897+ gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
34898+ gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
34899+ gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
34900+ pax_close_kernel();
34901+
34902 local_irq_restore(flags);
34903
34904 switch (return_code) {
34905- case 0:
34906- return address + entry;
34907- case 0x80: /* Not present */
34908- printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
34909- return 0;
34910- default: /* Shouldn't happen */
34911- printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
34912- service, return_code);
34913+ case 0: {
34914+ int cpu;
34915+ unsigned char flags;
34916+
34917+ printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
34918+ if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
34919+ printk(KERN_WARNING "bios32_service: not valid\n");
34920 return 0;
34921+ }
34922+ address = address + PAGE_OFFSET;
34923+ length += 16UL; /* some BIOSs underreport this... */
34924+ flags = 4;
34925+ if (length >= 64*1024*1024) {
34926+ length >>= PAGE_SHIFT;
34927+ flags |= 8;
34928+ }
34929+
34930+ for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
34931+ gdt = get_cpu_gdt_table(cpu);
34932+ pack_descriptor(&d, address, length, 0x9b, flags);
34933+ write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
34934+ pack_descriptor(&d, address, length, 0x93, flags);
34935+ write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
34936+ }
34937+ return entry;
34938+ }
34939+ case 0x80: /* Not present */
34940+ printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
34941+ return 0;
34942+ default: /* Shouldn't happen */
34943+ printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
34944+ service, return_code);
34945+ return 0;
34946 }
34947 }
34948
34949 static struct {
34950 unsigned long address;
34951 unsigned short segment;
34952-} pci_indirect = { 0, __KERNEL_CS };
34953+} pci_indirect __read_only = { 0, __PCIBIOS_CS };
34954
34955-static int pci_bios_present;
34956+static int pci_bios_present __read_only;
34957
34958 static int __init check_pcibios(void)
34959 {
34960@@ -131,11 +174,13 @@ static int __init check_pcibios(void)
34961 unsigned long flags, pcibios_entry;
34962
34963 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
34964- pci_indirect.address = pcibios_entry + PAGE_OFFSET;
34965+ pci_indirect.address = pcibios_entry;
34966
34967 local_irq_save(flags);
34968- __asm__(
34969- "lcall *(%%edi); cld\n\t"
34970+ __asm__("movw %w6, %%ds\n\t"
34971+ "lcall *%%ss:(%%edi); cld\n\t"
34972+ "push %%ss\n\t"
34973+ "pop %%ds\n\t"
34974 "jc 1f\n\t"
34975 "xor %%ah, %%ah\n"
34976 "1:"
34977@@ -144,7 +189,8 @@ static int __init check_pcibios(void)
34978 "=b" (ebx),
34979 "=c" (ecx)
34980 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
34981- "D" (&pci_indirect)
34982+ "D" (&pci_indirect),
34983+ "r" (__PCIBIOS_DS)
34984 : "memory");
34985 local_irq_restore(flags);
34986
34987@@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
34988
34989 switch (len) {
34990 case 1:
34991- __asm__("lcall *(%%esi); cld\n\t"
34992+ __asm__("movw %w6, %%ds\n\t"
34993+ "lcall *%%ss:(%%esi); cld\n\t"
34994+ "push %%ss\n\t"
34995+ "pop %%ds\n\t"
34996 "jc 1f\n\t"
34997 "xor %%ah, %%ah\n"
34998 "1:"
34999@@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
35000 : "1" (PCIBIOS_READ_CONFIG_BYTE),
35001 "b" (bx),
35002 "D" ((long)reg),
35003- "S" (&pci_indirect));
35004+ "S" (&pci_indirect),
35005+ "r" (__PCIBIOS_DS));
35006 /*
35007 * Zero-extend the result beyond 8 bits, do not trust the
35008 * BIOS having done it:
35009@@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
35010 *value &= 0xff;
35011 break;
35012 case 2:
35013- __asm__("lcall *(%%esi); cld\n\t"
35014+ __asm__("movw %w6, %%ds\n\t"
35015+ "lcall *%%ss:(%%esi); cld\n\t"
35016+ "push %%ss\n\t"
35017+ "pop %%ds\n\t"
35018 "jc 1f\n\t"
35019 "xor %%ah, %%ah\n"
35020 "1:"
35021@@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
35022 : "1" (PCIBIOS_READ_CONFIG_WORD),
35023 "b" (bx),
35024 "D" ((long)reg),
35025- "S" (&pci_indirect));
35026+ "S" (&pci_indirect),
35027+ "r" (__PCIBIOS_DS));
35028 /*
35029 * Zero-extend the result beyond 16 bits, do not trust the
35030 * BIOS having done it:
35031@@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
35032 *value &= 0xffff;
35033 break;
35034 case 4:
35035- __asm__("lcall *(%%esi); cld\n\t"
35036+ __asm__("movw %w6, %%ds\n\t"
35037+ "lcall *%%ss:(%%esi); cld\n\t"
35038+ "push %%ss\n\t"
35039+ "pop %%ds\n\t"
35040 "jc 1f\n\t"
35041 "xor %%ah, %%ah\n"
35042 "1:"
35043@@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
35044 : "1" (PCIBIOS_READ_CONFIG_DWORD),
35045 "b" (bx),
35046 "D" ((long)reg),
35047- "S" (&pci_indirect));
35048+ "S" (&pci_indirect),
35049+ "r" (__PCIBIOS_DS));
35050 break;
35051 }
35052
35053@@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
35054
35055 switch (len) {
35056 case 1:
35057- __asm__("lcall *(%%esi); cld\n\t"
35058+ __asm__("movw %w6, %%ds\n\t"
35059+ "lcall *%%ss:(%%esi); cld\n\t"
35060+ "push %%ss\n\t"
35061+ "pop %%ds\n\t"
35062 "jc 1f\n\t"
35063 "xor %%ah, %%ah\n"
35064 "1:"
35065@@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
35066 "c" (value),
35067 "b" (bx),
35068 "D" ((long)reg),
35069- "S" (&pci_indirect));
35070+ "S" (&pci_indirect),
35071+ "r" (__PCIBIOS_DS));
35072 break;
35073 case 2:
35074- __asm__("lcall *(%%esi); cld\n\t"
35075+ __asm__("movw %w6, %%ds\n\t"
35076+ "lcall *%%ss:(%%esi); cld\n\t"
35077+ "push %%ss\n\t"
35078+ "pop %%ds\n\t"
35079 "jc 1f\n\t"
35080 "xor %%ah, %%ah\n"
35081 "1:"
35082@@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
35083 "c" (value),
35084 "b" (bx),
35085 "D" ((long)reg),
35086- "S" (&pci_indirect));
35087+ "S" (&pci_indirect),
35088+ "r" (__PCIBIOS_DS));
35089 break;
35090 case 4:
35091- __asm__("lcall *(%%esi); cld\n\t"
35092+ __asm__("movw %w6, %%ds\n\t"
35093+ "lcall *%%ss:(%%esi); cld\n\t"
35094+ "push %%ss\n\t"
35095+ "pop %%ds\n\t"
35096 "jc 1f\n\t"
35097 "xor %%ah, %%ah\n"
35098 "1:"
35099@@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
35100 "c" (value),
35101 "b" (bx),
35102 "D" ((long)reg),
35103- "S" (&pci_indirect));
35104+ "S" (&pci_indirect),
35105+ "r" (__PCIBIOS_DS));
35106 break;
35107 }
35108
35109@@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
35110
35111 DBG("PCI: Fetching IRQ routing table... ");
35112 __asm__("push %%es\n\t"
35113+ "movw %w8, %%ds\n\t"
35114 "push %%ds\n\t"
35115 "pop %%es\n\t"
35116- "lcall *(%%esi); cld\n\t"
35117+ "lcall *%%ss:(%%esi); cld\n\t"
35118 "pop %%es\n\t"
35119+ "push %%ss\n\t"
35120+ "pop %%ds\n"
35121 "jc 1f\n\t"
35122 "xor %%ah, %%ah\n"
35123 "1:"
35124@@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
35125 "1" (0),
35126 "D" ((long) &opt),
35127 "S" (&pci_indirect),
35128- "m" (opt)
35129+ "m" (opt),
35130+ "r" (__PCIBIOS_DS)
35131 : "memory");
35132 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
35133 if (ret & 0xff00)
35134@@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
35135 {
35136 int ret;
35137
35138- __asm__("lcall *(%%esi); cld\n\t"
35139+ __asm__("movw %w5, %%ds\n\t"
35140+ "lcall *%%ss:(%%esi); cld\n\t"
35141+ "push %%ss\n\t"
35142+ "pop %%ds\n"
35143 "jc 1f\n\t"
35144 "xor %%ah, %%ah\n"
35145 "1:"
35146@@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
35147 : "0" (PCIBIOS_SET_PCI_HW_INT),
35148 "b" ((dev->bus->number << 8) | dev->devfn),
35149 "c" ((irq << 8) | (pin + 10)),
35150- "S" (&pci_indirect));
35151+ "S" (&pci_indirect),
35152+ "r" (__PCIBIOS_DS));
35153 return !(ret & 0xff00);
35154 }
35155 EXPORT_SYMBOL(pcibios_set_irq_routing);
35156diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
35157index 02744df..841ea05 100644
35158--- a/arch/x86/platform/efi/efi.c
35159+++ b/arch/x86/platform/efi/efi.c
35160@@ -946,6 +946,11 @@ u64 efi_mem_attributes(unsigned long phys_addr)
35161
35162 static int __init arch_parse_efi_cmdline(char *str)
35163 {
35164+ if (!str) {
35165+ pr_warn("need at least one option\n");
35166+ return -EINVAL;
35167+ }
35168+
35169 if (parse_option_str(str, "old_map"))
35170 set_bit(EFI_OLD_MEMMAP, &efi.flags);
35171 if (parse_option_str(str, "debug"))
35172diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
35173index ed5b673..24d2d53 100644
35174--- a/arch/x86/platform/efi/efi_32.c
35175+++ b/arch/x86/platform/efi/efi_32.c
35176@@ -61,11 +61,27 @@ pgd_t * __init efi_call_phys_prolog(void)
35177 struct desc_ptr gdt_descr;
35178 pgd_t *save_pgd;
35179
35180+#ifdef CONFIG_PAX_KERNEXEC
35181+ struct desc_struct d;
35182+#endif
35183+
35184 /* Current pgd is swapper_pg_dir, we'll restore it later: */
35185+#ifdef CONFIG_PAX_PER_CPU_PGD
35186+ save_pgd = get_cpu_pgd(smp_processor_id(), kernel);
35187+#else
35188 save_pgd = swapper_pg_dir;
35189+#endif
35190+
35191 load_cr3(initial_page_table);
35192 __flush_tlb_all();
35193
35194+#ifdef CONFIG_PAX_KERNEXEC
35195+ pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
35196+ write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
35197+ pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
35198+ write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
35199+#endif
35200+
35201 gdt_descr.address = __pa(get_cpu_gdt_table(0));
35202 gdt_descr.size = GDT_SIZE - 1;
35203 load_gdt(&gdt_descr);
35204@@ -77,6 +93,14 @@ void __init efi_call_phys_epilog(pgd_t *save_pgd)
35205 {
35206 struct desc_ptr gdt_descr;
35207
35208+#ifdef CONFIG_PAX_KERNEXEC
35209+ struct desc_struct d;
35210+
35211+ memset(&d, 0, sizeof d);
35212+ write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
35213+ write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
35214+#endif
35215+
35216 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
35217 gdt_descr.size = GDT_SIZE - 1;
35218 load_gdt(&gdt_descr);
35219diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
35220index a0ac0f9..f41d324 100644
35221--- a/arch/x86/platform/efi/efi_64.c
35222+++ b/arch/x86/platform/efi/efi_64.c
35223@@ -96,6 +96,11 @@ pgd_t * __init efi_call_phys_prolog(void)
35224 vaddress = (unsigned long)__va(pgd * PGDIR_SIZE);
35225 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress));
35226 }
35227+
35228+#ifdef CONFIG_PAX_PER_CPU_PGD
35229+ load_cr3(swapper_pg_dir);
35230+#endif
35231+
35232 __flush_tlb_all();
35233
35234 return save_pgd;
35235@@ -119,6 +124,10 @@ void __init efi_call_phys_epilog(pgd_t *save_pgd)
35236
35237 kfree(save_pgd);
35238
35239+#ifdef CONFIG_PAX_PER_CPU_PGD
35240+ load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
35241+#endif
35242+
35243 __flush_tlb_all();
35244 early_code_mapping_set_exec(0);
35245 }
35246@@ -148,8 +157,23 @@ int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
35247 unsigned npages;
35248 pgd_t *pgd;
35249
35250- if (efi_enabled(EFI_OLD_MEMMAP))
35251+ if (efi_enabled(EFI_OLD_MEMMAP)) {
35252+ /* PaX: We need to disable the NX bit in the PGD, otherwise we won't be
35253+ * able to execute the EFI services.
35254+ */
35255+ if (__supported_pte_mask & _PAGE_NX) {
35256+ unsigned long addr = (unsigned long) __va(0);
35257+ pgd_t pe = __pgd(pgd_val(*pgd_offset_k(addr)) & ~_PAGE_NX);
35258+
35259+ pr_alert("PAX: Disabling NX protection for low memory map. Try booting without \"efi=old_map\"\n");
35260+#ifdef CONFIG_PAX_PER_CPU_PGD
35261+ set_pgd(pgd_offset_cpu(0, kernel, addr), pe);
35262+#endif
35263+ set_pgd(pgd_offset_k(addr), pe);
35264+ }
35265+
35266 return 0;
35267+ }
35268
35269 efi_scratch.efi_pgt = (pgd_t *)(unsigned long)real_mode_header->trampoline_pgd;
35270 pgd = __va(efi_scratch.efi_pgt);
35271diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
35272index 040192b..7d3300f 100644
35273--- a/arch/x86/platform/efi/efi_stub_32.S
35274+++ b/arch/x86/platform/efi/efi_stub_32.S
35275@@ -6,7 +6,9 @@
35276 */
35277
35278 #include <linux/linkage.h>
35279+#include <linux/init.h>
35280 #include <asm/page_types.h>
35281+#include <asm/segment.h>
35282
35283 /*
35284 * efi_call_phys(void *, ...) is a function with variable parameters.
35285@@ -20,7 +22,7 @@
35286 * service functions will comply with gcc calling convention, too.
35287 */
35288
35289-.text
35290+__INIT
35291 ENTRY(efi_call_phys)
35292 /*
35293 * 0. The function can only be called in Linux kernel. So CS has been
35294@@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
35295 * The mapping of lower virtual memory has been created in prolog and
35296 * epilog.
35297 */
35298- movl $1f, %edx
35299- subl $__PAGE_OFFSET, %edx
35300- jmp *%edx
35301+#ifdef CONFIG_PAX_KERNEXEC
35302+ movl $(__KERNEXEC_EFI_DS), %edx
35303+ mov %edx, %ds
35304+ mov %edx, %es
35305+ mov %edx, %ss
35306+ addl $2f,(1f)
35307+ ljmp *(1f)
35308+
35309+__INITDATA
35310+1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
35311+.previous
35312+
35313+2:
35314+ subl $2b,(1b)
35315+#else
35316+ jmp 1f-__PAGE_OFFSET
35317 1:
35318+#endif
35319
35320 /*
35321 * 2. Now on the top of stack is the return
35322@@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
35323 * parameter 2, ..., param n. To make things easy, we save the return
35324 * address of efi_call_phys in a global variable.
35325 */
35326- popl %edx
35327- movl %edx, saved_return_addr
35328- /* get the function pointer into ECX*/
35329- popl %ecx
35330- movl %ecx, efi_rt_function_ptr
35331- movl $2f, %edx
35332- subl $__PAGE_OFFSET, %edx
35333- pushl %edx
35334+ popl (saved_return_addr)
35335+ popl (efi_rt_function_ptr)
35336
35337 /*
35338 * 3. Clear PG bit in %CR0.
35339@@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
35340 /*
35341 * 5. Call the physical function.
35342 */
35343- jmp *%ecx
35344+ call *(efi_rt_function_ptr-__PAGE_OFFSET)
35345
35346-2:
35347 /*
35348 * 6. After EFI runtime service returns, control will return to
35349 * following instruction. We'd better readjust stack pointer first.
35350@@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
35351 movl %cr0, %edx
35352 orl $0x80000000, %edx
35353 movl %edx, %cr0
35354- jmp 1f
35355-1:
35356+
35357 /*
35358 * 8. Now restore the virtual mode from flat mode by
35359 * adding EIP with PAGE_OFFSET.
35360 */
35361- movl $1f, %edx
35362- jmp *%edx
35363+#ifdef CONFIG_PAX_KERNEXEC
35364+ movl $(__KERNEL_DS), %edx
35365+ mov %edx, %ds
35366+ mov %edx, %es
35367+ mov %edx, %ss
35368+ ljmp $(__KERNEL_CS),$1f
35369+#else
35370+ jmp 1f+__PAGE_OFFSET
35371+#endif
35372 1:
35373
35374 /*
35375 * 9. Balance the stack. And because EAX contain the return value,
35376 * we'd better not clobber it.
35377 */
35378- leal efi_rt_function_ptr, %edx
35379- movl (%edx), %ecx
35380- pushl %ecx
35381+ pushl (efi_rt_function_ptr)
35382
35383 /*
35384- * 10. Push the saved return address onto the stack and return.
35385+ * 10. Return to the saved return address.
35386 */
35387- leal saved_return_addr, %edx
35388- movl (%edx), %ecx
35389- pushl %ecx
35390- ret
35391+ jmpl *(saved_return_addr)
35392 ENDPROC(efi_call_phys)
35393 .previous
35394
35395-.data
35396+__INITDATA
35397 saved_return_addr:
35398 .long 0
35399 efi_rt_function_ptr:
35400diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
35401index 86d0f9e..6d499f4 100644
35402--- a/arch/x86/platform/efi/efi_stub_64.S
35403+++ b/arch/x86/platform/efi/efi_stub_64.S
35404@@ -11,6 +11,7 @@
35405 #include <asm/msr.h>
35406 #include <asm/processor-flags.h>
35407 #include <asm/page_types.h>
35408+#include <asm/alternative-asm.h>
35409
35410 #define SAVE_XMM \
35411 mov %rsp, %rax; \
35412@@ -88,6 +89,7 @@ ENTRY(efi_call)
35413 RESTORE_PGT
35414 addq $48, %rsp
35415 RESTORE_XMM
35416+ pax_force_retaddr 0, 1
35417 ret
35418 ENDPROC(efi_call)
35419
35420diff --git a/arch/x86/platform/intel-mid/intel-mid.c b/arch/x86/platform/intel-mid/intel-mid.c
35421index 3005f0c..d06aeb0 100644
35422--- a/arch/x86/platform/intel-mid/intel-mid.c
35423+++ b/arch/x86/platform/intel-mid/intel-mid.c
35424@@ -63,7 +63,7 @@ enum intel_mid_timer_options intel_mid_timer_options;
35425 /* intel_mid_ops to store sub arch ops */
35426 struct intel_mid_ops *intel_mid_ops;
35427 /* getter function for sub arch ops*/
35428-static void *(*get_intel_mid_ops[])(void) = INTEL_MID_OPS_INIT;
35429+static const void *(*get_intel_mid_ops[])(void) = INTEL_MID_OPS_INIT;
35430 enum intel_mid_cpu_type __intel_mid_cpu_chip;
35431 EXPORT_SYMBOL_GPL(__intel_mid_cpu_chip);
35432
35433@@ -71,9 +71,10 @@ static void intel_mid_power_off(void)
35434 {
35435 };
35436
35437-static void intel_mid_reboot(void)
35438+static void __noreturn intel_mid_reboot(void)
35439 {
35440 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
35441+ BUG();
35442 }
35443
35444 static unsigned long __init intel_mid_calibrate_tsc(void)
35445diff --git a/arch/x86/platform/intel-mid/intel_mid_weak_decls.h b/arch/x86/platform/intel-mid/intel_mid_weak_decls.h
35446index 3c1c386..59a68ed 100644
35447--- a/arch/x86/platform/intel-mid/intel_mid_weak_decls.h
35448+++ b/arch/x86/platform/intel-mid/intel_mid_weak_decls.h
35449@@ -13,6 +13,6 @@
35450 /* For every CPU addition a new get_<cpuname>_ops interface needs
35451 * to be added.
35452 */
35453-extern void *get_penwell_ops(void);
35454-extern void *get_cloverview_ops(void);
35455-extern void *get_tangier_ops(void);
35456+extern const void *get_penwell_ops(void);
35457+extern const void *get_cloverview_ops(void);
35458+extern const void *get_tangier_ops(void);
35459diff --git a/arch/x86/platform/intel-mid/mfld.c b/arch/x86/platform/intel-mid/mfld.c
35460index 23381d2..8ddc10e 100644
35461--- a/arch/x86/platform/intel-mid/mfld.c
35462+++ b/arch/x86/platform/intel-mid/mfld.c
35463@@ -64,12 +64,12 @@ static void __init penwell_arch_setup(void)
35464 pm_power_off = mfld_power_off;
35465 }
35466
35467-void *get_penwell_ops(void)
35468+const void *get_penwell_ops(void)
35469 {
35470 return &penwell_ops;
35471 }
35472
35473-void *get_cloverview_ops(void)
35474+const void *get_cloverview_ops(void)
35475 {
35476 return &penwell_ops;
35477 }
35478diff --git a/arch/x86/platform/intel-mid/mrfl.c b/arch/x86/platform/intel-mid/mrfl.c
35479index aaca917..66eadbc 100644
35480--- a/arch/x86/platform/intel-mid/mrfl.c
35481+++ b/arch/x86/platform/intel-mid/mrfl.c
35482@@ -97,7 +97,7 @@ static struct intel_mid_ops tangier_ops = {
35483 .arch_setup = tangier_arch_setup,
35484 };
35485
35486-void *get_tangier_ops(void)
35487+const void *get_tangier_ops(void)
35488 {
35489 return &tangier_ops;
35490 }
35491diff --git a/arch/x86/platform/intel-quark/imr_selftest.c b/arch/x86/platform/intel-quark/imr_selftest.c
35492index 278e4da..55e8d8a 100644
35493--- a/arch/x86/platform/intel-quark/imr_selftest.c
35494+++ b/arch/x86/platform/intel-quark/imr_selftest.c
35495@@ -55,7 +55,7 @@ static void __init imr_self_test_result(int res, const char *fmt, ...)
35496 */
35497 static void __init imr_self_test(void)
35498 {
35499- phys_addr_t base = virt_to_phys(&_text);
35500+ phys_addr_t base = virt_to_phys(ktla_ktva(_text));
35501 size_t size = virt_to_phys(&__end_rodata) - base;
35502 const char *fmt_over = "overlapped IMR @ (0x%08lx - 0x%08lx)\n";
35503 int ret;
35504diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
35505index d6ee929..3637cb5 100644
35506--- a/arch/x86/platform/olpc/olpc_dt.c
35507+++ b/arch/x86/platform/olpc/olpc_dt.c
35508@@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
35509 return res;
35510 }
35511
35512-static struct of_pdt_ops prom_olpc_ops __initdata = {
35513+static struct of_pdt_ops prom_olpc_ops __initconst = {
35514 .nextprop = olpc_dt_nextprop,
35515 .getproplen = olpc_dt_getproplen,
35516 .getproperty = olpc_dt_getproperty,
35517diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
35518index 757678f..9895d9b 100644
35519--- a/arch/x86/power/cpu.c
35520+++ b/arch/x86/power/cpu.c
35521@@ -134,11 +134,8 @@ static void do_fpu_end(void)
35522 static void fix_processor_context(void)
35523 {
35524 int cpu = smp_processor_id();
35525- struct tss_struct *t = &per_cpu(cpu_tss, cpu);
35526-#ifdef CONFIG_X86_64
35527- struct desc_struct *desc = get_cpu_gdt_table(cpu);
35528- tss_desc tss;
35529-#endif
35530+ struct tss_struct *t = cpu_tss + cpu;
35531+
35532 set_tss_desc(cpu, t); /*
35533 * This just modifies memory; should not be
35534 * necessary. But... This is necessary, because
35535@@ -147,10 +144,6 @@ static void fix_processor_context(void)
35536 */
35537
35538 #ifdef CONFIG_X86_64
35539- memcpy(&tss, &desc[GDT_ENTRY_TSS], sizeof(tss_desc));
35540- tss.type = 0x9; /* The available 64-bit TSS (see AMD vol 2, pg 91 */
35541- write_gdt_entry(desc, GDT_ENTRY_TSS, &tss, DESC_TSS);
35542-
35543 syscall_init(); /* This sets MSR_*STAR and related */
35544 #endif
35545 load_TR_desc(); /* This does ltr */
35546diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
35547index 0b7a63d..0d0f2c2 100644
35548--- a/arch/x86/realmode/init.c
35549+++ b/arch/x86/realmode/init.c
35550@@ -68,7 +68,13 @@ void __init setup_real_mode(void)
35551 __va(real_mode_header->trampoline_header);
35552
35553 #ifdef CONFIG_X86_32
35554- trampoline_header->start = __pa_symbol(startup_32_smp);
35555+ trampoline_header->start = __pa_symbol(ktla_ktva(startup_32_smp));
35556+
35557+#ifdef CONFIG_PAX_KERNEXEC
35558+ trampoline_header->start -= LOAD_PHYSICAL_ADDR;
35559+#endif
35560+
35561+ trampoline_header->boot_cs = __BOOT_CS;
35562 trampoline_header->gdt_limit = __BOOT_DS + 7;
35563 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
35564 #else
35565@@ -84,7 +90,7 @@ void __init setup_real_mode(void)
35566 *trampoline_cr4_features = __read_cr4();
35567
35568 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
35569- trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
35570+ trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd & ~_PAGE_NX;
35571 trampoline_pgd[511] = init_level4_pgt[511].pgd;
35572 #endif
35573 }
35574diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
35575index 2730d77..2e4cd19 100644
35576--- a/arch/x86/realmode/rm/Makefile
35577+++ b/arch/x86/realmode/rm/Makefile
35578@@ -68,5 +68,8 @@ $(obj)/realmode.relocs: $(obj)/realmode.elf FORCE
35579
35580 KBUILD_CFLAGS := $(LINUXINCLUDE) $(REALMODE_CFLAGS) -D_SETUP -D_WAKEUP \
35581 -I$(srctree)/arch/x86/boot
35582+ifdef CONSTIFY_PLUGIN
35583+KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
35584+endif
35585 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
35586 GCOV_PROFILE := n
35587diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
35588index a28221d..93c40f1 100644
35589--- a/arch/x86/realmode/rm/header.S
35590+++ b/arch/x86/realmode/rm/header.S
35591@@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
35592 #endif
35593 /* APM/BIOS reboot */
35594 .long pa_machine_real_restart_asm
35595-#ifdef CONFIG_X86_64
35596+#ifdef CONFIG_X86_32
35597+ .long __KERNEL_CS
35598+#else
35599 .long __KERNEL32_CS
35600 #endif
35601 END(real_mode_header)
35602diff --git a/arch/x86/realmode/rm/reboot.S b/arch/x86/realmode/rm/reboot.S
35603index d66c607..3def845 100644
35604--- a/arch/x86/realmode/rm/reboot.S
35605+++ b/arch/x86/realmode/rm/reboot.S
35606@@ -27,6 +27,10 @@ ENTRY(machine_real_restart_asm)
35607 lgdtl pa_tr_gdt
35608
35609 /* Disable paging to drop us out of long mode */
35610+ movl %cr4, %eax
35611+ andl $~X86_CR4_PCIDE, %eax
35612+ movl %eax, %cr4
35613+
35614 movl %cr0, %eax
35615 andl $~X86_CR0_PG, %eax
35616 movl %eax, %cr0
35617diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
35618index 48ddd76..c26749f 100644
35619--- a/arch/x86/realmode/rm/trampoline_32.S
35620+++ b/arch/x86/realmode/rm/trampoline_32.S
35621@@ -24,6 +24,12 @@
35622 #include <asm/page_types.h>
35623 #include "realmode.h"
35624
35625+#ifdef CONFIG_PAX_KERNEXEC
35626+#define ta(X) (X)
35627+#else
35628+#define ta(X) (pa_ ## X)
35629+#endif
35630+
35631 .text
35632 .code16
35633
35634@@ -38,8 +44,6 @@ ENTRY(trampoline_start)
35635
35636 cli # We should be safe anyway
35637
35638- movl tr_start, %eax # where we need to go
35639-
35640 movl $0xA5A5A5A5, trampoline_status
35641 # write marker for master knows we're running
35642
35643@@ -55,7 +59,7 @@ ENTRY(trampoline_start)
35644 movw $1, %dx # protected mode (PE) bit
35645 lmsw %dx # into protected mode
35646
35647- ljmpl $__BOOT_CS, $pa_startup_32
35648+ ljmpl *(trampoline_header)
35649
35650 .section ".text32","ax"
35651 .code32
35652@@ -66,7 +70,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
35653 .balign 8
35654 GLOBAL(trampoline_header)
35655 tr_start: .space 4
35656- tr_gdt_pad: .space 2
35657+ tr_boot_cs: .space 2
35658 tr_gdt: .space 6
35659 END(trampoline_header)
35660
35661diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
35662index dac7b20..72dbaca 100644
35663--- a/arch/x86/realmode/rm/trampoline_64.S
35664+++ b/arch/x86/realmode/rm/trampoline_64.S
35665@@ -93,6 +93,7 @@ ENTRY(startup_32)
35666 movl %edx, %gs
35667
35668 movl pa_tr_cr4, %eax
35669+ andl $~X86_CR4_PCIDE, %eax
35670 movl %eax, %cr4 # Enable PAE mode
35671
35672 # Setup trampoline 4 level pagetables
35673@@ -106,7 +107,7 @@ ENTRY(startup_32)
35674 wrmsr
35675
35676 # Enable paging and in turn activate Long Mode
35677- movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
35678+ movl $(X86_CR0_PG | X86_CR0_PE), %eax
35679 movl %eax, %cr0
35680
35681 /*
35682diff --git a/arch/x86/realmode/rm/wakeup_asm.S b/arch/x86/realmode/rm/wakeup_asm.S
35683index 9e7e147..25a4158 100644
35684--- a/arch/x86/realmode/rm/wakeup_asm.S
35685+++ b/arch/x86/realmode/rm/wakeup_asm.S
35686@@ -126,11 +126,10 @@ ENTRY(wakeup_start)
35687 lgdtl pmode_gdt
35688
35689 /* This really couldn't... */
35690- movl pmode_entry, %eax
35691 movl pmode_cr0, %ecx
35692 movl %ecx, %cr0
35693- ljmpl $__KERNEL_CS, $pa_startup_32
35694- /* -> jmp *%eax in trampoline_32.S */
35695+
35696+ ljmpl *pmode_entry
35697 #else
35698 jmp trampoline_start
35699 #endif
35700diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile
35701index 604a37e..e49702a 100644
35702--- a/arch/x86/tools/Makefile
35703+++ b/arch/x86/tools/Makefile
35704@@ -37,7 +37,7 @@ $(obj)/test_get_len.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/in
35705
35706 $(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
35707
35708-HOST_EXTRACFLAGS += -I$(srctree)/tools/include
35709+HOST_EXTRACFLAGS += -I$(srctree)/tools/include -ggdb
35710 hostprogs-y += relocs
35711 relocs-objs := relocs_32.o relocs_64.o relocs_common.o
35712 PHONY += relocs
35713diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
35714index 0c2fae8..88036b7 100644
35715--- a/arch/x86/tools/relocs.c
35716+++ b/arch/x86/tools/relocs.c
35717@@ -1,5 +1,7 @@
35718 /* This is included from relocs_32/64.c */
35719
35720+#include "../../../include/generated/autoconf.h"
35721+
35722 #define ElfW(type) _ElfW(ELF_BITS, type)
35723 #define _ElfW(bits, type) __ElfW(bits, type)
35724 #define __ElfW(bits, type) Elf##bits##_##type
35725@@ -11,6 +13,7 @@
35726 #define Elf_Sym ElfW(Sym)
35727
35728 static Elf_Ehdr ehdr;
35729+static Elf_Phdr *phdr;
35730
35731 struct relocs {
35732 uint32_t *offset;
35733@@ -386,9 +389,39 @@ static void read_ehdr(FILE *fp)
35734 }
35735 }
35736
35737+static void read_phdrs(FILE *fp)
35738+{
35739+ unsigned int i;
35740+
35741+ phdr = calloc(ehdr.e_phnum, sizeof(Elf_Phdr));
35742+ if (!phdr) {
35743+ die("Unable to allocate %d program headers\n",
35744+ ehdr.e_phnum);
35745+ }
35746+ if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
35747+ die("Seek to %d failed: %s\n",
35748+ ehdr.e_phoff, strerror(errno));
35749+ }
35750+ if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
35751+ die("Cannot read ELF program headers: %s\n",
35752+ strerror(errno));
35753+ }
35754+ for(i = 0; i < ehdr.e_phnum; i++) {
35755+ phdr[i].p_type = elf_word_to_cpu(phdr[i].p_type);
35756+ phdr[i].p_offset = elf_off_to_cpu(phdr[i].p_offset);
35757+ phdr[i].p_vaddr = elf_addr_to_cpu(phdr[i].p_vaddr);
35758+ phdr[i].p_paddr = elf_addr_to_cpu(phdr[i].p_paddr);
35759+ phdr[i].p_filesz = elf_word_to_cpu(phdr[i].p_filesz);
35760+ phdr[i].p_memsz = elf_word_to_cpu(phdr[i].p_memsz);
35761+ phdr[i].p_flags = elf_word_to_cpu(phdr[i].p_flags);
35762+ phdr[i].p_align = elf_word_to_cpu(phdr[i].p_align);
35763+ }
35764+
35765+}
35766+
35767 static void read_shdrs(FILE *fp)
35768 {
35769- int i;
35770+ unsigned int i;
35771 Elf_Shdr shdr;
35772
35773 secs = calloc(ehdr.e_shnum, sizeof(struct section));
35774@@ -423,7 +456,7 @@ static void read_shdrs(FILE *fp)
35775
35776 static void read_strtabs(FILE *fp)
35777 {
35778- int i;
35779+ unsigned int i;
35780 for (i = 0; i < ehdr.e_shnum; i++) {
35781 struct section *sec = &secs[i];
35782 if (sec->shdr.sh_type != SHT_STRTAB) {
35783@@ -448,7 +481,7 @@ static void read_strtabs(FILE *fp)
35784
35785 static void read_symtabs(FILE *fp)
35786 {
35787- int i,j;
35788+ unsigned int i,j;
35789 for (i = 0; i < ehdr.e_shnum; i++) {
35790 struct section *sec = &secs[i];
35791 if (sec->shdr.sh_type != SHT_SYMTAB) {
35792@@ -479,9 +512,11 @@ static void read_symtabs(FILE *fp)
35793 }
35794
35795
35796-static void read_relocs(FILE *fp)
35797+static void read_relocs(FILE *fp, int use_real_mode)
35798 {
35799- int i,j;
35800+ unsigned int i,j;
35801+ uint32_t base;
35802+
35803 for (i = 0; i < ehdr.e_shnum; i++) {
35804 struct section *sec = &secs[i];
35805 if (sec->shdr.sh_type != SHT_REL_TYPE) {
35806@@ -501,9 +536,22 @@ static void read_relocs(FILE *fp)
35807 die("Cannot read symbol table: %s\n",
35808 strerror(errno));
35809 }
35810+ base = 0;
35811+
35812+#ifdef CONFIG_X86_32
35813+ for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
35814+ if (phdr[j].p_type != PT_LOAD )
35815+ continue;
35816+ 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)
35817+ continue;
35818+ base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
35819+ break;
35820+ }
35821+#endif
35822+
35823 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf_Rel); j++) {
35824 Elf_Rel *rel = &sec->reltab[j];
35825- rel->r_offset = elf_addr_to_cpu(rel->r_offset);
35826+ rel->r_offset = elf_addr_to_cpu(rel->r_offset) + base;
35827 rel->r_info = elf_xword_to_cpu(rel->r_info);
35828 #if (SHT_REL_TYPE == SHT_RELA)
35829 rel->r_addend = elf_xword_to_cpu(rel->r_addend);
35830@@ -515,7 +563,7 @@ static void read_relocs(FILE *fp)
35831
35832 static void print_absolute_symbols(void)
35833 {
35834- int i;
35835+ unsigned int i;
35836 const char *format;
35837
35838 if (ELF_BITS == 64)
35839@@ -528,7 +576,7 @@ static void print_absolute_symbols(void)
35840 for (i = 0; i < ehdr.e_shnum; i++) {
35841 struct section *sec = &secs[i];
35842 char *sym_strtab;
35843- int j;
35844+ unsigned int j;
35845
35846 if (sec->shdr.sh_type != SHT_SYMTAB) {
35847 continue;
35848@@ -555,7 +603,7 @@ static void print_absolute_symbols(void)
35849
35850 static void print_absolute_relocs(void)
35851 {
35852- int i, printed = 0;
35853+ unsigned int i, printed = 0;
35854 const char *format;
35855
35856 if (ELF_BITS == 64)
35857@@ -568,7 +616,7 @@ static void print_absolute_relocs(void)
35858 struct section *sec_applies, *sec_symtab;
35859 char *sym_strtab;
35860 Elf_Sym *sh_symtab;
35861- int j;
35862+ unsigned int j;
35863 if (sec->shdr.sh_type != SHT_REL_TYPE) {
35864 continue;
35865 }
35866@@ -645,13 +693,13 @@ static void add_reloc(struct relocs *r, uint32_t offset)
35867 static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
35868 Elf_Sym *sym, const char *symname))
35869 {
35870- int i;
35871+ unsigned int i;
35872 /* Walk through the relocations */
35873 for (i = 0; i < ehdr.e_shnum; i++) {
35874 char *sym_strtab;
35875 Elf_Sym *sh_symtab;
35876 struct section *sec_applies, *sec_symtab;
35877- int j;
35878+ unsigned int j;
35879 struct section *sec = &secs[i];
35880
35881 if (sec->shdr.sh_type != SHT_REL_TYPE) {
35882@@ -830,6 +878,23 @@ static int do_reloc32(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
35883 {
35884 unsigned r_type = ELF32_R_TYPE(rel->r_info);
35885 int shn_abs = (sym->st_shndx == SHN_ABS) && !is_reloc(S_REL, symname);
35886+ char *sym_strtab = sec->link->link->strtab;
35887+
35888+ /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
35889+ if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
35890+ return 0;
35891+
35892+#ifdef CONFIG_PAX_KERNEXEC
35893+ /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
35894+ if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
35895+ return 0;
35896+ if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
35897+ return 0;
35898+ if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
35899+ return 0;
35900+ if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
35901+ return 0;
35902+#endif
35903
35904 switch (r_type) {
35905 case R_386_NONE:
35906@@ -968,7 +1033,7 @@ static int write32_as_text(uint32_t v, FILE *f)
35907
35908 static void emit_relocs(int as_text, int use_real_mode)
35909 {
35910- int i;
35911+ unsigned int i;
35912 int (*write_reloc)(uint32_t, FILE *) = write32;
35913 int (*do_reloc)(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
35914 const char *symname);
35915@@ -1078,10 +1143,11 @@ void process(FILE *fp, int use_real_mode, int as_text,
35916 {
35917 regex_init(use_real_mode);
35918 read_ehdr(fp);
35919+ read_phdrs(fp);
35920 read_shdrs(fp);
35921 read_strtabs(fp);
35922 read_symtabs(fp);
35923- read_relocs(fp);
35924+ read_relocs(fp, use_real_mode);
35925 if (ELF_BITS == 64)
35926 percpu_init();
35927 if (show_absolute_syms) {
35928diff --git a/arch/x86/um/mem_32.c b/arch/x86/um/mem_32.c
35929index f40281e..92728c9 100644
35930--- a/arch/x86/um/mem_32.c
35931+++ b/arch/x86/um/mem_32.c
35932@@ -21,7 +21,7 @@ static int __init gate_vma_init(void)
35933 gate_vma.vm_start = FIXADDR_USER_START;
35934 gate_vma.vm_end = FIXADDR_USER_END;
35935 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
35936- gate_vma.vm_page_prot = __P101;
35937+ gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
35938
35939 return 0;
35940 }
35941diff --git a/arch/x86/um/tls_32.c b/arch/x86/um/tls_32.c
35942index 80ffa5b..a33bd15 100644
35943--- a/arch/x86/um/tls_32.c
35944+++ b/arch/x86/um/tls_32.c
35945@@ -260,7 +260,7 @@ out:
35946 if (unlikely(task == current &&
35947 !t->arch.tls_array[idx - GDT_ENTRY_TLS_MIN].flushed)) {
35948 printk(KERN_ERR "get_tls_entry: task with pid %d got here "
35949- "without flushed TLS.", current->pid);
35950+ "without flushed TLS.", task_pid_nr(current));
35951 }
35952
35953 return 0;
35954diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
35955index e970320..c006fea 100644
35956--- a/arch/x86/vdso/Makefile
35957+++ b/arch/x86/vdso/Makefile
35958@@ -175,7 +175,7 @@ quiet_cmd_vdso = VDSO $@
35959 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
35960 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
35961
35962-VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) \
35963+VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) \
35964 $(call cc-ldoption, -Wl$(comma)--build-id) -Wl,-Bsymbolic $(LTO_CFLAGS)
35965 GCOV_PROFILE := n
35966
35967diff --git a/arch/x86/vdso/vdso2c.h b/arch/x86/vdso/vdso2c.h
35968index 0224987..c7d65a5 100644
35969--- a/arch/x86/vdso/vdso2c.h
35970+++ b/arch/x86/vdso/vdso2c.h
35971@@ -12,7 +12,7 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
35972 unsigned long load_size = -1; /* Work around bogus warning */
35973 unsigned long mapping_size;
35974 ELF(Ehdr) *hdr = (ELF(Ehdr) *)raw_addr;
35975- int i;
35976+ unsigned int i;
35977 unsigned long j;
35978 ELF(Shdr) *symtab_hdr = NULL, *strtab_hdr, *secstrings_hdr,
35979 *alt_sec = NULL;
35980diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
35981index e904c27..b9eaa03 100644
35982--- a/arch/x86/vdso/vdso32-setup.c
35983+++ b/arch/x86/vdso/vdso32-setup.c
35984@@ -14,6 +14,7 @@
35985 #include <asm/cpufeature.h>
35986 #include <asm/processor.h>
35987 #include <asm/vdso.h>
35988+#include <asm/mman.h>
35989
35990 #ifdef CONFIG_COMPAT_VDSO
35991 #define VDSO_DEFAULT 0
35992diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
35993index 1c9f750..cfddb1a 100644
35994--- a/arch/x86/vdso/vma.c
35995+++ b/arch/x86/vdso/vma.c
35996@@ -19,10 +19,7 @@
35997 #include <asm/page.h>
35998 #include <asm/hpet.h>
35999 #include <asm/desc.h>
36000-
36001-#if defined(CONFIG_X86_64)
36002-unsigned int __read_mostly vdso64_enabled = 1;
36003-#endif
36004+#include <asm/mman.h>
36005
36006 void __init init_vdso_image(const struct vdso_image *image)
36007 {
36008@@ -101,6 +98,11 @@ static int map_vdso(const struct vdso_image *image, bool calculate_addr)
36009 .pages = no_pages,
36010 };
36011
36012+#ifdef CONFIG_PAX_RANDMMAP
36013+ if (mm->pax_flags & MF_PAX_RANDMMAP)
36014+ calculate_addr = false;
36015+#endif
36016+
36017 if (calculate_addr) {
36018 addr = vdso_addr(current->mm->start_stack,
36019 image->size - image->sym_vvar_start);
36020@@ -111,14 +113,14 @@ static int map_vdso(const struct vdso_image *image, bool calculate_addr)
36021 down_write(&mm->mmap_sem);
36022
36023 addr = get_unmapped_area(NULL, addr,
36024- image->size - image->sym_vvar_start, 0, 0);
36025+ image->size - image->sym_vvar_start, 0, MAP_EXECUTABLE);
36026 if (IS_ERR_VALUE(addr)) {
36027 ret = addr;
36028 goto up_fail;
36029 }
36030
36031 text_start = addr - image->sym_vvar_start;
36032- current->mm->context.vdso = (void __user *)text_start;
36033+ mm->context.vdso = text_start;
36034
36035 /*
36036 * MAYWRITE to allow gdb to COW and set breakpoints
36037@@ -163,15 +165,12 @@ static int map_vdso(const struct vdso_image *image, bool calculate_addr)
36038 hpet_address >> PAGE_SHIFT,
36039 PAGE_SIZE,
36040 pgprot_noncached(PAGE_READONLY));
36041-
36042- if (ret)
36043- goto up_fail;
36044 }
36045 #endif
36046
36047 up_fail:
36048 if (ret)
36049- current->mm->context.vdso = NULL;
36050+ current->mm->context.vdso = 0;
36051
36052 up_write(&mm->mmap_sem);
36053 return ret;
36054@@ -191,8 +190,8 @@ static int load_vdso32(void)
36055
36056 if (selected_vdso32->sym_VDSO32_SYSENTER_RETURN)
36057 current_thread_info()->sysenter_return =
36058- current->mm->context.vdso +
36059- selected_vdso32->sym_VDSO32_SYSENTER_RETURN;
36060+ (void __force_user *)(current->mm->context.vdso +
36061+ selected_vdso32->sym_VDSO32_SYSENTER_RETURN);
36062
36063 return 0;
36064 }
36065@@ -201,9 +200,6 @@ static int load_vdso32(void)
36066 #ifdef CONFIG_X86_64
36067 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
36068 {
36069- if (!vdso64_enabled)
36070- return 0;
36071-
36072 return map_vdso(&vdso_image_64, true);
36073 }
36074
36075@@ -212,12 +208,8 @@ int compat_arch_setup_additional_pages(struct linux_binprm *bprm,
36076 int uses_interp)
36077 {
36078 #ifdef CONFIG_X86_X32_ABI
36079- if (test_thread_flag(TIF_X32)) {
36080- if (!vdso64_enabled)
36081- return 0;
36082-
36083+ if (test_thread_flag(TIF_X32))
36084 return map_vdso(&vdso_image_x32, true);
36085- }
36086 #endif
36087
36088 return load_vdso32();
36089@@ -231,15 +223,6 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
36090 #endif
36091
36092 #ifdef CONFIG_X86_64
36093-static __init int vdso_setup(char *s)
36094-{
36095- vdso64_enabled = simple_strtoul(s, NULL, 0);
36096- return 0;
36097-}
36098-__setup("vdso=", vdso_setup);
36099-#endif
36100-
36101-#ifdef CONFIG_X86_64
36102 static void vgetcpu_cpu_init(void *arg)
36103 {
36104 int cpu = smp_processor_id();
36105diff --git a/arch/x86/xen/Kconfig b/arch/x86/xen/Kconfig
36106index e88fda8..76ce7ce 100644
36107--- a/arch/x86/xen/Kconfig
36108+++ b/arch/x86/xen/Kconfig
36109@@ -9,6 +9,7 @@ config XEN
36110 select XEN_HAVE_PVMMU
36111 depends on X86_64 || (X86_32 && X86_PAE)
36112 depends on X86_TSC
36113+ depends on !GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_VIRT_XEN
36114 help
36115 This is the Linux Xen port. Enabling this will allow the
36116 kernel to boot in a paravirtualized environment under the
36117diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
36118index 46957ea..a9dc1d9 100644
36119--- a/arch/x86/xen/enlighten.c
36120+++ b/arch/x86/xen/enlighten.c
36121@@ -125,8 +125,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
36122
36123 struct shared_info xen_dummy_shared_info;
36124
36125-void *xen_initial_gdt;
36126-
36127 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
36128 __read_mostly int xen_have_vector_callback;
36129 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
36130@@ -483,6 +481,7 @@ static void set_aliased_prot(void *v, pgprot_t prot)
36131 pte_t pte;
36132 unsigned long pfn;
36133 struct page *page;
36134+ unsigned char dummy;
36135
36136 ptep = lookup_address((unsigned long)v, &level);
36137 BUG_ON(ptep == NULL);
36138@@ -492,6 +491,32 @@ static void set_aliased_prot(void *v, pgprot_t prot)
36139
36140 pte = pfn_pte(pfn, prot);
36141
36142+ /*
36143+ * Careful: update_va_mapping() will fail if the virtual address
36144+ * we're poking isn't populated in the page tables. We don't
36145+ * need to worry about the direct map (that's always in the page
36146+ * tables), but we need to be careful about vmap space. In
36147+ * particular, the top level page table can lazily propagate
36148+ * entries between processes, so if we've switched mms since we
36149+ * vmapped the target in the first place, we might not have the
36150+ * top-level page table entry populated.
36151+ *
36152+ * We disable preemption because we want the same mm active when
36153+ * we probe the target and when we issue the hypercall. We'll
36154+ * have the same nominal mm, but if we're a kernel thread, lazy
36155+ * mm dropping could change our pgd.
36156+ *
36157+ * Out of an abundance of caution, this uses __get_user() to fault
36158+ * in the target address just in case there's some obscure case
36159+ * in which the target address isn't readable.
36160+ */
36161+
36162+ preempt_disable();
36163+
36164+ pagefault_disable(); /* Avoid warnings due to being atomic. */
36165+ __get_user(dummy, (unsigned char __user __force *)v);
36166+ pagefault_enable();
36167+
36168 if (HYPERVISOR_update_va_mapping((unsigned long)v, pte, 0))
36169 BUG();
36170
36171@@ -503,6 +528,8 @@ static void set_aliased_prot(void *v, pgprot_t prot)
36172 BUG();
36173 } else
36174 kmap_flush_unused();
36175+
36176+ preempt_enable();
36177 }
36178
36179 static void xen_alloc_ldt(struct desc_struct *ldt, unsigned entries)
36180@@ -510,6 +537,17 @@ static void xen_alloc_ldt(struct desc_struct *ldt, unsigned entries)
36181 const unsigned entries_per_page = PAGE_SIZE / LDT_ENTRY_SIZE;
36182 int i;
36183
36184+ /*
36185+ * We need to mark the all aliases of the LDT pages RO. We
36186+ * don't need to call vm_flush_aliases(), though, since that's
36187+ * only responsible for flushing aliases out the TLBs, not the
36188+ * page tables, and Xen will flush the TLB for us if needed.
36189+ *
36190+ * To avoid confusing future readers: none of this is necessary
36191+ * to load the LDT. The hypervisor only checks this when the
36192+ * LDT is faulted in due to subsequent descriptor access.
36193+ */
36194+
36195 for(i = 0; i < entries; i += entries_per_page)
36196 set_aliased_prot(ldt + i, PAGE_KERNEL_RO);
36197 }
36198@@ -544,8 +582,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
36199 {
36200 unsigned long va = dtr->address;
36201 unsigned int size = dtr->size + 1;
36202- unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
36203- unsigned long frames[pages];
36204+ unsigned long frames[65536 / PAGE_SIZE];
36205 int f;
36206
36207 /*
36208@@ -593,8 +630,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
36209 {
36210 unsigned long va = dtr->address;
36211 unsigned int size = dtr->size + 1;
36212- unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
36213- unsigned long frames[pages];
36214+ unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
36215 int f;
36216
36217 /*
36218@@ -602,7 +638,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
36219 * 8-byte entries, or 16 4k pages..
36220 */
36221
36222- BUG_ON(size > 65536);
36223+ BUG_ON(size > GDT_SIZE);
36224 BUG_ON(va & ~PAGE_MASK);
36225
36226 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
36227@@ -1223,30 +1259,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
36228 #endif
36229 };
36230
36231-static void xen_reboot(int reason)
36232+static __noreturn void xen_reboot(int reason)
36233 {
36234 struct sched_shutdown r = { .reason = reason };
36235
36236- if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
36237- BUG();
36238+ HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
36239+ BUG();
36240 }
36241
36242-static void xen_restart(char *msg)
36243+static __noreturn void xen_restart(char *msg)
36244 {
36245 xen_reboot(SHUTDOWN_reboot);
36246 }
36247
36248-static void xen_emergency_restart(void)
36249+static __noreturn void xen_emergency_restart(void)
36250 {
36251 xen_reboot(SHUTDOWN_reboot);
36252 }
36253
36254-static void xen_machine_halt(void)
36255+static __noreturn void xen_machine_halt(void)
36256 {
36257 xen_reboot(SHUTDOWN_poweroff);
36258 }
36259
36260-static void xen_machine_power_off(void)
36261+static __noreturn void xen_machine_power_off(void)
36262 {
36263 if (pm_power_off)
36264 pm_power_off();
36265@@ -1399,8 +1435,11 @@ static void __ref xen_setup_gdt(int cpu)
36266 pv_cpu_ops.write_gdt_entry = xen_write_gdt_entry_boot;
36267 pv_cpu_ops.load_gdt = xen_load_gdt_boot;
36268
36269- setup_stack_canary_segment(0);
36270- switch_to_new_gdt(0);
36271+ setup_stack_canary_segment(cpu);
36272+#ifdef CONFIG_X86_64
36273+ load_percpu_segment(cpu);
36274+#endif
36275+ switch_to_new_gdt(cpu);
36276
36277 pv_cpu_ops.write_gdt_entry = xen_write_gdt_entry;
36278 pv_cpu_ops.load_gdt = xen_load_gdt;
36279@@ -1515,7 +1554,17 @@ asmlinkage __visible void __init xen_start_kernel(void)
36280 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
36281
36282 /* Work out if we support NX */
36283- x86_configure_nx();
36284+#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
36285+ if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
36286+ (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
36287+ unsigned l, h;
36288+
36289+ __supported_pte_mask |= _PAGE_NX;
36290+ rdmsr(MSR_EFER, l, h);
36291+ l |= EFER_NX;
36292+ wrmsr(MSR_EFER, l, h);
36293+ }
36294+#endif
36295
36296 /* Get mfn list */
36297 xen_build_dynamic_phys_to_machine();
36298@@ -1543,13 +1592,6 @@ asmlinkage __visible void __init xen_start_kernel(void)
36299
36300 machine_ops = xen_machine_ops;
36301
36302- /*
36303- * The only reliable way to retain the initial address of the
36304- * percpu gdt_page is to remember it here, so we can go and
36305- * mark it RW later, when the initial percpu area is freed.
36306- */
36307- xen_initial_gdt = &per_cpu(gdt_page, 0);
36308-
36309 xen_smp_init();
36310
36311 #ifdef CONFIG_ACPI_NUMA
36312diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
36313index dd151b2..d5ab952 100644
36314--- a/arch/x86/xen/mmu.c
36315+++ b/arch/x86/xen/mmu.c
36316@@ -379,7 +379,7 @@ static pteval_t pte_mfn_to_pfn(pteval_t val)
36317 return val;
36318 }
36319
36320-static pteval_t pte_pfn_to_mfn(pteval_t val)
36321+static pteval_t __intentional_overflow(-1) pte_pfn_to_mfn(pteval_t val)
36322 {
36323 if (val & _PAGE_PRESENT) {
36324 unsigned long pfn = (val & PTE_PFN_MASK) >> PAGE_SHIFT;
36325@@ -1835,7 +1835,11 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
36326 * L3_k[511] -> level2_fixmap_pgt */
36327 convert_pfn_mfn(level3_kernel_pgt);
36328
36329+ convert_pfn_mfn(level3_vmalloc_start_pgt);
36330+ convert_pfn_mfn(level3_vmalloc_end_pgt);
36331+ convert_pfn_mfn(level3_vmemmap_pgt);
36332 /* L3_k[511][506] -> level1_fixmap_pgt */
36333+ /* L3_k[511][507] -> level1_vsyscall_pgt */
36334 convert_pfn_mfn(level2_fixmap_pgt);
36335 }
36336 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
36337@@ -1860,11 +1864,18 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
36338 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
36339 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
36340 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
36341+ set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
36342+ set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
36343+ set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
36344 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
36345 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
36346+ set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
36347 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
36348 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
36349- set_page_prot(level1_fixmap_pgt, PAGE_KERNEL_RO);
36350+ set_page_prot(level1_fixmap_pgt[0], PAGE_KERNEL_RO);
36351+ set_page_prot(level1_fixmap_pgt[1], PAGE_KERNEL_RO);
36352+ set_page_prot(level1_fixmap_pgt[2], PAGE_KERNEL_RO);
36353+ set_page_prot(level1_vsyscall_pgt, PAGE_KERNEL_RO);
36354
36355 /* Pin down new L4 */
36356 pin_pagetable_pfn(MMUEXT_PIN_L4_TABLE,
36357@@ -2048,6 +2059,7 @@ static void __init xen_post_allocator_init(void)
36358 pv_mmu_ops.set_pud = xen_set_pud;
36359 #if CONFIG_PGTABLE_LEVELS == 4
36360 pv_mmu_ops.set_pgd = xen_set_pgd;
36361+ pv_mmu_ops.set_pgd_batched = xen_set_pgd;
36362 #endif
36363
36364 /* This will work as long as patching hasn't happened yet
36365@@ -2126,6 +2138,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
36366 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
36367 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
36368 .set_pgd = xen_set_pgd_hyper,
36369+ .set_pgd_batched = xen_set_pgd_hyper,
36370
36371 .alloc_pud = xen_alloc_pmd_init,
36372 .release_pud = xen_release_pmd_init,
36373diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
36374index 8648438..18bac20 100644
36375--- a/arch/x86/xen/smp.c
36376+++ b/arch/x86/xen/smp.c
36377@@ -284,17 +284,13 @@ static void __init xen_smp_prepare_boot_cpu(void)
36378
36379 if (xen_pv_domain()) {
36380 if (!xen_feature(XENFEAT_writable_page_tables))
36381- /* We've switched to the "real" per-cpu gdt, so make
36382- * sure the old memory can be recycled. */
36383- make_lowmem_page_readwrite(xen_initial_gdt);
36384-
36385 #ifdef CONFIG_X86_32
36386 /*
36387 * Xen starts us with XEN_FLAT_RING1_DS, but linux code
36388 * expects __USER_DS
36389 */
36390- loadsegment(ds, __USER_DS);
36391- loadsegment(es, __USER_DS);
36392+ loadsegment(ds, __KERNEL_DS);
36393+ loadsegment(es, __KERNEL_DS);
36394 #endif
36395
36396 xen_filter_cpu_maps();
36397@@ -375,7 +371,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
36398 #ifdef CONFIG_X86_32
36399 /* Note: PVH is not yet supported on x86_32. */
36400 ctxt->user_regs.fs = __KERNEL_PERCPU;
36401- ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
36402+ savesegment(gs, ctxt->user_regs.gs);
36403 #endif
36404 memset(&ctxt->fpu_ctxt, 0, sizeof(ctxt->fpu_ctxt));
36405
36406@@ -383,8 +379,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
36407 ctxt->user_regs.eip = (unsigned long)cpu_bringup_and_idle;
36408 ctxt->flags = VGCF_IN_KERNEL;
36409 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
36410- ctxt->user_regs.ds = __USER_DS;
36411- ctxt->user_regs.es = __USER_DS;
36412+ ctxt->user_regs.ds = __KERNEL_DS;
36413+ ctxt->user_regs.es = __KERNEL_DS;
36414 ctxt->user_regs.ss = __KERNEL_DS;
36415
36416 xen_copy_trap_info(ctxt->trap_ctxt);
36417@@ -720,7 +716,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
36418
36419 void __init xen_smp_init(void)
36420 {
36421- smp_ops = xen_smp_ops;
36422+ memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
36423 xen_fill_possible_map();
36424 }
36425
36426diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
36427index fd92a64..1f72641 100644
36428--- a/arch/x86/xen/xen-asm_32.S
36429+++ b/arch/x86/xen/xen-asm_32.S
36430@@ -99,7 +99,7 @@ ENTRY(xen_iret)
36431 pushw %fs
36432 movl $(__KERNEL_PERCPU), %eax
36433 movl %eax, %fs
36434- movl %fs:xen_vcpu, %eax
36435+ mov PER_CPU_VAR(xen_vcpu), %eax
36436 POP_FS
36437 #else
36438 movl %ss:xen_vcpu, %eax
36439diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
36440index 8afdfcc..79239db 100644
36441--- a/arch/x86/xen/xen-head.S
36442+++ b/arch/x86/xen/xen-head.S
36443@@ -41,6 +41,17 @@ ENTRY(startup_xen)
36444 #ifdef CONFIG_X86_32
36445 mov %esi,xen_start_info
36446 mov $init_thread_union+THREAD_SIZE,%esp
36447+#ifdef CONFIG_SMP
36448+ movl $cpu_gdt_table,%edi
36449+ movl $__per_cpu_load,%eax
36450+ movw %ax,__KERNEL_PERCPU + 2(%edi)
36451+ rorl $16,%eax
36452+ movb %al,__KERNEL_PERCPU + 4(%edi)
36453+ movb %ah,__KERNEL_PERCPU + 7(%edi)
36454+ movl $__per_cpu_end - 1,%eax
36455+ subl $__per_cpu_start,%eax
36456+ movw %ax,__KERNEL_PERCPU + 0(%edi)
36457+#endif
36458 #else
36459 mov %rsi,xen_start_info
36460 mov $init_thread_union+THREAD_SIZE,%rsp
36461diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
36462index 9e195c6..523ed36 100644
36463--- a/arch/x86/xen/xen-ops.h
36464+++ b/arch/x86/xen/xen-ops.h
36465@@ -16,8 +16,6 @@ void xen_syscall_target(void);
36466 void xen_syscall32_target(void);
36467 #endif
36468
36469-extern void *xen_initial_gdt;
36470-
36471 struct trap_info;
36472 void xen_copy_trap_info(struct trap_info *traps);
36473
36474diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
36475index 525bd3d..ef888b1 100644
36476--- a/arch/xtensa/variants/dc232b/include/variant/core.h
36477+++ b/arch/xtensa/variants/dc232b/include/variant/core.h
36478@@ -119,9 +119,9 @@
36479 ----------------------------------------------------------------------*/
36480
36481 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
36482-#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
36483 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
36484 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
36485+#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
36486
36487 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
36488 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
36489diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
36490index 2f33760..835e50a 100644
36491--- a/arch/xtensa/variants/fsf/include/variant/core.h
36492+++ b/arch/xtensa/variants/fsf/include/variant/core.h
36493@@ -11,6 +11,7 @@
36494 #ifndef _XTENSA_CORE_H
36495 #define _XTENSA_CORE_H
36496
36497+#include <linux/const.h>
36498
36499 /****************************************************************************
36500 Parameters Useful for Any Code, USER or PRIVILEGED
36501@@ -112,9 +113,9 @@
36502 ----------------------------------------------------------------------*/
36503
36504 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
36505-#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
36506 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
36507 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
36508+#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
36509
36510 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
36511 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
36512diff --git a/block/bio.c b/block/bio.c
36513index f66a4ea..73ddf55 100644
36514--- a/block/bio.c
36515+++ b/block/bio.c
36516@@ -1172,7 +1172,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
36517 /*
36518 * Overflow, abort
36519 */
36520- if (end < start)
36521+ if (end < start || end - start > INT_MAX - nr_pages)
36522 return ERR_PTR(-EINVAL);
36523
36524 nr_pages += end - start;
36525@@ -1297,7 +1297,7 @@ struct bio *bio_map_user_iov(struct request_queue *q,
36526 /*
36527 * Overflow, abort
36528 */
36529- if (end < start)
36530+ if (end < start || end - start > INT_MAX - nr_pages)
36531 return ERR_PTR(-EINVAL);
36532
36533 nr_pages += end - start;
36534diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
36535index 0736729..2ec3b48 100644
36536--- a/block/blk-iopoll.c
36537+++ b/block/blk-iopoll.c
36538@@ -74,7 +74,7 @@ void blk_iopoll_complete(struct blk_iopoll *iop)
36539 }
36540 EXPORT_SYMBOL(blk_iopoll_complete);
36541
36542-static void blk_iopoll_softirq(struct softirq_action *h)
36543+static __latent_entropy void blk_iopoll_softirq(void)
36544 {
36545 struct list_head *list = this_cpu_ptr(&blk_cpu_iopoll);
36546 int rearm = 0, budget = blk_iopoll_budget;
36547diff --git a/block/blk-map.c b/block/blk-map.c
36548index da310a1..213b5c9 100644
36549--- a/block/blk-map.c
36550+++ b/block/blk-map.c
36551@@ -192,7 +192,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
36552 if (!len || !kbuf)
36553 return -EINVAL;
36554
36555- do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
36556+ do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
36557 if (do_copy)
36558 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
36559 else
36560diff --git a/block/blk-mq.c b/block/blk-mq.c
36561index 594eea0..2dc1fd6 100644
36562--- a/block/blk-mq.c
36563+++ b/block/blk-mq.c
36564@@ -1968,7 +1968,7 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
36565 goto err_hctxs;
36566
36567 setup_timer(&q->timeout, blk_mq_rq_timer, (unsigned long) q);
36568- blk_queue_rq_timeout(q, set->timeout ? set->timeout : 30000);
36569+ blk_queue_rq_timeout(q, set->timeout ? set->timeout : 30 * HZ);
36570
36571 q->nr_queues = nr_cpu_ids;
36572 q->nr_hw_queues = set->nr_hw_queues;
36573diff --git a/block/blk-softirq.c b/block/blk-softirq.c
36574index 53b1737..08177d2e 100644
36575--- a/block/blk-softirq.c
36576+++ b/block/blk-softirq.c
36577@@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
36578 * Softirq action handler - move entries to local list and loop over them
36579 * while passing them to the queue registered handler.
36580 */
36581-static void blk_done_softirq(struct softirq_action *h)
36582+static __latent_entropy void blk_done_softirq(void)
36583 {
36584 struct list_head *cpu_list, local_list;
36585
36586diff --git a/block/bsg.c b/block/bsg.c
36587index d214e92..9649863 100644
36588--- a/block/bsg.c
36589+++ b/block/bsg.c
36590@@ -140,16 +140,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
36591 struct sg_io_v4 *hdr, struct bsg_device *bd,
36592 fmode_t has_write_perm)
36593 {
36594+ unsigned char tmpcmd[sizeof(rq->__cmd)];
36595+ unsigned char *cmdptr;
36596+
36597 if (hdr->request_len > BLK_MAX_CDB) {
36598 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
36599 if (!rq->cmd)
36600 return -ENOMEM;
36601- }
36602+ cmdptr = rq->cmd;
36603+ } else
36604+ cmdptr = tmpcmd;
36605
36606- if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
36607+ if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
36608 hdr->request_len))
36609 return -EFAULT;
36610
36611+ if (cmdptr != rq->cmd)
36612+ memcpy(rq->cmd, cmdptr, hdr->request_len);
36613+
36614 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
36615 if (blk_verify_command(rq->cmd, has_write_perm))
36616 return -EPERM;
36617diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
36618index f678c73..f35aa18 100644
36619--- a/block/compat_ioctl.c
36620+++ b/block/compat_ioctl.c
36621@@ -156,7 +156,7 @@ static int compat_cdrom_generic_command(struct block_device *bdev, fmode_t mode,
36622 cgc = compat_alloc_user_space(sizeof(*cgc));
36623 cgc32 = compat_ptr(arg);
36624
36625- if (copy_in_user(&cgc->cmd, &cgc32->cmd, sizeof(cgc->cmd)) ||
36626+ if (copy_in_user(cgc->cmd, cgc32->cmd, sizeof(cgc->cmd)) ||
36627 get_user(data, &cgc32->buffer) ||
36628 put_user(compat_ptr(data), &cgc->buffer) ||
36629 copy_in_user(&cgc->buflen, &cgc32->buflen,
36630@@ -341,7 +341,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
36631 err |= __get_user(f->spec1, &uf->spec1);
36632 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
36633 err |= __get_user(name, &uf->name);
36634- f->name = compat_ptr(name);
36635+ f->name = (void __force_kernel *)compat_ptr(name);
36636 if (err) {
36637 err = -EFAULT;
36638 goto out;
36639diff --git a/block/genhd.c b/block/genhd.c
36640index ea982ea..86e0f9e 100644
36641--- a/block/genhd.c
36642+++ b/block/genhd.c
36643@@ -469,21 +469,24 @@ static char *bdevt_str(dev_t devt, char *buf)
36644
36645 /*
36646 * Register device numbers dev..(dev+range-1)
36647- * range must be nonzero
36648+ * Noop if @range is zero.
36649 * The hash chain is sorted on range, so that subranges can override.
36650 */
36651 void blk_register_region(dev_t devt, unsigned long range, struct module *module,
36652 struct kobject *(*probe)(dev_t, int *, void *),
36653 int (*lock)(dev_t, void *), void *data)
36654 {
36655- kobj_map(bdev_map, devt, range, module, probe, lock, data);
36656+ if (range)
36657+ kobj_map(bdev_map, devt, range, module, probe, lock, data);
36658 }
36659
36660 EXPORT_SYMBOL(blk_register_region);
36661
36662+/* undo blk_register_region(), noop if @range is zero */
36663 void blk_unregister_region(dev_t devt, unsigned long range)
36664 {
36665- kobj_unmap(bdev_map, devt, range);
36666+ if (range)
36667+ kobj_unmap(bdev_map, devt, range);
36668 }
36669
36670 EXPORT_SYMBOL(blk_unregister_region);
36671diff --git a/block/partitions/efi.c b/block/partitions/efi.c
36672index 26cb624..a49c3a5 100644
36673--- a/block/partitions/efi.c
36674+++ b/block/partitions/efi.c
36675@@ -293,14 +293,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
36676 if (!gpt)
36677 return NULL;
36678
36679+ if (!le32_to_cpu(gpt->num_partition_entries))
36680+ return NULL;
36681+ pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
36682+ if (!pte)
36683+ return NULL;
36684+
36685 count = le32_to_cpu(gpt->num_partition_entries) *
36686 le32_to_cpu(gpt->sizeof_partition_entry);
36687- if (!count)
36688- return NULL;
36689- pte = kmalloc(count, GFP_KERNEL);
36690- if (!pte)
36691- return NULL;
36692-
36693 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
36694 (u8 *) pte, count) < count) {
36695 kfree(pte);
36696diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
36697index 55b6f15..b602c9a 100644
36698--- a/block/scsi_ioctl.c
36699+++ b/block/scsi_ioctl.c
36700@@ -67,7 +67,7 @@ static int scsi_get_bus(struct request_queue *q, int __user *p)
36701 return put_user(0, p);
36702 }
36703
36704-static int sg_get_timeout(struct request_queue *q)
36705+static int __intentional_overflow(-1) sg_get_timeout(struct request_queue *q)
36706 {
36707 return jiffies_to_clock_t(q->sg_timeout);
36708 }
36709@@ -227,8 +227,20 @@ EXPORT_SYMBOL(blk_verify_command);
36710 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
36711 struct sg_io_hdr *hdr, fmode_t mode)
36712 {
36713- if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
36714+ unsigned char tmpcmd[sizeof(rq->__cmd)];
36715+ unsigned char *cmdptr;
36716+
36717+ if (rq->cmd != rq->__cmd)
36718+ cmdptr = rq->cmd;
36719+ else
36720+ cmdptr = tmpcmd;
36721+
36722+ if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
36723 return -EFAULT;
36724+
36725+ if (cmdptr != rq->cmd)
36726+ memcpy(rq->cmd, cmdptr, hdr->cmd_len);
36727+
36728 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
36729 return -EPERM;
36730
36731@@ -420,6 +432,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
36732 int err;
36733 unsigned int in_len, out_len, bytes, opcode, cmdlen;
36734 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
36735+ unsigned char tmpcmd[sizeof(rq->__cmd)];
36736+ unsigned char *cmdptr;
36737
36738 if (!sic)
36739 return -EINVAL;
36740@@ -458,9 +472,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
36741 */
36742 err = -EFAULT;
36743 rq->cmd_len = cmdlen;
36744- if (copy_from_user(rq->cmd, sic->data, cmdlen))
36745+
36746+ if (rq->cmd != rq->__cmd)
36747+ cmdptr = rq->cmd;
36748+ else
36749+ cmdptr = tmpcmd;
36750+
36751+ if (copy_from_user(cmdptr, sic->data, cmdlen))
36752 goto error;
36753
36754+ if (rq->cmd != cmdptr)
36755+ memcpy(rq->cmd, cmdptr, cmdlen);
36756+
36757 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
36758 goto error;
36759
36760diff --git a/crypto/cryptd.c b/crypto/cryptd.c
36761index b0602ba..fb71850 100644
36762--- a/crypto/cryptd.c
36763+++ b/crypto/cryptd.c
36764@@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
36765
36766 struct cryptd_blkcipher_request_ctx {
36767 crypto_completion_t complete;
36768-};
36769+} __no_const;
36770
36771 struct cryptd_hash_ctx {
36772 struct crypto_shash *child;
36773@@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
36774
36775 struct cryptd_aead_request_ctx {
36776 crypto_completion_t complete;
36777-};
36778+} __no_const;
36779
36780 static void cryptd_queue_worker(struct work_struct *work);
36781
36782diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
36783index c305d41..a96de79 100644
36784--- a/crypto/pcrypt.c
36785+++ b/crypto/pcrypt.c
36786@@ -440,7 +440,7 @@ static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name)
36787 int ret;
36788
36789 pinst->kobj.kset = pcrypt_kset;
36790- ret = kobject_add(&pinst->kobj, NULL, name);
36791+ ret = kobject_add(&pinst->kobj, NULL, "%s", name);
36792 if (!ret)
36793 kobject_uevent(&pinst->kobj, KOBJ_ADD);
36794
36795diff --git a/crypto/zlib.c b/crypto/zlib.c
36796index 0eefa9d..0fa3d29 100644
36797--- a/crypto/zlib.c
36798+++ b/crypto/zlib.c
36799@@ -95,10 +95,10 @@ static int zlib_compress_setup(struct crypto_pcomp *tfm, void *params,
36800 zlib_comp_exit(ctx);
36801
36802 window_bits = tb[ZLIB_COMP_WINDOWBITS]
36803- ? nla_get_u32(tb[ZLIB_COMP_WINDOWBITS])
36804+ ? nla_get_s32(tb[ZLIB_COMP_WINDOWBITS])
36805 : MAX_WBITS;
36806 mem_level = tb[ZLIB_COMP_MEMLEVEL]
36807- ? nla_get_u32(tb[ZLIB_COMP_MEMLEVEL])
36808+ ? nla_get_s32(tb[ZLIB_COMP_MEMLEVEL])
36809 : DEF_MEM_LEVEL;
36810
36811 workspacesize = zlib_deflate_workspacesize(window_bits, mem_level);
36812diff --git a/drivers/acpi/acpica/hwxfsleep.c b/drivers/acpi/acpica/hwxfsleep.c
36813index 3b37676..898edfa 100644
36814--- a/drivers/acpi/acpica/hwxfsleep.c
36815+++ b/drivers/acpi/acpica/hwxfsleep.c
36816@@ -63,11 +63,12 @@ static acpi_status acpi_hw_sleep_dispatch(u8 sleep_state, u32 function_id);
36817 /* Legacy functions are optional, based upon ACPI_REDUCED_HARDWARE */
36818
36819 static struct acpi_sleep_functions acpi_sleep_dispatch[] = {
36820- {ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_sleep),
36821- acpi_hw_extended_sleep},
36822- {ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake_prep),
36823- acpi_hw_extended_wake_prep},
36824- {ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake), acpi_hw_extended_wake}
36825+ {.legacy_function = ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_sleep),
36826+ .extended_function = acpi_hw_extended_sleep},
36827+ {.legacy_function = ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake_prep),
36828+ .extended_function = acpi_hw_extended_wake_prep},
36829+ {.legacy_function = ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake),
36830+ .extended_function = acpi_hw_extended_wake}
36831 };
36832
36833 /*
36834diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
36835index 16129c7..8b675cd 100644
36836--- a/drivers/acpi/apei/apei-internal.h
36837+++ b/drivers/acpi/apei/apei-internal.h
36838@@ -19,7 +19,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
36839 struct apei_exec_ins_type {
36840 u32 flags;
36841 apei_exec_ins_func_t run;
36842-};
36843+} __do_const;
36844
36845 struct apei_exec_context {
36846 u32 ip;
36847diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
36848index e82d097..0c855c1 100644
36849--- a/drivers/acpi/apei/ghes.c
36850+++ b/drivers/acpi/apei/ghes.c
36851@@ -478,7 +478,7 @@ static void __ghes_print_estatus(const char *pfx,
36852 const struct acpi_hest_generic *generic,
36853 const struct acpi_hest_generic_status *estatus)
36854 {
36855- static atomic_t seqno;
36856+ static atomic_unchecked_t seqno;
36857 unsigned int curr_seqno;
36858 char pfx_seq[64];
36859
36860@@ -489,7 +489,7 @@ static void __ghes_print_estatus(const char *pfx,
36861 else
36862 pfx = KERN_ERR;
36863 }
36864- curr_seqno = atomic_inc_return(&seqno);
36865+ curr_seqno = atomic_inc_return_unchecked(&seqno);
36866 snprintf(pfx_seq, sizeof(pfx_seq), "%s{%u}" HW_ERR, pfx, curr_seqno);
36867 printk("%s""Hardware error from APEI Generic Hardware Error Source: %d\n",
36868 pfx_seq, generic->header.source_id);
36869diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
36870index a83e3c6..c3d617f 100644
36871--- a/drivers/acpi/bgrt.c
36872+++ b/drivers/acpi/bgrt.c
36873@@ -86,8 +86,10 @@ static int __init bgrt_init(void)
36874 if (!bgrt_image)
36875 return -ENODEV;
36876
36877- bin_attr_image.private = bgrt_image;
36878- bin_attr_image.size = bgrt_image_size;
36879+ pax_open_kernel();
36880+ *(void **)&bin_attr_image.private = bgrt_image;
36881+ *(size_t *)&bin_attr_image.size = bgrt_image_size;
36882+ pax_close_kernel();
36883
36884 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
36885 if (!bgrt_kobj)
36886diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
36887index 1d17919..315e955 100644
36888--- a/drivers/acpi/blacklist.c
36889+++ b/drivers/acpi/blacklist.c
36890@@ -51,7 +51,7 @@ struct acpi_blacklist_item {
36891 u32 is_critical_error;
36892 };
36893
36894-static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
36895+static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
36896
36897 /*
36898 * POLICY: If *anything* doesn't work, put it on the blacklist.
36899@@ -163,7 +163,7 @@ static int __init dmi_disable_osi_win8(const struct dmi_system_id *d)
36900 return 0;
36901 }
36902
36903-static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
36904+static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
36905 {
36906 .callback = dmi_disable_osi_vista,
36907 .ident = "Fujitsu Siemens",
36908diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
36909index 513e7230e..802015a 100644
36910--- a/drivers/acpi/bus.c
36911+++ b/drivers/acpi/bus.c
36912@@ -67,7 +67,7 @@ static int set_copy_dsdt(const struct dmi_system_id *id)
36913 }
36914 #endif
36915
36916-static struct dmi_system_id dsdt_dmi_table[] __initdata = {
36917+static const struct dmi_system_id dsdt_dmi_table[] __initconst = {
36918 /*
36919 * Invoke DSDT corruption work-around on all Toshiba Satellite.
36920 * https://bugzilla.kernel.org/show_bug.cgi?id=14679
36921@@ -83,7 +83,7 @@ static struct dmi_system_id dsdt_dmi_table[] __initdata = {
36922 {}
36923 };
36924 #else
36925-static struct dmi_system_id dsdt_dmi_table[] __initdata = {
36926+static const struct dmi_system_id dsdt_dmi_table[] __initconst = {
36927 {}
36928 };
36929 #endif
36930diff --git a/drivers/acpi/custom_method.c b/drivers/acpi/custom_method.c
36931index c68e724..e863008 100644
36932--- a/drivers/acpi/custom_method.c
36933+++ b/drivers/acpi/custom_method.c
36934@@ -29,6 +29,10 @@ static ssize_t cm_write(struct file *file, const char __user * user_buf,
36935 struct acpi_table_header table;
36936 acpi_status status;
36937
36938+#ifdef CONFIG_GRKERNSEC_KMEM
36939+ return -EPERM;
36940+#endif
36941+
36942 if (!(*ppos)) {
36943 /* parse the table header to get the table length */
36944 if (count <= sizeof(struct acpi_table_header))
36945diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
36946index 8217e0b..3294cb6 100644
36947--- a/drivers/acpi/device_pm.c
36948+++ b/drivers/acpi/device_pm.c
36949@@ -1026,6 +1026,8 @@ EXPORT_SYMBOL_GPL(acpi_subsys_freeze);
36950
36951 #endif /* CONFIG_PM_SLEEP */
36952
36953+static void acpi_dev_pm_detach(struct device *dev, bool power_off);
36954+
36955 static struct dev_pm_domain acpi_general_pm_domain = {
36956 .ops = {
36957 .runtime_suspend = acpi_subsys_runtime_suspend,
36958@@ -1042,6 +1044,7 @@ static struct dev_pm_domain acpi_general_pm_domain = {
36959 .restore_early = acpi_subsys_resume_early,
36960 #endif
36961 },
36962+ .detach = acpi_dev_pm_detach
36963 };
36964
36965 /**
36966@@ -1111,7 +1114,6 @@ int acpi_dev_pm_attach(struct device *dev, bool power_on)
36967 acpi_device_wakeup(adev, ACPI_STATE_S0, false);
36968 }
36969
36970- dev->pm_domain->detach = acpi_dev_pm_detach;
36971 return 0;
36972 }
36973 EXPORT_SYMBOL_GPL(acpi_dev_pm_attach);
36974diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
36975index 5e8fed4..d9bb545 100644
36976--- a/drivers/acpi/ec.c
36977+++ b/drivers/acpi/ec.c
36978@@ -1293,7 +1293,7 @@ static int ec_clear_on_resume(const struct dmi_system_id *id)
36979 return 0;
36980 }
36981
36982-static struct dmi_system_id ec_dmi_table[] __initdata = {
36983+static const struct dmi_system_id ec_dmi_table[] __initconst = {
36984 {
36985 ec_skip_dsdt_scan, "Compal JFL92", {
36986 DMI_MATCH(DMI_BIOS_VENDOR, "COMPAL"),
36987diff --git a/drivers/acpi/pci_slot.c b/drivers/acpi/pci_slot.c
36988index 139d9e4..9a9d799 100644
36989--- a/drivers/acpi/pci_slot.c
36990+++ b/drivers/acpi/pci_slot.c
36991@@ -195,7 +195,7 @@ static int do_sta_before_sun(const struct dmi_system_id *d)
36992 return 0;
36993 }
36994
36995-static struct dmi_system_id acpi_pci_slot_dmi_table[] __initdata = {
36996+static const struct dmi_system_id acpi_pci_slot_dmi_table[] __initconst = {
36997 /*
36998 * Fujitsu Primequest machines will return 1023 to indicate an
36999 * error if the _SUN method is evaluated on SxFy objects that
37000diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
37001index d9f7158..168e742 100644
37002--- a/drivers/acpi/processor_driver.c
37003+++ b/drivers/acpi/processor_driver.c
37004@@ -159,7 +159,7 @@ static int acpi_cpu_soft_notify(struct notifier_block *nfb,
37005 return NOTIFY_OK;
37006 }
37007
37008-static struct notifier_block __refdata acpi_cpu_notifier = {
37009+static struct notifier_block __refconst acpi_cpu_notifier = {
37010 .notifier_call = acpi_cpu_soft_notify,
37011 };
37012
37013diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
37014index 39e0c8e..b5ae20c 100644
37015--- a/drivers/acpi/processor_idle.c
37016+++ b/drivers/acpi/processor_idle.c
37017@@ -910,7 +910,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
37018 {
37019 int i, count = CPUIDLE_DRIVER_STATE_START;
37020 struct acpi_processor_cx *cx;
37021- struct cpuidle_state *state;
37022+ cpuidle_state_no_const *state;
37023 struct cpuidle_driver *drv = &acpi_idle_driver;
37024
37025 if (!pr->flags.power_setup_done)
37026diff --git a/drivers/acpi/processor_pdc.c b/drivers/acpi/processor_pdc.c
37027index e5dd808..1eceed1 100644
37028--- a/drivers/acpi/processor_pdc.c
37029+++ b/drivers/acpi/processor_pdc.c
37030@@ -176,7 +176,7 @@ static int __init set_no_mwait(const struct dmi_system_id *id)
37031 return 0;
37032 }
37033
37034-static struct dmi_system_id processor_idle_dmi_table[] __initdata = {
37035+static const struct dmi_system_id processor_idle_dmi_table[] __initconst = {
37036 {
37037 set_no_mwait, "Extensa 5220", {
37038 DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
37039diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
37040index 2f0d4db..b9e9b15 100644
37041--- a/drivers/acpi/sleep.c
37042+++ b/drivers/acpi/sleep.c
37043@@ -148,7 +148,7 @@ static int __init init_nvs_nosave(const struct dmi_system_id *d)
37044 return 0;
37045 }
37046
37047-static struct dmi_system_id acpisleep_dmi_table[] __initdata = {
37048+static const struct dmi_system_id acpisleep_dmi_table[] __initconst = {
37049 {
37050 .callback = init_old_suspend_ordering,
37051 .ident = "Abit KN9 (nForce4 variant)",
37052diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
37053index 0876d77b..3ba0127 100644
37054--- a/drivers/acpi/sysfs.c
37055+++ b/drivers/acpi/sysfs.c
37056@@ -423,11 +423,11 @@ static u32 num_counters;
37057 static struct attribute **all_attrs;
37058 static u32 acpi_gpe_count;
37059
37060-static struct attribute_group interrupt_stats_attr_group = {
37061+static attribute_group_no_const interrupt_stats_attr_group = {
37062 .name = "interrupts",
37063 };
37064
37065-static struct kobj_attribute *counter_attrs;
37066+static kobj_attribute_no_const *counter_attrs;
37067
37068 static void delete_gpe_attr_array(void)
37069 {
37070diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
37071index d24fa19..782f1e6 100644
37072--- a/drivers/acpi/thermal.c
37073+++ b/drivers/acpi/thermal.c
37074@@ -1209,7 +1209,7 @@ static int thermal_psv(const struct dmi_system_id *d) {
37075 return 0;
37076 }
37077
37078-static struct dmi_system_id thermal_dmi_table[] __initdata = {
37079+static const struct dmi_system_id thermal_dmi_table[] __initconst = {
37080 /*
37081 * Award BIOS on this AOpen makes thermal control almost worthless.
37082 * http://bugzilla.kernel.org/show_bug.cgi?id=8842
37083diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
37084index cc79d3f..28adb33 100644
37085--- a/drivers/acpi/video.c
37086+++ b/drivers/acpi/video.c
37087@@ -431,7 +431,7 @@ static int __init video_enable_native_backlight(const struct dmi_system_id *d)
37088 return 0;
37089 }
37090
37091-static struct dmi_system_id video_dmi_table[] __initdata = {
37092+static const struct dmi_system_id video_dmi_table[] __initconst = {
37093 /*
37094 * Broken _BQC workaround http://bugzilla.kernel.org/show_bug.cgi?id=13121
37095 */
37096diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
37097index 287c4ba..6a600bc 100644
37098--- a/drivers/ata/libahci.c
37099+++ b/drivers/ata/libahci.c
37100@@ -1252,7 +1252,7 @@ int ahci_kick_engine(struct ata_port *ap)
37101 }
37102 EXPORT_SYMBOL_GPL(ahci_kick_engine);
37103
37104-static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
37105+static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
37106 struct ata_taskfile *tf, int is_cmd, u16 flags,
37107 unsigned long timeout_msec)
37108 {
37109diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
37110index 577849c..920847c 100644
37111--- a/drivers/ata/libata-core.c
37112+++ b/drivers/ata/libata-core.c
37113@@ -102,7 +102,7 @@ static unsigned int ata_dev_set_xfermode(struct ata_device *dev);
37114 static void ata_dev_xfermask(struct ata_device *dev);
37115 static unsigned long ata_dev_blacklisted(const struct ata_device *dev);
37116
37117-atomic_t ata_print_id = ATOMIC_INIT(0);
37118+atomic_unchecked_t ata_print_id = ATOMIC_INIT(0);
37119
37120 struct ata_force_param {
37121 const char *name;
37122@@ -4801,7 +4801,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
37123 struct ata_port *ap;
37124 unsigned int tag;
37125
37126- WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
37127+ BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
37128 ap = qc->ap;
37129
37130 qc->flags = 0;
37131@@ -4818,7 +4818,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
37132 struct ata_port *ap;
37133 struct ata_link *link;
37134
37135- WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
37136+ BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
37137 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
37138 ap = qc->ap;
37139 link = qc->dev->link;
37140@@ -5925,6 +5925,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
37141 return;
37142
37143 spin_lock(&lock);
37144+ pax_open_kernel();
37145
37146 for (cur = ops->inherits; cur; cur = cur->inherits) {
37147 void **inherit = (void **)cur;
37148@@ -5938,8 +5939,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
37149 if (IS_ERR(*pp))
37150 *pp = NULL;
37151
37152- ops->inherits = NULL;
37153+ *(struct ata_port_operations **)&ops->inherits = NULL;
37154
37155+ pax_close_kernel();
37156 spin_unlock(&lock);
37157 }
37158
37159@@ -6135,7 +6137,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
37160
37161 /* give ports names and add SCSI hosts */
37162 for (i = 0; i < host->n_ports; i++) {
37163- host->ports[i]->print_id = atomic_inc_return(&ata_print_id);
37164+ host->ports[i]->print_id = atomic_inc_return_unchecked(&ata_print_id);
37165 host->ports[i]->local_port_no = i + 1;
37166 }
37167
37168diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
37169index 3131adc..93e7aa0 100644
37170--- a/drivers/ata/libata-scsi.c
37171+++ b/drivers/ata/libata-scsi.c
37172@@ -4209,7 +4209,7 @@ int ata_sas_port_init(struct ata_port *ap)
37173
37174 if (rc)
37175 return rc;
37176- ap->print_id = atomic_inc_return(&ata_print_id);
37177+ ap->print_id = atomic_inc_return_unchecked(&ata_print_id);
37178 return 0;
37179 }
37180 EXPORT_SYMBOL_GPL(ata_sas_port_init);
37181diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
37182index a998a17..8de4bf4 100644
37183--- a/drivers/ata/libata.h
37184+++ b/drivers/ata/libata.h
37185@@ -53,7 +53,7 @@ enum {
37186 ATA_DNXFER_QUIET = (1 << 31),
37187 };
37188
37189-extern atomic_t ata_print_id;
37190+extern atomic_unchecked_t ata_print_id;
37191 extern int atapi_passthru16;
37192 extern int libata_fua;
37193 extern int libata_noacpi;
37194diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
37195index a9b0c82..207d97d 100644
37196--- a/drivers/ata/pata_arasan_cf.c
37197+++ b/drivers/ata/pata_arasan_cf.c
37198@@ -865,7 +865,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
37199 /* Handle platform specific quirks */
37200 if (quirk) {
37201 if (quirk & CF_BROKEN_PIO) {
37202- ap->ops->set_piomode = NULL;
37203+ pax_open_kernel();
37204+ *(void **)&ap->ops->set_piomode = NULL;
37205+ pax_close_kernel();
37206 ap->pio_mask = 0;
37207 }
37208 if (quirk & CF_BROKEN_MWDMA)
37209diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
37210index f9b983a..887b9d8 100644
37211--- a/drivers/atm/adummy.c
37212+++ b/drivers/atm/adummy.c
37213@@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
37214 vcc->pop(vcc, skb);
37215 else
37216 dev_kfree_skb_any(skb);
37217- atomic_inc(&vcc->stats->tx);
37218+ atomic_inc_unchecked(&vcc->stats->tx);
37219
37220 return 0;
37221 }
37222diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
37223index f1a9198..f466a4a 100644
37224--- a/drivers/atm/ambassador.c
37225+++ b/drivers/atm/ambassador.c
37226@@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
37227 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
37228
37229 // VC layer stats
37230- atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
37231+ atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
37232
37233 // free the descriptor
37234 kfree (tx_descr);
37235@@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
37236 dump_skb ("<<<", vc, skb);
37237
37238 // VC layer stats
37239- atomic_inc(&atm_vcc->stats->rx);
37240+ atomic_inc_unchecked(&atm_vcc->stats->rx);
37241 __net_timestamp(skb);
37242 // end of our responsibility
37243 atm_vcc->push (atm_vcc, skb);
37244@@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
37245 } else {
37246 PRINTK (KERN_INFO, "dropped over-size frame");
37247 // should we count this?
37248- atomic_inc(&atm_vcc->stats->rx_drop);
37249+ atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
37250 }
37251
37252 } else {
37253@@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
37254 }
37255
37256 if (check_area (skb->data, skb->len)) {
37257- atomic_inc(&atm_vcc->stats->tx_err);
37258+ atomic_inc_unchecked(&atm_vcc->stats->tx_err);
37259 return -ENOMEM; // ?
37260 }
37261
37262diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
37263index 480fa6f..947067c 100644
37264--- a/drivers/atm/atmtcp.c
37265+++ b/drivers/atm/atmtcp.c
37266@@ -206,7 +206,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
37267 if (vcc->pop) vcc->pop(vcc,skb);
37268 else dev_kfree_skb(skb);
37269 if (dev_data) return 0;
37270- atomic_inc(&vcc->stats->tx_err);
37271+ atomic_inc_unchecked(&vcc->stats->tx_err);
37272 return -ENOLINK;
37273 }
37274 size = skb->len+sizeof(struct atmtcp_hdr);
37275@@ -214,7 +214,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
37276 if (!new_skb) {
37277 if (vcc->pop) vcc->pop(vcc,skb);
37278 else dev_kfree_skb(skb);
37279- atomic_inc(&vcc->stats->tx_err);
37280+ atomic_inc_unchecked(&vcc->stats->tx_err);
37281 return -ENOBUFS;
37282 }
37283 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
37284@@ -225,8 +225,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
37285 if (vcc->pop) vcc->pop(vcc,skb);
37286 else dev_kfree_skb(skb);
37287 out_vcc->push(out_vcc,new_skb);
37288- atomic_inc(&vcc->stats->tx);
37289- atomic_inc(&out_vcc->stats->rx);
37290+ atomic_inc_unchecked(&vcc->stats->tx);
37291+ atomic_inc_unchecked(&out_vcc->stats->rx);
37292 return 0;
37293 }
37294
37295@@ -300,7 +300,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
37296 read_unlock(&vcc_sklist_lock);
37297 if (!out_vcc) {
37298 result = -EUNATCH;
37299- atomic_inc(&vcc->stats->tx_err);
37300+ atomic_inc_unchecked(&vcc->stats->tx_err);
37301 goto done;
37302 }
37303 skb_pull(skb,sizeof(struct atmtcp_hdr));
37304@@ -312,8 +312,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
37305 __net_timestamp(new_skb);
37306 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
37307 out_vcc->push(out_vcc,new_skb);
37308- atomic_inc(&vcc->stats->tx);
37309- atomic_inc(&out_vcc->stats->rx);
37310+ atomic_inc_unchecked(&vcc->stats->tx);
37311+ atomic_inc_unchecked(&out_vcc->stats->rx);
37312 done:
37313 if (vcc->pop) vcc->pop(vcc,skb);
37314 else dev_kfree_skb(skb);
37315diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
37316index 6339efd..2b441d5 100644
37317--- a/drivers/atm/eni.c
37318+++ b/drivers/atm/eni.c
37319@@ -525,7 +525,7 @@ static int rx_aal0(struct atm_vcc *vcc)
37320 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
37321 vcc->dev->number);
37322 length = 0;
37323- atomic_inc(&vcc->stats->rx_err);
37324+ atomic_inc_unchecked(&vcc->stats->rx_err);
37325 }
37326 else {
37327 length = ATM_CELL_SIZE-1; /* no HEC */
37328@@ -580,7 +580,7 @@ static int rx_aal5(struct atm_vcc *vcc)
37329 size);
37330 }
37331 eff = length = 0;
37332- atomic_inc(&vcc->stats->rx_err);
37333+ atomic_inc_unchecked(&vcc->stats->rx_err);
37334 }
37335 else {
37336 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
37337@@ -597,7 +597,7 @@ static int rx_aal5(struct atm_vcc *vcc)
37338 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
37339 vcc->dev->number,vcc->vci,length,size << 2,descr);
37340 length = eff = 0;
37341- atomic_inc(&vcc->stats->rx_err);
37342+ atomic_inc_unchecked(&vcc->stats->rx_err);
37343 }
37344 }
37345 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
37346@@ -770,7 +770,7 @@ rx_dequeued++;
37347 vcc->push(vcc,skb);
37348 pushed++;
37349 }
37350- atomic_inc(&vcc->stats->rx);
37351+ atomic_inc_unchecked(&vcc->stats->rx);
37352 }
37353 wake_up(&eni_dev->rx_wait);
37354 }
37355@@ -1230,7 +1230,7 @@ static void dequeue_tx(struct atm_dev *dev)
37356 DMA_TO_DEVICE);
37357 if (vcc->pop) vcc->pop(vcc,skb);
37358 else dev_kfree_skb_irq(skb);
37359- atomic_inc(&vcc->stats->tx);
37360+ atomic_inc_unchecked(&vcc->stats->tx);
37361 wake_up(&eni_dev->tx_wait);
37362 dma_complete++;
37363 }
37364diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
37365index 82f2ae0..f205c02 100644
37366--- a/drivers/atm/firestream.c
37367+++ b/drivers/atm/firestream.c
37368@@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
37369 }
37370 }
37371
37372- atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
37373+ atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
37374
37375 fs_dprintk (FS_DEBUG_TXMEM, "i");
37376 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
37377@@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
37378 #endif
37379 skb_put (skb, qe->p1 & 0xffff);
37380 ATM_SKB(skb)->vcc = atm_vcc;
37381- atomic_inc(&atm_vcc->stats->rx);
37382+ atomic_inc_unchecked(&atm_vcc->stats->rx);
37383 __net_timestamp(skb);
37384 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
37385 atm_vcc->push (atm_vcc, skb);
37386@@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
37387 kfree (pe);
37388 }
37389 if (atm_vcc)
37390- atomic_inc(&atm_vcc->stats->rx_drop);
37391+ atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
37392 break;
37393 case 0x1f: /* Reassembly abort: no buffers. */
37394 /* Silently increment error counter. */
37395 if (atm_vcc)
37396- atomic_inc(&atm_vcc->stats->rx_drop);
37397+ atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
37398 break;
37399 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
37400 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
37401diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
37402index 75dde90..4309ead 100644
37403--- a/drivers/atm/fore200e.c
37404+++ b/drivers/atm/fore200e.c
37405@@ -932,9 +932,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
37406 #endif
37407 /* check error condition */
37408 if (*entry->status & STATUS_ERROR)
37409- atomic_inc(&vcc->stats->tx_err);
37410+ atomic_inc_unchecked(&vcc->stats->tx_err);
37411 else
37412- atomic_inc(&vcc->stats->tx);
37413+ atomic_inc_unchecked(&vcc->stats->tx);
37414 }
37415 }
37416
37417@@ -1083,7 +1083,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
37418 if (skb == NULL) {
37419 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
37420
37421- atomic_inc(&vcc->stats->rx_drop);
37422+ atomic_inc_unchecked(&vcc->stats->rx_drop);
37423 return -ENOMEM;
37424 }
37425
37426@@ -1126,14 +1126,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
37427
37428 dev_kfree_skb_any(skb);
37429
37430- atomic_inc(&vcc->stats->rx_drop);
37431+ atomic_inc_unchecked(&vcc->stats->rx_drop);
37432 return -ENOMEM;
37433 }
37434
37435 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
37436
37437 vcc->push(vcc, skb);
37438- atomic_inc(&vcc->stats->rx);
37439+ atomic_inc_unchecked(&vcc->stats->rx);
37440
37441 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
37442
37443@@ -1211,7 +1211,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
37444 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
37445 fore200e->atm_dev->number,
37446 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
37447- atomic_inc(&vcc->stats->rx_err);
37448+ atomic_inc_unchecked(&vcc->stats->rx_err);
37449 }
37450 }
37451
37452@@ -1656,7 +1656,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
37453 goto retry_here;
37454 }
37455
37456- atomic_inc(&vcc->stats->tx_err);
37457+ atomic_inc_unchecked(&vcc->stats->tx_err);
37458
37459 fore200e->tx_sat++;
37460 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
37461diff --git a/drivers/atm/he.c b/drivers/atm/he.c
37462index 93dca2e..c5daa69 100644
37463--- a/drivers/atm/he.c
37464+++ b/drivers/atm/he.c
37465@@ -1692,7 +1692,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
37466
37467 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
37468 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
37469- atomic_inc(&vcc->stats->rx_drop);
37470+ atomic_inc_unchecked(&vcc->stats->rx_drop);
37471 goto return_host_buffers;
37472 }
37473
37474@@ -1719,7 +1719,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
37475 RBRQ_LEN_ERR(he_dev->rbrq_head)
37476 ? "LEN_ERR" : "",
37477 vcc->vpi, vcc->vci);
37478- atomic_inc(&vcc->stats->rx_err);
37479+ atomic_inc_unchecked(&vcc->stats->rx_err);
37480 goto return_host_buffers;
37481 }
37482
37483@@ -1771,7 +1771,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
37484 vcc->push(vcc, skb);
37485 spin_lock(&he_dev->global_lock);
37486
37487- atomic_inc(&vcc->stats->rx);
37488+ atomic_inc_unchecked(&vcc->stats->rx);
37489
37490 return_host_buffers:
37491 ++pdus_assembled;
37492@@ -2097,7 +2097,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
37493 tpd->vcc->pop(tpd->vcc, tpd->skb);
37494 else
37495 dev_kfree_skb_any(tpd->skb);
37496- atomic_inc(&tpd->vcc->stats->tx_err);
37497+ atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
37498 }
37499 dma_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
37500 return;
37501@@ -2509,7 +2509,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
37502 vcc->pop(vcc, skb);
37503 else
37504 dev_kfree_skb_any(skb);
37505- atomic_inc(&vcc->stats->tx_err);
37506+ atomic_inc_unchecked(&vcc->stats->tx_err);
37507 return -EINVAL;
37508 }
37509
37510@@ -2520,7 +2520,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
37511 vcc->pop(vcc, skb);
37512 else
37513 dev_kfree_skb_any(skb);
37514- atomic_inc(&vcc->stats->tx_err);
37515+ atomic_inc_unchecked(&vcc->stats->tx_err);
37516 return -EINVAL;
37517 }
37518 #endif
37519@@ -2532,7 +2532,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
37520 vcc->pop(vcc, skb);
37521 else
37522 dev_kfree_skb_any(skb);
37523- atomic_inc(&vcc->stats->tx_err);
37524+ atomic_inc_unchecked(&vcc->stats->tx_err);
37525 spin_unlock_irqrestore(&he_dev->global_lock, flags);
37526 return -ENOMEM;
37527 }
37528@@ -2574,7 +2574,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
37529 vcc->pop(vcc, skb);
37530 else
37531 dev_kfree_skb_any(skb);
37532- atomic_inc(&vcc->stats->tx_err);
37533+ atomic_inc_unchecked(&vcc->stats->tx_err);
37534 spin_unlock_irqrestore(&he_dev->global_lock, flags);
37535 return -ENOMEM;
37536 }
37537@@ -2605,7 +2605,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
37538 __enqueue_tpd(he_dev, tpd, cid);
37539 spin_unlock_irqrestore(&he_dev->global_lock, flags);
37540
37541- atomic_inc(&vcc->stats->tx);
37542+ atomic_inc_unchecked(&vcc->stats->tx);
37543
37544 return 0;
37545 }
37546diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
37547index 527bbd5..96570c8 100644
37548--- a/drivers/atm/horizon.c
37549+++ b/drivers/atm/horizon.c
37550@@ -1018,7 +1018,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
37551 {
37552 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
37553 // VC layer stats
37554- atomic_inc(&vcc->stats->rx);
37555+ atomic_inc_unchecked(&vcc->stats->rx);
37556 __net_timestamp(skb);
37557 // end of our responsibility
37558 vcc->push (vcc, skb);
37559@@ -1170,7 +1170,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
37560 dev->tx_iovec = NULL;
37561
37562 // VC layer stats
37563- atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
37564+ atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
37565
37566 // free the skb
37567 hrz_kfree_skb (skb);
37568diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
37569index 074616b..d6b3d5f 100644
37570--- a/drivers/atm/idt77252.c
37571+++ b/drivers/atm/idt77252.c
37572@@ -811,7 +811,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
37573 else
37574 dev_kfree_skb(skb);
37575
37576- atomic_inc(&vcc->stats->tx);
37577+ atomic_inc_unchecked(&vcc->stats->tx);
37578 }
37579
37580 atomic_dec(&scq->used);
37581@@ -1073,13 +1073,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
37582 if ((sb = dev_alloc_skb(64)) == NULL) {
37583 printk("%s: Can't allocate buffers for aal0.\n",
37584 card->name);
37585- atomic_add(i, &vcc->stats->rx_drop);
37586+ atomic_add_unchecked(i, &vcc->stats->rx_drop);
37587 break;
37588 }
37589 if (!atm_charge(vcc, sb->truesize)) {
37590 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
37591 card->name);
37592- atomic_add(i - 1, &vcc->stats->rx_drop);
37593+ atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
37594 dev_kfree_skb(sb);
37595 break;
37596 }
37597@@ -1096,7 +1096,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
37598 ATM_SKB(sb)->vcc = vcc;
37599 __net_timestamp(sb);
37600 vcc->push(vcc, sb);
37601- atomic_inc(&vcc->stats->rx);
37602+ atomic_inc_unchecked(&vcc->stats->rx);
37603
37604 cell += ATM_CELL_PAYLOAD;
37605 }
37606@@ -1133,13 +1133,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
37607 "(CDC: %08x)\n",
37608 card->name, len, rpp->len, readl(SAR_REG_CDC));
37609 recycle_rx_pool_skb(card, rpp);
37610- atomic_inc(&vcc->stats->rx_err);
37611+ atomic_inc_unchecked(&vcc->stats->rx_err);
37612 return;
37613 }
37614 if (stat & SAR_RSQE_CRC) {
37615 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
37616 recycle_rx_pool_skb(card, rpp);
37617- atomic_inc(&vcc->stats->rx_err);
37618+ atomic_inc_unchecked(&vcc->stats->rx_err);
37619 return;
37620 }
37621 if (skb_queue_len(&rpp->queue) > 1) {
37622@@ -1150,7 +1150,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
37623 RXPRINTK("%s: Can't alloc RX skb.\n",
37624 card->name);
37625 recycle_rx_pool_skb(card, rpp);
37626- atomic_inc(&vcc->stats->rx_err);
37627+ atomic_inc_unchecked(&vcc->stats->rx_err);
37628 return;
37629 }
37630 if (!atm_charge(vcc, skb->truesize)) {
37631@@ -1169,7 +1169,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
37632 __net_timestamp(skb);
37633
37634 vcc->push(vcc, skb);
37635- atomic_inc(&vcc->stats->rx);
37636+ atomic_inc_unchecked(&vcc->stats->rx);
37637
37638 return;
37639 }
37640@@ -1191,7 +1191,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
37641 __net_timestamp(skb);
37642
37643 vcc->push(vcc, skb);
37644- atomic_inc(&vcc->stats->rx);
37645+ atomic_inc_unchecked(&vcc->stats->rx);
37646
37647 if (skb->truesize > SAR_FB_SIZE_3)
37648 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
37649@@ -1302,14 +1302,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
37650 if (vcc->qos.aal != ATM_AAL0) {
37651 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
37652 card->name, vpi, vci);
37653- atomic_inc(&vcc->stats->rx_drop);
37654+ atomic_inc_unchecked(&vcc->stats->rx_drop);
37655 goto drop;
37656 }
37657
37658 if ((sb = dev_alloc_skb(64)) == NULL) {
37659 printk("%s: Can't allocate buffers for AAL0.\n",
37660 card->name);
37661- atomic_inc(&vcc->stats->rx_err);
37662+ atomic_inc_unchecked(&vcc->stats->rx_err);
37663 goto drop;
37664 }
37665
37666@@ -1328,7 +1328,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
37667 ATM_SKB(sb)->vcc = vcc;
37668 __net_timestamp(sb);
37669 vcc->push(vcc, sb);
37670- atomic_inc(&vcc->stats->rx);
37671+ atomic_inc_unchecked(&vcc->stats->rx);
37672
37673 drop:
37674 skb_pull(queue, 64);
37675@@ -1953,13 +1953,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
37676
37677 if (vc == NULL) {
37678 printk("%s: NULL connection in send().\n", card->name);
37679- atomic_inc(&vcc->stats->tx_err);
37680+ atomic_inc_unchecked(&vcc->stats->tx_err);
37681 dev_kfree_skb(skb);
37682 return -EINVAL;
37683 }
37684 if (!test_bit(VCF_TX, &vc->flags)) {
37685 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
37686- atomic_inc(&vcc->stats->tx_err);
37687+ atomic_inc_unchecked(&vcc->stats->tx_err);
37688 dev_kfree_skb(skb);
37689 return -EINVAL;
37690 }
37691@@ -1971,14 +1971,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
37692 break;
37693 default:
37694 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
37695- atomic_inc(&vcc->stats->tx_err);
37696+ atomic_inc_unchecked(&vcc->stats->tx_err);
37697 dev_kfree_skb(skb);
37698 return -EINVAL;
37699 }
37700
37701 if (skb_shinfo(skb)->nr_frags != 0) {
37702 printk("%s: No scatter-gather yet.\n", card->name);
37703- atomic_inc(&vcc->stats->tx_err);
37704+ atomic_inc_unchecked(&vcc->stats->tx_err);
37705 dev_kfree_skb(skb);
37706 return -EINVAL;
37707 }
37708@@ -1986,7 +1986,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
37709
37710 err = queue_skb(card, vc, skb, oam);
37711 if (err) {
37712- atomic_inc(&vcc->stats->tx_err);
37713+ atomic_inc_unchecked(&vcc->stats->tx_err);
37714 dev_kfree_skb(skb);
37715 return err;
37716 }
37717@@ -2009,7 +2009,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
37718 skb = dev_alloc_skb(64);
37719 if (!skb) {
37720 printk("%s: Out of memory in send_oam().\n", card->name);
37721- atomic_inc(&vcc->stats->tx_err);
37722+ atomic_inc_unchecked(&vcc->stats->tx_err);
37723 return -ENOMEM;
37724 }
37725 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
37726diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
37727index 924f8e2..3375a3e 100644
37728--- a/drivers/atm/iphase.c
37729+++ b/drivers/atm/iphase.c
37730@@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
37731 status = (u_short) (buf_desc_ptr->desc_mode);
37732 if (status & (RX_CER | RX_PTE | RX_OFL))
37733 {
37734- atomic_inc(&vcc->stats->rx_err);
37735+ atomic_inc_unchecked(&vcc->stats->rx_err);
37736 IF_ERR(printk("IA: bad packet, dropping it");)
37737 if (status & RX_CER) {
37738 IF_ERR(printk(" cause: packet CRC error\n");)
37739@@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
37740 len = dma_addr - buf_addr;
37741 if (len > iadev->rx_buf_sz) {
37742 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
37743- atomic_inc(&vcc->stats->rx_err);
37744+ atomic_inc_unchecked(&vcc->stats->rx_err);
37745 goto out_free_desc;
37746 }
37747
37748@@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
37749 ia_vcc = INPH_IA_VCC(vcc);
37750 if (ia_vcc == NULL)
37751 {
37752- atomic_inc(&vcc->stats->rx_err);
37753+ atomic_inc_unchecked(&vcc->stats->rx_err);
37754 atm_return(vcc, skb->truesize);
37755 dev_kfree_skb_any(skb);
37756 goto INCR_DLE;
37757@@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
37758 if ((length > iadev->rx_buf_sz) || (length >
37759 (skb->len - sizeof(struct cpcs_trailer))))
37760 {
37761- atomic_inc(&vcc->stats->rx_err);
37762+ atomic_inc_unchecked(&vcc->stats->rx_err);
37763 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
37764 length, skb->len);)
37765 atm_return(vcc, skb->truesize);
37766@@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
37767
37768 IF_RX(printk("rx_dle_intr: skb push");)
37769 vcc->push(vcc,skb);
37770- atomic_inc(&vcc->stats->rx);
37771+ atomic_inc_unchecked(&vcc->stats->rx);
37772 iadev->rx_pkt_cnt++;
37773 }
37774 INCR_DLE:
37775@@ -2828,15 +2828,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
37776 {
37777 struct k_sonet_stats *stats;
37778 stats = &PRIV(_ia_dev[board])->sonet_stats;
37779- printk("section_bip: %d\n", atomic_read(&stats->section_bip));
37780- printk("line_bip : %d\n", atomic_read(&stats->line_bip));
37781- printk("path_bip : %d\n", atomic_read(&stats->path_bip));
37782- printk("line_febe : %d\n", atomic_read(&stats->line_febe));
37783- printk("path_febe : %d\n", atomic_read(&stats->path_febe));
37784- printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
37785- printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
37786- printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
37787- printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
37788+ printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
37789+ printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
37790+ printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
37791+ printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
37792+ printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
37793+ printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
37794+ printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
37795+ printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
37796+ printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
37797 }
37798 ia_cmds.status = 0;
37799 break;
37800@@ -2941,7 +2941,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
37801 if ((desc == 0) || (desc > iadev->num_tx_desc))
37802 {
37803 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
37804- atomic_inc(&vcc->stats->tx);
37805+ atomic_inc_unchecked(&vcc->stats->tx);
37806 if (vcc->pop)
37807 vcc->pop(vcc, skb);
37808 else
37809@@ -3046,14 +3046,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
37810 ATM_DESC(skb) = vcc->vci;
37811 skb_queue_tail(&iadev->tx_dma_q, skb);
37812
37813- atomic_inc(&vcc->stats->tx);
37814+ atomic_inc_unchecked(&vcc->stats->tx);
37815 iadev->tx_pkt_cnt++;
37816 /* Increment transaction counter */
37817 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
37818
37819 #if 0
37820 /* add flow control logic */
37821- if (atomic_read(&vcc->stats->tx) % 20 == 0) {
37822+ if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
37823 if (iavcc->vc_desc_cnt > 10) {
37824 vcc->tx_quota = vcc->tx_quota * 3 / 4;
37825 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
37826diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
37827index ce43ae3..969de38 100644
37828--- a/drivers/atm/lanai.c
37829+++ b/drivers/atm/lanai.c
37830@@ -1295,7 +1295,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
37831 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
37832 lanai_endtx(lanai, lvcc);
37833 lanai_free_skb(lvcc->tx.atmvcc, skb);
37834- atomic_inc(&lvcc->tx.atmvcc->stats->tx);
37835+ atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
37836 }
37837
37838 /* Try to fill the buffer - don't call unless there is backlog */
37839@@ -1418,7 +1418,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
37840 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
37841 __net_timestamp(skb);
37842 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
37843- atomic_inc(&lvcc->rx.atmvcc->stats->rx);
37844+ atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
37845 out:
37846 lvcc->rx.buf.ptr = end;
37847 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
37848@@ -1659,7 +1659,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
37849 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
37850 "vcc %d\n", lanai->number, (unsigned int) s, vci);
37851 lanai->stats.service_rxnotaal5++;
37852- atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
37853+ atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
37854 return 0;
37855 }
37856 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
37857@@ -1671,7 +1671,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
37858 int bytes;
37859 read_unlock(&vcc_sklist_lock);
37860 DPRINTK("got trashed rx pdu on vci %d\n", vci);
37861- atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
37862+ atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
37863 lvcc->stats.x.aal5.service_trash++;
37864 bytes = (SERVICE_GET_END(s) * 16) -
37865 (((unsigned long) lvcc->rx.buf.ptr) -
37866@@ -1683,7 +1683,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
37867 }
37868 if (s & SERVICE_STREAM) {
37869 read_unlock(&vcc_sklist_lock);
37870- atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
37871+ atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
37872 lvcc->stats.x.aal5.service_stream++;
37873 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
37874 "PDU on VCI %d!\n", lanai->number, vci);
37875@@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
37876 return 0;
37877 }
37878 DPRINTK("got rx crc error on vci %d\n", vci);
37879- atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
37880+ atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
37881 lvcc->stats.x.aal5.service_rxcrc++;
37882 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
37883 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
37884diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
37885index ddc4ceb..36e29aa 100644
37886--- a/drivers/atm/nicstar.c
37887+++ b/drivers/atm/nicstar.c
37888@@ -1632,7 +1632,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
37889 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
37890 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
37891 card->index);
37892- atomic_inc(&vcc->stats->tx_err);
37893+ atomic_inc_unchecked(&vcc->stats->tx_err);
37894 dev_kfree_skb_any(skb);
37895 return -EINVAL;
37896 }
37897@@ -1640,7 +1640,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
37898 if (!vc->tx) {
37899 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
37900 card->index);
37901- atomic_inc(&vcc->stats->tx_err);
37902+ atomic_inc_unchecked(&vcc->stats->tx_err);
37903 dev_kfree_skb_any(skb);
37904 return -EINVAL;
37905 }
37906@@ -1648,14 +1648,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
37907 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
37908 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
37909 card->index);
37910- atomic_inc(&vcc->stats->tx_err);
37911+ atomic_inc_unchecked(&vcc->stats->tx_err);
37912 dev_kfree_skb_any(skb);
37913 return -EINVAL;
37914 }
37915
37916 if (skb_shinfo(skb)->nr_frags != 0) {
37917 printk("nicstar%d: No scatter-gather yet.\n", card->index);
37918- atomic_inc(&vcc->stats->tx_err);
37919+ atomic_inc_unchecked(&vcc->stats->tx_err);
37920 dev_kfree_skb_any(skb);
37921 return -EINVAL;
37922 }
37923@@ -1703,11 +1703,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
37924 }
37925
37926 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
37927- atomic_inc(&vcc->stats->tx_err);
37928+ atomic_inc_unchecked(&vcc->stats->tx_err);
37929 dev_kfree_skb_any(skb);
37930 return -EIO;
37931 }
37932- atomic_inc(&vcc->stats->tx);
37933+ atomic_inc_unchecked(&vcc->stats->tx);
37934
37935 return 0;
37936 }
37937@@ -2024,14 +2024,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
37938 printk
37939 ("nicstar%d: Can't allocate buffers for aal0.\n",
37940 card->index);
37941- atomic_add(i, &vcc->stats->rx_drop);
37942+ atomic_add_unchecked(i, &vcc->stats->rx_drop);
37943 break;
37944 }
37945 if (!atm_charge(vcc, sb->truesize)) {
37946 RXPRINTK
37947 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
37948 card->index);
37949- atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
37950+ atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
37951 dev_kfree_skb_any(sb);
37952 break;
37953 }
37954@@ -2046,7 +2046,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
37955 ATM_SKB(sb)->vcc = vcc;
37956 __net_timestamp(sb);
37957 vcc->push(vcc, sb);
37958- atomic_inc(&vcc->stats->rx);
37959+ atomic_inc_unchecked(&vcc->stats->rx);
37960 cell += ATM_CELL_PAYLOAD;
37961 }
37962
37963@@ -2063,7 +2063,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
37964 if (iovb == NULL) {
37965 printk("nicstar%d: Out of iovec buffers.\n",
37966 card->index);
37967- atomic_inc(&vcc->stats->rx_drop);
37968+ atomic_inc_unchecked(&vcc->stats->rx_drop);
37969 recycle_rx_buf(card, skb);
37970 return;
37971 }
37972@@ -2087,7 +2087,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
37973 small or large buffer itself. */
37974 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
37975 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
37976- atomic_inc(&vcc->stats->rx_err);
37977+ atomic_inc_unchecked(&vcc->stats->rx_err);
37978 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
37979 NS_MAX_IOVECS);
37980 NS_PRV_IOVCNT(iovb) = 0;
37981@@ -2107,7 +2107,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
37982 ("nicstar%d: Expected a small buffer, and this is not one.\n",
37983 card->index);
37984 which_list(card, skb);
37985- atomic_inc(&vcc->stats->rx_err);
37986+ atomic_inc_unchecked(&vcc->stats->rx_err);
37987 recycle_rx_buf(card, skb);
37988 vc->rx_iov = NULL;
37989 recycle_iov_buf(card, iovb);
37990@@ -2120,7 +2120,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
37991 ("nicstar%d: Expected a large buffer, and this is not one.\n",
37992 card->index);
37993 which_list(card, skb);
37994- atomic_inc(&vcc->stats->rx_err);
37995+ atomic_inc_unchecked(&vcc->stats->rx_err);
37996 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
37997 NS_PRV_IOVCNT(iovb));
37998 vc->rx_iov = NULL;
37999@@ -2143,7 +2143,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38000 printk(" - PDU size mismatch.\n");
38001 else
38002 printk(".\n");
38003- atomic_inc(&vcc->stats->rx_err);
38004+ atomic_inc_unchecked(&vcc->stats->rx_err);
38005 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
38006 NS_PRV_IOVCNT(iovb));
38007 vc->rx_iov = NULL;
38008@@ -2157,14 +2157,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38009 /* skb points to a small buffer */
38010 if (!atm_charge(vcc, skb->truesize)) {
38011 push_rxbufs(card, skb);
38012- atomic_inc(&vcc->stats->rx_drop);
38013+ atomic_inc_unchecked(&vcc->stats->rx_drop);
38014 } else {
38015 skb_put(skb, len);
38016 dequeue_sm_buf(card, skb);
38017 ATM_SKB(skb)->vcc = vcc;
38018 __net_timestamp(skb);
38019 vcc->push(vcc, skb);
38020- atomic_inc(&vcc->stats->rx);
38021+ atomic_inc_unchecked(&vcc->stats->rx);
38022 }
38023 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
38024 struct sk_buff *sb;
38025@@ -2175,14 +2175,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38026 if (len <= NS_SMBUFSIZE) {
38027 if (!atm_charge(vcc, sb->truesize)) {
38028 push_rxbufs(card, sb);
38029- atomic_inc(&vcc->stats->rx_drop);
38030+ atomic_inc_unchecked(&vcc->stats->rx_drop);
38031 } else {
38032 skb_put(sb, len);
38033 dequeue_sm_buf(card, sb);
38034 ATM_SKB(sb)->vcc = vcc;
38035 __net_timestamp(sb);
38036 vcc->push(vcc, sb);
38037- atomic_inc(&vcc->stats->rx);
38038+ atomic_inc_unchecked(&vcc->stats->rx);
38039 }
38040
38041 push_rxbufs(card, skb);
38042@@ -2191,7 +2191,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38043
38044 if (!atm_charge(vcc, skb->truesize)) {
38045 push_rxbufs(card, skb);
38046- atomic_inc(&vcc->stats->rx_drop);
38047+ atomic_inc_unchecked(&vcc->stats->rx_drop);
38048 } else {
38049 dequeue_lg_buf(card, skb);
38050 skb_push(skb, NS_SMBUFSIZE);
38051@@ -2201,7 +2201,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38052 ATM_SKB(skb)->vcc = vcc;
38053 __net_timestamp(skb);
38054 vcc->push(vcc, skb);
38055- atomic_inc(&vcc->stats->rx);
38056+ atomic_inc_unchecked(&vcc->stats->rx);
38057 }
38058
38059 push_rxbufs(card, sb);
38060@@ -2222,7 +2222,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38061 printk
38062 ("nicstar%d: Out of huge buffers.\n",
38063 card->index);
38064- atomic_inc(&vcc->stats->rx_drop);
38065+ atomic_inc_unchecked(&vcc->stats->rx_drop);
38066 recycle_iovec_rx_bufs(card,
38067 (struct iovec *)
38068 iovb->data,
38069@@ -2273,7 +2273,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38070 card->hbpool.count++;
38071 } else
38072 dev_kfree_skb_any(hb);
38073- atomic_inc(&vcc->stats->rx_drop);
38074+ atomic_inc_unchecked(&vcc->stats->rx_drop);
38075 } else {
38076 /* Copy the small buffer to the huge buffer */
38077 sb = (struct sk_buff *)iov->iov_base;
38078@@ -2307,7 +2307,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
38079 ATM_SKB(hb)->vcc = vcc;
38080 __net_timestamp(hb);
38081 vcc->push(vcc, hb);
38082- atomic_inc(&vcc->stats->rx);
38083+ atomic_inc_unchecked(&vcc->stats->rx);
38084 }
38085 }
38086
38087diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
38088index 74e18b0..f16afa0 100644
38089--- a/drivers/atm/solos-pci.c
38090+++ b/drivers/atm/solos-pci.c
38091@@ -838,7 +838,7 @@ static void solos_bh(unsigned long card_arg)
38092 }
38093 atm_charge(vcc, skb->truesize);
38094 vcc->push(vcc, skb);
38095- atomic_inc(&vcc->stats->rx);
38096+ atomic_inc_unchecked(&vcc->stats->rx);
38097 break;
38098
38099 case PKT_STATUS:
38100@@ -1116,7 +1116,7 @@ static uint32_t fpga_tx(struct solos_card *card)
38101 vcc = SKB_CB(oldskb)->vcc;
38102
38103 if (vcc) {
38104- atomic_inc(&vcc->stats->tx);
38105+ atomic_inc_unchecked(&vcc->stats->tx);
38106 solos_pop(vcc, oldskb);
38107 } else {
38108 dev_kfree_skb_irq(oldskb);
38109diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
38110index 0215934..ce9f5b1 100644
38111--- a/drivers/atm/suni.c
38112+++ b/drivers/atm/suni.c
38113@@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
38114
38115
38116 #define ADD_LIMITED(s,v) \
38117- atomic_add((v),&stats->s); \
38118- if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
38119+ atomic_add_unchecked((v),&stats->s); \
38120+ if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
38121
38122
38123 static void suni_hz(unsigned long from_timer)
38124diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
38125index 5120a96..e2572bd 100644
38126--- a/drivers/atm/uPD98402.c
38127+++ b/drivers/atm/uPD98402.c
38128@@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
38129 struct sonet_stats tmp;
38130 int error = 0;
38131
38132- atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
38133+ atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
38134 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
38135 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
38136 if (zero && !error) {
38137@@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
38138
38139
38140 #define ADD_LIMITED(s,v) \
38141- { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
38142- if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
38143- atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
38144+ { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
38145+ if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
38146+ atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
38147
38148
38149 static void stat_event(struct atm_dev *dev)
38150@@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
38151 if (reason & uPD98402_INT_PFM) stat_event(dev);
38152 if (reason & uPD98402_INT_PCO) {
38153 (void) GET(PCOCR); /* clear interrupt cause */
38154- atomic_add(GET(HECCT),
38155+ atomic_add_unchecked(GET(HECCT),
38156 &PRIV(dev)->sonet_stats.uncorr_hcs);
38157 }
38158 if ((reason & uPD98402_INT_RFO) &&
38159@@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
38160 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
38161 uPD98402_INT_LOS),PIMR); /* enable them */
38162 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
38163- atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
38164- atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
38165- atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
38166+ atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
38167+ atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
38168+ atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
38169 return 0;
38170 }
38171
38172diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
38173index cecfb94..87009ec 100644
38174--- a/drivers/atm/zatm.c
38175+++ b/drivers/atm/zatm.c
38176@@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
38177 }
38178 if (!size) {
38179 dev_kfree_skb_irq(skb);
38180- if (vcc) atomic_inc(&vcc->stats->rx_err);
38181+ if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
38182 continue;
38183 }
38184 if (!atm_charge(vcc,skb->truesize)) {
38185@@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
38186 skb->len = size;
38187 ATM_SKB(skb)->vcc = vcc;
38188 vcc->push(vcc,skb);
38189- atomic_inc(&vcc->stats->rx);
38190+ atomic_inc_unchecked(&vcc->stats->rx);
38191 }
38192 zout(pos & 0xffff,MTA(mbx));
38193 #if 0 /* probably a stupid idea */
38194@@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
38195 skb_queue_head(&zatm_vcc->backlog,skb);
38196 break;
38197 }
38198- atomic_inc(&vcc->stats->tx);
38199+ atomic_inc_unchecked(&vcc->stats->tx);
38200 wake_up(&zatm_vcc->tx_wait);
38201 }
38202
38203diff --git a/drivers/base/bus.c b/drivers/base/bus.c
38204index 79bc203..fa3945b 100644
38205--- a/drivers/base/bus.c
38206+++ b/drivers/base/bus.c
38207@@ -1126,7 +1126,7 @@ int subsys_interface_register(struct subsys_interface *sif)
38208 return -EINVAL;
38209
38210 mutex_lock(&subsys->p->mutex);
38211- list_add_tail(&sif->node, &subsys->p->interfaces);
38212+ pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
38213 if (sif->add_dev) {
38214 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
38215 while ((dev = subsys_dev_iter_next(&iter)))
38216@@ -1151,7 +1151,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
38217 subsys = sif->subsys;
38218
38219 mutex_lock(&subsys->p->mutex);
38220- list_del_init(&sif->node);
38221+ pax_list_del_init((struct list_head *)&sif->node);
38222 if (sif->remove_dev) {
38223 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
38224 while ((dev = subsys_dev_iter_next(&iter)))
38225diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
38226index 68f0314..ca2a609 100644
38227--- a/drivers/base/devtmpfs.c
38228+++ b/drivers/base/devtmpfs.c
38229@@ -354,7 +354,7 @@ int devtmpfs_mount(const char *mntdir)
38230 if (!thread)
38231 return 0;
38232
38233- err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
38234+ err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
38235 if (err)
38236 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
38237 else
38238@@ -380,11 +380,11 @@ static int devtmpfsd(void *p)
38239 *err = sys_unshare(CLONE_NEWNS);
38240 if (*err)
38241 goto out;
38242- *err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
38243+ *err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)"/", (char __force_user *)"devtmpfs", MS_SILENT, (char __force_user *)options);
38244 if (*err)
38245 goto out;
38246- sys_chdir("/.."); /* will traverse into overmounted root */
38247- sys_chroot(".");
38248+ sys_chdir((char __force_user *)"/.."); /* will traverse into overmounted root */
38249+ sys_chroot((char __force_user *)".");
38250 complete(&setup_done);
38251 while (1) {
38252 spin_lock(&req_lock);
38253diff --git a/drivers/base/node.c b/drivers/base/node.c
38254index a2aa65b..8831326 100644
38255--- a/drivers/base/node.c
38256+++ b/drivers/base/node.c
38257@@ -613,7 +613,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
38258 struct node_attr {
38259 struct device_attribute attr;
38260 enum node_states state;
38261-};
38262+} __do_const;
38263
38264 static ssize_t show_node_state(struct device *dev,
38265 struct device_attribute *attr, char *buf)
38266diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
38267index 2327613..211d7f5 100644
38268--- a/drivers/base/power/domain.c
38269+++ b/drivers/base/power/domain.c
38270@@ -1725,7 +1725,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
38271 {
38272 struct cpuidle_driver *cpuidle_drv;
38273 struct gpd_cpuidle_data *cpuidle_data;
38274- struct cpuidle_state *idle_state;
38275+ cpuidle_state_no_const *idle_state;
38276 int ret = 0;
38277
38278 if (IS_ERR_OR_NULL(genpd) || state < 0)
38279@@ -1793,7 +1793,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
38280 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
38281 {
38282 struct gpd_cpuidle_data *cpuidle_data;
38283- struct cpuidle_state *idle_state;
38284+ cpuidle_state_no_const *idle_state;
38285 int ret = 0;
38286
38287 if (IS_ERR_OR_NULL(genpd))
38288@@ -2222,8 +2222,11 @@ int genpd_dev_pm_attach(struct device *dev)
38289 return ret;
38290 }
38291
38292- dev->pm_domain->detach = genpd_dev_pm_detach;
38293- dev->pm_domain->sync = genpd_dev_pm_sync;
38294+ pax_open_kernel();
38295+ *(void **)&dev->pm_domain->detach = genpd_dev_pm_detach;
38296+ *(void **)&dev->pm_domain->sync = genpd_dev_pm_sync;
38297+ pax_close_kernel();
38298+
38299 pm_genpd_poweron(pd);
38300
38301 return 0;
38302diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
38303index d2be3f9..0a3167a 100644
38304--- a/drivers/base/power/sysfs.c
38305+++ b/drivers/base/power/sysfs.c
38306@@ -181,7 +181,7 @@ static ssize_t rtpm_status_show(struct device *dev,
38307 return -EIO;
38308 }
38309 }
38310- return sprintf(buf, p);
38311+ return sprintf(buf, "%s", p);
38312 }
38313
38314 static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
38315diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
38316index 7726200..a417da7 100644
38317--- a/drivers/base/power/wakeup.c
38318+++ b/drivers/base/power/wakeup.c
38319@@ -32,14 +32,14 @@ static bool pm_abort_suspend __read_mostly;
38320 * They need to be modified together atomically, so it's better to use one
38321 * atomic variable to hold them both.
38322 */
38323-static atomic_t combined_event_count = ATOMIC_INIT(0);
38324+static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
38325
38326 #define IN_PROGRESS_BITS (sizeof(int) * 4)
38327 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
38328
38329 static void split_counters(unsigned int *cnt, unsigned int *inpr)
38330 {
38331- unsigned int comb = atomic_read(&combined_event_count);
38332+ unsigned int comb = atomic_read_unchecked(&combined_event_count);
38333
38334 *cnt = (comb >> IN_PROGRESS_BITS);
38335 *inpr = comb & MAX_IN_PROGRESS;
38336@@ -404,7 +404,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
38337 ws->start_prevent_time = ws->last_time;
38338
38339 /* Increment the counter of events in progress. */
38340- cec = atomic_inc_return(&combined_event_count);
38341+ cec = atomic_inc_return_unchecked(&combined_event_count);
38342
38343 trace_wakeup_source_activate(ws->name, cec);
38344 }
38345@@ -530,7 +530,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
38346 * Increment the counter of registered wakeup events and decrement the
38347 * couter of wakeup events in progress simultaneously.
38348 */
38349- cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
38350+ cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
38351 trace_wakeup_source_deactivate(ws->name, cec);
38352
38353 split_counters(&cnt, &inpr);
38354diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
38355index 8d98a32..61d3165 100644
38356--- a/drivers/base/syscore.c
38357+++ b/drivers/base/syscore.c
38358@@ -22,7 +22,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
38359 void register_syscore_ops(struct syscore_ops *ops)
38360 {
38361 mutex_lock(&syscore_ops_lock);
38362- list_add_tail(&ops->node, &syscore_ops_list);
38363+ pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
38364 mutex_unlock(&syscore_ops_lock);
38365 }
38366 EXPORT_SYMBOL_GPL(register_syscore_ops);
38367@@ -34,7 +34,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
38368 void unregister_syscore_ops(struct syscore_ops *ops)
38369 {
38370 mutex_lock(&syscore_ops_lock);
38371- list_del(&ops->node);
38372+ pax_list_del((struct list_head *)&ops->node);
38373 mutex_unlock(&syscore_ops_lock);
38374 }
38375 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
38376diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
38377index ff20f19..018f1da 100644
38378--- a/drivers/block/cciss.c
38379+++ b/drivers/block/cciss.c
38380@@ -3008,7 +3008,7 @@ static void start_io(ctlr_info_t *h)
38381 while (!list_empty(&h->reqQ)) {
38382 c = list_entry(h->reqQ.next, CommandList_struct, list);
38383 /* can't do anything if fifo is full */
38384- if ((h->access.fifo_full(h))) {
38385+ if ((h->access->fifo_full(h))) {
38386 dev_warn(&h->pdev->dev, "fifo full\n");
38387 break;
38388 }
38389@@ -3018,7 +3018,7 @@ static void start_io(ctlr_info_t *h)
38390 h->Qdepth--;
38391
38392 /* Tell the controller execute command */
38393- h->access.submit_command(h, c);
38394+ h->access->submit_command(h, c);
38395
38396 /* Put job onto the completed Q */
38397 addQ(&h->cmpQ, c);
38398@@ -3444,17 +3444,17 @@ startio:
38399
38400 static inline unsigned long get_next_completion(ctlr_info_t *h)
38401 {
38402- return h->access.command_completed(h);
38403+ return h->access->command_completed(h);
38404 }
38405
38406 static inline int interrupt_pending(ctlr_info_t *h)
38407 {
38408- return h->access.intr_pending(h);
38409+ return h->access->intr_pending(h);
38410 }
38411
38412 static inline long interrupt_not_for_us(ctlr_info_t *h)
38413 {
38414- return ((h->access.intr_pending(h) == 0) ||
38415+ return ((h->access->intr_pending(h) == 0) ||
38416 (h->interrupts_enabled == 0));
38417 }
38418
38419@@ -3487,7 +3487,7 @@ static inline u32 next_command(ctlr_info_t *h)
38420 u32 a;
38421
38422 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
38423- return h->access.command_completed(h);
38424+ return h->access->command_completed(h);
38425
38426 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
38427 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
38428@@ -4044,7 +4044,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
38429 trans_support & CFGTBL_Trans_use_short_tags);
38430
38431 /* Change the access methods to the performant access methods */
38432- h->access = SA5_performant_access;
38433+ h->access = &SA5_performant_access;
38434 h->transMethod = CFGTBL_Trans_Performant;
38435
38436 return;
38437@@ -4318,7 +4318,7 @@ static int cciss_pci_init(ctlr_info_t *h)
38438 if (prod_index < 0)
38439 return -ENODEV;
38440 h->product_name = products[prod_index].product_name;
38441- h->access = *(products[prod_index].access);
38442+ h->access = products[prod_index].access;
38443
38444 if (cciss_board_disabled(h)) {
38445 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
38446@@ -5050,7 +5050,7 @@ reinit_after_soft_reset:
38447 }
38448
38449 /* make sure the board interrupts are off */
38450- h->access.set_intr_mask(h, CCISS_INTR_OFF);
38451+ h->access->set_intr_mask(h, CCISS_INTR_OFF);
38452 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
38453 if (rc)
38454 goto clean2;
38455@@ -5100,7 +5100,7 @@ reinit_after_soft_reset:
38456 * fake ones to scoop up any residual completions.
38457 */
38458 spin_lock_irqsave(&h->lock, flags);
38459- h->access.set_intr_mask(h, CCISS_INTR_OFF);
38460+ h->access->set_intr_mask(h, CCISS_INTR_OFF);
38461 spin_unlock_irqrestore(&h->lock, flags);
38462 free_irq(h->intr[h->intr_mode], h);
38463 rc = cciss_request_irq(h, cciss_msix_discard_completions,
38464@@ -5120,9 +5120,9 @@ reinit_after_soft_reset:
38465 dev_info(&h->pdev->dev, "Board READY.\n");
38466 dev_info(&h->pdev->dev,
38467 "Waiting for stale completions to drain.\n");
38468- h->access.set_intr_mask(h, CCISS_INTR_ON);
38469+ h->access->set_intr_mask(h, CCISS_INTR_ON);
38470 msleep(10000);
38471- h->access.set_intr_mask(h, CCISS_INTR_OFF);
38472+ h->access->set_intr_mask(h, CCISS_INTR_OFF);
38473
38474 rc = controller_reset_failed(h->cfgtable);
38475 if (rc)
38476@@ -5145,7 +5145,7 @@ reinit_after_soft_reset:
38477 cciss_scsi_setup(h);
38478
38479 /* Turn the interrupts on so we can service requests */
38480- h->access.set_intr_mask(h, CCISS_INTR_ON);
38481+ h->access->set_intr_mask(h, CCISS_INTR_ON);
38482
38483 /* Get the firmware version */
38484 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
38485@@ -5217,7 +5217,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
38486 kfree(flush_buf);
38487 if (return_code != IO_OK)
38488 dev_warn(&h->pdev->dev, "Error flushing cache\n");
38489- h->access.set_intr_mask(h, CCISS_INTR_OFF);
38490+ h->access->set_intr_mask(h, CCISS_INTR_OFF);
38491 free_irq(h->intr[h->intr_mode], h);
38492 }
38493
38494diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
38495index 7fda30e..2f27946 100644
38496--- a/drivers/block/cciss.h
38497+++ b/drivers/block/cciss.h
38498@@ -101,7 +101,7 @@ struct ctlr_info
38499 /* information about each logical volume */
38500 drive_info_struct *drv[CISS_MAX_LUN];
38501
38502- struct access_method access;
38503+ struct access_method *access;
38504
38505 /* queue and queue Info */
38506 struct list_head reqQ;
38507@@ -402,27 +402,27 @@ static bool SA5_performant_intr_pending(ctlr_info_t *h)
38508 }
38509
38510 static struct access_method SA5_access = {
38511- SA5_submit_command,
38512- SA5_intr_mask,
38513- SA5_fifo_full,
38514- SA5_intr_pending,
38515- SA5_completed,
38516+ .submit_command = SA5_submit_command,
38517+ .set_intr_mask = SA5_intr_mask,
38518+ .fifo_full = SA5_fifo_full,
38519+ .intr_pending = SA5_intr_pending,
38520+ .command_completed = SA5_completed,
38521 };
38522
38523 static struct access_method SA5B_access = {
38524- SA5_submit_command,
38525- SA5B_intr_mask,
38526- SA5_fifo_full,
38527- SA5B_intr_pending,
38528- SA5_completed,
38529+ .submit_command = SA5_submit_command,
38530+ .set_intr_mask = SA5B_intr_mask,
38531+ .fifo_full = SA5_fifo_full,
38532+ .intr_pending = SA5B_intr_pending,
38533+ .command_completed = SA5_completed,
38534 };
38535
38536 static struct access_method SA5_performant_access = {
38537- SA5_submit_command,
38538- SA5_performant_intr_mask,
38539- SA5_fifo_full,
38540- SA5_performant_intr_pending,
38541- SA5_performant_completed,
38542+ .submit_command = SA5_submit_command,
38543+ .set_intr_mask = SA5_performant_intr_mask,
38544+ .fifo_full = SA5_fifo_full,
38545+ .intr_pending = SA5_performant_intr_pending,
38546+ .command_completed = SA5_performant_completed,
38547 };
38548
38549 struct board_type {
38550diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
38551index f749df9..5f8b9c4 100644
38552--- a/drivers/block/cpqarray.c
38553+++ b/drivers/block/cpqarray.c
38554@@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
38555 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
38556 goto Enomem4;
38557 }
38558- hba[i]->access.set_intr_mask(hba[i], 0);
38559+ hba[i]->access->set_intr_mask(hba[i], 0);
38560 if (request_irq(hba[i]->intr, do_ida_intr, IRQF_SHARED,
38561 hba[i]->devname, hba[i]))
38562 {
38563@@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
38564 add_timer(&hba[i]->timer);
38565
38566 /* Enable IRQ now that spinlock and rate limit timer are set up */
38567- hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
38568+ hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
38569
38570 for(j=0; j<NWD; j++) {
38571 struct gendisk *disk = ida_gendisk[i][j];
38572@@ -694,7 +694,7 @@ DBGINFO(
38573 for(i=0; i<NR_PRODUCTS; i++) {
38574 if (board_id == products[i].board_id) {
38575 c->product_name = products[i].product_name;
38576- c->access = *(products[i].access);
38577+ c->access = products[i].access;
38578 break;
38579 }
38580 }
38581@@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
38582 hba[ctlr]->intr = intr;
38583 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
38584 hba[ctlr]->product_name = products[j].product_name;
38585- hba[ctlr]->access = *(products[j].access);
38586+ hba[ctlr]->access = products[j].access;
38587 hba[ctlr]->ctlr = ctlr;
38588 hba[ctlr]->board_id = board_id;
38589 hba[ctlr]->pci_dev = NULL; /* not PCI */
38590@@ -978,7 +978,7 @@ static void start_io(ctlr_info_t *h)
38591
38592 while((c = h->reqQ) != NULL) {
38593 /* Can't do anything if we're busy */
38594- if (h->access.fifo_full(h) == 0)
38595+ if (h->access->fifo_full(h) == 0)
38596 return;
38597
38598 /* Get the first entry from the request Q */
38599@@ -986,7 +986,7 @@ static void start_io(ctlr_info_t *h)
38600 h->Qdepth--;
38601
38602 /* Tell the controller to do our bidding */
38603- h->access.submit_command(h, c);
38604+ h->access->submit_command(h, c);
38605
38606 /* Get onto the completion Q */
38607 addQ(&h->cmpQ, c);
38608@@ -1048,7 +1048,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
38609 unsigned long flags;
38610 __u32 a,a1;
38611
38612- istat = h->access.intr_pending(h);
38613+ istat = h->access->intr_pending(h);
38614 /* Is this interrupt for us? */
38615 if (istat == 0)
38616 return IRQ_NONE;
38617@@ -1059,7 +1059,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
38618 */
38619 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
38620 if (istat & FIFO_NOT_EMPTY) {
38621- while((a = h->access.command_completed(h))) {
38622+ while((a = h->access->command_completed(h))) {
38623 a1 = a; a &= ~3;
38624 if ((c = h->cmpQ) == NULL)
38625 {
38626@@ -1448,11 +1448,11 @@ static int sendcmd(
38627 /*
38628 * Disable interrupt
38629 */
38630- info_p->access.set_intr_mask(info_p, 0);
38631+ info_p->access->set_intr_mask(info_p, 0);
38632 /* Make sure there is room in the command FIFO */
38633 /* Actually it should be completely empty at this time. */
38634 for (i = 200000; i > 0; i--) {
38635- temp = info_p->access.fifo_full(info_p);
38636+ temp = info_p->access->fifo_full(info_p);
38637 if (temp != 0) {
38638 break;
38639 }
38640@@ -1465,7 +1465,7 @@ DBG(
38641 /*
38642 * Send the cmd
38643 */
38644- info_p->access.submit_command(info_p, c);
38645+ info_p->access->submit_command(info_p, c);
38646 complete = pollcomplete(ctlr);
38647
38648 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
38649@@ -1548,9 +1548,9 @@ static int revalidate_allvol(ctlr_info_t *host)
38650 * we check the new geometry. Then turn interrupts back on when
38651 * we're done.
38652 */
38653- host->access.set_intr_mask(host, 0);
38654+ host->access->set_intr_mask(host, 0);
38655 getgeometry(ctlr);
38656- host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
38657+ host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
38658
38659 for(i=0; i<NWD; i++) {
38660 struct gendisk *disk = ida_gendisk[ctlr][i];
38661@@ -1590,7 +1590,7 @@ static int pollcomplete(int ctlr)
38662 /* Wait (up to 2 seconds) for a command to complete */
38663
38664 for (i = 200000; i > 0; i--) {
38665- done = hba[ctlr]->access.command_completed(hba[ctlr]);
38666+ done = hba[ctlr]->access->command_completed(hba[ctlr]);
38667 if (done == 0) {
38668 udelay(10); /* a short fixed delay */
38669 } else
38670diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
38671index be73e9d..7fbf140 100644
38672--- a/drivers/block/cpqarray.h
38673+++ b/drivers/block/cpqarray.h
38674@@ -99,7 +99,7 @@ struct ctlr_info {
38675 drv_info_t drv[NWD];
38676 struct proc_dir_entry *proc;
38677
38678- struct access_method access;
38679+ struct access_method *access;
38680
38681 cmdlist_t *reqQ;
38682 cmdlist_t *cmpQ;
38683diff --git a/drivers/block/drbd/drbd_bitmap.c b/drivers/block/drbd/drbd_bitmap.c
38684index 434c77d..6d3219a 100644
38685--- a/drivers/block/drbd/drbd_bitmap.c
38686+++ b/drivers/block/drbd/drbd_bitmap.c
38687@@ -1036,7 +1036,7 @@ static void bm_page_io_async(struct drbd_bm_aio_ctx *ctx, int page_nr) __must_ho
38688 submit_bio(rw, bio);
38689 /* this should not count as user activity and cause the
38690 * resync to throttle -- see drbd_rs_should_slow_down(). */
38691- atomic_add(len >> 9, &device->rs_sect_ev);
38692+ atomic_add_unchecked(len >> 9, &device->rs_sect_ev);
38693 }
38694 }
38695
38696diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
38697index b905e98..0812ed8 100644
38698--- a/drivers/block/drbd/drbd_int.h
38699+++ b/drivers/block/drbd/drbd_int.h
38700@@ -385,7 +385,7 @@ struct drbd_epoch {
38701 struct drbd_connection *connection;
38702 struct list_head list;
38703 unsigned int barrier_nr;
38704- atomic_t epoch_size; /* increased on every request added. */
38705+ atomic_unchecked_t epoch_size; /* increased on every request added. */
38706 atomic_t active; /* increased on every req. added, and dec on every finished. */
38707 unsigned long flags;
38708 };
38709@@ -946,7 +946,7 @@ struct drbd_device {
38710 unsigned int al_tr_number;
38711 int al_tr_cycle;
38712 wait_queue_head_t seq_wait;
38713- atomic_t packet_seq;
38714+ atomic_unchecked_t packet_seq;
38715 unsigned int peer_seq;
38716 spinlock_t peer_seq_lock;
38717 unsigned long comm_bm_set; /* communicated number of set bits. */
38718@@ -955,8 +955,8 @@ struct drbd_device {
38719 struct mutex own_state_mutex;
38720 struct mutex *state_mutex; /* either own_state_mutex or first_peer_device(device)->connection->cstate_mutex */
38721 char congestion_reason; /* Why we where congested... */
38722- atomic_t rs_sect_in; /* for incoming resync data rate, SyncTarget */
38723- atomic_t rs_sect_ev; /* for submitted resync data rate, both */
38724+ atomic_unchecked_t rs_sect_in; /* for incoming resync data rate, SyncTarget */
38725+ atomic_unchecked_t rs_sect_ev; /* for submitted resync data rate, both */
38726 int rs_last_sect_ev; /* counter to compare with */
38727 int rs_last_events; /* counter of read or write "events" (unit sectors)
38728 * on the lower level device when we last looked. */
38729diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
38730index 81fde9e..9948c05 100644
38731--- a/drivers/block/drbd/drbd_main.c
38732+++ b/drivers/block/drbd/drbd_main.c
38733@@ -1328,7 +1328,7 @@ static int _drbd_send_ack(struct drbd_peer_device *peer_device, enum drbd_packet
38734 p->sector = sector;
38735 p->block_id = block_id;
38736 p->blksize = blksize;
38737- p->seq_num = cpu_to_be32(atomic_inc_return(&peer_device->device->packet_seq));
38738+ p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&peer_device->device->packet_seq));
38739 return drbd_send_command(peer_device, sock, cmd, sizeof(*p), NULL, 0);
38740 }
38741
38742@@ -1634,7 +1634,7 @@ int drbd_send_dblock(struct drbd_peer_device *peer_device, struct drbd_request *
38743 return -EIO;
38744 p->sector = cpu_to_be64(req->i.sector);
38745 p->block_id = (unsigned long)req;
38746- p->seq_num = cpu_to_be32(atomic_inc_return(&device->packet_seq));
38747+ p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&device->packet_seq));
38748 dp_flags = bio_flags_to_wire(peer_device->connection, req->master_bio->bi_rw);
38749 if (device->state.conn >= C_SYNC_SOURCE &&
38750 device->state.conn <= C_PAUSED_SYNC_T)
38751@@ -1915,8 +1915,8 @@ void drbd_init_set_defaults(struct drbd_device *device)
38752 atomic_set(&device->unacked_cnt, 0);
38753 atomic_set(&device->local_cnt, 0);
38754 atomic_set(&device->pp_in_use_by_net, 0);
38755- atomic_set(&device->rs_sect_in, 0);
38756- atomic_set(&device->rs_sect_ev, 0);
38757+ atomic_set_unchecked(&device->rs_sect_in, 0);
38758+ atomic_set_unchecked(&device->rs_sect_ev, 0);
38759 atomic_set(&device->ap_in_flight, 0);
38760 atomic_set(&device->md_io.in_use, 0);
38761
38762@@ -2683,8 +2683,8 @@ void drbd_destroy_connection(struct kref *kref)
38763 struct drbd_connection *connection = container_of(kref, struct drbd_connection, kref);
38764 struct drbd_resource *resource = connection->resource;
38765
38766- if (atomic_read(&connection->current_epoch->epoch_size) != 0)
38767- drbd_err(connection, "epoch_size:%d\n", atomic_read(&connection->current_epoch->epoch_size));
38768+ if (atomic_read_unchecked(&connection->current_epoch->epoch_size) != 0)
38769+ drbd_err(connection, "epoch_size:%d\n", atomic_read_unchecked(&connection->current_epoch->epoch_size));
38770 kfree(connection->current_epoch);
38771
38772 idr_destroy(&connection->peer_devices);
38773diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
38774index 74df8cf..e41fc24 100644
38775--- a/drivers/block/drbd/drbd_nl.c
38776+++ b/drivers/block/drbd/drbd_nl.c
38777@@ -3637,13 +3637,13 @@ finish:
38778
38779 void drbd_bcast_event(struct drbd_device *device, const struct sib_info *sib)
38780 {
38781- static atomic_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
38782+ static atomic_unchecked_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
38783 struct sk_buff *msg;
38784 struct drbd_genlmsghdr *d_out;
38785 unsigned seq;
38786 int err = -ENOMEM;
38787
38788- seq = atomic_inc_return(&drbd_genl_seq);
38789+ seq = atomic_inc_return_unchecked(&drbd_genl_seq);
38790 msg = genlmsg_new(NLMSG_GOODSIZE, GFP_NOIO);
38791 if (!msg)
38792 goto failed;
38793diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
38794index cee2035..22f66bd 100644
38795--- a/drivers/block/drbd/drbd_receiver.c
38796+++ b/drivers/block/drbd/drbd_receiver.c
38797@@ -870,7 +870,7 @@ int drbd_connected(struct drbd_peer_device *peer_device)
38798 struct drbd_device *device = peer_device->device;
38799 int err;
38800
38801- atomic_set(&device->packet_seq, 0);
38802+ atomic_set_unchecked(&device->packet_seq, 0);
38803 device->peer_seq = 0;
38804
38805 device->state_mutex = peer_device->connection->agreed_pro_version < 100 ?
38806@@ -1233,7 +1233,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_connection *connectio
38807 do {
38808 next_epoch = NULL;
38809
38810- epoch_size = atomic_read(&epoch->epoch_size);
38811+ epoch_size = atomic_read_unchecked(&epoch->epoch_size);
38812
38813 switch (ev & ~EV_CLEANUP) {
38814 case EV_PUT:
38815@@ -1273,7 +1273,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_connection *connectio
38816 rv = FE_DESTROYED;
38817 } else {
38818 epoch->flags = 0;
38819- atomic_set(&epoch->epoch_size, 0);
38820+ atomic_set_unchecked(&epoch->epoch_size, 0);
38821 /* atomic_set(&epoch->active, 0); is already zero */
38822 if (rv == FE_STILL_LIVE)
38823 rv = FE_RECYCLED;
38824@@ -1550,7 +1550,7 @@ static int receive_Barrier(struct drbd_connection *connection, struct packet_inf
38825 conn_wait_active_ee_empty(connection);
38826 drbd_flush(connection);
38827
38828- if (atomic_read(&connection->current_epoch->epoch_size)) {
38829+ if (atomic_read_unchecked(&connection->current_epoch->epoch_size)) {
38830 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
38831 if (epoch)
38832 break;
38833@@ -1564,11 +1564,11 @@ static int receive_Barrier(struct drbd_connection *connection, struct packet_inf
38834 }
38835
38836 epoch->flags = 0;
38837- atomic_set(&epoch->epoch_size, 0);
38838+ atomic_set_unchecked(&epoch->epoch_size, 0);
38839 atomic_set(&epoch->active, 0);
38840
38841 spin_lock(&connection->epoch_lock);
38842- if (atomic_read(&connection->current_epoch->epoch_size)) {
38843+ if (atomic_read_unchecked(&connection->current_epoch->epoch_size)) {
38844 list_add(&epoch->list, &connection->current_epoch->list);
38845 connection->current_epoch = epoch;
38846 connection->epochs++;
38847@@ -1802,7 +1802,7 @@ static int recv_resync_read(struct drbd_peer_device *peer_device, sector_t secto
38848 list_add_tail(&peer_req->w.list, &device->sync_ee);
38849 spin_unlock_irq(&device->resource->req_lock);
38850
38851- atomic_add(pi->size >> 9, &device->rs_sect_ev);
38852+ atomic_add_unchecked(pi->size >> 9, &device->rs_sect_ev);
38853 if (drbd_submit_peer_request(device, peer_req, WRITE, DRBD_FAULT_RS_WR) == 0)
38854 return 0;
38855
38856@@ -1900,7 +1900,7 @@ static int receive_RSDataReply(struct drbd_connection *connection, struct packet
38857 drbd_send_ack_dp(peer_device, P_NEG_ACK, p, pi->size);
38858 }
38859
38860- atomic_add(pi->size >> 9, &device->rs_sect_in);
38861+ atomic_add_unchecked(pi->size >> 9, &device->rs_sect_in);
38862
38863 return err;
38864 }
38865@@ -2290,7 +2290,7 @@ static int receive_Data(struct drbd_connection *connection, struct packet_info *
38866
38867 err = wait_for_and_update_peer_seq(peer_device, peer_seq);
38868 drbd_send_ack_dp(peer_device, P_NEG_ACK, p, pi->size);
38869- atomic_inc(&connection->current_epoch->epoch_size);
38870+ atomic_inc_unchecked(&connection->current_epoch->epoch_size);
38871 err2 = drbd_drain_block(peer_device, pi->size);
38872 if (!err)
38873 err = err2;
38874@@ -2334,7 +2334,7 @@ static int receive_Data(struct drbd_connection *connection, struct packet_info *
38875
38876 spin_lock(&connection->epoch_lock);
38877 peer_req->epoch = connection->current_epoch;
38878- atomic_inc(&peer_req->epoch->epoch_size);
38879+ atomic_inc_unchecked(&peer_req->epoch->epoch_size);
38880 atomic_inc(&peer_req->epoch->active);
38881 spin_unlock(&connection->epoch_lock);
38882
38883@@ -2479,7 +2479,7 @@ bool drbd_rs_c_min_rate_throttle(struct drbd_device *device)
38884
38885 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
38886 (int)part_stat_read(&disk->part0, sectors[1]) -
38887- atomic_read(&device->rs_sect_ev);
38888+ atomic_read_unchecked(&device->rs_sect_ev);
38889
38890 if (atomic_read(&device->ap_actlog_cnt)
38891 || curr_events - device->rs_last_events > 64) {
38892@@ -2618,7 +2618,7 @@ static int receive_DataRequest(struct drbd_connection *connection, struct packet
38893 device->use_csums = true;
38894 } else if (pi->cmd == P_OV_REPLY) {
38895 /* track progress, we may need to throttle */
38896- atomic_add(size >> 9, &device->rs_sect_in);
38897+ atomic_add_unchecked(size >> 9, &device->rs_sect_in);
38898 peer_req->w.cb = w_e_end_ov_reply;
38899 dec_rs_pending(device);
38900 /* drbd_rs_begin_io done when we sent this request,
38901@@ -2691,7 +2691,7 @@ static int receive_DataRequest(struct drbd_connection *connection, struct packet
38902 goto out_free_e;
38903
38904 submit_for_resync:
38905- atomic_add(size >> 9, &device->rs_sect_ev);
38906+ atomic_add_unchecked(size >> 9, &device->rs_sect_ev);
38907
38908 submit:
38909 update_receiver_timing_details(connection, drbd_submit_peer_request);
38910@@ -4564,7 +4564,7 @@ struct data_cmd {
38911 int expect_payload;
38912 size_t pkt_size;
38913 int (*fn)(struct drbd_connection *, struct packet_info *);
38914-};
38915+} __do_const;
38916
38917 static struct data_cmd drbd_cmd_handler[] = {
38918 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
38919@@ -4678,7 +4678,7 @@ static void conn_disconnect(struct drbd_connection *connection)
38920 if (!list_empty(&connection->current_epoch->list))
38921 drbd_err(connection, "ASSERTION FAILED: connection->current_epoch->list not empty\n");
38922 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
38923- atomic_set(&connection->current_epoch->epoch_size, 0);
38924+ atomic_set_unchecked(&connection->current_epoch->epoch_size, 0);
38925 connection->send.seen_any_write_yet = false;
38926
38927 drbd_info(connection, "Connection closed\n");
38928@@ -5182,7 +5182,7 @@ static int got_IsInSync(struct drbd_connection *connection, struct packet_info *
38929 put_ldev(device);
38930 }
38931 dec_rs_pending(device);
38932- atomic_add(blksize >> 9, &device->rs_sect_in);
38933+ atomic_add_unchecked(blksize >> 9, &device->rs_sect_in);
38934
38935 return 0;
38936 }
38937@@ -5470,7 +5470,7 @@ static int connection_finish_peer_reqs(struct drbd_connection *connection)
38938 struct asender_cmd {
38939 size_t pkt_size;
38940 int (*fn)(struct drbd_connection *connection, struct packet_info *);
38941-};
38942+} __do_const;
38943
38944 static struct asender_cmd asender_tbl[] = {
38945 [P_PING] = { 0, got_Ping },
38946diff --git a/drivers/block/drbd/drbd_worker.c b/drivers/block/drbd/drbd_worker.c
38947index d0fae55..4469096 100644
38948--- a/drivers/block/drbd/drbd_worker.c
38949+++ b/drivers/block/drbd/drbd_worker.c
38950@@ -408,7 +408,7 @@ static int read_for_csum(struct drbd_peer_device *peer_device, sector_t sector,
38951 list_add_tail(&peer_req->w.list, &device->read_ee);
38952 spin_unlock_irq(&device->resource->req_lock);
38953
38954- atomic_add(size >> 9, &device->rs_sect_ev);
38955+ atomic_add_unchecked(size >> 9, &device->rs_sect_ev);
38956 if (drbd_submit_peer_request(device, peer_req, READ, DRBD_FAULT_RS_RD) == 0)
38957 return 0;
38958
38959@@ -553,7 +553,7 @@ static int drbd_rs_number_requests(struct drbd_device *device)
38960 unsigned int sect_in; /* Number of sectors that came in since the last turn */
38961 int number, mxb;
38962
38963- sect_in = atomic_xchg(&device->rs_sect_in, 0);
38964+ sect_in = atomic_xchg_unchecked(&device->rs_sect_in, 0);
38965 device->rs_in_flight -= sect_in;
38966
38967 rcu_read_lock();
38968@@ -1595,8 +1595,8 @@ void drbd_rs_controller_reset(struct drbd_device *device)
38969 struct gendisk *disk = device->ldev->backing_bdev->bd_contains->bd_disk;
38970 struct fifo_buffer *plan;
38971
38972- atomic_set(&device->rs_sect_in, 0);
38973- atomic_set(&device->rs_sect_ev, 0);
38974+ atomic_set_unchecked(&device->rs_sect_in, 0);
38975+ atomic_set_unchecked(&device->rs_sect_ev, 0);
38976 device->rs_in_flight = 0;
38977 device->rs_last_events =
38978 (int)part_stat_read(&disk->part0, sectors[0]) +
38979diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
38980index 09e628da..7607aaa 100644
38981--- a/drivers/block/pktcdvd.c
38982+++ b/drivers/block/pktcdvd.c
38983@@ -108,7 +108,7 @@ static int pkt_seq_show(struct seq_file *m, void *p);
38984
38985 static sector_t get_zone(sector_t sector, struct pktcdvd_device *pd)
38986 {
38987- return (sector + pd->offset) & ~(sector_t)(pd->settings.size - 1);
38988+ return (sector + pd->offset) & ~(sector_t)(pd->settings.size - 1UL);
38989 }
38990
38991 /*
38992@@ -1890,7 +1890,7 @@ static noinline_for_stack int pkt_probe_settings(struct pktcdvd_device *pd)
38993 return -EROFS;
38994 }
38995 pd->settings.fp = ti.fp;
38996- pd->offset = (be32_to_cpu(ti.track_start) << 2) & (pd->settings.size - 1);
38997+ pd->offset = (be32_to_cpu(ti.track_start) << 2) & (pd->settings.size - 1UL);
38998
38999 if (ti.nwa_v) {
39000 pd->nwa = be32_to_cpu(ti.next_writable);
39001diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
39002index ec6c5c6..820ee2abc 100644
39003--- a/drivers/block/rbd.c
39004+++ b/drivers/block/rbd.c
39005@@ -64,7 +64,7 @@
39006 * If the counter is already at its maximum value returns
39007 * -EINVAL without updating it.
39008 */
39009-static int atomic_inc_return_safe(atomic_t *v)
39010+static int __intentional_overflow(-1) atomic_inc_return_safe(atomic_t *v)
39011 {
39012 unsigned int counter;
39013
39014diff --git a/drivers/block/smart1,2.h b/drivers/block/smart1,2.h
39015index e5565fb..71be10b4 100644
39016--- a/drivers/block/smart1,2.h
39017+++ b/drivers/block/smart1,2.h
39018@@ -108,11 +108,11 @@ static unsigned long smart4_intr_pending(ctlr_info_t *h)
39019 }
39020
39021 static struct access_method smart4_access = {
39022- smart4_submit_command,
39023- smart4_intr_mask,
39024- smart4_fifo_full,
39025- smart4_intr_pending,
39026- smart4_completed,
39027+ .submit_command = smart4_submit_command,
39028+ .set_intr_mask = smart4_intr_mask,
39029+ .fifo_full = smart4_fifo_full,
39030+ .intr_pending = smart4_intr_pending,
39031+ .command_completed = smart4_completed,
39032 };
39033
39034 /*
39035@@ -144,11 +144,11 @@ static unsigned long smart2_intr_pending(ctlr_info_t *h)
39036 }
39037
39038 static struct access_method smart2_access = {
39039- smart2_submit_command,
39040- smart2_intr_mask,
39041- smart2_fifo_full,
39042- smart2_intr_pending,
39043- smart2_completed,
39044+ .submit_command = smart2_submit_command,
39045+ .set_intr_mask = smart2_intr_mask,
39046+ .fifo_full = smart2_fifo_full,
39047+ .intr_pending = smart2_intr_pending,
39048+ .command_completed = smart2_completed,
39049 };
39050
39051 /*
39052@@ -180,11 +180,11 @@ static unsigned long smart2e_intr_pending(ctlr_info_t *h)
39053 }
39054
39055 static struct access_method smart2e_access = {
39056- smart2e_submit_command,
39057- smart2e_intr_mask,
39058- smart2e_fifo_full,
39059- smart2e_intr_pending,
39060- smart2e_completed,
39061+ .submit_command = smart2e_submit_command,
39062+ .set_intr_mask = smart2e_intr_mask,
39063+ .fifo_full = smart2e_fifo_full,
39064+ .intr_pending = smart2e_intr_pending,
39065+ .command_completed = smart2e_completed,
39066 };
39067
39068 /*
39069@@ -270,9 +270,9 @@ static unsigned long smart1_intr_pending(ctlr_info_t *h)
39070 }
39071
39072 static struct access_method smart1_access = {
39073- smart1_submit_command,
39074- smart1_intr_mask,
39075- smart1_fifo_full,
39076- smart1_intr_pending,
39077- smart1_completed,
39078+ .submit_command = smart1_submit_command,
39079+ .set_intr_mask = smart1_intr_mask,
39080+ .fifo_full = smart1_fifo_full,
39081+ .intr_pending = smart1_intr_pending,
39082+ .command_completed = smart1_completed,
39083 };
39084diff --git a/drivers/bluetooth/btwilink.c b/drivers/bluetooth/btwilink.c
39085index 55c135b..9f8d60c 100644
39086--- a/drivers/bluetooth/btwilink.c
39087+++ b/drivers/bluetooth/btwilink.c
39088@@ -288,7 +288,7 @@ static int ti_st_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
39089
39090 static int bt_ti_probe(struct platform_device *pdev)
39091 {
39092- static struct ti_st *hst;
39093+ struct ti_st *hst;
39094 struct hci_dev *hdev;
39095 int err;
39096
39097diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
39098index 5d28a45..a538f90 100644
39099--- a/drivers/cdrom/cdrom.c
39100+++ b/drivers/cdrom/cdrom.c
39101@@ -610,7 +610,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
39102 ENSURE(reset, CDC_RESET);
39103 ENSURE(generic_packet, CDC_GENERIC_PACKET);
39104 cdi->mc_flags = 0;
39105- cdo->n_minors = 0;
39106 cdi->options = CDO_USE_FFLAGS;
39107
39108 if (autoclose == 1 && CDROM_CAN(CDC_CLOSE_TRAY))
39109@@ -630,8 +629,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
39110 else
39111 cdi->cdda_method = CDDA_OLD;
39112
39113- if (!cdo->generic_packet)
39114- cdo->generic_packet = cdrom_dummy_generic_packet;
39115+ if (!cdo->generic_packet) {
39116+ pax_open_kernel();
39117+ *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
39118+ pax_close_kernel();
39119+ }
39120
39121 cd_dbg(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
39122 mutex_lock(&cdrom_mutex);
39123@@ -652,7 +654,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
39124 if (cdi->exit)
39125 cdi->exit(cdi);
39126
39127- cdi->ops->n_minors--;
39128 cd_dbg(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
39129 }
39130
39131@@ -2126,7 +2127,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
39132 */
39133 nr = nframes;
39134 do {
39135- cgc.buffer = kmalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
39136+ cgc.buffer = kzalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
39137 if (cgc.buffer)
39138 break;
39139
39140@@ -3434,7 +3435,7 @@ static int cdrom_print_info(const char *header, int val, char *info,
39141 struct cdrom_device_info *cdi;
39142 int ret;
39143
39144- ret = scnprintf(info + *pos, max_size - *pos, header);
39145+ ret = scnprintf(info + *pos, max_size - *pos, "%s", header);
39146 if (!ret)
39147 return 1;
39148
39149diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
39150index 584bc31..e64a12c 100644
39151--- a/drivers/cdrom/gdrom.c
39152+++ b/drivers/cdrom/gdrom.c
39153@@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
39154 .audio_ioctl = gdrom_audio_ioctl,
39155 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
39156 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
39157- .n_minors = 1,
39158 };
39159
39160 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
39161diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
39162index a4af822..ed58cd1 100644
39163--- a/drivers/char/Kconfig
39164+++ b/drivers/char/Kconfig
39165@@ -17,7 +17,8 @@ config DEVMEM
39166
39167 config DEVKMEM
39168 bool "/dev/kmem virtual device support"
39169- default y
39170+ default n
39171+ depends on !GRKERNSEC_KMEM
39172 help
39173 Say Y here if you want to support the /dev/kmem device. The
39174 /dev/kmem device is rarely used, but can be used for certain
39175@@ -586,6 +587,7 @@ config DEVPORT
39176 bool
39177 depends on !M68K
39178 depends on ISA || PCI
39179+ depends on !GRKERNSEC_KMEM
39180 default y
39181
39182 source "drivers/s390/char/Kconfig"
39183diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
39184index a48e05b..6bac831 100644
39185--- a/drivers/char/agp/compat_ioctl.c
39186+++ b/drivers/char/agp/compat_ioctl.c
39187@@ -108,7 +108,7 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
39188 return -ENOMEM;
39189 }
39190
39191- if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
39192+ if (copy_from_user(usegment, (void __force_user *) ureserve.seg_list,
39193 sizeof(*usegment) * ureserve.seg_count)) {
39194 kfree(usegment);
39195 kfree(ksegment);
39196diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
39197index 09f17eb..8531d2f 100644
39198--- a/drivers/char/agp/frontend.c
39199+++ b/drivers/char/agp/frontend.c
39200@@ -806,7 +806,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
39201 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
39202 return -EFAULT;
39203
39204- if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
39205+ if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
39206 return -EFAULT;
39207
39208 client = agp_find_client_by_pid(reserve.pid);
39209@@ -836,7 +836,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
39210 if (segment == NULL)
39211 return -ENOMEM;
39212
39213- if (copy_from_user(segment, (void __user *) reserve.seg_list,
39214+ if (copy_from_user(segment, (void __force_user *) reserve.seg_list,
39215 sizeof(struct agp_segment) * reserve.seg_count)) {
39216 kfree(segment);
39217 return -EFAULT;
39218diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
39219index 4f94375..413694e 100644
39220--- a/drivers/char/genrtc.c
39221+++ b/drivers/char/genrtc.c
39222@@ -273,6 +273,7 @@ static int gen_rtc_ioctl(struct file *file,
39223 switch (cmd) {
39224
39225 case RTC_PLL_GET:
39226+ memset(&pll, 0, sizeof(pll));
39227 if (get_rtc_pll(&pll))
39228 return -EINVAL;
39229 else
39230diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
39231index 5c0baa9..44011b1 100644
39232--- a/drivers/char/hpet.c
39233+++ b/drivers/char/hpet.c
39234@@ -575,7 +575,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
39235 }
39236
39237 static int
39238-hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
39239+hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
39240 struct hpet_info *info)
39241 {
39242 struct hpet_timer __iomem *timer;
39243diff --git a/drivers/char/i8k.c b/drivers/char/i8k.c
39244index a43048b..14724d5 100644
39245--- a/drivers/char/i8k.c
39246+++ b/drivers/char/i8k.c
39247@@ -790,7 +790,7 @@ static const struct i8k_config_data i8k_config_data[] = {
39248 },
39249 };
39250
39251-static struct dmi_system_id i8k_dmi_table[] __initdata = {
39252+static const struct dmi_system_id i8k_dmi_table[] __initconst = {
39253 {
39254 .ident = "Dell Inspiron",
39255 .matches = {
39256diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
39257index bf75f63..359fa10 100644
39258--- a/drivers/char/ipmi/ipmi_msghandler.c
39259+++ b/drivers/char/ipmi/ipmi_msghandler.c
39260@@ -436,7 +436,7 @@ struct ipmi_smi {
39261 struct proc_dir_entry *proc_dir;
39262 char proc_dir_name[10];
39263
39264- atomic_t stats[IPMI_NUM_STATS];
39265+ atomic_unchecked_t stats[IPMI_NUM_STATS];
39266
39267 /*
39268 * run_to_completion duplicate of smb_info, smi_info
39269@@ -468,9 +468,9 @@ static LIST_HEAD(smi_watchers);
39270 static DEFINE_MUTEX(smi_watchers_mutex);
39271
39272 #define ipmi_inc_stat(intf, stat) \
39273- atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
39274+ atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
39275 #define ipmi_get_stat(intf, stat) \
39276- ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
39277+ ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
39278
39279 static char *addr_src_to_str[] = { "invalid", "hotmod", "hardcoded", "SPMI",
39280 "ACPI", "SMBIOS", "PCI",
39281@@ -2828,7 +2828,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
39282 INIT_LIST_HEAD(&intf->cmd_rcvrs);
39283 init_waitqueue_head(&intf->waitq);
39284 for (i = 0; i < IPMI_NUM_STATS; i++)
39285- atomic_set(&intf->stats[i], 0);
39286+ atomic_set_unchecked(&intf->stats[i], 0);
39287
39288 intf->proc_dir = NULL;
39289
39290diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
39291index 8a45e92..e41b1c7 100644
39292--- a/drivers/char/ipmi/ipmi_si_intf.c
39293+++ b/drivers/char/ipmi/ipmi_si_intf.c
39294@@ -289,7 +289,7 @@ struct smi_info {
39295 unsigned char slave_addr;
39296
39297 /* Counters and things for the proc filesystem. */
39298- atomic_t stats[SI_NUM_STATS];
39299+ atomic_unchecked_t stats[SI_NUM_STATS];
39300
39301 struct task_struct *thread;
39302
39303@@ -298,9 +298,9 @@ struct smi_info {
39304 };
39305
39306 #define smi_inc_stat(smi, stat) \
39307- atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
39308+ atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
39309 #define smi_get_stat(smi, stat) \
39310- ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
39311+ ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
39312
39313 #define SI_MAX_PARMS 4
39314
39315@@ -3500,7 +3500,7 @@ static int try_smi_init(struct smi_info *new_smi)
39316 atomic_set(&new_smi->req_events, 0);
39317 new_smi->run_to_completion = false;
39318 for (i = 0; i < SI_NUM_STATS; i++)
39319- atomic_set(&new_smi->stats[i], 0);
39320+ atomic_set_unchecked(&new_smi->stats[i], 0);
39321
39322 new_smi->interrupt_disabled = true;
39323 atomic_set(&new_smi->need_watch, 0);
39324diff --git a/drivers/char/mem.c b/drivers/char/mem.c
39325index 6b1721f..fda9398 100644
39326--- a/drivers/char/mem.c
39327+++ b/drivers/char/mem.c
39328@@ -18,6 +18,7 @@
39329 #include <linux/raw.h>
39330 #include <linux/tty.h>
39331 #include <linux/capability.h>
39332+#include <linux/security.h>
39333 #include <linux/ptrace.h>
39334 #include <linux/device.h>
39335 #include <linux/highmem.h>
39336@@ -36,6 +37,10 @@
39337
39338 #define DEVPORT_MINOR 4
39339
39340+#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
39341+extern const struct file_operations grsec_fops;
39342+#endif
39343+
39344 static inline unsigned long size_inside_page(unsigned long start,
39345 unsigned long size)
39346 {
39347@@ -67,9 +72,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
39348
39349 while (cursor < to) {
39350 if (!devmem_is_allowed(pfn)) {
39351+#ifdef CONFIG_GRKERNSEC_KMEM
39352+ gr_handle_mem_readwrite(from, to);
39353+#else
39354 printk(KERN_INFO
39355 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
39356 current->comm, from, to);
39357+#endif
39358 return 0;
39359 }
39360 cursor += PAGE_SIZE;
39361@@ -77,6 +86,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
39362 }
39363 return 1;
39364 }
39365+#elif defined(CONFIG_GRKERNSEC_KMEM)
39366+static inline int range_is_allowed(unsigned long pfn, unsigned long size)
39367+{
39368+ return 0;
39369+}
39370 #else
39371 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
39372 {
39373@@ -124,7 +138,8 @@ static ssize_t read_mem(struct file *file, char __user *buf,
39374 #endif
39375
39376 while (count > 0) {
39377- unsigned long remaining;
39378+ unsigned long remaining = 0;
39379+ char *temp;
39380
39381 sz = size_inside_page(p, count);
39382
39383@@ -140,7 +155,24 @@ static ssize_t read_mem(struct file *file, char __user *buf,
39384 if (!ptr)
39385 return -EFAULT;
39386
39387- remaining = copy_to_user(buf, ptr, sz);
39388+#ifdef CONFIG_PAX_USERCOPY
39389+ temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
39390+ if (!temp) {
39391+ unxlate_dev_mem_ptr(p, ptr);
39392+ return -ENOMEM;
39393+ }
39394+ remaining = probe_kernel_read(temp, ptr, sz);
39395+#else
39396+ temp = ptr;
39397+#endif
39398+
39399+ if (!remaining)
39400+ remaining = copy_to_user(buf, temp, sz);
39401+
39402+#ifdef CONFIG_PAX_USERCOPY
39403+ kfree(temp);
39404+#endif
39405+
39406 unxlate_dev_mem_ptr(p, ptr);
39407 if (remaining)
39408 return -EFAULT;
39409@@ -380,9 +412,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
39410 size_t count, loff_t *ppos)
39411 {
39412 unsigned long p = *ppos;
39413- ssize_t low_count, read, sz;
39414+ ssize_t low_count, read, sz, err = 0;
39415 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
39416- int err = 0;
39417
39418 read = 0;
39419 if (p < (unsigned long) high_memory) {
39420@@ -404,6 +435,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
39421 }
39422 #endif
39423 while (low_count > 0) {
39424+ char *temp;
39425+
39426 sz = size_inside_page(p, low_count);
39427
39428 /*
39429@@ -413,7 +446,23 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
39430 */
39431 kbuf = xlate_dev_kmem_ptr((void *)p);
39432
39433- if (copy_to_user(buf, kbuf, sz))
39434+#ifdef CONFIG_PAX_USERCOPY
39435+ temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
39436+ if (!temp)
39437+ return -ENOMEM;
39438+ err = probe_kernel_read(temp, kbuf, sz);
39439+#else
39440+ temp = kbuf;
39441+#endif
39442+
39443+ if (!err)
39444+ err = copy_to_user(buf, temp, sz);
39445+
39446+#ifdef CONFIG_PAX_USERCOPY
39447+ kfree(temp);
39448+#endif
39449+
39450+ if (err)
39451 return -EFAULT;
39452 buf += sz;
39453 p += sz;
39454@@ -802,6 +851,9 @@ static const struct memdev {
39455 #ifdef CONFIG_PRINTK
39456 [11] = { "kmsg", 0644, &kmsg_fops, 0 },
39457 #endif
39458+#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
39459+ [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, 0 },
39460+#endif
39461 };
39462
39463 static int memory_open(struct inode *inode, struct file *filp)
39464@@ -863,7 +915,7 @@ static int __init chr_dev_init(void)
39465 continue;
39466
39467 device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor),
39468- NULL, devlist[minor].name);
39469+ NULL, "%s", devlist[minor].name);
39470 }
39471
39472 return tty_init();
39473diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
39474index 9df78e2..01ba9ae 100644
39475--- a/drivers/char/nvram.c
39476+++ b/drivers/char/nvram.c
39477@@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
39478
39479 spin_unlock_irq(&rtc_lock);
39480
39481- if (copy_to_user(buf, contents, tmp - contents))
39482+ if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
39483 return -EFAULT;
39484
39485 *ppos = i;
39486diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
39487index 0ea9986..e7b07e4 100644
39488--- a/drivers/char/pcmcia/synclink_cs.c
39489+++ b/drivers/char/pcmcia/synclink_cs.c
39490@@ -2345,7 +2345,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
39491
39492 if (debug_level >= DEBUG_LEVEL_INFO)
39493 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
39494- __FILE__, __LINE__, info->device_name, port->count);
39495+ __FILE__, __LINE__, info->device_name, atomic_read(&port->count));
39496
39497 if (tty_port_close_start(port, tty, filp) == 0)
39498 goto cleanup;
39499@@ -2363,7 +2363,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
39500 cleanup:
39501 if (debug_level >= DEBUG_LEVEL_INFO)
39502 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__, __LINE__,
39503- tty->driver->name, port->count);
39504+ tty->driver->name, atomic_read(&port->count));
39505 }
39506
39507 /* Wait until the transmitter is empty.
39508@@ -2505,7 +2505,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
39509
39510 if (debug_level >= DEBUG_LEVEL_INFO)
39511 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
39512- __FILE__, __LINE__, tty->driver->name, port->count);
39513+ __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
39514
39515 /* If port is closing, signal caller to try again */
39516 if (port->flags & ASYNC_CLOSING){
39517@@ -2525,11 +2525,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
39518 goto cleanup;
39519 }
39520 spin_lock(&port->lock);
39521- port->count++;
39522+ atomic_inc(&port->count);
39523 spin_unlock(&port->lock);
39524 spin_unlock_irqrestore(&info->netlock, flags);
39525
39526- if (port->count == 1) {
39527+ if (atomic_read(&port->count) == 1) {
39528 /* 1st open on this device, init hardware */
39529 retval = startup(info, tty);
39530 if (retval < 0)
39531@@ -3918,7 +3918,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
39532 unsigned short new_crctype;
39533
39534 /* return error if TTY interface open */
39535- if (info->port.count)
39536+ if (atomic_read(&info->port.count))
39537 return -EBUSY;
39538
39539 switch (encoding)
39540@@ -4022,7 +4022,7 @@ static int hdlcdev_open(struct net_device *dev)
39541
39542 /* arbitrate between network and tty opens */
39543 spin_lock_irqsave(&info->netlock, flags);
39544- if (info->port.count != 0 || info->netcount != 0) {
39545+ if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
39546 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
39547 spin_unlock_irqrestore(&info->netlock, flags);
39548 return -EBUSY;
39549@@ -4112,7 +4112,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
39550 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name);
39551
39552 /* return error if TTY interface open */
39553- if (info->port.count)
39554+ if (atomic_read(&info->port.count))
39555 return -EBUSY;
39556
39557 if (cmd != SIOCWANDEV)
39558diff --git a/drivers/char/random.c b/drivers/char/random.c
39559index 9cd6968..6416f00 100644
39560--- a/drivers/char/random.c
39561+++ b/drivers/char/random.c
39562@@ -289,9 +289,6 @@
39563 /*
39564 * To allow fractional bits to be tracked, the entropy_count field is
39565 * denominated in units of 1/8th bits.
39566- *
39567- * 2*(ENTROPY_SHIFT + log2(poolbits)) must <= 31, or the multiply in
39568- * credit_entropy_bits() needs to be 64 bits wide.
39569 */
39570 #define ENTROPY_SHIFT 3
39571 #define ENTROPY_BITS(r) ((r)->entropy_count >> ENTROPY_SHIFT)
39572@@ -439,9 +436,9 @@ struct entropy_store {
39573 };
39574
39575 static void push_to_pool(struct work_struct *work);
39576-static __u32 input_pool_data[INPUT_POOL_WORDS];
39577-static __u32 blocking_pool_data[OUTPUT_POOL_WORDS];
39578-static __u32 nonblocking_pool_data[OUTPUT_POOL_WORDS];
39579+static __u32 input_pool_data[INPUT_POOL_WORDS] __latent_entropy;
39580+static __u32 blocking_pool_data[OUTPUT_POOL_WORDS] __latent_entropy;
39581+static __u32 nonblocking_pool_data[OUTPUT_POOL_WORDS] __latent_entropy;
39582
39583 static struct entropy_store input_pool = {
39584 .poolinfo = &poolinfo_table[0],
39585@@ -635,7 +632,7 @@ retry:
39586 /* The +2 corresponds to the /4 in the denominator */
39587
39588 do {
39589- unsigned int anfrac = min(pnfrac, pool_size/2);
39590+ u64 anfrac = min(pnfrac, pool_size/2);
39591 unsigned int add =
39592 ((pool_size - entropy_count)*anfrac*3) >> s;
39593
39594@@ -1207,7 +1204,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
39595
39596 extract_buf(r, tmp);
39597 i = min_t(int, nbytes, EXTRACT_SIZE);
39598- if (copy_to_user(buf, tmp, i)) {
39599+ if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
39600 ret = -EFAULT;
39601 break;
39602 }
39603@@ -1590,7 +1587,7 @@ static char sysctl_bootid[16];
39604 static int proc_do_uuid(struct ctl_table *table, int write,
39605 void __user *buffer, size_t *lenp, loff_t *ppos)
39606 {
39607- struct ctl_table fake_table;
39608+ ctl_table_no_const fake_table;
39609 unsigned char buf[64], tmp_uuid[16], *uuid;
39610
39611 uuid = table->data;
39612@@ -1620,7 +1617,7 @@ static int proc_do_uuid(struct ctl_table *table, int write,
39613 static int proc_do_entropy(struct ctl_table *table, int write,
39614 void __user *buffer, size_t *lenp, loff_t *ppos)
39615 {
39616- struct ctl_table fake_table;
39617+ ctl_table_no_const fake_table;
39618 int entropy_count;
39619
39620 entropy_count = *(int *)table->data >> ENTROPY_SHIFT;
39621diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
39622index e496dae..3db53b6 100644
39623--- a/drivers/char/sonypi.c
39624+++ b/drivers/char/sonypi.c
39625@@ -54,6 +54,7 @@
39626
39627 #include <asm/uaccess.h>
39628 #include <asm/io.h>
39629+#include <asm/local.h>
39630
39631 #include <linux/sonypi.h>
39632
39633@@ -490,7 +491,7 @@ static struct sonypi_device {
39634 spinlock_t fifo_lock;
39635 wait_queue_head_t fifo_proc_list;
39636 struct fasync_struct *fifo_async;
39637- int open_count;
39638+ local_t open_count;
39639 int model;
39640 struct input_dev *input_jog_dev;
39641 struct input_dev *input_key_dev;
39642@@ -892,7 +893,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
39643 static int sonypi_misc_release(struct inode *inode, struct file *file)
39644 {
39645 mutex_lock(&sonypi_device.lock);
39646- sonypi_device.open_count--;
39647+ local_dec(&sonypi_device.open_count);
39648 mutex_unlock(&sonypi_device.lock);
39649 return 0;
39650 }
39651@@ -901,9 +902,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
39652 {
39653 mutex_lock(&sonypi_device.lock);
39654 /* Flush input queue on first open */
39655- if (!sonypi_device.open_count)
39656+ if (!local_read(&sonypi_device.open_count))
39657 kfifo_reset(&sonypi_device.fifo);
39658- sonypi_device.open_count++;
39659+ local_inc(&sonypi_device.open_count);
39660 mutex_unlock(&sonypi_device.lock);
39661
39662 return 0;
39663@@ -1491,7 +1492,7 @@ static struct platform_driver sonypi_driver = {
39664
39665 static struct platform_device *sonypi_platform_device;
39666
39667-static struct dmi_system_id __initdata sonypi_dmi_table[] = {
39668+static const struct dmi_system_id __initconst sonypi_dmi_table[] = {
39669 {
39670 .ident = "Sony Vaio",
39671 .matches = {
39672diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
39673index 565a947..dcdc06e 100644
39674--- a/drivers/char/tpm/tpm_acpi.c
39675+++ b/drivers/char/tpm/tpm_acpi.c
39676@@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
39677 virt = acpi_os_map_iomem(start, len);
39678 if (!virt) {
39679 kfree(log->bios_event_log);
39680+ log->bios_event_log = NULL;
39681 printk("%s: ERROR - Unable to map memory\n", __func__);
39682 return -EIO;
39683 }
39684
39685- memcpy_fromio(log->bios_event_log, virt, len);
39686+ memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
39687
39688 acpi_os_unmap_iomem(virt, len);
39689 return 0;
39690diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
39691index 3a56a13..f8cbd25 100644
39692--- a/drivers/char/tpm/tpm_eventlog.c
39693+++ b/drivers/char/tpm/tpm_eventlog.c
39694@@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
39695 event = addr;
39696
39697 if ((event->event_type == 0 && event->event_size == 0) ||
39698- ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
39699+ (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
39700 return NULL;
39701
39702 return addr;
39703@@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
39704 return NULL;
39705
39706 if ((event->event_type == 0 && event->event_size == 0) ||
39707- ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
39708+ (event->event_size >= limit - v - sizeof(struct tcpa_event)))
39709 return NULL;
39710
39711 (*pos)++;
39712@@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
39713 int i;
39714
39715 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
39716- seq_putc(m, data[i]);
39717+ if (!seq_putc(m, data[i]))
39718+ return -EFAULT;
39719
39720 return 0;
39721 }
39722diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
39723index 50754d20..9561cdc 100644
39724--- a/drivers/char/virtio_console.c
39725+++ b/drivers/char/virtio_console.c
39726@@ -685,7 +685,7 @@ static ssize_t fill_readbuf(struct port *port, char __user *out_buf,
39727 if (to_user) {
39728 ssize_t ret;
39729
39730- ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
39731+ ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
39732 if (ret)
39733 return -EFAULT;
39734 } else {
39735@@ -789,7 +789,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
39736 if (!port_has_data(port) && !port->host_connected)
39737 return 0;
39738
39739- return fill_readbuf(port, ubuf, count, true);
39740+ return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
39741 }
39742
39743 static int wait_port_writable(struct port *port, bool nonblock)
39744diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
39745index 956b7e5..b655045 100644
39746--- a/drivers/clk/clk-composite.c
39747+++ b/drivers/clk/clk-composite.c
39748@@ -197,7 +197,7 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
39749 struct clk *clk;
39750 struct clk_init_data init;
39751 struct clk_composite *composite;
39752- struct clk_ops *clk_composite_ops;
39753+ clk_ops_no_const *clk_composite_ops;
39754
39755 composite = kzalloc(sizeof(*composite), GFP_KERNEL);
39756 if (!composite) {
39757diff --git a/drivers/clk/clk-mux.c b/drivers/clk/clk-mux.c
39758index 69a094c..1fa2a8d 100644
39759--- a/drivers/clk/clk-mux.c
39760+++ b/drivers/clk/clk-mux.c
39761@@ -114,7 +114,7 @@ const struct clk_ops clk_mux_ro_ops = {
39762 EXPORT_SYMBOL_GPL(clk_mux_ro_ops);
39763
39764 struct clk *clk_register_mux_table(struct device *dev, const char *name,
39765- const char **parent_names, u8 num_parents, unsigned long flags,
39766+ const char * const *parent_names, u8 num_parents, unsigned long flags,
39767 void __iomem *reg, u8 shift, u32 mask,
39768 u8 clk_mux_flags, u32 *table, spinlock_t *lock)
39769 {
39770@@ -166,7 +166,7 @@ struct clk *clk_register_mux_table(struct device *dev, const char *name,
39771 EXPORT_SYMBOL_GPL(clk_register_mux_table);
39772
39773 struct clk *clk_register_mux(struct device *dev, const char *name,
39774- const char **parent_names, u8 num_parents, unsigned long flags,
39775+ const char * const *parent_names, u8 num_parents, unsigned long flags,
39776 void __iomem *reg, u8 shift, u8 width,
39777 u8 clk_mux_flags, spinlock_t *lock)
39778 {
39779diff --git a/drivers/clk/samsung/clk.h b/drivers/clk/samsung/clk.h
39780index e4c7538..9d5c18a 100644
39781--- a/drivers/clk/samsung/clk.h
39782+++ b/drivers/clk/samsung/clk.h
39783@@ -121,7 +121,7 @@ struct samsung_mux_clock {
39784 unsigned int id;
39785 const char *dev_name;
39786 const char *name;
39787- const char **parent_names;
39788+ const char * const *parent_names;
39789 u8 num_parents;
39790 unsigned long flags;
39791 unsigned long offset;
39792@@ -260,7 +260,7 @@ struct samsung_gate_clock {
39793 #define GATE_DA(_id, dname, cname, pname, o, b, f, gf, a) \
39794 __GATE(_id, dname, cname, pname, o, b, f, gf, a)
39795
39796-#define PNAME(x) static const char *x[] __initdata
39797+#define PNAME(x) static const char * const x[] __initconst
39798
39799 /**
39800 * struct samsung_clk_reg_dump: register dump of clock controller registers.
39801diff --git a/drivers/clk/socfpga/clk-gate.c b/drivers/clk/socfpga/clk-gate.c
39802index dd3a78c..386d49c 100644
39803--- a/drivers/clk/socfpga/clk-gate.c
39804+++ b/drivers/clk/socfpga/clk-gate.c
39805@@ -22,6 +22,7 @@
39806 #include <linux/mfd/syscon.h>
39807 #include <linux/of.h>
39808 #include <linux/regmap.h>
39809+#include <asm/pgtable.h>
39810
39811 #include "clk.h"
39812
39813@@ -174,7 +175,7 @@ static int socfpga_clk_prepare(struct clk_hw *hwclk)
39814 return 0;
39815 }
39816
39817-static struct clk_ops gateclk_ops = {
39818+static clk_ops_no_const gateclk_ops __read_only = {
39819 .prepare = socfpga_clk_prepare,
39820 .recalc_rate = socfpga_clk_recalc_rate,
39821 .get_parent = socfpga_clk_get_parent,
39822@@ -208,8 +209,10 @@ static void __init __socfpga_gate_init(struct device_node *node,
39823 socfpga_clk->hw.reg = clk_mgr_base_addr + clk_gate[0];
39824 socfpga_clk->hw.bit_idx = clk_gate[1];
39825
39826- gateclk_ops.enable = clk_gate_ops.enable;
39827- gateclk_ops.disable = clk_gate_ops.disable;
39828+ pax_open_kernel();
39829+ *(void **)&gateclk_ops.enable = clk_gate_ops.enable;
39830+ *(void **)&gateclk_ops.disable = clk_gate_ops.disable;
39831+ pax_close_kernel();
39832 }
39833
39834 rc = of_property_read_u32(node, "fixed-divider", &fixed_div);
39835diff --git a/drivers/clk/socfpga/clk-pll.c b/drivers/clk/socfpga/clk-pll.c
39836index de6da95..c98278b 100644
39837--- a/drivers/clk/socfpga/clk-pll.c
39838+++ b/drivers/clk/socfpga/clk-pll.c
39839@@ -21,6 +21,7 @@
39840 #include <linux/io.h>
39841 #include <linux/of.h>
39842 #include <linux/of_address.h>
39843+#include <asm/pgtable.h>
39844
39845 #include "clk.h"
39846
39847@@ -76,7 +77,7 @@ static u8 clk_pll_get_parent(struct clk_hw *hwclk)
39848 CLK_MGR_PLL_CLK_SRC_MASK;
39849 }
39850
39851-static struct clk_ops clk_pll_ops = {
39852+static clk_ops_no_const clk_pll_ops __read_only = {
39853 .recalc_rate = clk_pll_recalc_rate,
39854 .get_parent = clk_pll_get_parent,
39855 };
39856@@ -120,8 +121,10 @@ static __init struct clk *__socfpga_pll_init(struct device_node *node,
39857 pll_clk->hw.hw.init = &init;
39858
39859 pll_clk->hw.bit_idx = SOCFPGA_PLL_EXT_ENA;
39860- clk_pll_ops.enable = clk_gate_ops.enable;
39861- clk_pll_ops.disable = clk_gate_ops.disable;
39862+ pax_open_kernel();
39863+ *(void **)&clk_pll_ops.enable = clk_gate_ops.enable;
39864+ *(void **)&clk_pll_ops.disable = clk_gate_ops.disable;
39865+ pax_close_kernel();
39866
39867 clk = clk_register(NULL, &pll_clk->hw.hw);
39868 if (WARN_ON(IS_ERR(clk))) {
39869diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
39870index b0c18ed..1713a80 100644
39871--- a/drivers/cpufreq/acpi-cpufreq.c
39872+++ b/drivers/cpufreq/acpi-cpufreq.c
39873@@ -675,8 +675,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
39874 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
39875 per_cpu(acfreq_data, cpu) = data;
39876
39877- if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
39878- acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
39879+ if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
39880+ pax_open_kernel();
39881+ *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
39882+ pax_close_kernel();
39883+ }
39884
39885 result = acpi_processor_register_performance(data->acpi_data, cpu);
39886 if (result)
39887@@ -809,7 +812,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
39888 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
39889 break;
39890 case ACPI_ADR_SPACE_FIXED_HARDWARE:
39891- acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
39892+ pax_open_kernel();
39893+ *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
39894+ pax_close_kernel();
39895 break;
39896 default:
39897 break;
39898@@ -903,8 +908,10 @@ static void __init acpi_cpufreq_boost_init(void)
39899 if (!msrs)
39900 return;
39901
39902- acpi_cpufreq_driver.boost_supported = true;
39903- acpi_cpufreq_driver.boost_enabled = boost_state(0);
39904+ pax_open_kernel();
39905+ *(bool *)&acpi_cpufreq_driver.boost_supported = true;
39906+ *(bool *)&acpi_cpufreq_driver.boost_enabled = boost_state(0);
39907+ pax_close_kernel();
39908
39909 cpu_notifier_register_begin();
39910
39911diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c
39912index bab67db..91af7e3 100644
39913--- a/drivers/cpufreq/cpufreq-dt.c
39914+++ b/drivers/cpufreq/cpufreq-dt.c
39915@@ -392,7 +392,9 @@ static int dt_cpufreq_probe(struct platform_device *pdev)
39916 if (!IS_ERR(cpu_reg))
39917 regulator_put(cpu_reg);
39918
39919- dt_cpufreq_driver.driver_data = dev_get_platdata(&pdev->dev);
39920+ pax_open_kernel();
39921+ *(void **)&dt_cpufreq_driver.driver_data = dev_get_platdata(&pdev->dev);
39922+ pax_close_kernel();
39923
39924 ret = cpufreq_register_driver(&dt_cpufreq_driver);
39925 if (ret)
39926diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
39927index 8ae655c..3141442 100644
39928--- a/drivers/cpufreq/cpufreq.c
39929+++ b/drivers/cpufreq/cpufreq.c
39930@@ -2108,7 +2108,7 @@ void cpufreq_unregister_governor(struct cpufreq_governor *governor)
39931 }
39932
39933 mutex_lock(&cpufreq_governor_mutex);
39934- list_del(&governor->governor_list);
39935+ pax_list_del(&governor->governor_list);
39936 mutex_unlock(&cpufreq_governor_mutex);
39937 return;
39938 }
39939@@ -2323,7 +2323,7 @@ static int cpufreq_cpu_callback(struct notifier_block *nfb,
39940 return NOTIFY_OK;
39941 }
39942
39943-static struct notifier_block __refdata cpufreq_cpu_notifier = {
39944+static struct notifier_block cpufreq_cpu_notifier = {
39945 .notifier_call = cpufreq_cpu_callback,
39946 };
39947
39948@@ -2363,13 +2363,17 @@ int cpufreq_boost_trigger_state(int state)
39949 return 0;
39950
39951 write_lock_irqsave(&cpufreq_driver_lock, flags);
39952- cpufreq_driver->boost_enabled = state;
39953+ pax_open_kernel();
39954+ *(bool *)&cpufreq_driver->boost_enabled = state;
39955+ pax_close_kernel();
39956 write_unlock_irqrestore(&cpufreq_driver_lock, flags);
39957
39958 ret = cpufreq_driver->set_boost(state);
39959 if (ret) {
39960 write_lock_irqsave(&cpufreq_driver_lock, flags);
39961- cpufreq_driver->boost_enabled = !state;
39962+ pax_open_kernel();
39963+ *(bool *)&cpufreq_driver->boost_enabled = !state;
39964+ pax_close_kernel();
39965 write_unlock_irqrestore(&cpufreq_driver_lock, flags);
39966
39967 pr_err("%s: Cannot %s BOOST\n",
39968@@ -2434,16 +2438,22 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
39969 cpufreq_driver = driver_data;
39970 write_unlock_irqrestore(&cpufreq_driver_lock, flags);
39971
39972- if (driver_data->setpolicy)
39973- driver_data->flags |= CPUFREQ_CONST_LOOPS;
39974+ if (driver_data->setpolicy) {
39975+ pax_open_kernel();
39976+ *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
39977+ pax_close_kernel();
39978+ }
39979
39980 if (cpufreq_boost_supported()) {
39981 /*
39982 * Check if driver provides function to enable boost -
39983 * if not, use cpufreq_boost_set_sw as default
39984 */
39985- if (!cpufreq_driver->set_boost)
39986- cpufreq_driver->set_boost = cpufreq_boost_set_sw;
39987+ if (!cpufreq_driver->set_boost) {
39988+ pax_open_kernel();
39989+ *(void **)&cpufreq_driver->set_boost = cpufreq_boost_set_sw;
39990+ pax_close_kernel();
39991+ }
39992
39993 ret = cpufreq_sysfs_create_file(&boost.attr);
39994 if (ret) {
39995diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
39996index 1b44496..b80ff5e 100644
39997--- a/drivers/cpufreq/cpufreq_governor.c
39998+++ b/drivers/cpufreq/cpufreq_governor.c
39999@@ -245,7 +245,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
40000 struct dbs_data *dbs_data;
40001 struct od_cpu_dbs_info_s *od_dbs_info = NULL;
40002 struct cs_cpu_dbs_info_s *cs_dbs_info = NULL;
40003- struct od_ops *od_ops = NULL;
40004+ const struct od_ops *od_ops = NULL;
40005 struct od_dbs_tuners *od_tuners = NULL;
40006 struct cs_dbs_tuners *cs_tuners = NULL;
40007 struct cpu_dbs_common_info *cpu_cdbs;
40008@@ -311,7 +311,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
40009
40010 if ((cdata->governor == GOV_CONSERVATIVE) &&
40011 (!policy->governor->initialized)) {
40012- struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
40013+ const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
40014
40015 cpufreq_register_notifier(cs_ops->notifier_block,
40016 CPUFREQ_TRANSITION_NOTIFIER);
40017@@ -331,7 +331,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
40018
40019 if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) &&
40020 (policy->governor->initialized == 1)) {
40021- struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
40022+ const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
40023
40024 cpufreq_unregister_notifier(cs_ops->notifier_block,
40025 CPUFREQ_TRANSITION_NOTIFIER);
40026diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
40027index cc401d1..8197340 100644
40028--- a/drivers/cpufreq/cpufreq_governor.h
40029+++ b/drivers/cpufreq/cpufreq_governor.h
40030@@ -212,7 +212,7 @@ struct common_dbs_data {
40031 void (*exit)(struct dbs_data *dbs_data);
40032
40033 /* Governor specific ops, see below */
40034- void *gov_ops;
40035+ const void *gov_ops;
40036 };
40037
40038 /* Governor Per policy data */
40039@@ -232,7 +232,7 @@ struct od_ops {
40040 unsigned int (*powersave_bias_target)(struct cpufreq_policy *policy,
40041 unsigned int freq_next, unsigned int relation);
40042 void (*freq_increase)(struct cpufreq_policy *policy, unsigned int freq);
40043-};
40044+} __no_const;
40045
40046 struct cs_ops {
40047 struct notifier_block *notifier_block;
40048diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
40049index ad3f38f..8f086cd 100644
40050--- a/drivers/cpufreq/cpufreq_ondemand.c
40051+++ b/drivers/cpufreq/cpufreq_ondemand.c
40052@@ -524,7 +524,7 @@ static void od_exit(struct dbs_data *dbs_data)
40053
40054 define_get_cpu_dbs_routines(od_cpu_dbs_info);
40055
40056-static struct od_ops od_ops = {
40057+static struct od_ops od_ops __read_only = {
40058 .powersave_bias_init_cpu = ondemand_powersave_bias_init_cpu,
40059 .powersave_bias_target = generic_powersave_bias_target,
40060 .freq_increase = dbs_freq_increase,
40061@@ -579,14 +579,18 @@ void od_register_powersave_bias_handler(unsigned int (*f)
40062 (struct cpufreq_policy *, unsigned int, unsigned int),
40063 unsigned int powersave_bias)
40064 {
40065- od_ops.powersave_bias_target = f;
40066+ pax_open_kernel();
40067+ *(void **)&od_ops.powersave_bias_target = f;
40068+ pax_close_kernel();
40069 od_set_powersave_bias(powersave_bias);
40070 }
40071 EXPORT_SYMBOL_GPL(od_register_powersave_bias_handler);
40072
40073 void od_unregister_powersave_bias_handler(void)
40074 {
40075- od_ops.powersave_bias_target = generic_powersave_bias_target;
40076+ pax_open_kernel();
40077+ *(void **)&od_ops.powersave_bias_target = generic_powersave_bias_target;
40078+ pax_close_kernel();
40079 od_set_powersave_bias(0);
40080 }
40081 EXPORT_SYMBOL_GPL(od_unregister_powersave_bias_handler);
40082diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
40083index c45d274..0f469f7 100644
40084--- a/drivers/cpufreq/intel_pstate.c
40085+++ b/drivers/cpufreq/intel_pstate.c
40086@@ -134,10 +134,10 @@ struct pstate_funcs {
40087 struct cpu_defaults {
40088 struct pstate_adjust_policy pid_policy;
40089 struct pstate_funcs funcs;
40090-};
40091+} __do_const;
40092
40093 static struct pstate_adjust_policy pid_params;
40094-static struct pstate_funcs pstate_funcs;
40095+static struct pstate_funcs *pstate_funcs;
40096 static int hwp_active;
40097
40098 struct perf_limits {
40099@@ -721,18 +721,18 @@ static void intel_pstate_set_pstate(struct cpudata *cpu, int pstate)
40100
40101 cpu->pstate.current_pstate = pstate;
40102
40103- pstate_funcs.set(cpu, pstate);
40104+ pstate_funcs->set(cpu, pstate);
40105 }
40106
40107 static void intel_pstate_get_cpu_pstates(struct cpudata *cpu)
40108 {
40109- cpu->pstate.min_pstate = pstate_funcs.get_min();
40110- cpu->pstate.max_pstate = pstate_funcs.get_max();
40111- cpu->pstate.turbo_pstate = pstate_funcs.get_turbo();
40112- cpu->pstate.scaling = pstate_funcs.get_scaling();
40113+ cpu->pstate.min_pstate = pstate_funcs->get_min();
40114+ cpu->pstate.max_pstate = pstate_funcs->get_max();
40115+ cpu->pstate.turbo_pstate = pstate_funcs->get_turbo();
40116+ cpu->pstate.scaling = pstate_funcs->get_scaling();
40117
40118- if (pstate_funcs.get_vid)
40119- pstate_funcs.get_vid(cpu);
40120+ if (pstate_funcs->get_vid)
40121+ pstate_funcs->get_vid(cpu);
40122 intel_pstate_set_pstate(cpu, cpu->pstate.min_pstate);
40123 }
40124
40125@@ -1056,15 +1056,15 @@ static unsigned int force_load;
40126
40127 static int intel_pstate_msrs_not_valid(void)
40128 {
40129- if (!pstate_funcs.get_max() ||
40130- !pstate_funcs.get_min() ||
40131- !pstate_funcs.get_turbo())
40132+ if (!pstate_funcs->get_max() ||
40133+ !pstate_funcs->get_min() ||
40134+ !pstate_funcs->get_turbo())
40135 return -ENODEV;
40136
40137 return 0;
40138 }
40139
40140-static void copy_pid_params(struct pstate_adjust_policy *policy)
40141+static void copy_pid_params(const struct pstate_adjust_policy *policy)
40142 {
40143 pid_params.sample_rate_ms = policy->sample_rate_ms;
40144 pid_params.p_gain_pct = policy->p_gain_pct;
40145@@ -1076,12 +1076,7 @@ static void copy_pid_params(struct pstate_adjust_policy *policy)
40146
40147 static void copy_cpu_funcs(struct pstate_funcs *funcs)
40148 {
40149- pstate_funcs.get_max = funcs->get_max;
40150- pstate_funcs.get_min = funcs->get_min;
40151- pstate_funcs.get_turbo = funcs->get_turbo;
40152- pstate_funcs.get_scaling = funcs->get_scaling;
40153- pstate_funcs.set = funcs->set;
40154- pstate_funcs.get_vid = funcs->get_vid;
40155+ pstate_funcs = funcs;
40156 }
40157
40158 #if IS_ENABLED(CONFIG_ACPI)
40159diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
40160index 529cfd9..0e28fff 100644
40161--- a/drivers/cpufreq/p4-clockmod.c
40162+++ b/drivers/cpufreq/p4-clockmod.c
40163@@ -134,10 +134,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
40164 case 0x0F: /* Core Duo */
40165 case 0x16: /* Celeron Core */
40166 case 0x1C: /* Atom */
40167- p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
40168+ pax_open_kernel();
40169+ *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
40170+ pax_close_kernel();
40171 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
40172 case 0x0D: /* Pentium M (Dothan) */
40173- p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
40174+ pax_open_kernel();
40175+ *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
40176+ pax_close_kernel();
40177 /* fall through */
40178 case 0x09: /* Pentium M (Banias) */
40179 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
40180@@ -149,7 +153,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
40181
40182 /* on P-4s, the TSC runs with constant frequency independent whether
40183 * throttling is active or not. */
40184- p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
40185+ pax_open_kernel();
40186+ *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
40187+ pax_close_kernel();
40188
40189 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
40190 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
40191diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
40192index 9bb42ba..b01b4a2 100644
40193--- a/drivers/cpufreq/sparc-us3-cpufreq.c
40194+++ b/drivers/cpufreq/sparc-us3-cpufreq.c
40195@@ -18,14 +18,12 @@
40196 #include <asm/head.h>
40197 #include <asm/timer.h>
40198
40199-static struct cpufreq_driver *cpufreq_us3_driver;
40200-
40201 struct us3_freq_percpu_info {
40202 struct cpufreq_frequency_table table[4];
40203 };
40204
40205 /* Indexed by cpu number. */
40206-static struct us3_freq_percpu_info *us3_freq_table;
40207+static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
40208
40209 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
40210 * in the Safari config register.
40211@@ -156,16 +154,27 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
40212
40213 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
40214 {
40215- if (cpufreq_us3_driver)
40216- us3_freq_target(policy, 0);
40217+ us3_freq_target(policy, 0);
40218
40219 return 0;
40220 }
40221
40222+static int __init us3_freq_init(void);
40223+static void __exit us3_freq_exit(void);
40224+
40225+static struct cpufreq_driver cpufreq_us3_driver = {
40226+ .init = us3_freq_cpu_init,
40227+ .verify = cpufreq_generic_frequency_table_verify,
40228+ .target_index = us3_freq_target,
40229+ .get = us3_freq_get,
40230+ .exit = us3_freq_cpu_exit,
40231+ .name = "UltraSPARC-III",
40232+
40233+};
40234+
40235 static int __init us3_freq_init(void)
40236 {
40237 unsigned long manuf, impl, ver;
40238- int ret;
40239
40240 if (tlb_type != cheetah && tlb_type != cheetah_plus)
40241 return -ENODEV;
40242@@ -178,55 +187,15 @@ static int __init us3_freq_init(void)
40243 (impl == CHEETAH_IMPL ||
40244 impl == CHEETAH_PLUS_IMPL ||
40245 impl == JAGUAR_IMPL ||
40246- impl == PANTHER_IMPL)) {
40247- struct cpufreq_driver *driver;
40248-
40249- ret = -ENOMEM;
40250- driver = kzalloc(sizeof(*driver), GFP_KERNEL);
40251- if (!driver)
40252- goto err_out;
40253-
40254- us3_freq_table = kzalloc((NR_CPUS * sizeof(*us3_freq_table)),
40255- GFP_KERNEL);
40256- if (!us3_freq_table)
40257- goto err_out;
40258-
40259- driver->init = us3_freq_cpu_init;
40260- driver->verify = cpufreq_generic_frequency_table_verify;
40261- driver->target_index = us3_freq_target;
40262- driver->get = us3_freq_get;
40263- driver->exit = us3_freq_cpu_exit;
40264- strcpy(driver->name, "UltraSPARC-III");
40265-
40266- cpufreq_us3_driver = driver;
40267- ret = cpufreq_register_driver(driver);
40268- if (ret)
40269- goto err_out;
40270-
40271- return 0;
40272-
40273-err_out:
40274- if (driver) {
40275- kfree(driver);
40276- cpufreq_us3_driver = NULL;
40277- }
40278- kfree(us3_freq_table);
40279- us3_freq_table = NULL;
40280- return ret;
40281- }
40282+ impl == PANTHER_IMPL))
40283+ return cpufreq_register_driver(&cpufreq_us3_driver);
40284
40285 return -ENODEV;
40286 }
40287
40288 static void __exit us3_freq_exit(void)
40289 {
40290- if (cpufreq_us3_driver) {
40291- cpufreq_unregister_driver(cpufreq_us3_driver);
40292- kfree(cpufreq_us3_driver);
40293- cpufreq_us3_driver = NULL;
40294- kfree(us3_freq_table);
40295- us3_freq_table = NULL;
40296- }
40297+ cpufreq_unregister_driver(&cpufreq_us3_driver);
40298 }
40299
40300 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
40301diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
40302index 7d4a315..21bb886 100644
40303--- a/drivers/cpufreq/speedstep-centrino.c
40304+++ b/drivers/cpufreq/speedstep-centrino.c
40305@@ -351,8 +351,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
40306 !cpu_has(cpu, X86_FEATURE_EST))
40307 return -ENODEV;
40308
40309- if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
40310- centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
40311+ if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
40312+ pax_open_kernel();
40313+ *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
40314+ pax_close_kernel();
40315+ }
40316
40317 if (policy->cpu != 0)
40318 return -ENODEV;
40319diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c
40320index 5db1478..e90e25e 100644
40321--- a/drivers/cpuidle/driver.c
40322+++ b/drivers/cpuidle/driver.c
40323@@ -193,7 +193,7 @@ static int poll_idle(struct cpuidle_device *dev,
40324
40325 static void poll_idle_init(struct cpuidle_driver *drv)
40326 {
40327- struct cpuidle_state *state = &drv->states[0];
40328+ cpuidle_state_no_const *state = &drv->states[0];
40329
40330 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
40331 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
40332diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
40333index fb9f511..213e6cc 100644
40334--- a/drivers/cpuidle/governor.c
40335+++ b/drivers/cpuidle/governor.c
40336@@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
40337 mutex_lock(&cpuidle_lock);
40338 if (__cpuidle_find_governor(gov->name) == NULL) {
40339 ret = 0;
40340- list_add_tail(&gov->governor_list, &cpuidle_governors);
40341+ pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
40342 if (!cpuidle_curr_governor ||
40343 cpuidle_curr_governor->rating < gov->rating)
40344 cpuidle_switch_governor(gov);
40345diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
40346index 832a2c3..1794080 100644
40347--- a/drivers/cpuidle/sysfs.c
40348+++ b/drivers/cpuidle/sysfs.c
40349@@ -135,7 +135,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
40350 NULL
40351 };
40352
40353-static struct attribute_group cpuidle_attr_group = {
40354+static attribute_group_no_const cpuidle_attr_group = {
40355 .attrs = cpuidle_default_attrs,
40356 .name = "cpuidle",
40357 };
40358diff --git a/drivers/crypto/hifn_795x.c b/drivers/crypto/hifn_795x.c
40359index 8d2a772..33826c9 100644
40360--- a/drivers/crypto/hifn_795x.c
40361+++ b/drivers/crypto/hifn_795x.c
40362@@ -51,7 +51,7 @@ module_param_string(hifn_pll_ref, hifn_pll_ref, sizeof(hifn_pll_ref), 0444);
40363 MODULE_PARM_DESC(hifn_pll_ref,
40364 "PLL reference clock (pci[freq] or ext[freq], default ext)");
40365
40366-static atomic_t hifn_dev_number;
40367+static atomic_unchecked_t hifn_dev_number;
40368
40369 #define ACRYPTO_OP_DECRYPT 0
40370 #define ACRYPTO_OP_ENCRYPT 1
40371@@ -2577,7 +2577,7 @@ static int hifn_probe(struct pci_dev *pdev, const struct pci_device_id *id)
40372 goto err_out_disable_pci_device;
40373
40374 snprintf(name, sizeof(name), "hifn%d",
40375- atomic_inc_return(&hifn_dev_number)-1);
40376+ atomic_inc_return_unchecked(&hifn_dev_number)-1);
40377
40378 err = pci_request_regions(pdev, name);
40379 if (err)
40380diff --git a/drivers/crypto/omap-des.c b/drivers/crypto/omap-des.c
40381index 4630709..0a70e46 100644
40382--- a/drivers/crypto/omap-des.c
40383+++ b/drivers/crypto/omap-des.c
40384@@ -536,9 +536,6 @@ static int omap_des_crypt_dma_stop(struct omap_des_dev *dd)
40385 dmaengine_terminate_all(dd->dma_lch_in);
40386 dmaengine_terminate_all(dd->dma_lch_out);
40387
40388- dma_unmap_sg(dd->dev, dd->in_sg, dd->in_sg_len, DMA_TO_DEVICE);
40389- dma_unmap_sg(dd->dev, dd->out_sg, dd->out_sg_len, DMA_FROM_DEVICE);
40390-
40391 return err;
40392 }
40393
40394diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
40395index ca1b362..01cae6a 100644
40396--- a/drivers/devfreq/devfreq.c
40397+++ b/drivers/devfreq/devfreq.c
40398@@ -672,7 +672,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
40399 goto err_out;
40400 }
40401
40402- list_add(&governor->node, &devfreq_governor_list);
40403+ pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
40404
40405 list_for_each_entry(devfreq, &devfreq_list, node) {
40406 int ret = 0;
40407@@ -760,7 +760,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
40408 }
40409 }
40410
40411- list_del(&governor->node);
40412+ pax_list_del((struct list_head *)&governor->node);
40413 err_out:
40414 mutex_unlock(&devfreq_list_lock);
40415
40416diff --git a/drivers/dma/sh/shdma-base.c b/drivers/dma/sh/shdma-base.c
40417index 10fcaba..326f709 100644
40418--- a/drivers/dma/sh/shdma-base.c
40419+++ b/drivers/dma/sh/shdma-base.c
40420@@ -227,8 +227,8 @@ static int shdma_alloc_chan_resources(struct dma_chan *chan)
40421 schan->slave_id = -EINVAL;
40422 }
40423
40424- schan->desc = kcalloc(NR_DESCS_PER_CHANNEL,
40425- sdev->desc_size, GFP_KERNEL);
40426+ schan->desc = kcalloc(sdev->desc_size,
40427+ NR_DESCS_PER_CHANNEL, GFP_KERNEL);
40428 if (!schan->desc) {
40429 ret = -ENOMEM;
40430 goto edescalloc;
40431diff --git a/drivers/dma/sh/shdmac.c b/drivers/dma/sh/shdmac.c
40432index 11707df..2ea96f7 100644
40433--- a/drivers/dma/sh/shdmac.c
40434+++ b/drivers/dma/sh/shdmac.c
40435@@ -513,7 +513,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
40436 return ret;
40437 }
40438
40439-static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
40440+static struct notifier_block sh_dmae_nmi_notifier = {
40441 .notifier_call = sh_dmae_nmi_handler,
40442
40443 /* Run before NMI debug handler and KGDB */
40444diff --git a/drivers/edac/edac_device.c b/drivers/edac/edac_device.c
40445index 592af5f..bb1d583 100644
40446--- a/drivers/edac/edac_device.c
40447+++ b/drivers/edac/edac_device.c
40448@@ -477,9 +477,9 @@ void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev,
40449 */
40450 int edac_device_alloc_index(void)
40451 {
40452- static atomic_t device_indexes = ATOMIC_INIT(0);
40453+ static atomic_unchecked_t device_indexes = ATOMIC_INIT(0);
40454
40455- return atomic_inc_return(&device_indexes) - 1;
40456+ return atomic_inc_return_unchecked(&device_indexes) - 1;
40457 }
40458 EXPORT_SYMBOL_GPL(edac_device_alloc_index);
40459
40460diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
40461index 112d63a..5443a61 100644
40462--- a/drivers/edac/edac_mc_sysfs.c
40463+++ b/drivers/edac/edac_mc_sysfs.c
40464@@ -154,7 +154,7 @@ static const char * const edac_caps[] = {
40465 struct dev_ch_attribute {
40466 struct device_attribute attr;
40467 int channel;
40468-};
40469+} __do_const;
40470
40471 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
40472 static struct dev_ch_attribute dev_attr_legacy_##_name = \
40473diff --git a/drivers/edac/edac_pci.c b/drivers/edac/edac_pci.c
40474index 2cf44b4d..6dd2dc7 100644
40475--- a/drivers/edac/edac_pci.c
40476+++ b/drivers/edac/edac_pci.c
40477@@ -29,7 +29,7 @@
40478
40479 static DEFINE_MUTEX(edac_pci_ctls_mutex);
40480 static LIST_HEAD(edac_pci_list);
40481-static atomic_t pci_indexes = ATOMIC_INIT(0);
40482+static atomic_unchecked_t pci_indexes = ATOMIC_INIT(0);
40483
40484 /*
40485 * edac_pci_alloc_ctl_info
40486@@ -315,7 +315,7 @@ EXPORT_SYMBOL_GPL(edac_pci_reset_delay_period);
40487 */
40488 int edac_pci_alloc_index(void)
40489 {
40490- return atomic_inc_return(&pci_indexes) - 1;
40491+ return atomic_inc_return_unchecked(&pci_indexes) - 1;
40492 }
40493 EXPORT_SYMBOL_GPL(edac_pci_alloc_index);
40494
40495diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
40496index 24d877f..4e30133 100644
40497--- a/drivers/edac/edac_pci_sysfs.c
40498+++ b/drivers/edac/edac_pci_sysfs.c
40499@@ -23,8 +23,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
40500 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
40501 static int edac_pci_poll_msec = 1000; /* one second workq period */
40502
40503-static atomic_t pci_parity_count = ATOMIC_INIT(0);
40504-static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
40505+static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
40506+static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
40507
40508 static struct kobject *edac_pci_top_main_kobj;
40509 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
40510@@ -232,7 +232,7 @@ struct edac_pci_dev_attribute {
40511 void *value;
40512 ssize_t(*show) (void *, char *);
40513 ssize_t(*store) (void *, const char *, size_t);
40514-};
40515+} __do_const;
40516
40517 /* Set of show/store abstract level functions for PCI Parity object */
40518 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
40519@@ -576,7 +576,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
40520 edac_printk(KERN_CRIT, EDAC_PCI,
40521 "Signaled System Error on %s\n",
40522 pci_name(dev));
40523- atomic_inc(&pci_nonparity_count);
40524+ atomic_inc_unchecked(&pci_nonparity_count);
40525 }
40526
40527 if (status & (PCI_STATUS_PARITY)) {
40528@@ -584,7 +584,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
40529 "Master Data Parity Error on %s\n",
40530 pci_name(dev));
40531
40532- atomic_inc(&pci_parity_count);
40533+ atomic_inc_unchecked(&pci_parity_count);
40534 }
40535
40536 if (status & (PCI_STATUS_DETECTED_PARITY)) {
40537@@ -592,7 +592,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
40538 "Detected Parity Error on %s\n",
40539 pci_name(dev));
40540
40541- atomic_inc(&pci_parity_count);
40542+ atomic_inc_unchecked(&pci_parity_count);
40543 }
40544 }
40545
40546@@ -615,7 +615,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
40547 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
40548 "Signaled System Error on %s\n",
40549 pci_name(dev));
40550- atomic_inc(&pci_nonparity_count);
40551+ atomic_inc_unchecked(&pci_nonparity_count);
40552 }
40553
40554 if (status & (PCI_STATUS_PARITY)) {
40555@@ -623,7 +623,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
40556 "Master Data Parity Error on "
40557 "%s\n", pci_name(dev));
40558
40559- atomic_inc(&pci_parity_count);
40560+ atomic_inc_unchecked(&pci_parity_count);
40561 }
40562
40563 if (status & (PCI_STATUS_DETECTED_PARITY)) {
40564@@ -631,7 +631,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
40565 "Detected Parity Error on %s\n",
40566 pci_name(dev));
40567
40568- atomic_inc(&pci_parity_count);
40569+ atomic_inc_unchecked(&pci_parity_count);
40570 }
40571 }
40572 }
40573@@ -669,7 +669,7 @@ void edac_pci_do_parity_check(void)
40574 if (!check_pci_errors)
40575 return;
40576
40577- before_count = atomic_read(&pci_parity_count);
40578+ before_count = atomic_read_unchecked(&pci_parity_count);
40579
40580 /* scan all PCI devices looking for a Parity Error on devices and
40581 * bridges.
40582@@ -681,7 +681,7 @@ void edac_pci_do_parity_check(void)
40583 /* Only if operator has selected panic on PCI Error */
40584 if (edac_pci_get_panic_on_pe()) {
40585 /* If the count is different 'after' from 'before' */
40586- if (before_count != atomic_read(&pci_parity_count))
40587+ if (before_count != atomic_read_unchecked(&pci_parity_count))
40588 panic("EDAC: PCI Parity Error");
40589 }
40590 }
40591diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
40592index c2359a1..8bd119d 100644
40593--- a/drivers/edac/mce_amd.h
40594+++ b/drivers/edac/mce_amd.h
40595@@ -74,7 +74,7 @@ struct amd_decoder_ops {
40596 bool (*mc0_mce)(u16, u8);
40597 bool (*mc1_mce)(u16, u8);
40598 bool (*mc2_mce)(u16, u8);
40599-};
40600+} __no_const;
40601
40602 void amd_report_gart_errors(bool);
40603 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
40604diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
40605index 57ea7f4..af06b76 100644
40606--- a/drivers/firewire/core-card.c
40607+++ b/drivers/firewire/core-card.c
40608@@ -528,9 +528,9 @@ void fw_card_initialize(struct fw_card *card,
40609 const struct fw_card_driver *driver,
40610 struct device *device)
40611 {
40612- static atomic_t index = ATOMIC_INIT(-1);
40613+ static atomic_unchecked_t index = ATOMIC_INIT(-1);
40614
40615- card->index = atomic_inc_return(&index);
40616+ card->index = atomic_inc_return_unchecked(&index);
40617 card->driver = driver;
40618 card->device = device;
40619 card->current_tlabel = 0;
40620@@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
40621
40622 void fw_core_remove_card(struct fw_card *card)
40623 {
40624- struct fw_card_driver dummy_driver = dummy_driver_template;
40625+ fw_card_driver_no_const dummy_driver = dummy_driver_template;
40626
40627 card->driver->update_phy_reg(card, 4,
40628 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
40629diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
40630index f9e3aee..269dbdb 100644
40631--- a/drivers/firewire/core-device.c
40632+++ b/drivers/firewire/core-device.c
40633@@ -256,7 +256,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
40634 struct config_rom_attribute {
40635 struct device_attribute attr;
40636 u32 key;
40637-};
40638+} __do_const;
40639
40640 static ssize_t show_immediate(struct device *dev,
40641 struct device_attribute *dattr, char *buf)
40642diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
40643index d6a09b9..18e90dd 100644
40644--- a/drivers/firewire/core-transaction.c
40645+++ b/drivers/firewire/core-transaction.c
40646@@ -38,6 +38,7 @@
40647 #include <linux/timer.h>
40648 #include <linux/types.h>
40649 #include <linux/workqueue.h>
40650+#include <linux/sched.h>
40651
40652 #include <asm/byteorder.h>
40653
40654diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
40655index e1480ff6..1a429bd 100644
40656--- a/drivers/firewire/core.h
40657+++ b/drivers/firewire/core.h
40658@@ -111,6 +111,7 @@ struct fw_card_driver {
40659
40660 int (*stop_iso)(struct fw_iso_context *ctx);
40661 };
40662+typedef struct fw_card_driver __no_const fw_card_driver_no_const;
40663
40664 void fw_card_initialize(struct fw_card *card,
40665 const struct fw_card_driver *driver, struct device *device);
40666diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c
40667index f51d376..b118e40 100644
40668--- a/drivers/firewire/ohci.c
40669+++ b/drivers/firewire/ohci.c
40670@@ -2049,10 +2049,12 @@ static void bus_reset_work(struct work_struct *work)
40671 be32_to_cpu(ohci->next_header));
40672 }
40673
40674+#ifndef CONFIG_GRKERNSEC
40675 if (param_remote_dma) {
40676 reg_write(ohci, OHCI1394_PhyReqFilterHiSet, ~0);
40677 reg_write(ohci, OHCI1394_PhyReqFilterLoSet, ~0);
40678 }
40679+#endif
40680
40681 spin_unlock_irq(&ohci->lock);
40682
40683@@ -2584,8 +2586,10 @@ static int ohci_enable_phys_dma(struct fw_card *card,
40684 unsigned long flags;
40685 int n, ret = 0;
40686
40687+#ifndef CONFIG_GRKERNSEC
40688 if (param_remote_dma)
40689 return 0;
40690+#endif
40691
40692 /*
40693 * FIXME: Make sure this bitmask is cleared when we clear the busReset
40694diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
40695index 94a58a0..f5eba42 100644
40696--- a/drivers/firmware/dmi-id.c
40697+++ b/drivers/firmware/dmi-id.c
40698@@ -16,7 +16,7 @@
40699 struct dmi_device_attribute{
40700 struct device_attribute dev_attr;
40701 int field;
40702-};
40703+} __do_const;
40704 #define to_dmi_dev_attr(_dev_attr) \
40705 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
40706
40707diff --git a/drivers/firmware/efi/cper.c b/drivers/firmware/efi/cper.c
40708index 4fd9961..52d60ce 100644
40709--- a/drivers/firmware/efi/cper.c
40710+++ b/drivers/firmware/efi/cper.c
40711@@ -44,12 +44,12 @@ static char rcd_decode_str[CPER_REC_LEN];
40712 */
40713 u64 cper_next_record_id(void)
40714 {
40715- static atomic64_t seq;
40716+ static atomic64_unchecked_t seq;
40717
40718- if (!atomic64_read(&seq))
40719- atomic64_set(&seq, ((u64)get_seconds()) << 32);
40720+ if (!atomic64_read_unchecked(&seq))
40721+ atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
40722
40723- return atomic64_inc_return(&seq);
40724+ return atomic64_inc_return_unchecked(&seq);
40725 }
40726 EXPORT_SYMBOL_GPL(cper_next_record_id);
40727
40728diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
40729index e14363d..302716e 100644
40730--- a/drivers/firmware/efi/efi.c
40731+++ b/drivers/firmware/efi/efi.c
40732@@ -57,6 +57,11 @@ bool efi_runtime_disabled(void)
40733
40734 static int __init parse_efi_cmdline(char *str)
40735 {
40736+ if (!str) {
40737+ pr_warn("need at least one option\n");
40738+ return -EINVAL;
40739+ }
40740+
40741 if (parse_option_str(str, "noruntime"))
40742 disable_runtime = true;
40743
40744@@ -159,14 +164,16 @@ static struct attribute_group efi_subsys_attr_group = {
40745 };
40746
40747 static struct efivars generic_efivars;
40748-static struct efivar_operations generic_ops;
40749+static efivar_operations_no_const generic_ops __read_only;
40750
40751 static int generic_ops_register(void)
40752 {
40753- generic_ops.get_variable = efi.get_variable;
40754- generic_ops.set_variable = efi.set_variable;
40755- generic_ops.get_next_variable = efi.get_next_variable;
40756- generic_ops.query_variable_store = efi_query_variable_store;
40757+ pax_open_kernel();
40758+ *(void **)&generic_ops.get_variable = efi.get_variable;
40759+ *(void **)&generic_ops.set_variable = efi.set_variable;
40760+ *(void **)&generic_ops.get_next_variable = efi.get_next_variable;
40761+ *(void **)&generic_ops.query_variable_store = efi_query_variable_store;
40762+ pax_close_kernel();
40763
40764 return efivars_register(&generic_efivars, &generic_ops, efi_kobj);
40765 }
40766diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
40767index 7b2e049..a253334 100644
40768--- a/drivers/firmware/efi/efivars.c
40769+++ b/drivers/firmware/efi/efivars.c
40770@@ -589,7 +589,7 @@ efivar_create_sysfs_entry(struct efivar_entry *new_var)
40771 static int
40772 create_efivars_bin_attributes(void)
40773 {
40774- struct bin_attribute *attr;
40775+ bin_attribute_no_const *attr;
40776 int error;
40777
40778 /* new_var */
40779diff --git a/drivers/firmware/efi/runtime-map.c b/drivers/firmware/efi/runtime-map.c
40780index 5c55227..97f4978 100644
40781--- a/drivers/firmware/efi/runtime-map.c
40782+++ b/drivers/firmware/efi/runtime-map.c
40783@@ -97,7 +97,7 @@ static void map_release(struct kobject *kobj)
40784 kfree(entry);
40785 }
40786
40787-static struct kobj_type __refdata map_ktype = {
40788+static const struct kobj_type __refconst map_ktype = {
40789 .sysfs_ops = &map_attr_ops,
40790 .default_attrs = def_attrs,
40791 .release = map_release,
40792diff --git a/drivers/firmware/google/gsmi.c b/drivers/firmware/google/gsmi.c
40793index f1ab05e..ab51228 100644
40794--- a/drivers/firmware/google/gsmi.c
40795+++ b/drivers/firmware/google/gsmi.c
40796@@ -709,7 +709,7 @@ static u32 __init hash_oem_table_id(char s[8])
40797 return local_hash_64(input, 32);
40798 }
40799
40800-static struct dmi_system_id gsmi_dmi_table[] __initdata = {
40801+static const struct dmi_system_id gsmi_dmi_table[] __initconst = {
40802 {
40803 .ident = "Google Board",
40804 .matches = {
40805diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
40806index 2f569aa..26e4f39 100644
40807--- a/drivers/firmware/google/memconsole.c
40808+++ b/drivers/firmware/google/memconsole.c
40809@@ -136,7 +136,7 @@ static bool __init found_memconsole(void)
40810 return false;
40811 }
40812
40813-static struct dmi_system_id memconsole_dmi_table[] __initdata = {
40814+static const struct dmi_system_id memconsole_dmi_table[] __initconst = {
40815 {
40816 .ident = "Google Board",
40817 .matches = {
40818@@ -155,7 +155,10 @@ static int __init memconsole_init(void)
40819 if (!found_memconsole())
40820 return -ENODEV;
40821
40822- memconsole_bin_attr.size = memconsole_length;
40823+ pax_open_kernel();
40824+ *(size_t *)&memconsole_bin_attr.size = memconsole_length;
40825+ pax_close_kernel();
40826+
40827 return sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
40828 }
40829
40830diff --git a/drivers/firmware/memmap.c b/drivers/firmware/memmap.c
40831index cc016c61..d35279e 100644
40832--- a/drivers/firmware/memmap.c
40833+++ b/drivers/firmware/memmap.c
40834@@ -124,7 +124,7 @@ static void __meminit release_firmware_map_entry(struct kobject *kobj)
40835 kfree(entry);
40836 }
40837
40838-static struct kobj_type __refdata memmap_ktype = {
40839+static const struct kobj_type __refconst memmap_ktype = {
40840 .release = release_firmware_map_entry,
40841 .sysfs_ops = &memmap_attr_ops,
40842 .default_attrs = def_attrs,
40843diff --git a/drivers/gpio/gpio-em.c b/drivers/gpio/gpio-em.c
40844index 3cfcfc6..09d6f117 100644
40845--- a/drivers/gpio/gpio-em.c
40846+++ b/drivers/gpio/gpio-em.c
40847@@ -278,7 +278,7 @@ static int em_gio_probe(struct platform_device *pdev)
40848 struct em_gio_priv *p;
40849 struct resource *io[2], *irq[2];
40850 struct gpio_chip *gpio_chip;
40851- struct irq_chip *irq_chip;
40852+ irq_chip_no_const *irq_chip;
40853 const char *name = dev_name(&pdev->dev);
40854 int ret;
40855
40856diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
40857index 4ba7ed5..1536b5d 100644
40858--- a/drivers/gpio/gpio-ich.c
40859+++ b/drivers/gpio/gpio-ich.c
40860@@ -94,7 +94,7 @@ struct ichx_desc {
40861 * this option allows driver caching written output values
40862 */
40863 bool use_outlvl_cache;
40864-};
40865+} __do_const;
40866
40867 static struct {
40868 spinlock_t lock;
40869diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
40870index b232397..ce8c4dc 100644
40871--- a/drivers/gpio/gpio-omap.c
40872+++ b/drivers/gpio/gpio-omap.c
40873@@ -1054,7 +1054,7 @@ static void omap_gpio_mod_init(struct gpio_bank *bank)
40874 dev_err(bank->dev, "Could not get gpio dbck\n");
40875 }
40876
40877-static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc)
40878+static int omap_gpio_chip_init(struct gpio_bank *bank, irq_chip_no_const *irqc)
40879 {
40880 static int gpio;
40881 int irq_base = 0;
40882@@ -1137,7 +1137,7 @@ static int omap_gpio_probe(struct platform_device *pdev)
40883 const struct omap_gpio_platform_data *pdata;
40884 struct resource *res;
40885 struct gpio_bank *bank;
40886- struct irq_chip *irqc;
40887+ irq_chip_no_const *irqc;
40888 int ret;
40889
40890 match = of_match_device(of_match_ptr(omap_gpio_match), dev);
40891diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
40892index 1e14a6c..0442450 100644
40893--- a/drivers/gpio/gpio-rcar.c
40894+++ b/drivers/gpio/gpio-rcar.c
40895@@ -379,7 +379,7 @@ static int gpio_rcar_probe(struct platform_device *pdev)
40896 struct gpio_rcar_priv *p;
40897 struct resource *io, *irq;
40898 struct gpio_chip *gpio_chip;
40899- struct irq_chip *irq_chip;
40900+ irq_chip_no_const *irq_chip;
40901 struct device *dev = &pdev->dev;
40902 const char *name = dev_name(dev);
40903 int ret;
40904diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
40905index c1caa45..f0f97d2 100644
40906--- a/drivers/gpio/gpio-vr41xx.c
40907+++ b/drivers/gpio/gpio-vr41xx.c
40908@@ -224,7 +224,7 @@ static int giu_get_irq(unsigned int irq)
40909 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
40910 maskl, pendl, maskh, pendh);
40911
40912- atomic_inc(&irq_err_count);
40913+ atomic_inc_unchecked(&irq_err_count);
40914
40915 return -EINVAL;
40916 }
40917diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
40918index 6bc612b..3932464 100644
40919--- a/drivers/gpio/gpiolib.c
40920+++ b/drivers/gpio/gpiolib.c
40921@@ -558,8 +558,10 @@ static void gpiochip_irqchip_remove(struct gpio_chip *gpiochip)
40922 }
40923
40924 if (gpiochip->irqchip) {
40925- gpiochip->irqchip->irq_request_resources = NULL;
40926- gpiochip->irqchip->irq_release_resources = NULL;
40927+ pax_open_kernel();
40928+ *(void **)&gpiochip->irqchip->irq_request_resources = NULL;
40929+ *(void **)&gpiochip->irqchip->irq_release_resources = NULL;
40930+ pax_close_kernel();
40931 gpiochip->irqchip = NULL;
40932 }
40933 }
40934@@ -625,8 +627,11 @@ int gpiochip_irqchip_add(struct gpio_chip *gpiochip,
40935 gpiochip->irqchip = NULL;
40936 return -EINVAL;
40937 }
40938- irqchip->irq_request_resources = gpiochip_irq_reqres;
40939- irqchip->irq_release_resources = gpiochip_irq_relres;
40940+
40941+ pax_open_kernel();
40942+ *(void **)&irqchip->irq_request_resources = gpiochip_irq_reqres;
40943+ *(void **)&irqchip->irq_release_resources = gpiochip_irq_relres;
40944+ pax_close_kernel();
40945
40946 /*
40947 * Prepare the mapping since the irqchip shall be orthogonal to
40948diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h
40949index 488f51d..301d462 100644
40950--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h
40951+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h
40952@@ -118,7 +118,7 @@ struct device_queue_manager_ops {
40953 enum cache_policy alternate_policy,
40954 void __user *alternate_aperture_base,
40955 uint64_t alternate_aperture_size);
40956-};
40957+} __no_const;
40958
40959 /**
40960 * struct device_queue_manager
40961diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.h b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.h
40962index 5940531..a75b0e5 100644
40963--- a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.h
40964+++ b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.h
40965@@ -62,7 +62,7 @@ struct kernel_queue_ops {
40966
40967 void (*submit_packet)(struct kernel_queue *kq);
40968 void (*rollback_packet)(struct kernel_queue *kq);
40969-};
40970+} __no_const;
40971
40972 struct kernel_queue {
40973 struct kernel_queue_ops ops;
40974diff --git a/drivers/gpu/drm/drm_context.c b/drivers/gpu/drm/drm_context.c
40975index 9b23525..65f4110 100644
40976--- a/drivers/gpu/drm/drm_context.c
40977+++ b/drivers/gpu/drm/drm_context.c
40978@@ -53,6 +53,9 @@ struct drm_ctx_list {
40979 */
40980 void drm_legacy_ctxbitmap_free(struct drm_device * dev, int ctx_handle)
40981 {
40982+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
40983+ return;
40984+
40985 mutex_lock(&dev->struct_mutex);
40986 idr_remove(&dev->ctx_idr, ctx_handle);
40987 mutex_unlock(&dev->struct_mutex);
40988@@ -87,6 +90,9 @@ static int drm_legacy_ctxbitmap_next(struct drm_device * dev)
40989 */
40990 int drm_legacy_ctxbitmap_init(struct drm_device * dev)
40991 {
40992+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
40993+ return -EINVAL;
40994+
40995 idr_init(&dev->ctx_idr);
40996 return 0;
40997 }
40998@@ -101,6 +107,9 @@ int drm_legacy_ctxbitmap_init(struct drm_device * dev)
40999 */
41000 void drm_legacy_ctxbitmap_cleanup(struct drm_device * dev)
41001 {
41002+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
41003+ return;
41004+
41005 mutex_lock(&dev->struct_mutex);
41006 idr_destroy(&dev->ctx_idr);
41007 mutex_unlock(&dev->struct_mutex);
41008@@ -119,11 +128,14 @@ void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file)
41009 {
41010 struct drm_ctx_list *pos, *tmp;
41011
41012+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
41013+ return;
41014+
41015 mutex_lock(&dev->ctxlist_mutex);
41016
41017 list_for_each_entry_safe(pos, tmp, &dev->ctxlist, head) {
41018 if (pos->tag == file &&
41019- pos->handle != DRM_KERNEL_CONTEXT) {
41020+ _DRM_LOCKING_CONTEXT(pos->handle) != DRM_KERNEL_CONTEXT) {
41021 if (dev->driver->context_dtor)
41022 dev->driver->context_dtor(dev, pos->handle);
41023
41024@@ -161,6 +173,9 @@ int drm_legacy_getsareactx(struct drm_device *dev, void *data,
41025 struct drm_local_map *map;
41026 struct drm_map_list *_entry;
41027
41028+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
41029+ return -EINVAL;
41030+
41031 mutex_lock(&dev->struct_mutex);
41032
41033 map = idr_find(&dev->ctx_idr, request->ctx_id);
41034@@ -205,6 +220,9 @@ int drm_legacy_setsareactx(struct drm_device *dev, void *data,
41035 struct drm_local_map *map = NULL;
41036 struct drm_map_list *r_list = NULL;
41037
41038+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
41039+ return -EINVAL;
41040+
41041 mutex_lock(&dev->struct_mutex);
41042 list_for_each_entry(r_list, &dev->maplist, head) {
41043 if (r_list->map
41044@@ -277,7 +295,13 @@ static int drm_context_switch_complete(struct drm_device *dev,
41045 {
41046 dev->last_context = new; /* PRE/POST: This is the _only_ writer. */
41047
41048- if (!_DRM_LOCK_IS_HELD(file_priv->master->lock.hw_lock->lock)) {
41049+ if (file_priv->master->lock.hw_lock == NULL) {
41050+ DRM_ERROR(
41051+ "Device has been unregistered. Hard exit. Process %d\n",
41052+ task_pid_nr(current));
41053+ send_sig(SIGTERM, current, 0);
41054+ return -EPERM;
41055+ } else if (!_DRM_LOCK_IS_HELD(file_priv->master->lock.hw_lock->lock)) {
41056 DRM_ERROR("Lock isn't held after context switch\n");
41057 }
41058
41059@@ -305,6 +329,9 @@ int drm_legacy_resctx(struct drm_device *dev, void *data,
41060 struct drm_ctx ctx;
41061 int i;
41062
41063+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
41064+ return -EINVAL;
41065+
41066 if (res->count >= DRM_RESERVED_CONTEXTS) {
41067 memset(&ctx, 0, sizeof(ctx));
41068 for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) {
41069@@ -335,8 +362,11 @@ int drm_legacy_addctx(struct drm_device *dev, void *data,
41070 struct drm_ctx_list *ctx_entry;
41071 struct drm_ctx *ctx = data;
41072
41073+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
41074+ return -EINVAL;
41075+
41076 ctx->handle = drm_legacy_ctxbitmap_next(dev);
41077- if (ctx->handle == DRM_KERNEL_CONTEXT) {
41078+ if (_DRM_LOCKING_CONTEXT(ctx->handle) == DRM_KERNEL_CONTEXT) {
41079 /* Skip kernel's context and get a new one. */
41080 ctx->handle = drm_legacy_ctxbitmap_next(dev);
41081 }
41082@@ -378,6 +408,9 @@ int drm_legacy_getctx(struct drm_device *dev, void *data,
41083 {
41084 struct drm_ctx *ctx = data;
41085
41086+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
41087+ return -EINVAL;
41088+
41089 /* This is 0, because we don't handle any context flags */
41090 ctx->flags = 0;
41091
41092@@ -400,6 +433,9 @@ int drm_legacy_switchctx(struct drm_device *dev, void *data,
41093 {
41094 struct drm_ctx *ctx = data;
41095
41096+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
41097+ return -EINVAL;
41098+
41099 DRM_DEBUG("%d\n", ctx->handle);
41100 return drm_context_switch(dev, dev->last_context, ctx->handle);
41101 }
41102@@ -420,6 +456,9 @@ int drm_legacy_newctx(struct drm_device *dev, void *data,
41103 {
41104 struct drm_ctx *ctx = data;
41105
41106+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
41107+ return -EINVAL;
41108+
41109 DRM_DEBUG("%d\n", ctx->handle);
41110 drm_context_switch_complete(dev, file_priv, ctx->handle);
41111
41112@@ -442,8 +481,11 @@ int drm_legacy_rmctx(struct drm_device *dev, void *data,
41113 {
41114 struct drm_ctx *ctx = data;
41115
41116+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
41117+ return -EINVAL;
41118+
41119 DRM_DEBUG("%d\n", ctx->handle);
41120- if (ctx->handle != DRM_KERNEL_CONTEXT) {
41121+ if (_DRM_LOCKING_CONTEXT(ctx->handle) != DRM_KERNEL_CONTEXT) {
41122 if (dev->driver->context_dtor)
41123 dev->driver->context_dtor(dev, ctx->handle);
41124 drm_legacy_ctxbitmap_free(dev, ctx->handle);
41125diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
41126index 3007b44..420b4a3 100644
41127--- a/drivers/gpu/drm/drm_crtc.c
41128+++ b/drivers/gpu/drm/drm_crtc.c
41129@@ -4176,7 +4176,7 @@ int drm_mode_getproperty_ioctl(struct drm_device *dev,
41130 goto done;
41131 }
41132
41133- if (copy_to_user(&enum_ptr[copied].name,
41134+ if (copy_to_user(enum_ptr[copied].name,
41135 &prop_enum->name, DRM_PROP_NAME_LEN)) {
41136 ret = -EFAULT;
41137 goto done;
41138diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
41139index 48f7359..8c3b594 100644
41140--- a/drivers/gpu/drm/drm_drv.c
41141+++ b/drivers/gpu/drm/drm_drv.c
41142@@ -448,7 +448,7 @@ void drm_unplug_dev(struct drm_device *dev)
41143
41144 drm_device_set_unplugged(dev);
41145
41146- if (dev->open_count == 0) {
41147+ if (local_read(&dev->open_count) == 0) {
41148 drm_put_dev(dev);
41149 }
41150 mutex_unlock(&drm_global_mutex);
41151@@ -596,10 +596,13 @@ struct drm_device *drm_dev_alloc(struct drm_driver *driver,
41152 if (drm_ht_create(&dev->map_hash, 12))
41153 goto err_minors;
41154
41155- ret = drm_legacy_ctxbitmap_init(dev);
41156- if (ret) {
41157- DRM_ERROR("Cannot allocate memory for context bitmap.\n");
41158- goto err_ht;
41159+ if (drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT)) {
41160+ ret = drm_legacy_ctxbitmap_init(dev);
41161+ if (ret) {
41162+ DRM_ERROR(
41163+ "Cannot allocate memory for context bitmap.\n");
41164+ goto err_ht;
41165+ }
41166 }
41167
41168 if (drm_core_check_feature(dev, DRIVER_GEM)) {
41169diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
41170index 076dd60..e4a4ba7 100644
41171--- a/drivers/gpu/drm/drm_fops.c
41172+++ b/drivers/gpu/drm/drm_fops.c
41173@@ -89,7 +89,7 @@ int drm_open(struct inode *inode, struct file *filp)
41174 return PTR_ERR(minor);
41175
41176 dev = minor->dev;
41177- if (!dev->open_count++)
41178+ if (local_inc_return(&dev->open_count) == 1)
41179 need_setup = 1;
41180
41181 /* share address_space across all char-devs of a single device */
41182@@ -106,7 +106,7 @@ int drm_open(struct inode *inode, struct file *filp)
41183 return 0;
41184
41185 err_undo:
41186- dev->open_count--;
41187+ local_dec(&dev->open_count);
41188 drm_minor_release(minor);
41189 return retcode;
41190 }
41191@@ -376,7 +376,7 @@ int drm_release(struct inode *inode, struct file *filp)
41192
41193 mutex_lock(&drm_global_mutex);
41194
41195- DRM_DEBUG("open_count = %d\n", dev->open_count);
41196+ DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
41197
41198 mutex_lock(&dev->struct_mutex);
41199 list_del(&file_priv->lhead);
41200@@ -389,10 +389,10 @@ int drm_release(struct inode *inode, struct file *filp)
41201 * Begin inline drm_release
41202 */
41203
41204- DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
41205+ DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
41206 task_pid_nr(current),
41207 (long)old_encode_dev(file_priv->minor->kdev->devt),
41208- dev->open_count);
41209+ local_read(&dev->open_count));
41210
41211 /* Release any auth tokens that might point to this file_priv,
41212 (do that under the drm_global_mutex) */
41213@@ -465,7 +465,7 @@ int drm_release(struct inode *inode, struct file *filp)
41214 * End inline drm_release
41215 */
41216
41217- if (!--dev->open_count) {
41218+ if (local_dec_and_test(&dev->open_count)) {
41219 retcode = drm_lastclose(dev);
41220 if (drm_device_is_unplugged(dev))
41221 drm_put_dev(dev);
41222diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
41223index 3d2e91c..d31c4c9 100644
41224--- a/drivers/gpu/drm/drm_global.c
41225+++ b/drivers/gpu/drm/drm_global.c
41226@@ -36,7 +36,7 @@
41227 struct drm_global_item {
41228 struct mutex mutex;
41229 void *object;
41230- int refcount;
41231+ atomic_t refcount;
41232 };
41233
41234 static struct drm_global_item glob[DRM_GLOBAL_NUM];
41235@@ -49,7 +49,7 @@ void drm_global_init(void)
41236 struct drm_global_item *item = &glob[i];
41237 mutex_init(&item->mutex);
41238 item->object = NULL;
41239- item->refcount = 0;
41240+ atomic_set(&item->refcount, 0);
41241 }
41242 }
41243
41244@@ -59,7 +59,7 @@ void drm_global_release(void)
41245 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
41246 struct drm_global_item *item = &glob[i];
41247 BUG_ON(item->object != NULL);
41248- BUG_ON(item->refcount != 0);
41249+ BUG_ON(atomic_read(&item->refcount) != 0);
41250 }
41251 }
41252
41253@@ -69,7 +69,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
41254 struct drm_global_item *item = &glob[ref->global_type];
41255
41256 mutex_lock(&item->mutex);
41257- if (item->refcount == 0) {
41258+ if (atomic_read(&item->refcount) == 0) {
41259 item->object = kzalloc(ref->size, GFP_KERNEL);
41260 if (unlikely(item->object == NULL)) {
41261 ret = -ENOMEM;
41262@@ -82,7 +82,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
41263 goto out_err;
41264
41265 }
41266- ++item->refcount;
41267+ atomic_inc(&item->refcount);
41268 ref->object = item->object;
41269 mutex_unlock(&item->mutex);
41270 return 0;
41271@@ -98,9 +98,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
41272 struct drm_global_item *item = &glob[ref->global_type];
41273
41274 mutex_lock(&item->mutex);
41275- BUG_ON(item->refcount == 0);
41276+ BUG_ON(atomic_read(&item->refcount) == 0);
41277 BUG_ON(ref->object != item->object);
41278- if (--item->refcount == 0) {
41279+ if (atomic_dec_and_test(&item->refcount)) {
41280 ref->release(ref);
41281 item->object = NULL;
41282 }
41283diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
41284index cbb4fc0..5c756cb9 100644
41285--- a/drivers/gpu/drm/drm_info.c
41286+++ b/drivers/gpu/drm/drm_info.c
41287@@ -77,10 +77,13 @@ int drm_vm_info(struct seq_file *m, void *data)
41288 struct drm_local_map *map;
41289 struct drm_map_list *r_list;
41290
41291- /* Hardcoded from _DRM_FRAME_BUFFER,
41292- _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
41293- _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
41294- const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
41295+ static const char * const types[] = {
41296+ [_DRM_FRAME_BUFFER] = "FB",
41297+ [_DRM_REGISTERS] = "REG",
41298+ [_DRM_SHM] = "SHM",
41299+ [_DRM_AGP] = "AGP",
41300+ [_DRM_SCATTER_GATHER] = "SG",
41301+ [_DRM_CONSISTENT] = "PCI"};
41302 const char *type;
41303 int i;
41304
41305@@ -91,7 +94,7 @@ int drm_vm_info(struct seq_file *m, void *data)
41306 map = r_list->map;
41307 if (!map)
41308 continue;
41309- if (map->type < 0 || map->type > 5)
41310+ if (map->type >= ARRAY_SIZE(types))
41311 type = "??";
41312 else
41313 type = types[map->type];
41314diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
41315index aa8bbb4..0f62630 100644
41316--- a/drivers/gpu/drm/drm_ioc32.c
41317+++ b/drivers/gpu/drm/drm_ioc32.c
41318@@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
41319 request = compat_alloc_user_space(nbytes);
41320 if (!access_ok(VERIFY_WRITE, request, nbytes))
41321 return -EFAULT;
41322- list = (struct drm_buf_desc *) (request + 1);
41323+ list = (struct drm_buf_desc __user *) (request + 1);
41324
41325 if (__put_user(count, &request->count)
41326 || __put_user(list, &request->list))
41327@@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
41328 request = compat_alloc_user_space(nbytes);
41329 if (!access_ok(VERIFY_WRITE, request, nbytes))
41330 return -EFAULT;
41331- list = (struct drm_buf_pub *) (request + 1);
41332+ list = (struct drm_buf_pub __user *) (request + 1);
41333
41334 if (__put_user(count, &request->count)
41335 || __put_user(list, &request->list))
41336@@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
41337 return 0;
41338 }
41339
41340-static drm_ioctl_compat_t *drm_compat_ioctls[] = {
41341+static drm_ioctl_compat_t drm_compat_ioctls[] = {
41342 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
41343 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
41344 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
41345@@ -1062,7 +1062,6 @@ static drm_ioctl_compat_t *drm_compat_ioctls[] = {
41346 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
41347 {
41348 unsigned int nr = DRM_IOCTL_NR(cmd);
41349- drm_ioctl_compat_t *fn;
41350 int ret;
41351
41352 /* Assume that ioctls without an explicit compat routine will just
41353@@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
41354 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
41355 return drm_ioctl(filp, cmd, arg);
41356
41357- fn = drm_compat_ioctls[nr];
41358-
41359- if (fn != NULL)
41360- ret = (*fn) (filp, cmd, arg);
41361+ if (drm_compat_ioctls[nr] != NULL)
41362+ ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
41363 else
41364 ret = drm_ioctl(filp, cmd, arg);
41365
41366diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
41367index 266dcd6..d0194d9 100644
41368--- a/drivers/gpu/drm/drm_ioctl.c
41369+++ b/drivers/gpu/drm/drm_ioctl.c
41370@@ -663,7 +663,7 @@ long drm_ioctl(struct file *filp,
41371 struct drm_file *file_priv = filp->private_data;
41372 struct drm_device *dev;
41373 const struct drm_ioctl_desc *ioctl = NULL;
41374- drm_ioctl_t *func;
41375+ drm_ioctl_no_const_t func;
41376 unsigned int nr = DRM_IOCTL_NR(cmd);
41377 int retcode = -EINVAL;
41378 char stack_kdata[128];
41379diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
41380index f861361..b61d4c7 100644
41381--- a/drivers/gpu/drm/drm_lock.c
41382+++ b/drivers/gpu/drm/drm_lock.c
41383@@ -61,9 +61,12 @@ int drm_legacy_lock(struct drm_device *dev, void *data,
41384 struct drm_master *master = file_priv->master;
41385 int ret = 0;
41386
41387+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
41388+ return -EINVAL;
41389+
41390 ++file_priv->lock_count;
41391
41392- if (lock->context == DRM_KERNEL_CONTEXT) {
41393+ if (_DRM_LOCKING_CONTEXT(lock->context) == DRM_KERNEL_CONTEXT) {
41394 DRM_ERROR("Process %d using kernel context %d\n",
41395 task_pid_nr(current), lock->context);
41396 return -EINVAL;
41397@@ -153,12 +156,23 @@ int drm_legacy_unlock(struct drm_device *dev, void *data, struct drm_file *file_
41398 struct drm_lock *lock = data;
41399 struct drm_master *master = file_priv->master;
41400
41401- if (lock->context == DRM_KERNEL_CONTEXT) {
41402+ if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT))
41403+ return -EINVAL;
41404+
41405+ if (_DRM_LOCKING_CONTEXT(lock->context) == DRM_KERNEL_CONTEXT) {
41406 DRM_ERROR("Process %d using kernel context %d\n",
41407 task_pid_nr(current), lock->context);
41408 return -EINVAL;
41409 }
41410
41411+ if (!master->lock.hw_lock) {
41412+ DRM_ERROR(
41413+ "Device has been unregistered. Hard exit. Process %d\n",
41414+ task_pid_nr(current));
41415+ send_sig(SIGTERM, current, 0);
41416+ return -EPERM;
41417+ }
41418+
41419 if (drm_legacy_lock_free(&master->lock, lock->context)) {
41420 /* FIXME: Should really bail out here. */
41421 }
41422diff --git a/drivers/gpu/drm/gma500/mdfld_dsi_dpi.c b/drivers/gpu/drm/gma500/mdfld_dsi_dpi.c
41423index d4813e0..6c1ab4d 100644
41424--- a/drivers/gpu/drm/gma500/mdfld_dsi_dpi.c
41425+++ b/drivers/gpu/drm/gma500/mdfld_dsi_dpi.c
41426@@ -825,10 +825,16 @@ void mdfld_dsi_dpi_mode_set(struct drm_encoder *encoder,
41427 u32 pipeconf_reg = PIPEACONF;
41428 u32 dspcntr_reg = DSPACNTR;
41429
41430- u32 pipeconf = dev_priv->pipeconf[pipe];
41431- u32 dspcntr = dev_priv->dspcntr[pipe];
41432+ u32 pipeconf;
41433+ u32 dspcntr;
41434 u32 mipi = MIPI_PORT_EN | PASS_FROM_SPHY_TO_AFE | SEL_FLOPPED_HSTX;
41435
41436+ if (pipe == -1)
41437+ return;
41438+
41439+ pipeconf = dev_priv->pipeconf[pipe];
41440+ dspcntr = dev_priv->dspcntr[pipe];
41441+
41442 if (pipe) {
41443 pipeconf_reg = PIPECCONF;
41444 dspcntr_reg = DSPCCNTR;
41445diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
41446index 93ec5dc..82acbaf 100644
41447--- a/drivers/gpu/drm/i810/i810_drv.h
41448+++ b/drivers/gpu/drm/i810/i810_drv.h
41449@@ -110,8 +110,8 @@ typedef struct drm_i810_private {
41450 int page_flipping;
41451
41452 wait_queue_head_t irq_queue;
41453- atomic_t irq_received;
41454- atomic_t irq_emitted;
41455+ atomic_unchecked_t irq_received;
41456+ atomic_unchecked_t irq_emitted;
41457
41458 int front_offset;
41459 } drm_i810_private_t;
41460diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
41461index 68e0c85..3303192 100644
41462--- a/drivers/gpu/drm/i915/i915_dma.c
41463+++ b/drivers/gpu/drm/i915/i915_dma.c
41464@@ -162,6 +162,8 @@ static int i915_getparam(struct drm_device *dev, void *data,
41465 value = INTEL_INFO(dev)->eu_total;
41466 if (!value)
41467 return -ENODEV;
41468+ case I915_PARAM_HAS_LEGACY_CONTEXT:
41469+ value = drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT);
41470 break;
41471 default:
41472 DRM_DEBUG("Unknown parameter %d\n", param->param);
41473@@ -376,7 +378,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
41474 * locking inversion with the driver load path. And the access here is
41475 * completely racy anyway. So don't bother with locking for now.
41476 */
41477- return dev->open_count == 0;
41478+ return local_read(&dev->open_count) == 0;
41479 }
41480
41481 static const struct vga_switcheroo_client_ops i915_switcheroo_ops = {
41482diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
41483index a3190e79..86b06cb 100644
41484--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
41485+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
41486@@ -936,12 +936,12 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
41487 static int
41488 validate_exec_list(struct drm_device *dev,
41489 struct drm_i915_gem_exec_object2 *exec,
41490- int count)
41491+ unsigned int count)
41492 {
41493 unsigned relocs_total = 0;
41494 unsigned relocs_max = UINT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
41495 unsigned invalid_flags;
41496- int i;
41497+ unsigned int i;
41498
41499 invalid_flags = __EXEC_OBJECT_UNKNOWN_FLAGS;
41500 if (USES_FULL_PPGTT(dev))
41501diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
41502index 176de63..b50b66a 100644
41503--- a/drivers/gpu/drm/i915/i915_ioc32.c
41504+++ b/drivers/gpu/drm/i915/i915_ioc32.c
41505@@ -62,7 +62,7 @@ static int compat_i915_batchbuffer(struct file *file, unsigned int cmd,
41506 || __put_user(batchbuffer32.DR4, &batchbuffer->DR4)
41507 || __put_user(batchbuffer32.num_cliprects,
41508 &batchbuffer->num_cliprects)
41509- || __put_user((int __user *)(unsigned long)batchbuffer32.cliprects,
41510+ || __put_user((struct drm_clip_rect __user *)(unsigned long)batchbuffer32.cliprects,
41511 &batchbuffer->cliprects))
41512 return -EFAULT;
41513
41514@@ -91,13 +91,13 @@ static int compat_i915_cmdbuffer(struct file *file, unsigned int cmd,
41515
41516 cmdbuffer = compat_alloc_user_space(sizeof(*cmdbuffer));
41517 if (!access_ok(VERIFY_WRITE, cmdbuffer, sizeof(*cmdbuffer))
41518- || __put_user((int __user *)(unsigned long)cmdbuffer32.buf,
41519+ || __put_user((char __user *)(unsigned long)cmdbuffer32.buf,
41520 &cmdbuffer->buf)
41521 || __put_user(cmdbuffer32.sz, &cmdbuffer->sz)
41522 || __put_user(cmdbuffer32.DR1, &cmdbuffer->DR1)
41523 || __put_user(cmdbuffer32.DR4, &cmdbuffer->DR4)
41524 || __put_user(cmdbuffer32.num_cliprects, &cmdbuffer->num_cliprects)
41525- || __put_user((int __user *)(unsigned long)cmdbuffer32.cliprects,
41526+ || __put_user((struct drm_clip_rect __user *)(unsigned long)cmdbuffer32.cliprects,
41527 &cmdbuffer->cliprects))
41528 return -EFAULT;
41529
41530@@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
41531 (unsigned long)request);
41532 }
41533
41534-static drm_ioctl_compat_t *i915_compat_ioctls[] = {
41535+static drm_ioctl_compat_t i915_compat_ioctls[] = {
41536 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
41537 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
41538 [DRM_I915_GETPARAM] = compat_i915_getparam,
41539@@ -201,17 +201,13 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
41540 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
41541 {
41542 unsigned int nr = DRM_IOCTL_NR(cmd);
41543- drm_ioctl_compat_t *fn = NULL;
41544 int ret;
41545
41546 if (nr < DRM_COMMAND_BASE)
41547 return drm_compat_ioctl(filp, cmd, arg);
41548
41549- if (nr < DRM_COMMAND_BASE + ARRAY_SIZE(i915_compat_ioctls))
41550- fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
41551-
41552- if (fn != NULL)
41553- ret = (*fn) (filp, cmd, arg);
41554+ if (nr < DRM_COMMAND_BASE + ARRAY_SIZE(i915_compat_ioctls) && i915_compat_ioctls[nr - DRM_COMMAND_BASE])
41555+ ret = (*i915_compat_ioctls[nr - DRM_COMMAND_BASE])(filp, cmd, arg);
41556 else
41557 ret = drm_ioctl(filp, cmd, arg);
41558
41559diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
41560index d0f3cbc..f3ab4cc 100644
41561--- a/drivers/gpu/drm/i915/intel_display.c
41562+++ b/drivers/gpu/drm/i915/intel_display.c
41563@@ -13604,13 +13604,13 @@ struct intel_quirk {
41564 int subsystem_vendor;
41565 int subsystem_device;
41566 void (*hook)(struct drm_device *dev);
41567-};
41568+} __do_const;
41569
41570 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
41571 struct intel_dmi_quirk {
41572 void (*hook)(struct drm_device *dev);
41573 const struct dmi_system_id (*dmi_id_list)[];
41574-};
41575+} __do_const;
41576
41577 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
41578 {
41579@@ -13618,18 +13618,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
41580 return 1;
41581 }
41582
41583-static const struct intel_dmi_quirk intel_dmi_quirks[] = {
41584+static const struct dmi_system_id intel_dmi_quirks_table[] = {
41585 {
41586- .dmi_id_list = &(const struct dmi_system_id[]) {
41587- {
41588- .callback = intel_dmi_reverse_brightness,
41589- .ident = "NCR Corporation",
41590- .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
41591- DMI_MATCH(DMI_PRODUCT_NAME, ""),
41592- },
41593- },
41594- { } /* terminating entry */
41595+ .callback = intel_dmi_reverse_brightness,
41596+ .ident = "NCR Corporation",
41597+ .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
41598+ DMI_MATCH(DMI_PRODUCT_NAME, ""),
41599 },
41600+ },
41601+ { } /* terminating entry */
41602+};
41603+
41604+static const struct intel_dmi_quirk intel_dmi_quirks[] = {
41605+ {
41606+ .dmi_id_list = &intel_dmi_quirks_table,
41607 .hook = quirk_invert_brightness,
41608 },
41609 };
41610diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c
41611index 74f505b..21f6914 100644
41612--- a/drivers/gpu/drm/imx/imx-drm-core.c
41613+++ b/drivers/gpu/drm/imx/imx-drm-core.c
41614@@ -355,7 +355,7 @@ int imx_drm_add_crtc(struct drm_device *drm, struct drm_crtc *crtc,
41615 if (imxdrm->pipes >= MAX_CRTC)
41616 return -EINVAL;
41617
41618- if (imxdrm->drm->open_count)
41619+ if (local_read(&imxdrm->drm->open_count))
41620 return -EBUSY;
41621
41622 imx_drm_crtc = kzalloc(sizeof(*imx_drm_crtc), GFP_KERNEL);
41623diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
41624index b4a20149..219ab78 100644
41625--- a/drivers/gpu/drm/mga/mga_drv.h
41626+++ b/drivers/gpu/drm/mga/mga_drv.h
41627@@ -122,9 +122,9 @@ typedef struct drm_mga_private {
41628 u32 clear_cmd;
41629 u32 maccess;
41630
41631- atomic_t vbl_received; /**< Number of vblanks received. */
41632+ atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
41633 wait_queue_head_t fence_queue;
41634- atomic_t last_fence_retired;
41635+ atomic_unchecked_t last_fence_retired;
41636 u32 next_fence_to_post;
41637
41638 unsigned int fb_cpp;
41639diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
41640index 729bfd5..14bae78 100644
41641--- a/drivers/gpu/drm/mga/mga_ioc32.c
41642+++ b/drivers/gpu/drm/mga/mga_ioc32.c
41643@@ -190,7 +190,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
41644 return 0;
41645 }
41646
41647-drm_ioctl_compat_t *mga_compat_ioctls[] = {
41648+drm_ioctl_compat_t mga_compat_ioctls[] = {
41649 [DRM_MGA_INIT] = compat_mga_init,
41650 [DRM_MGA_GETPARAM] = compat_mga_getparam,
41651 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
41652@@ -208,17 +208,13 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
41653 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
41654 {
41655 unsigned int nr = DRM_IOCTL_NR(cmd);
41656- drm_ioctl_compat_t *fn = NULL;
41657 int ret;
41658
41659 if (nr < DRM_COMMAND_BASE)
41660 return drm_compat_ioctl(filp, cmd, arg);
41661
41662- if (nr < DRM_COMMAND_BASE + ARRAY_SIZE(mga_compat_ioctls))
41663- fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
41664-
41665- if (fn != NULL)
41666- ret = (*fn) (filp, cmd, arg);
41667+ if (nr < DRM_COMMAND_BASE + ARRAY_SIZE(mga_compat_ioctls) && mga_compat_ioctls[nr - DRM_COMMAND_BASE])
41668+ ret = (*mga_compat_ioctls[nr - DRM_COMMAND_BASE]) (filp, cmd, arg);
41669 else
41670 ret = drm_ioctl(filp, cmd, arg);
41671
41672diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
41673index 1b071b8..de8601a 100644
41674--- a/drivers/gpu/drm/mga/mga_irq.c
41675+++ b/drivers/gpu/drm/mga/mga_irq.c
41676@@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
41677 if (crtc != 0)
41678 return 0;
41679
41680- return atomic_read(&dev_priv->vbl_received);
41681+ return atomic_read_unchecked(&dev_priv->vbl_received);
41682 }
41683
41684
41685@@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(int irq, void *arg)
41686 /* VBLANK interrupt */
41687 if (status & MGA_VLINEPEN) {
41688 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
41689- atomic_inc(&dev_priv->vbl_received);
41690+ atomic_inc_unchecked(&dev_priv->vbl_received);
41691 drm_handle_vblank(dev, 0);
41692 handled = 1;
41693 }
41694@@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(int irq, void *arg)
41695 if ((prim_start & ~0x03) != (prim_end & ~0x03))
41696 MGA_WRITE(MGA_PRIMEND, prim_end);
41697
41698- atomic_inc(&dev_priv->last_fence_retired);
41699+ atomic_inc_unchecked(&dev_priv->last_fence_retired);
41700 wake_up(&dev_priv->fence_queue);
41701 handled = 1;
41702 }
41703@@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
41704 * using fences.
41705 */
41706 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * HZ,
41707- (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
41708+ (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
41709 - *sequence) <= (1 << 23)));
41710
41711 *sequence = cur_fence;
41712diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
41713index 0190b69..60c3eaf 100644
41714--- a/drivers/gpu/drm/nouveau/nouveau_bios.c
41715+++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
41716@@ -963,7 +963,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
41717 struct bit_table {
41718 const char id;
41719 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
41720-};
41721+} __no_const;
41722
41723 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
41724
41725diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
41726index 8904933..9624b38 100644
41727--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
41728+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
41729@@ -941,7 +941,8 @@ static struct drm_driver
41730 driver_stub = {
41731 .driver_features =
41732 DRIVER_USE_AGP |
41733- DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_RENDER,
41734+ DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_RENDER |
41735+ DRIVER_KMS_LEGACY_CONTEXT,
41736
41737 .load = nouveau_drm_load,
41738 .unload = nouveau_drm_unload,
41739diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
41740index dd72652..1fd2368 100644
41741--- a/drivers/gpu/drm/nouveau/nouveau_drm.h
41742+++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
41743@@ -123,7 +123,6 @@ struct nouveau_drm {
41744 struct drm_global_reference mem_global_ref;
41745 struct ttm_bo_global_ref bo_global_ref;
41746 struct ttm_bo_device bdev;
41747- atomic_t validate_sequence;
41748 int (*move)(struct nouveau_channel *,
41749 struct ttm_buffer_object *,
41750 struct ttm_mem_reg *, struct ttm_mem_reg *);
41751diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
41752index 462679a..88e32a7 100644
41753--- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
41754+++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
41755@@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
41756 unsigned long arg)
41757 {
41758 unsigned int nr = DRM_IOCTL_NR(cmd);
41759- drm_ioctl_compat_t *fn = NULL;
41760+ drm_ioctl_compat_t fn = NULL;
41761 int ret;
41762
41763 if (nr < DRM_COMMAND_BASE)
41764diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
41765index 18f4497..10f6025 100644
41766--- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
41767+++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
41768@@ -130,11 +130,11 @@ nouveau_vram_manager_debug(struct ttm_mem_type_manager *man, const char *prefix)
41769 }
41770
41771 const struct ttm_mem_type_manager_func nouveau_vram_manager = {
41772- nouveau_vram_manager_init,
41773- nouveau_vram_manager_fini,
41774- nouveau_vram_manager_new,
41775- nouveau_vram_manager_del,
41776- nouveau_vram_manager_debug
41777+ .init = nouveau_vram_manager_init,
41778+ .takedown = nouveau_vram_manager_fini,
41779+ .get_node = nouveau_vram_manager_new,
41780+ .put_node = nouveau_vram_manager_del,
41781+ .debug = nouveau_vram_manager_debug
41782 };
41783
41784 static int
41785@@ -198,11 +198,11 @@ nouveau_gart_manager_debug(struct ttm_mem_type_manager *man, const char *prefix)
41786 }
41787
41788 const struct ttm_mem_type_manager_func nouveau_gart_manager = {
41789- nouveau_gart_manager_init,
41790- nouveau_gart_manager_fini,
41791- nouveau_gart_manager_new,
41792- nouveau_gart_manager_del,
41793- nouveau_gart_manager_debug
41794+ .init = nouveau_gart_manager_init,
41795+ .takedown = nouveau_gart_manager_fini,
41796+ .get_node = nouveau_gart_manager_new,
41797+ .put_node = nouveau_gart_manager_del,
41798+ .debug = nouveau_gart_manager_debug
41799 };
41800
41801 /*XXX*/
41802@@ -271,11 +271,11 @@ nv04_gart_manager_debug(struct ttm_mem_type_manager *man, const char *prefix)
41803 }
41804
41805 const struct ttm_mem_type_manager_func nv04_gart_manager = {
41806- nv04_gart_manager_init,
41807- nv04_gart_manager_fini,
41808- nv04_gart_manager_new,
41809- nv04_gart_manager_del,
41810- nv04_gart_manager_debug
41811+ .init = nv04_gart_manager_init,
41812+ .takedown = nv04_gart_manager_fini,
41813+ .get_node = nv04_gart_manager_new,
41814+ .put_node = nv04_gart_manager_del,
41815+ .debug = nv04_gart_manager_debug
41816 };
41817
41818 int
41819diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
41820index c7592ec..dd45ebc 100644
41821--- a/drivers/gpu/drm/nouveau/nouveau_vga.c
41822+++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
41823@@ -72,7 +72,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
41824 * locking inversion with the driver load path. And the access here is
41825 * completely racy anyway. So don't bother with locking for now.
41826 */
41827- return dev->open_count == 0;
41828+ return local_read(&dev->open_count) == 0;
41829 }
41830
41831 static const struct vga_switcheroo_client_ops
41832diff --git a/drivers/gpu/drm/qxl/qxl_cmd.c b/drivers/gpu/drm/qxl/qxl_cmd.c
41833index 9782364..89bd954 100644
41834--- a/drivers/gpu/drm/qxl/qxl_cmd.c
41835+++ b/drivers/gpu/drm/qxl/qxl_cmd.c
41836@@ -285,27 +285,27 @@ static int wait_for_io_cmd_user(struct qxl_device *qdev, uint8_t val, long port,
41837 int ret;
41838
41839 mutex_lock(&qdev->async_io_mutex);
41840- irq_num = atomic_read(&qdev->irq_received_io_cmd);
41841+ irq_num = atomic_read_unchecked(&qdev->irq_received_io_cmd);
41842 if (qdev->last_sent_io_cmd > irq_num) {
41843 if (intr)
41844 ret = wait_event_interruptible_timeout(qdev->io_cmd_event,
41845- atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
41846+ atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
41847 else
41848 ret = wait_event_timeout(qdev->io_cmd_event,
41849- atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
41850+ atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
41851 /* 0 is timeout, just bail the "hw" has gone away */
41852 if (ret <= 0)
41853 goto out;
41854- irq_num = atomic_read(&qdev->irq_received_io_cmd);
41855+ irq_num = atomic_read_unchecked(&qdev->irq_received_io_cmd);
41856 }
41857 outb(val, addr);
41858 qdev->last_sent_io_cmd = irq_num + 1;
41859 if (intr)
41860 ret = wait_event_interruptible_timeout(qdev->io_cmd_event,
41861- atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
41862+ atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
41863 else
41864 ret = wait_event_timeout(qdev->io_cmd_event,
41865- atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
41866+ atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
41867 out:
41868 if (ret > 0)
41869 ret = 0;
41870diff --git a/drivers/gpu/drm/qxl/qxl_debugfs.c b/drivers/gpu/drm/qxl/qxl_debugfs.c
41871index 6911b8c..89d6867 100644
41872--- a/drivers/gpu/drm/qxl/qxl_debugfs.c
41873+++ b/drivers/gpu/drm/qxl/qxl_debugfs.c
41874@@ -42,10 +42,10 @@ qxl_debugfs_irq_received(struct seq_file *m, void *data)
41875 struct drm_info_node *node = (struct drm_info_node *) m->private;
41876 struct qxl_device *qdev = node->minor->dev->dev_private;
41877
41878- seq_printf(m, "%d\n", atomic_read(&qdev->irq_received));
41879- seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_display));
41880- seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_cursor));
41881- seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_io_cmd));
41882+ seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received));
41883+ seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received_display));
41884+ seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received_cursor));
41885+ seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received_io_cmd));
41886 seq_printf(m, "%d\n", qdev->irq_received_error);
41887 return 0;
41888 }
41889diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
41890index 7c6cafe..460f542 100644
41891--- a/drivers/gpu/drm/qxl/qxl_drv.h
41892+++ b/drivers/gpu/drm/qxl/qxl_drv.h
41893@@ -290,10 +290,10 @@ struct qxl_device {
41894 unsigned int last_sent_io_cmd;
41895
41896 /* interrupt handling */
41897- atomic_t irq_received;
41898- atomic_t irq_received_display;
41899- atomic_t irq_received_cursor;
41900- atomic_t irq_received_io_cmd;
41901+ atomic_unchecked_t irq_received;
41902+ atomic_unchecked_t irq_received_display;
41903+ atomic_unchecked_t irq_received_cursor;
41904+ atomic_unchecked_t irq_received_io_cmd;
41905 unsigned irq_received_error;
41906 wait_queue_head_t display_event;
41907 wait_queue_head_t cursor_event;
41908diff --git a/drivers/gpu/drm/qxl/qxl_ioctl.c b/drivers/gpu/drm/qxl/qxl_ioctl.c
41909index b110883..dd06418 100644
41910--- a/drivers/gpu/drm/qxl/qxl_ioctl.c
41911+++ b/drivers/gpu/drm/qxl/qxl_ioctl.c
41912@@ -181,7 +181,7 @@ static int qxl_process_single_command(struct qxl_device *qdev,
41913
41914 /* TODO copy slow path code from i915 */
41915 fb_cmd = qxl_bo_kmap_atomic_page(qdev, cmd_bo, (release->release_offset & PAGE_SIZE));
41916- unwritten = __copy_from_user_inatomic_nocache(fb_cmd + sizeof(union qxl_release_info) + (release->release_offset & ~PAGE_SIZE), (void *)(unsigned long)cmd->command, cmd->command_size);
41917+ unwritten = __copy_from_user_inatomic_nocache(fb_cmd + sizeof(union qxl_release_info) + (release->release_offset & ~PAGE_SIZE), (void __force_user *)(unsigned long)cmd->command, cmd->command_size);
41918
41919 {
41920 struct qxl_drawable *draw = fb_cmd;
41921@@ -201,7 +201,7 @@ static int qxl_process_single_command(struct qxl_device *qdev,
41922 struct drm_qxl_reloc reloc;
41923
41924 if (copy_from_user(&reloc,
41925- &((struct drm_qxl_reloc *)(uintptr_t)cmd->relocs)[i],
41926+ &((struct drm_qxl_reloc __force_user *)(uintptr_t)cmd->relocs)[i],
41927 sizeof(reloc))) {
41928 ret = -EFAULT;
41929 goto out_free_bos;
41930@@ -294,10 +294,10 @@ static int qxl_execbuffer_ioctl(struct drm_device *dev, void *data,
41931
41932 for (cmd_num = 0; cmd_num < execbuffer->commands_num; ++cmd_num) {
41933
41934- struct drm_qxl_command *commands =
41935- (struct drm_qxl_command *)(uintptr_t)execbuffer->commands;
41936+ struct drm_qxl_command __user *commands =
41937+ (struct drm_qxl_command __user *)(uintptr_t)execbuffer->commands;
41938
41939- if (copy_from_user(&user_cmd, &commands[cmd_num],
41940+ if (copy_from_user(&user_cmd, (struct drm_qxl_command __force_user *)&commands[cmd_num],
41941 sizeof(user_cmd)))
41942 return -EFAULT;
41943
41944diff --git a/drivers/gpu/drm/qxl/qxl_irq.c b/drivers/gpu/drm/qxl/qxl_irq.c
41945index 0bf1e20..42a7310 100644
41946--- a/drivers/gpu/drm/qxl/qxl_irq.c
41947+++ b/drivers/gpu/drm/qxl/qxl_irq.c
41948@@ -36,19 +36,19 @@ irqreturn_t qxl_irq_handler(int irq, void *arg)
41949 if (!pending)
41950 return IRQ_NONE;
41951
41952- atomic_inc(&qdev->irq_received);
41953+ atomic_inc_unchecked(&qdev->irq_received);
41954
41955 if (pending & QXL_INTERRUPT_DISPLAY) {
41956- atomic_inc(&qdev->irq_received_display);
41957+ atomic_inc_unchecked(&qdev->irq_received_display);
41958 wake_up_all(&qdev->display_event);
41959 qxl_queue_garbage_collect(qdev, false);
41960 }
41961 if (pending & QXL_INTERRUPT_CURSOR) {
41962- atomic_inc(&qdev->irq_received_cursor);
41963+ atomic_inc_unchecked(&qdev->irq_received_cursor);
41964 wake_up_all(&qdev->cursor_event);
41965 }
41966 if (pending & QXL_INTERRUPT_IO_CMD) {
41967- atomic_inc(&qdev->irq_received_io_cmd);
41968+ atomic_inc_unchecked(&qdev->irq_received_io_cmd);
41969 wake_up_all(&qdev->io_cmd_event);
41970 }
41971 if (pending & QXL_INTERRUPT_ERROR) {
41972@@ -85,10 +85,10 @@ int qxl_irq_init(struct qxl_device *qdev)
41973 init_waitqueue_head(&qdev->io_cmd_event);
41974 INIT_WORK(&qdev->client_monitors_config_work,
41975 qxl_client_monitors_config_work_func);
41976- atomic_set(&qdev->irq_received, 0);
41977- atomic_set(&qdev->irq_received_display, 0);
41978- atomic_set(&qdev->irq_received_cursor, 0);
41979- atomic_set(&qdev->irq_received_io_cmd, 0);
41980+ atomic_set_unchecked(&qdev->irq_received, 0);
41981+ atomic_set_unchecked(&qdev->irq_received_display, 0);
41982+ atomic_set_unchecked(&qdev->irq_received_cursor, 0);
41983+ atomic_set_unchecked(&qdev->irq_received_io_cmd, 0);
41984 qdev->irq_received_error = 0;
41985 ret = drm_irq_install(qdev->ddev, qdev->ddev->pdev->irq);
41986 qdev->ram_header->int_mask = QXL_INTERRUPT_MASK;
41987diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
41988index 0cbc4c9..0e46686 100644
41989--- a/drivers/gpu/drm/qxl/qxl_ttm.c
41990+++ b/drivers/gpu/drm/qxl/qxl_ttm.c
41991@@ -103,7 +103,7 @@ static void qxl_ttm_global_fini(struct qxl_device *qdev)
41992 }
41993 }
41994
41995-static struct vm_operations_struct qxl_ttm_vm_ops;
41996+static vm_operations_struct_no_const qxl_ttm_vm_ops __read_only;
41997 static const struct vm_operations_struct *ttm_vm_ops;
41998
41999 static int qxl_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
42000@@ -145,8 +145,10 @@ int qxl_mmap(struct file *filp, struct vm_area_struct *vma)
42001 return r;
42002 if (unlikely(ttm_vm_ops == NULL)) {
42003 ttm_vm_ops = vma->vm_ops;
42004+ pax_open_kernel();
42005 qxl_ttm_vm_ops = *ttm_vm_ops;
42006 qxl_ttm_vm_ops.fault = &qxl_ttm_fault;
42007+ pax_close_kernel();
42008 }
42009 vma->vm_ops = &qxl_ttm_vm_ops;
42010 return 0;
42011@@ -464,25 +466,23 @@ static int qxl_mm_dump_table(struct seq_file *m, void *data)
42012 static int qxl_ttm_debugfs_init(struct qxl_device *qdev)
42013 {
42014 #if defined(CONFIG_DEBUG_FS)
42015- static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES];
42016- static char qxl_mem_types_names[QXL_DEBUGFS_MEM_TYPES][32];
42017- unsigned i;
42018+ static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES] = {
42019+ {
42020+ .name = "qxl_mem_mm",
42021+ .show = &qxl_mm_dump_table,
42022+ },
42023+ {
42024+ .name = "qxl_surf_mm",
42025+ .show = &qxl_mm_dump_table,
42026+ }
42027+ };
42028
42029- for (i = 0; i < QXL_DEBUGFS_MEM_TYPES; i++) {
42030- if (i == 0)
42031- sprintf(qxl_mem_types_names[i], "qxl_mem_mm");
42032- else
42033- sprintf(qxl_mem_types_names[i], "qxl_surf_mm");
42034- qxl_mem_types_list[i].name = qxl_mem_types_names[i];
42035- qxl_mem_types_list[i].show = &qxl_mm_dump_table;
42036- qxl_mem_types_list[i].driver_features = 0;
42037- if (i == 0)
42038- qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
42039- else
42040- qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
42041+ pax_open_kernel();
42042+ *(void **)&qxl_mem_types_list[0].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
42043+ *(void **)&qxl_mem_types_list[1].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
42044+ pax_close_kernel();
42045
42046- }
42047- return qxl_debugfs_add_files(qdev, qxl_mem_types_list, i);
42048+ return qxl_debugfs_add_files(qdev, qxl_mem_types_list, QXL_DEBUGFS_MEM_TYPES);
42049 #else
42050 return 0;
42051 #endif
42052diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
42053index 2c45ac9..5d740f8 100644
42054--- a/drivers/gpu/drm/r128/r128_cce.c
42055+++ b/drivers/gpu/drm/r128/r128_cce.c
42056@@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
42057
42058 /* GH: Simple idle check.
42059 */
42060- atomic_set(&dev_priv->idle_count, 0);
42061+ atomic_set_unchecked(&dev_priv->idle_count, 0);
42062
42063 /* We don't support anything other than bus-mastering ring mode,
42064 * but the ring can be in either AGP or PCI space for the ring
42065diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
42066index 723e5d6..102dbaf 100644
42067--- a/drivers/gpu/drm/r128/r128_drv.h
42068+++ b/drivers/gpu/drm/r128/r128_drv.h
42069@@ -93,14 +93,14 @@ typedef struct drm_r128_private {
42070 int is_pci;
42071 unsigned long cce_buffers_offset;
42072
42073- atomic_t idle_count;
42074+ atomic_unchecked_t idle_count;
42075
42076 int page_flipping;
42077 int current_page;
42078 u32 crtc_offset;
42079 u32 crtc_offset_cntl;
42080
42081- atomic_t vbl_received;
42082+ atomic_unchecked_t vbl_received;
42083
42084 u32 color_fmt;
42085 unsigned int front_offset;
42086diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
42087index 663f38c..ec159a1 100644
42088--- a/drivers/gpu/drm/r128/r128_ioc32.c
42089+++ b/drivers/gpu/drm/r128/r128_ioc32.c
42090@@ -178,7 +178,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
42091 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
42092 }
42093
42094-drm_ioctl_compat_t *r128_compat_ioctls[] = {
42095+drm_ioctl_compat_t r128_compat_ioctls[] = {
42096 [DRM_R128_INIT] = compat_r128_init,
42097 [DRM_R128_DEPTH] = compat_r128_depth,
42098 [DRM_R128_STIPPLE] = compat_r128_stipple,
42099@@ -197,17 +197,13 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
42100 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
42101 {
42102 unsigned int nr = DRM_IOCTL_NR(cmd);
42103- drm_ioctl_compat_t *fn = NULL;
42104 int ret;
42105
42106 if (nr < DRM_COMMAND_BASE)
42107 return drm_compat_ioctl(filp, cmd, arg);
42108
42109- if (nr < DRM_COMMAND_BASE + ARRAY_SIZE(r128_compat_ioctls))
42110- fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
42111-
42112- if (fn != NULL)
42113- ret = (*fn) (filp, cmd, arg);
42114+ if (nr < DRM_COMMAND_BASE + ARRAY_SIZE(r128_compat_ioctls) && r128_compat_ioctls[nr - DRM_COMMAND_BASE])
42115+ ret = (*r128_compat_ioctls[nr - DRM_COMMAND_BASE]) (filp, cmd, arg);
42116 else
42117 ret = drm_ioctl(filp, cmd, arg);
42118
42119diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
42120index c2ae496..30b5993 100644
42121--- a/drivers/gpu/drm/r128/r128_irq.c
42122+++ b/drivers/gpu/drm/r128/r128_irq.c
42123@@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
42124 if (crtc != 0)
42125 return 0;
42126
42127- return atomic_read(&dev_priv->vbl_received);
42128+ return atomic_read_unchecked(&dev_priv->vbl_received);
42129 }
42130
42131 irqreturn_t r128_driver_irq_handler(int irq, void *arg)
42132@@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(int irq, void *arg)
42133 /* VBLANK interrupt */
42134 if (status & R128_CRTC_VBLANK_INT) {
42135 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
42136- atomic_inc(&dev_priv->vbl_received);
42137+ atomic_inc_unchecked(&dev_priv->vbl_received);
42138 drm_handle_vblank(dev, 0);
42139 return IRQ_HANDLED;
42140 }
42141diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
42142index 8fd2d9f..18c9660 100644
42143--- a/drivers/gpu/drm/r128/r128_state.c
42144+++ b/drivers/gpu/drm/r128/r128_state.c
42145@@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
42146
42147 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
42148 {
42149- if (atomic_read(&dev_priv->idle_count) == 0)
42150+ if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
42151 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
42152 else
42153- atomic_set(&dev_priv->idle_count, 0);
42154+ atomic_set_unchecked(&dev_priv->idle_count, 0);
42155 }
42156
42157 #endif
42158diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
42159index b928c17..e5d9400 100644
42160--- a/drivers/gpu/drm/radeon/mkregtable.c
42161+++ b/drivers/gpu/drm/radeon/mkregtable.c
42162@@ -624,14 +624,14 @@ static int parser_auth(struct table *t, const char *filename)
42163 regex_t mask_rex;
42164 regmatch_t match[4];
42165 char buf[1024];
42166- size_t end;
42167+ long end;
42168 int len;
42169 int done = 0;
42170 int r;
42171 unsigned o;
42172 struct offset *offset;
42173 char last_reg_s[10];
42174- int last_reg;
42175+ unsigned long last_reg;
42176
42177 if (regcomp
42178 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
42179diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
42180index a7fdfa4..04a3964 100644
42181--- a/drivers/gpu/drm/radeon/radeon_device.c
42182+++ b/drivers/gpu/drm/radeon/radeon_device.c
42183@@ -1247,7 +1247,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
42184 * locking inversion with the driver load path. And the access here is
42185 * completely racy anyway. So don't bother with locking for now.
42186 */
42187- return dev->open_count == 0;
42188+ return local_read(&dev->open_count) == 0;
42189 }
42190
42191 static const struct vga_switcheroo_client_ops radeon_switcheroo_ops = {
42192diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
42193index 46bd393..6ae4719 100644
42194--- a/drivers/gpu/drm/radeon/radeon_drv.h
42195+++ b/drivers/gpu/drm/radeon/radeon_drv.h
42196@@ -264,7 +264,7 @@ typedef struct drm_radeon_private {
42197
42198 /* SW interrupt */
42199 wait_queue_head_t swi_queue;
42200- atomic_t swi_emitted;
42201+ atomic_unchecked_t swi_emitted;
42202 int vblank_crtc;
42203 uint32_t irq_enable_reg;
42204 uint32_t r500_disp_irq_reg;
42205diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
42206index 0b98ea1..a3c770f 100644
42207--- a/drivers/gpu/drm/radeon/radeon_ioc32.c
42208+++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
42209@@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
42210 request = compat_alloc_user_space(sizeof(*request));
42211 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
42212 || __put_user(req32.param, &request->param)
42213- || __put_user((void __user *)(unsigned long)req32.value,
42214+ || __put_user((unsigned long)req32.value,
42215 &request->value))
42216 return -EFAULT;
42217
42218@@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
42219 #define compat_radeon_cp_setparam NULL
42220 #endif /* X86_64 || IA64 */
42221
42222-static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
42223+static drm_ioctl_compat_t radeon_compat_ioctls[] = {
42224 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
42225 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
42226 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
42227@@ -393,17 +393,13 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
42228 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
42229 {
42230 unsigned int nr = DRM_IOCTL_NR(cmd);
42231- drm_ioctl_compat_t *fn = NULL;
42232 int ret;
42233
42234 if (nr < DRM_COMMAND_BASE)
42235 return drm_compat_ioctl(filp, cmd, arg);
42236
42237- if (nr < DRM_COMMAND_BASE + ARRAY_SIZE(radeon_compat_ioctls))
42238- fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
42239-
42240- if (fn != NULL)
42241- ret = (*fn) (filp, cmd, arg);
42242+ if (nr < DRM_COMMAND_BASE + ARRAY_SIZE(radeon_compat_ioctls) && radeon_compat_ioctls[nr - DRM_COMMAND_BASE])
42243+ ret = (*radeon_compat_ioctls[nr - DRM_COMMAND_BASE]) (filp, cmd, arg);
42244 else
42245 ret = drm_ioctl(filp, cmd, arg);
42246
42247diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
42248index 244b19b..c19226d 100644
42249--- a/drivers/gpu/drm/radeon/radeon_irq.c
42250+++ b/drivers/gpu/drm/radeon/radeon_irq.c
42251@@ -226,8 +226,8 @@ static int radeon_emit_irq(struct drm_device * dev)
42252 unsigned int ret;
42253 RING_LOCALS;
42254
42255- atomic_inc(&dev_priv->swi_emitted);
42256- ret = atomic_read(&dev_priv->swi_emitted);
42257+ atomic_inc_unchecked(&dev_priv->swi_emitted);
42258+ ret = atomic_read_unchecked(&dev_priv->swi_emitted);
42259
42260 BEGIN_RING(4);
42261 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
42262@@ -353,7 +353,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
42263 drm_radeon_private_t *dev_priv =
42264 (drm_radeon_private_t *) dev->dev_private;
42265
42266- atomic_set(&dev_priv->swi_emitted, 0);
42267+ atomic_set_unchecked(&dev_priv->swi_emitted, 0);
42268 init_waitqueue_head(&dev_priv->swi_queue);
42269
42270 dev->max_vblank_count = 0x001fffff;
42271diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
42272index 15aee72..cda326e 100644
42273--- a/drivers/gpu/drm/radeon/radeon_state.c
42274+++ b/drivers/gpu/drm/radeon/radeon_state.c
42275@@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
42276 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
42277 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
42278
42279- if (copy_from_user(&depth_boxes, clear->depth_boxes,
42280+ if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || copy_from_user(&depth_boxes, clear->depth_boxes,
42281 sarea_priv->nbox * sizeof(depth_boxes[0])))
42282 return -EFAULT;
42283
42284@@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
42285 {
42286 drm_radeon_private_t *dev_priv = dev->dev_private;
42287 drm_radeon_getparam_t *param = data;
42288- int value;
42289+ int value = 0;
42290
42291 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
42292
42293diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
42294index edafd3c..3af7c9c 100644
42295--- a/drivers/gpu/drm/radeon/radeon_ttm.c
42296+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
42297@@ -961,7 +961,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
42298 man->size = size >> PAGE_SHIFT;
42299 }
42300
42301-static struct vm_operations_struct radeon_ttm_vm_ops;
42302+static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
42303 static const struct vm_operations_struct *ttm_vm_ops = NULL;
42304
42305 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
42306@@ -1002,8 +1002,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
42307 }
42308 if (unlikely(ttm_vm_ops == NULL)) {
42309 ttm_vm_ops = vma->vm_ops;
42310+ pax_open_kernel();
42311 radeon_ttm_vm_ops = *ttm_vm_ops;
42312 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
42313+ pax_close_kernel();
42314 }
42315 vma->vm_ops = &radeon_ttm_vm_ops;
42316 return 0;
42317diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
42318index a287e4f..df1d5dd 100644
42319--- a/drivers/gpu/drm/tegra/dc.c
42320+++ b/drivers/gpu/drm/tegra/dc.c
42321@@ -1594,7 +1594,7 @@ static int tegra_dc_debugfs_init(struct tegra_dc *dc, struct drm_minor *minor)
42322 }
42323
42324 for (i = 0; i < ARRAY_SIZE(debugfs_files); i++)
42325- dc->debugfs_files[i].data = dc;
42326+ *(void **)&dc->debugfs_files[i].data = dc;
42327
42328 err = drm_debugfs_create_files(dc->debugfs_files,
42329 ARRAY_SIZE(debugfs_files),
42330diff --git a/drivers/gpu/drm/tegra/dsi.c b/drivers/gpu/drm/tegra/dsi.c
42331index ed970f6..4eeea42 100644
42332--- a/drivers/gpu/drm/tegra/dsi.c
42333+++ b/drivers/gpu/drm/tegra/dsi.c
42334@@ -62,7 +62,7 @@ struct tegra_dsi {
42335 struct clk *clk_lp;
42336 struct clk *clk;
42337
42338- struct drm_info_list *debugfs_files;
42339+ drm_info_list_no_const *debugfs_files;
42340 struct drm_minor *minor;
42341 struct dentry *debugfs;
42342
42343diff --git a/drivers/gpu/drm/tegra/hdmi.c b/drivers/gpu/drm/tegra/hdmi.c
42344index 06ab178..b5324e4 100644
42345--- a/drivers/gpu/drm/tegra/hdmi.c
42346+++ b/drivers/gpu/drm/tegra/hdmi.c
42347@@ -64,7 +64,7 @@ struct tegra_hdmi {
42348 bool stereo;
42349 bool dvi;
42350
42351- struct drm_info_list *debugfs_files;
42352+ drm_info_list_no_const *debugfs_files;
42353 struct drm_minor *minor;
42354 struct dentry *debugfs;
42355 };
42356diff --git a/drivers/gpu/drm/tegra/sor.c b/drivers/gpu/drm/tegra/sor.c
42357index 7591d89..463e2b6 100644
42358--- a/drivers/gpu/drm/tegra/sor.c
42359+++ b/drivers/gpu/drm/tegra/sor.c
42360@@ -826,8 +826,11 @@ static int tegra_sor_debugfs_init(struct tegra_sor *sor,
42361 goto remove;
42362 }
42363
42364- for (i = 0; i < ARRAY_SIZE(debugfs_files); i++)
42365- sor->debugfs_files[i].data = sor;
42366+ for (i = 0; i < ARRAY_SIZE(debugfs_files); i++) {
42367+ pax_open_kernel();
42368+ *(void **)&sor->debugfs_files[i].data = sor;
42369+ pax_close_kernel();
42370+ }
42371
42372 err = drm_debugfs_create_files(sor->debugfs_files,
42373 ARRAY_SIZE(debugfs_files),
42374diff --git a/drivers/gpu/drm/ttm/ttm_bo_manager.c b/drivers/gpu/drm/ttm/ttm_bo_manager.c
42375index aa0bd054..aea6a01 100644
42376--- a/drivers/gpu/drm/ttm/ttm_bo_manager.c
42377+++ b/drivers/gpu/drm/ttm/ttm_bo_manager.c
42378@@ -148,10 +148,10 @@ static void ttm_bo_man_debug(struct ttm_mem_type_manager *man,
42379 }
42380
42381 const struct ttm_mem_type_manager_func ttm_bo_manager_func = {
42382- ttm_bo_man_init,
42383- ttm_bo_man_takedown,
42384- ttm_bo_man_get_node,
42385- ttm_bo_man_put_node,
42386- ttm_bo_man_debug
42387+ .init = ttm_bo_man_init,
42388+ .takedown = ttm_bo_man_takedown,
42389+ .get_node = ttm_bo_man_get_node,
42390+ .put_node = ttm_bo_man_put_node,
42391+ .debug = ttm_bo_man_debug
42392 };
42393 EXPORT_SYMBOL(ttm_bo_manager_func);
42394diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
42395index a1803fb..c53f6b0 100644
42396--- a/drivers/gpu/drm/ttm/ttm_memory.c
42397+++ b/drivers/gpu/drm/ttm/ttm_memory.c
42398@@ -264,7 +264,7 @@ static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob,
42399 zone->glob = glob;
42400 glob->zone_kernel = zone;
42401 ret = kobject_init_and_add(
42402- &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
42403+ &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
42404 if (unlikely(ret != 0)) {
42405 kobject_put(&zone->kobj);
42406 return ret;
42407@@ -348,7 +348,7 @@ static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob,
42408 zone->glob = glob;
42409 glob->zone_dma32 = zone;
42410 ret = kobject_init_and_add(
42411- &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
42412+ &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
42413 if (unlikely(ret != 0)) {
42414 kobject_put(&zone->kobj);
42415 return ret;
42416diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
42417index 025c429..314062f 100644
42418--- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
42419+++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
42420@@ -54,7 +54,7 @@
42421
42422 #define NUM_PAGES_TO_ALLOC (PAGE_SIZE/sizeof(struct page *))
42423 #define SMALL_ALLOCATION 16
42424-#define FREE_ALL_PAGES (~0U)
42425+#define FREE_ALL_PAGES (~0UL)
42426 /* times are in msecs */
42427 #define PAGE_FREE_INTERVAL 1000
42428
42429@@ -299,15 +299,14 @@ static void ttm_pool_update_free_locked(struct ttm_page_pool *pool,
42430 * @free_all: If set to true will free all pages in pool
42431 * @use_static: Safe to use static buffer
42432 **/
42433-static int ttm_page_pool_free(struct ttm_page_pool *pool, unsigned nr_free,
42434+static unsigned long ttm_page_pool_free(struct ttm_page_pool *pool, unsigned long nr_free,
42435 bool use_static)
42436 {
42437 static struct page *static_buf[NUM_PAGES_TO_ALLOC];
42438 unsigned long irq_flags;
42439 struct page *p;
42440 struct page **pages_to_free;
42441- unsigned freed_pages = 0,
42442- npages_to_free = nr_free;
42443+ unsigned long freed_pages = 0, npages_to_free = nr_free;
42444
42445 if (NUM_PAGES_TO_ALLOC < nr_free)
42446 npages_to_free = NUM_PAGES_TO_ALLOC;
42447@@ -371,7 +370,8 @@ restart:
42448 __list_del(&p->lru, &pool->list);
42449
42450 ttm_pool_update_free_locked(pool, freed_pages);
42451- nr_free -= freed_pages;
42452+ if (likely(nr_free != FREE_ALL_PAGES))
42453+ nr_free -= freed_pages;
42454 }
42455
42456 spin_unlock_irqrestore(&pool->lock, irq_flags);
42457@@ -399,7 +399,7 @@ ttm_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
42458 unsigned i;
42459 unsigned pool_offset;
42460 struct ttm_page_pool *pool;
42461- int shrink_pages = sc->nr_to_scan;
42462+ unsigned long shrink_pages = sc->nr_to_scan;
42463 unsigned long freed = 0;
42464
42465 if (!mutex_trylock(&lock))
42466@@ -407,7 +407,7 @@ ttm_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
42467 pool_offset = ++start_pool % NUM_POOLS;
42468 /* select start pool in round robin fashion */
42469 for (i = 0; i < NUM_POOLS; ++i) {
42470- unsigned nr_free = shrink_pages;
42471+ unsigned long nr_free = shrink_pages;
42472 if (shrink_pages == 0)
42473 break;
42474 pool = &_manager->pools[(i + pool_offset)%NUM_POOLS];
42475@@ -673,7 +673,7 @@ out:
42476 }
42477
42478 /* Put all pages in pages list to correct pool to wait for reuse */
42479-static void ttm_put_pages(struct page **pages, unsigned npages, int flags,
42480+static void ttm_put_pages(struct page **pages, unsigned long npages, int flags,
42481 enum ttm_caching_state cstate)
42482 {
42483 unsigned long irq_flags;
42484@@ -728,7 +728,7 @@ static int ttm_get_pages(struct page **pages, unsigned npages, int flags,
42485 struct list_head plist;
42486 struct page *p = NULL;
42487 gfp_t gfp_flags = GFP_USER;
42488- unsigned count;
42489+ unsigned long count;
42490 int r;
42491
42492 /* set zero flag for page allocation if required */
42493diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
42494index 01e1d27..aaa018a 100644
42495--- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
42496+++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
42497@@ -56,7 +56,7 @@
42498
42499 #define NUM_PAGES_TO_ALLOC (PAGE_SIZE/sizeof(struct page *))
42500 #define SMALL_ALLOCATION 4
42501-#define FREE_ALL_PAGES (~0U)
42502+#define FREE_ALL_PAGES (~0UL)
42503 /* times are in msecs */
42504 #define IS_UNDEFINED (0)
42505 #define IS_WC (1<<1)
42506@@ -413,7 +413,7 @@ static void ttm_dma_page_put(struct dma_pool *pool, struct dma_page *d_page)
42507 * @nr_free: If set to true will free all pages in pool
42508 * @use_static: Safe to use static buffer
42509 **/
42510-static unsigned ttm_dma_page_pool_free(struct dma_pool *pool, unsigned nr_free,
42511+static unsigned long ttm_dma_page_pool_free(struct dma_pool *pool, unsigned long nr_free,
42512 bool use_static)
42513 {
42514 static struct page *static_buf[NUM_PAGES_TO_ALLOC];
42515@@ -421,8 +421,7 @@ static unsigned ttm_dma_page_pool_free(struct dma_pool *pool, unsigned nr_free,
42516 struct dma_page *dma_p, *tmp;
42517 struct page **pages_to_free;
42518 struct list_head d_pages;
42519- unsigned freed_pages = 0,
42520- npages_to_free = nr_free;
42521+ unsigned long freed_pages = 0, npages_to_free = nr_free;
42522
42523 if (NUM_PAGES_TO_ALLOC < nr_free)
42524 npages_to_free = NUM_PAGES_TO_ALLOC;
42525@@ -499,7 +498,8 @@ restart:
42526 /* remove range of pages from the pool */
42527 if (freed_pages) {
42528 ttm_pool_update_free_locked(pool, freed_pages);
42529- nr_free -= freed_pages;
42530+ if (likely(nr_free != FREE_ALL_PAGES))
42531+ nr_free -= freed_pages;
42532 }
42533
42534 spin_unlock_irqrestore(&pool->lock, irq_flags);
42535@@ -936,7 +936,7 @@ void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev)
42536 struct dma_page *d_page, *next;
42537 enum pool_type type;
42538 bool is_cached = false;
42539- unsigned count = 0, i, npages = 0;
42540+ unsigned long count = 0, i, npages = 0;
42541 unsigned long irq_flags;
42542
42543 type = ttm_to_type(ttm->page_flags, ttm->caching_state);
42544@@ -1012,7 +1012,7 @@ ttm_dma_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
42545 static unsigned start_pool;
42546 unsigned idx = 0;
42547 unsigned pool_offset;
42548- unsigned shrink_pages = sc->nr_to_scan;
42549+ unsigned long shrink_pages = sc->nr_to_scan;
42550 struct device_pools *p;
42551 unsigned long freed = 0;
42552
42553@@ -1025,7 +1025,7 @@ ttm_dma_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
42554 goto out;
42555 pool_offset = ++start_pool % _manager->npools;
42556 list_for_each_entry(p, &_manager->pools, pools) {
42557- unsigned nr_free;
42558+ unsigned long nr_free;
42559
42560 if (!p->dev)
42561 continue;
42562@@ -1039,7 +1039,7 @@ ttm_dma_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
42563 shrink_pages = ttm_dma_page_pool_free(p->pool, nr_free, true);
42564 freed += nr_free - shrink_pages;
42565
42566- pr_debug("%s: (%s:%d) Asked to shrink %d, have %d more to go\n",
42567+ pr_debug("%s: (%s:%d) Asked to shrink %lu, have %lu more to go\n",
42568 p->pool->dev_name, p->pool->name, current->pid,
42569 nr_free, shrink_pages);
42570 }
42571diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
42572index 5fc16ce..1bd84ec 100644
42573--- a/drivers/gpu/drm/udl/udl_fb.c
42574+++ b/drivers/gpu/drm/udl/udl_fb.c
42575@@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
42576 fb_deferred_io_cleanup(info);
42577 kfree(info->fbdefio);
42578 info->fbdefio = NULL;
42579- info->fbops->fb_mmap = udl_fb_mmap;
42580 }
42581
42582 pr_warn("released /dev/fb%d user=%d count=%d\n",
42583diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
42584index ef8c500..01030c8 100644
42585--- a/drivers/gpu/drm/via/via_drv.h
42586+++ b/drivers/gpu/drm/via/via_drv.h
42587@@ -53,7 +53,7 @@ typedef struct drm_via_ring_buffer {
42588 typedef uint32_t maskarray_t[5];
42589
42590 typedef struct drm_via_irq {
42591- atomic_t irq_received;
42592+ atomic_unchecked_t irq_received;
42593 uint32_t pending_mask;
42594 uint32_t enable_mask;
42595 wait_queue_head_t irq_queue;
42596@@ -77,7 +77,7 @@ typedef struct drm_via_private {
42597 struct timeval last_vblank;
42598 int last_vblank_valid;
42599 unsigned usec_per_vblank;
42600- atomic_t vbl_received;
42601+ atomic_unchecked_t vbl_received;
42602 drm_via_state_t hc_state;
42603 char pci_buf[VIA_PCI_BUF_SIZE];
42604 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
42605diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
42606index 1319433..a993b0c 100644
42607--- a/drivers/gpu/drm/via/via_irq.c
42608+++ b/drivers/gpu/drm/via/via_irq.c
42609@@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
42610 if (crtc != 0)
42611 return 0;
42612
42613- return atomic_read(&dev_priv->vbl_received);
42614+ return atomic_read_unchecked(&dev_priv->vbl_received);
42615 }
42616
42617 irqreturn_t via_driver_irq_handler(int irq, void *arg)
42618@@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(int irq, void *arg)
42619
42620 status = VIA_READ(VIA_REG_INTERRUPT);
42621 if (status & VIA_IRQ_VBLANK_PENDING) {
42622- atomic_inc(&dev_priv->vbl_received);
42623- if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
42624+ atomic_inc_unchecked(&dev_priv->vbl_received);
42625+ if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
42626 do_gettimeofday(&cur_vblank);
42627 if (dev_priv->last_vblank_valid) {
42628 dev_priv->usec_per_vblank =
42629@@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(int irq, void *arg)
42630 dev_priv->last_vblank = cur_vblank;
42631 dev_priv->last_vblank_valid = 1;
42632 }
42633- if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
42634+ if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
42635 DRM_DEBUG("US per vblank is: %u\n",
42636 dev_priv->usec_per_vblank);
42637 }
42638@@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(int irq, void *arg)
42639
42640 for (i = 0; i < dev_priv->num_irqs; ++i) {
42641 if (status & cur_irq->pending_mask) {
42642- atomic_inc(&cur_irq->irq_received);
42643+ atomic_inc_unchecked(&cur_irq->irq_received);
42644 wake_up(&cur_irq->irq_queue);
42645 handled = 1;
42646 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
42647@@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
42648 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * HZ,
42649 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
42650 masks[irq][4]));
42651- cur_irq_sequence = atomic_read(&cur_irq->irq_received);
42652+ cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
42653 } else {
42654 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * HZ,
42655 (((cur_irq_sequence =
42656- atomic_read(&cur_irq->irq_received)) -
42657+ atomic_read_unchecked(&cur_irq->irq_received)) -
42658 *sequence) <= (1 << 23)));
42659 }
42660 *sequence = cur_irq_sequence;
42661@@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
42662 }
42663
42664 for (i = 0; i < dev_priv->num_irqs; ++i) {
42665- atomic_set(&cur_irq->irq_received, 0);
42666+ atomic_set_unchecked(&cur_irq->irq_received, 0);
42667 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
42668 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
42669 init_waitqueue_head(&cur_irq->irq_queue);
42670@@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
42671 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
42672 case VIA_IRQ_RELATIVE:
42673 irqwait->request.sequence +=
42674- atomic_read(&cur_irq->irq_received);
42675+ atomic_read_unchecked(&cur_irq->irq_received);
42676 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
42677 case VIA_IRQ_ABSOLUTE:
42678 break;
42679diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
42680index d26a6da..5fa41ed 100644
42681--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
42682+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
42683@@ -447,7 +447,7 @@ struct vmw_private {
42684 * Fencing and IRQs.
42685 */
42686
42687- atomic_t marker_seq;
42688+ atomic_unchecked_t marker_seq;
42689 wait_queue_head_t fence_queue;
42690 wait_queue_head_t fifo_queue;
42691 spinlock_t waiter_lock;
42692diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
42693index 39f2b03..d1b0a64 100644
42694--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
42695+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
42696@@ -152,7 +152,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
42697 (unsigned int) min,
42698 (unsigned int) fifo->capabilities);
42699
42700- atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
42701+ atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
42702 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
42703 vmw_marker_queue_init(&fifo->marker_queue);
42704 return vmw_fifo_send_fence(dev_priv, &dummy);
42705@@ -372,7 +372,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
42706 if (reserveable)
42707 iowrite32(bytes, fifo_mem +
42708 SVGA_FIFO_RESERVED);
42709- return fifo_mem + (next_cmd >> 2);
42710+ return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
42711 } else {
42712 need_bounce = true;
42713 }
42714@@ -492,7 +492,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
42715
42716 fm = vmw_fifo_reserve(dev_priv, bytes);
42717 if (unlikely(fm == NULL)) {
42718- *seqno = atomic_read(&dev_priv->marker_seq);
42719+ *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
42720 ret = -ENOMEM;
42721 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
42722 false, 3*HZ);
42723@@ -500,7 +500,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
42724 }
42725
42726 do {
42727- *seqno = atomic_add_return(1, &dev_priv->marker_seq);
42728+ *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
42729 } while (*seqno == 0);
42730
42731 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
42732diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
42733index 170b61b..fec7348 100644
42734--- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
42735+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
42736@@ -164,9 +164,9 @@ static void vmw_gmrid_man_debug(struct ttm_mem_type_manager *man,
42737 }
42738
42739 const struct ttm_mem_type_manager_func vmw_gmrid_manager_func = {
42740- vmw_gmrid_man_init,
42741- vmw_gmrid_man_takedown,
42742- vmw_gmrid_man_get_node,
42743- vmw_gmrid_man_put_node,
42744- vmw_gmrid_man_debug
42745+ .init = vmw_gmrid_man_init,
42746+ .takedown = vmw_gmrid_man_takedown,
42747+ .get_node = vmw_gmrid_man_get_node,
42748+ .put_node = vmw_gmrid_man_put_node,
42749+ .debug = vmw_gmrid_man_debug
42750 };
42751diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
42752index 69c8ce2..cacb0ab 100644
42753--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
42754+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
42755@@ -235,7 +235,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
42756 int ret;
42757
42758 num_clips = arg->num_clips;
42759- clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
42760+ clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
42761
42762 if (unlikely(num_clips == 0))
42763 return 0;
42764@@ -318,7 +318,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
42765 int ret;
42766
42767 num_clips = arg->num_clips;
42768- clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
42769+ clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
42770
42771 if (unlikely(num_clips == 0))
42772 return 0;
42773diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
42774index 9fe9827..0aa2fc0 100644
42775--- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
42776+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
42777@@ -102,7 +102,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
42778 * emitted. Then the fence is stale and signaled.
42779 */
42780
42781- ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
42782+ ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
42783 > VMW_FENCE_WRAP);
42784
42785 return ret;
42786@@ -133,7 +133,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
42787
42788 if (fifo_idle)
42789 down_read(&fifo_state->rwsem);
42790- signal_seq = atomic_read(&dev_priv->marker_seq);
42791+ signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
42792 ret = 0;
42793
42794 for (;;) {
42795diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
42796index efd1ffd..0ae13ca 100644
42797--- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
42798+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
42799@@ -135,7 +135,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
42800 while (!vmw_lag_lt(queue, us)) {
42801 spin_lock(&queue->lock);
42802 if (list_empty(&queue->head))
42803- seqno = atomic_read(&dev_priv->marker_seq);
42804+ seqno = atomic_read_unchecked(&dev_priv->marker_seq);
42805 else {
42806 marker = list_first_entry(&queue->head,
42807 struct vmw_marker, head);
42808diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c
42809index 37ac7b5..d52a5c9 100644
42810--- a/drivers/gpu/vga/vga_switcheroo.c
42811+++ b/drivers/gpu/vga/vga_switcheroo.c
42812@@ -644,7 +644,7 @@ static int vga_switcheroo_runtime_resume(struct device *dev)
42813
42814 /* this version is for the case where the power switch is separate
42815 to the device being powered down. */
42816-int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain)
42817+int vga_switcheroo_init_domain_pm_ops(struct device *dev, dev_pm_domain_no_const *domain)
42818 {
42819 /* copy over all the bus versions */
42820 if (dev->bus && dev->bus->pm) {
42821@@ -695,7 +695,7 @@ static int vga_switcheroo_runtime_resume_hdmi_audio(struct device *dev)
42822 return ret;
42823 }
42824
42825-int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain)
42826+int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, dev_pm_domain_no_const *domain)
42827 {
42828 /* copy over all the bus versions */
42829 if (dev->bus && dev->bus->pm) {
42830diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
42831index 722a925..594c312 100644
42832--- a/drivers/hid/hid-core.c
42833+++ b/drivers/hid/hid-core.c
42834@@ -2552,7 +2552,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
42835
42836 int hid_add_device(struct hid_device *hdev)
42837 {
42838- static atomic_t id = ATOMIC_INIT(0);
42839+ static atomic_unchecked_t id = ATOMIC_INIT(0);
42840 int ret;
42841
42842 if (WARN_ON(hdev->status & HID_STAT_ADDED))
42843@@ -2595,7 +2595,7 @@ int hid_add_device(struct hid_device *hdev)
42844 /* XXX hack, any other cleaner solution after the driver core
42845 * is converted to allow more than 20 bytes as the device name? */
42846 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
42847- hdev->vendor, hdev->product, atomic_inc_return(&id));
42848+ hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
42849
42850 hid_debug_register(hdev, dev_name(&hdev->dev));
42851 ret = device_add(&hdev->dev);
42852diff --git a/drivers/hid/hid-sensor-custom.c b/drivers/hid/hid-sensor-custom.c
42853index 5614fee..8301fbf 100644
42854--- a/drivers/hid/hid-sensor-custom.c
42855+++ b/drivers/hid/hid-sensor-custom.c
42856@@ -34,7 +34,7 @@ struct hid_sensor_custom_field {
42857 int report_id;
42858 char group_name[HID_CUSTOM_NAME_LENGTH];
42859 struct hid_sensor_hub_attribute_info attribute;
42860- struct device_attribute sd_attrs[HID_CUSTOM_MAX_CORE_ATTRS];
42861+ device_attribute_no_const sd_attrs[HID_CUSTOM_MAX_CORE_ATTRS];
42862 char attr_name[HID_CUSTOM_TOTAL_ATTRS][HID_CUSTOM_NAME_LENGTH];
42863 struct attribute *attrs[HID_CUSTOM_TOTAL_ATTRS];
42864 struct attribute_group hid_custom_attribute_group;
42865@@ -590,7 +590,7 @@ static int hid_sensor_custom_add_attributes(struct hid_sensor_custom
42866 j = 0;
42867 while (j < HID_CUSTOM_TOTAL_ATTRS &&
42868 hid_custom_attrs[j].name) {
42869- struct device_attribute *device_attr;
42870+ device_attribute_no_const *device_attr;
42871
42872 device_attr = &sensor_inst->fields[i].sd_attrs[j];
42873
42874diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
42875index c13fb5b..55a3802 100644
42876--- a/drivers/hid/hid-wiimote-debug.c
42877+++ b/drivers/hid/hid-wiimote-debug.c
42878@@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
42879 else if (size == 0)
42880 return -EIO;
42881
42882- if (copy_to_user(u, buf, size))
42883+ if (size > sizeof(buf) || copy_to_user(u, buf, size))
42884 return -EFAULT;
42885
42886 *off += size;
42887diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
42888index 54da66d..aa3a3d7 100644
42889--- a/drivers/hv/channel.c
42890+++ b/drivers/hv/channel.c
42891@@ -373,7 +373,7 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
42892 int ret = 0;
42893
42894 next_gpadl_handle =
42895- (atomic_inc_return(&vmbus_connection.next_gpadl_handle) - 1);
42896+ (atomic_inc_return_unchecked(&vmbus_connection.next_gpadl_handle) - 1);
42897
42898 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
42899 if (ret)
42900diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
42901index d3943bc..3de28a9 100644
42902--- a/drivers/hv/hv.c
42903+++ b/drivers/hv/hv.c
42904@@ -118,7 +118,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
42905 u64 output_address = (output) ? virt_to_phys(output) : 0;
42906 u32 output_address_hi = output_address >> 32;
42907 u32 output_address_lo = output_address & 0xFFFFFFFF;
42908- void *hypercall_page = hv_context.hypercall_page;
42909+ void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
42910
42911 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
42912 "=a"(hv_status_lo) : "d" (control_hi),
42913@@ -164,7 +164,7 @@ int hv_init(void)
42914 /* See if the hypercall page is already set */
42915 rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
42916
42917- virtaddr = __vmalloc(PAGE_SIZE, GFP_KERNEL, PAGE_KERNEL_EXEC);
42918+ virtaddr = __vmalloc(PAGE_SIZE, GFP_KERNEL, PAGE_KERNEL_RX);
42919
42920 if (!virtaddr)
42921 goto cleanup;
42922diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
42923index cb5b7dc..6052f22 100644
42924--- a/drivers/hv/hv_balloon.c
42925+++ b/drivers/hv/hv_balloon.c
42926@@ -469,7 +469,7 @@ MODULE_PARM_DESC(hot_add, "If set attempt memory hot_add");
42927
42928 module_param(pressure_report_delay, uint, (S_IRUGO | S_IWUSR));
42929 MODULE_PARM_DESC(pressure_report_delay, "Delay in secs in reporting pressure");
42930-static atomic_t trans_id = ATOMIC_INIT(0);
42931+static atomic_unchecked_t trans_id = ATOMIC_INIT(0);
42932
42933 static int dm_ring_size = (5 * PAGE_SIZE);
42934
42935@@ -941,7 +941,7 @@ static void hot_add_req(struct work_struct *dummy)
42936 pr_info("Memory hot add failed\n");
42937
42938 dm->state = DM_INITIALIZED;
42939- resp.hdr.trans_id = atomic_inc_return(&trans_id);
42940+ resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
42941 vmbus_sendpacket(dm->dev->channel, &resp,
42942 sizeof(struct dm_hot_add_response),
42943 (unsigned long)NULL,
42944@@ -1022,7 +1022,7 @@ static void post_status(struct hv_dynmem_device *dm)
42945 memset(&status, 0, sizeof(struct dm_status));
42946 status.hdr.type = DM_STATUS_REPORT;
42947 status.hdr.size = sizeof(struct dm_status);
42948- status.hdr.trans_id = atomic_inc_return(&trans_id);
42949+ status.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
42950
42951 /*
42952 * The host expects the guest to report free and committed memory.
42953@@ -1046,7 +1046,7 @@ static void post_status(struct hv_dynmem_device *dm)
42954 * send the status. This can happen if we were interrupted
42955 * after we picked our transaction ID.
42956 */
42957- if (status.hdr.trans_id != atomic_read(&trans_id))
42958+ if (status.hdr.trans_id != atomic_read_unchecked(&trans_id))
42959 return;
42960
42961 /*
42962@@ -1191,7 +1191,7 @@ static void balloon_up(struct work_struct *dummy)
42963 */
42964
42965 do {
42966- bl_resp->hdr.trans_id = atomic_inc_return(&trans_id);
42967+ bl_resp->hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
42968 ret = vmbus_sendpacket(dm_device.dev->channel,
42969 bl_resp,
42970 bl_resp->hdr.size,
42971@@ -1237,7 +1237,7 @@ static void balloon_down(struct hv_dynmem_device *dm,
42972
42973 memset(&resp, 0, sizeof(struct dm_unballoon_response));
42974 resp.hdr.type = DM_UNBALLOON_RESPONSE;
42975- resp.hdr.trans_id = atomic_inc_return(&trans_id);
42976+ resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
42977 resp.hdr.size = sizeof(struct dm_unballoon_response);
42978
42979 vmbus_sendpacket(dm_device.dev->channel, &resp,
42980@@ -1298,7 +1298,7 @@ static void version_resp(struct hv_dynmem_device *dm,
42981 memset(&version_req, 0, sizeof(struct dm_version_request));
42982 version_req.hdr.type = DM_VERSION_REQUEST;
42983 version_req.hdr.size = sizeof(struct dm_version_request);
42984- version_req.hdr.trans_id = atomic_inc_return(&trans_id);
42985+ version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
42986 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN7;
42987 version_req.is_last_attempt = 1;
42988
42989@@ -1471,7 +1471,7 @@ static int balloon_probe(struct hv_device *dev,
42990 memset(&version_req, 0, sizeof(struct dm_version_request));
42991 version_req.hdr.type = DM_VERSION_REQUEST;
42992 version_req.hdr.size = sizeof(struct dm_version_request);
42993- version_req.hdr.trans_id = atomic_inc_return(&trans_id);
42994+ version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
42995 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN8;
42996 version_req.is_last_attempt = 0;
42997
42998@@ -1502,7 +1502,7 @@ static int balloon_probe(struct hv_device *dev,
42999 memset(&cap_msg, 0, sizeof(struct dm_capabilities));
43000 cap_msg.hdr.type = DM_CAPABILITIES_REPORT;
43001 cap_msg.hdr.size = sizeof(struct dm_capabilities);
43002- cap_msg.hdr.trans_id = atomic_inc_return(&trans_id);
43003+ cap_msg.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
43004
43005 cap_msg.caps.cap_bits.balloon = 1;
43006 cap_msg.caps.cap_bits.hot_add = 1;
43007diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
43008index 887287a..238a626 100644
43009--- a/drivers/hv/hyperv_vmbus.h
43010+++ b/drivers/hv/hyperv_vmbus.h
43011@@ -645,7 +645,7 @@ enum vmbus_connect_state {
43012 struct vmbus_connection {
43013 enum vmbus_connect_state conn_state;
43014
43015- atomic_t next_gpadl_handle;
43016+ atomic_unchecked_t next_gpadl_handle;
43017
43018 /*
43019 * Represents channel interrupts. Each bit position represents a
43020diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
43021index 579bdf9..0dac21d5 100644
43022--- a/drivers/hwmon/acpi_power_meter.c
43023+++ b/drivers/hwmon/acpi_power_meter.c
43024@@ -116,7 +116,7 @@ struct sensor_template {
43025 struct device_attribute *devattr,
43026 const char *buf, size_t count);
43027 int index;
43028-};
43029+} __do_const;
43030
43031 /* Averaging interval */
43032 static int update_avg_interval(struct acpi_power_meter_resource *resource)
43033@@ -631,7 +631,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
43034 struct sensor_template *attrs)
43035 {
43036 struct device *dev = &resource->acpi_dev->dev;
43037- struct sensor_device_attribute *sensors =
43038+ sensor_device_attribute_no_const *sensors =
43039 &resource->sensors[resource->num_sensors];
43040 int res = 0;
43041
43042@@ -973,7 +973,7 @@ static int __init enable_cap_knobs(const struct dmi_system_id *d)
43043 return 0;
43044 }
43045
43046-static struct dmi_system_id __initdata pm_dmi_table[] = {
43047+static const struct dmi_system_id __initconst pm_dmi_table[] = {
43048 {
43049 enable_cap_knobs, "IBM Active Energy Manager",
43050 {
43051diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
43052index 0af63da..05a183a 100644
43053--- a/drivers/hwmon/applesmc.c
43054+++ b/drivers/hwmon/applesmc.c
43055@@ -1105,7 +1105,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
43056 {
43057 struct applesmc_node_group *grp;
43058 struct applesmc_dev_attr *node;
43059- struct attribute *attr;
43060+ attribute_no_const *attr;
43061 int ret, i;
43062
43063 for (grp = groups; grp->format; grp++) {
43064diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
43065index cccef87..06ce8ec 100644
43066--- a/drivers/hwmon/asus_atk0110.c
43067+++ b/drivers/hwmon/asus_atk0110.c
43068@@ -147,10 +147,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
43069 struct atk_sensor_data {
43070 struct list_head list;
43071 struct atk_data *data;
43072- struct device_attribute label_attr;
43073- struct device_attribute input_attr;
43074- struct device_attribute limit1_attr;
43075- struct device_attribute limit2_attr;
43076+ device_attribute_no_const label_attr;
43077+ device_attribute_no_const input_attr;
43078+ device_attribute_no_const limit1_attr;
43079+ device_attribute_no_const limit2_attr;
43080 char label_attr_name[ATTR_NAME_SIZE];
43081 char input_attr_name[ATTR_NAME_SIZE];
43082 char limit1_attr_name[ATTR_NAME_SIZE];
43083@@ -270,7 +270,7 @@ static ssize_t atk_name_show(struct device *dev,
43084 static struct device_attribute atk_name_attr =
43085 __ATTR(name, 0444, atk_name_show, NULL);
43086
43087-static void atk_init_attribute(struct device_attribute *attr, char *name,
43088+static void atk_init_attribute(device_attribute_no_const *attr, char *name,
43089 sysfs_show_func show)
43090 {
43091 sysfs_attr_init(&attr->attr);
43092diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
43093index ed303ba..e24bd26f 100644
43094--- a/drivers/hwmon/coretemp.c
43095+++ b/drivers/hwmon/coretemp.c
43096@@ -782,7 +782,7 @@ static int coretemp_cpu_callback(struct notifier_block *nfb,
43097 return NOTIFY_OK;
43098 }
43099
43100-static struct notifier_block coretemp_cpu_notifier __refdata = {
43101+static struct notifier_block coretemp_cpu_notifier = {
43102 .notifier_call = coretemp_cpu_callback,
43103 };
43104
43105diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
43106index 7a8a6fb..015c1fd 100644
43107--- a/drivers/hwmon/ibmaem.c
43108+++ b/drivers/hwmon/ibmaem.c
43109@@ -924,7 +924,7 @@ static int aem_register_sensors(struct aem_data *data,
43110 struct aem_rw_sensor_template *rw)
43111 {
43112 struct device *dev = &data->pdev->dev;
43113- struct sensor_device_attribute *sensors = data->sensors;
43114+ sensor_device_attribute_no_const *sensors = data->sensors;
43115 int err;
43116
43117 /* Set up read-only sensors */
43118diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
43119index 17ae2eb..21b71dd 100644
43120--- a/drivers/hwmon/iio_hwmon.c
43121+++ b/drivers/hwmon/iio_hwmon.c
43122@@ -61,7 +61,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
43123 {
43124 struct device *dev = &pdev->dev;
43125 struct iio_hwmon_state *st;
43126- struct sensor_device_attribute *a;
43127+ sensor_device_attribute_no_const *a;
43128 int ret, i;
43129 int in_i = 1, temp_i = 1, curr_i = 1, humidity_i = 1;
43130 enum iio_chan_type type;
43131diff --git a/drivers/hwmon/nct6683.c b/drivers/hwmon/nct6683.c
43132index 37f0170..414ec2c 100644
43133--- a/drivers/hwmon/nct6683.c
43134+++ b/drivers/hwmon/nct6683.c
43135@@ -397,11 +397,11 @@ static struct attribute_group *
43136 nct6683_create_attr_group(struct device *dev, struct sensor_template_group *tg,
43137 int repeat)
43138 {
43139- struct sensor_device_attribute_2 *a2;
43140- struct sensor_device_attribute *a;
43141+ sensor_device_attribute_2_no_const *a2;
43142+ sensor_device_attribute_no_const *a;
43143 struct sensor_device_template **t;
43144 struct sensor_device_attr_u *su;
43145- struct attribute_group *group;
43146+ attribute_group_no_const *group;
43147 struct attribute **attrs;
43148 int i, j, count;
43149
43150diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
43151index bd1c99d..2fa55ad 100644
43152--- a/drivers/hwmon/nct6775.c
43153+++ b/drivers/hwmon/nct6775.c
43154@@ -953,10 +953,10 @@ static struct attribute_group *
43155 nct6775_create_attr_group(struct device *dev, struct sensor_template_group *tg,
43156 int repeat)
43157 {
43158- struct attribute_group *group;
43159+ attribute_group_no_const *group;
43160 struct sensor_device_attr_u *su;
43161- struct sensor_device_attribute *a;
43162- struct sensor_device_attribute_2 *a2;
43163+ sensor_device_attribute_no_const *a;
43164+ sensor_device_attribute_2_no_const *a2;
43165 struct attribute **attrs;
43166 struct sensor_device_template **t;
43167 int i, count;
43168diff --git a/drivers/hwmon/nct7802.c b/drivers/hwmon/nct7802.c
43169index 5576579..9192666 100644
43170--- a/drivers/hwmon/nct7802.c
43171+++ b/drivers/hwmon/nct7802.c
43172@@ -195,7 +195,7 @@ abort:
43173 }
43174
43175 static int nct7802_write_voltage(struct nct7802_data *data, int nr, int index,
43176- unsigned int voltage)
43177+ unsigned long voltage)
43178 {
43179 int shift = 8 - REG_VOLTAGE_LIMIT_MSB_SHIFT[index - 1][nr];
43180 int err;
43181diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
43182index f2e47c7..45d7941 100644
43183--- a/drivers/hwmon/pmbus/pmbus_core.c
43184+++ b/drivers/hwmon/pmbus/pmbus_core.c
43185@@ -816,7 +816,7 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
43186 return 0;
43187 }
43188
43189-static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
43190+static void pmbus_dev_attr_init(device_attribute_no_const *dev_attr,
43191 const char *name,
43192 umode_t mode,
43193 ssize_t (*show)(struct device *dev,
43194@@ -833,7 +833,7 @@ static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
43195 dev_attr->store = store;
43196 }
43197
43198-static void pmbus_attr_init(struct sensor_device_attribute *a,
43199+static void pmbus_attr_init(sensor_device_attribute_no_const *a,
43200 const char *name,
43201 umode_t mode,
43202 ssize_t (*show)(struct device *dev,
43203@@ -855,7 +855,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
43204 u16 reg, u8 mask)
43205 {
43206 struct pmbus_boolean *boolean;
43207- struct sensor_device_attribute *a;
43208+ sensor_device_attribute_no_const *a;
43209
43210 boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL);
43211 if (!boolean)
43212@@ -880,7 +880,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
43213 bool update, bool readonly)
43214 {
43215 struct pmbus_sensor *sensor;
43216- struct device_attribute *a;
43217+ device_attribute_no_const *a;
43218
43219 sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL);
43220 if (!sensor)
43221@@ -911,7 +911,7 @@ static int pmbus_add_label(struct pmbus_data *data,
43222 const char *lstring, int index)
43223 {
43224 struct pmbus_label *label;
43225- struct device_attribute *a;
43226+ device_attribute_no_const *a;
43227
43228 label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL);
43229 if (!label)
43230diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
43231index d4f0935..7420593 100644
43232--- a/drivers/hwmon/sht15.c
43233+++ b/drivers/hwmon/sht15.c
43234@@ -169,7 +169,7 @@ struct sht15_data {
43235 int supply_uv;
43236 bool supply_uv_valid;
43237 struct work_struct update_supply_work;
43238- atomic_t interrupt_handled;
43239+ atomic_unchecked_t interrupt_handled;
43240 };
43241
43242 /**
43243@@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
43244 ret = gpio_direction_input(data->pdata->gpio_data);
43245 if (ret)
43246 return ret;
43247- atomic_set(&data->interrupt_handled, 0);
43248+ atomic_set_unchecked(&data->interrupt_handled, 0);
43249
43250 enable_irq(gpio_to_irq(data->pdata->gpio_data));
43251 if (gpio_get_value(data->pdata->gpio_data) == 0) {
43252 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
43253 /* Only relevant if the interrupt hasn't occurred. */
43254- if (!atomic_read(&data->interrupt_handled))
43255+ if (!atomic_read_unchecked(&data->interrupt_handled))
43256 schedule_work(&data->read_work);
43257 }
43258 ret = wait_event_timeout(data->wait_queue,
43259@@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
43260
43261 /* First disable the interrupt */
43262 disable_irq_nosync(irq);
43263- atomic_inc(&data->interrupt_handled);
43264+ atomic_inc_unchecked(&data->interrupt_handled);
43265 /* Then schedule a reading work struct */
43266 if (data->state != SHT15_READING_NOTHING)
43267 schedule_work(&data->read_work);
43268@@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
43269 * If not, then start the interrupt again - care here as could
43270 * have gone low in meantime so verify it hasn't!
43271 */
43272- atomic_set(&data->interrupt_handled, 0);
43273+ atomic_set_unchecked(&data->interrupt_handled, 0);
43274 enable_irq(gpio_to_irq(data->pdata->gpio_data));
43275 /* If still not occurred or another handler was scheduled */
43276 if (gpio_get_value(data->pdata->gpio_data)
43277- || atomic_read(&data->interrupt_handled))
43278+ || atomic_read_unchecked(&data->interrupt_handled))
43279 return;
43280 }
43281
43282diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
43283index ac91c07..8e69663 100644
43284--- a/drivers/hwmon/via-cputemp.c
43285+++ b/drivers/hwmon/via-cputemp.c
43286@@ -295,7 +295,7 @@ static int via_cputemp_cpu_callback(struct notifier_block *nfb,
43287 return NOTIFY_OK;
43288 }
43289
43290-static struct notifier_block via_cputemp_cpu_notifier __refdata = {
43291+static struct notifier_block via_cputemp_cpu_notifier = {
43292 .notifier_call = via_cputemp_cpu_callback,
43293 };
43294
43295diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
43296index 65e3240..e6c511d 100644
43297--- a/drivers/i2c/busses/i2c-amd756-s4882.c
43298+++ b/drivers/i2c/busses/i2c-amd756-s4882.c
43299@@ -39,7 +39,7 @@
43300 extern struct i2c_adapter amd756_smbus;
43301
43302 static struct i2c_adapter *s4882_adapter;
43303-static struct i2c_algorithm *s4882_algo;
43304+static i2c_algorithm_no_const *s4882_algo;
43305
43306 /* Wrapper access functions for multiplexed SMBus */
43307 static DEFINE_MUTEX(amd756_lock);
43308diff --git a/drivers/i2c/busses/i2c-diolan-u2c.c b/drivers/i2c/busses/i2c-diolan-u2c.c
43309index b19a310..d6eece0 100644
43310--- a/drivers/i2c/busses/i2c-diolan-u2c.c
43311+++ b/drivers/i2c/busses/i2c-diolan-u2c.c
43312@@ -98,7 +98,7 @@ MODULE_PARM_DESC(frequency, "I2C clock frequency in hertz");
43313 /* usb layer */
43314
43315 /* Send command to device, and get response. */
43316-static int diolan_usb_transfer(struct i2c_diolan_u2c *dev)
43317+static int __intentional_overflow(-1) diolan_usb_transfer(struct i2c_diolan_u2c *dev)
43318 {
43319 int ret = 0;
43320 int actual;
43321diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
43322index 88eda09..cf40434 100644
43323--- a/drivers/i2c/busses/i2c-nforce2-s4985.c
43324+++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
43325@@ -37,7 +37,7 @@
43326 extern struct i2c_adapter *nforce2_smbus;
43327
43328 static struct i2c_adapter *s4985_adapter;
43329-static struct i2c_algorithm *s4985_algo;
43330+static i2c_algorithm_no_const *s4985_algo;
43331
43332 /* Wrapper access functions for multiplexed SMBus */
43333 static DEFINE_MUTEX(nforce2_lock);
43334diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
43335index 71c7a39..71dd3e0 100644
43336--- a/drivers/i2c/i2c-dev.c
43337+++ b/drivers/i2c/i2c-dev.c
43338@@ -272,7 +272,7 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
43339 break;
43340 }
43341
43342- data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
43343+ data_ptrs[i] = (u8 __force_user *)rdwr_pa[i].buf;
43344 rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);
43345 if (IS_ERR(rdwr_pa[i].buf)) {
43346 res = PTR_ERR(rdwr_pa[i].buf);
43347diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
43348index 0b510ba..4fbb5085 100644
43349--- a/drivers/ide/ide-cd.c
43350+++ b/drivers/ide/ide-cd.c
43351@@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
43352 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
43353 if ((unsigned long)buf & alignment
43354 || blk_rq_bytes(rq) & q->dma_pad_mask
43355- || object_is_on_stack(buf))
43356+ || object_starts_on_stack(buf))
43357 drive->dma = 0;
43358 }
43359 }
43360diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
43361index 4df97f6..c751151 100644
43362--- a/drivers/iio/industrialio-core.c
43363+++ b/drivers/iio/industrialio-core.c
43364@@ -570,7 +570,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
43365 }
43366
43367 static
43368-int __iio_device_attr_init(struct device_attribute *dev_attr,
43369+int __iio_device_attr_init(device_attribute_no_const *dev_attr,
43370 const char *postfix,
43371 struct iio_chan_spec const *chan,
43372 ssize_t (*readfunc)(struct device *dev,
43373diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
43374index 0271608..81998c5 100644
43375--- a/drivers/infiniband/core/cm.c
43376+++ b/drivers/infiniband/core/cm.c
43377@@ -115,7 +115,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
43378
43379 struct cm_counter_group {
43380 struct kobject obj;
43381- atomic_long_t counter[CM_ATTR_COUNT];
43382+ atomic_long_unchecked_t counter[CM_ATTR_COUNT];
43383 };
43384
43385 struct cm_counter_attribute {
43386@@ -1397,7 +1397,7 @@ static void cm_dup_req_handler(struct cm_work *work,
43387 struct ib_mad_send_buf *msg = NULL;
43388 int ret;
43389
43390- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
43391+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
43392 counter[CM_REQ_COUNTER]);
43393
43394 /* Quick state check to discard duplicate REQs. */
43395@@ -1784,7 +1784,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
43396 if (!cm_id_priv)
43397 return;
43398
43399- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
43400+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
43401 counter[CM_REP_COUNTER]);
43402 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
43403 if (ret)
43404@@ -1951,7 +1951,7 @@ static int cm_rtu_handler(struct cm_work *work)
43405 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
43406 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
43407 spin_unlock_irq(&cm_id_priv->lock);
43408- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
43409+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
43410 counter[CM_RTU_COUNTER]);
43411 goto out;
43412 }
43413@@ -2134,7 +2134,7 @@ static int cm_dreq_handler(struct cm_work *work)
43414 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
43415 dreq_msg->local_comm_id);
43416 if (!cm_id_priv) {
43417- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
43418+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
43419 counter[CM_DREQ_COUNTER]);
43420 cm_issue_drep(work->port, work->mad_recv_wc);
43421 return -EINVAL;
43422@@ -2159,7 +2159,7 @@ static int cm_dreq_handler(struct cm_work *work)
43423 case IB_CM_MRA_REP_RCVD:
43424 break;
43425 case IB_CM_TIMEWAIT:
43426- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
43427+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
43428 counter[CM_DREQ_COUNTER]);
43429 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
43430 goto unlock;
43431@@ -2173,7 +2173,7 @@ static int cm_dreq_handler(struct cm_work *work)
43432 cm_free_msg(msg);
43433 goto deref;
43434 case IB_CM_DREQ_RCVD:
43435- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
43436+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
43437 counter[CM_DREQ_COUNTER]);
43438 goto unlock;
43439 default:
43440@@ -2540,7 +2540,7 @@ static int cm_mra_handler(struct cm_work *work)
43441 ib_modify_mad(cm_id_priv->av.port->mad_agent,
43442 cm_id_priv->msg, timeout)) {
43443 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
43444- atomic_long_inc(&work->port->
43445+ atomic_long_inc_unchecked(&work->port->
43446 counter_group[CM_RECV_DUPLICATES].
43447 counter[CM_MRA_COUNTER]);
43448 goto out;
43449@@ -2549,7 +2549,7 @@ static int cm_mra_handler(struct cm_work *work)
43450 break;
43451 case IB_CM_MRA_REQ_RCVD:
43452 case IB_CM_MRA_REP_RCVD:
43453- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
43454+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
43455 counter[CM_MRA_COUNTER]);
43456 /* fall through */
43457 default:
43458@@ -2711,7 +2711,7 @@ static int cm_lap_handler(struct cm_work *work)
43459 case IB_CM_LAP_IDLE:
43460 break;
43461 case IB_CM_MRA_LAP_SENT:
43462- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
43463+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
43464 counter[CM_LAP_COUNTER]);
43465 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
43466 goto unlock;
43467@@ -2727,7 +2727,7 @@ static int cm_lap_handler(struct cm_work *work)
43468 cm_free_msg(msg);
43469 goto deref;
43470 case IB_CM_LAP_RCVD:
43471- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
43472+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
43473 counter[CM_LAP_COUNTER]);
43474 goto unlock;
43475 default:
43476@@ -3011,7 +3011,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
43477 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
43478 if (cur_cm_id_priv) {
43479 spin_unlock_irq(&cm.lock);
43480- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
43481+ atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
43482 counter[CM_SIDR_REQ_COUNTER]);
43483 goto out; /* Duplicate message. */
43484 }
43485@@ -3223,10 +3223,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
43486 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
43487 msg->retries = 1;
43488
43489- atomic_long_add(1 + msg->retries,
43490+ atomic_long_add_unchecked(1 + msg->retries,
43491 &port->counter_group[CM_XMIT].counter[attr_index]);
43492 if (msg->retries)
43493- atomic_long_add(msg->retries,
43494+ atomic_long_add_unchecked(msg->retries,
43495 &port->counter_group[CM_XMIT_RETRIES].
43496 counter[attr_index]);
43497
43498@@ -3436,7 +3436,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
43499 }
43500
43501 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
43502- atomic_long_inc(&port->counter_group[CM_RECV].
43503+ atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
43504 counter[attr_id - CM_ATTR_ID_OFFSET]);
43505
43506 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
43507@@ -3667,7 +3667,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
43508 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
43509
43510 return sprintf(buf, "%ld\n",
43511- atomic_long_read(&group->counter[cm_attr->index]));
43512+ atomic_long_read_unchecked(&group->counter[cm_attr->index]));
43513 }
43514
43515 static const struct sysfs_ops cm_counter_ops = {
43516diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
43517index 9f5ad7c..588cd84 100644
43518--- a/drivers/infiniband/core/fmr_pool.c
43519+++ b/drivers/infiniband/core/fmr_pool.c
43520@@ -98,8 +98,8 @@ struct ib_fmr_pool {
43521
43522 struct task_struct *thread;
43523
43524- atomic_t req_ser;
43525- atomic_t flush_ser;
43526+ atomic_unchecked_t req_ser;
43527+ atomic_unchecked_t flush_ser;
43528
43529 wait_queue_head_t force_wait;
43530 };
43531@@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
43532 struct ib_fmr_pool *pool = pool_ptr;
43533
43534 do {
43535- if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
43536+ if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
43537 ib_fmr_batch_release(pool);
43538
43539- atomic_inc(&pool->flush_ser);
43540+ atomic_inc_unchecked(&pool->flush_ser);
43541 wake_up_interruptible(&pool->force_wait);
43542
43543 if (pool->flush_function)
43544@@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
43545 }
43546
43547 set_current_state(TASK_INTERRUPTIBLE);
43548- if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
43549+ if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
43550 !kthread_should_stop())
43551 schedule();
43552 __set_current_state(TASK_RUNNING);
43553@@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
43554 pool->dirty_watermark = params->dirty_watermark;
43555 pool->dirty_len = 0;
43556 spin_lock_init(&pool->pool_lock);
43557- atomic_set(&pool->req_ser, 0);
43558- atomic_set(&pool->flush_ser, 0);
43559+ atomic_set_unchecked(&pool->req_ser, 0);
43560+ atomic_set_unchecked(&pool->flush_ser, 0);
43561 init_waitqueue_head(&pool->force_wait);
43562
43563 pool->thread = kthread_run(ib_fmr_cleanup_thread,
43564@@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
43565 }
43566 spin_unlock_irq(&pool->pool_lock);
43567
43568- serial = atomic_inc_return(&pool->req_ser);
43569+ serial = atomic_inc_return_unchecked(&pool->req_ser);
43570 wake_up_process(pool->thread);
43571
43572 if (wait_event_interruptible(pool->force_wait,
43573- atomic_read(&pool->flush_ser) - serial >= 0))
43574+ atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
43575 return -EINTR;
43576
43577 return 0;
43578@@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
43579 } else {
43580 list_add_tail(&fmr->list, &pool->dirty_list);
43581 if (++pool->dirty_len >= pool->dirty_watermark) {
43582- atomic_inc(&pool->req_ser);
43583+ atomic_inc_unchecked(&pool->req_ser);
43584 wake_up_process(pool->thread);
43585 }
43586 }
43587diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
43588index a9f0489..27a161b 100644
43589--- a/drivers/infiniband/core/uverbs_cmd.c
43590+++ b/drivers/infiniband/core/uverbs_cmd.c
43591@@ -951,6 +951,9 @@ ssize_t ib_uverbs_reg_mr(struct ib_uverbs_file *file,
43592 if (copy_from_user(&cmd, buf, sizeof cmd))
43593 return -EFAULT;
43594
43595+ if (!access_ok_noprefault(VERIFY_READ, cmd.start, cmd.length))
43596+ return -EFAULT;
43597+
43598 INIT_UDATA(&udata, buf + sizeof cmd,
43599 (unsigned long) cmd.response + sizeof resp,
43600 in_len - sizeof cmd, out_len - sizeof resp);
43601diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
43602index cff815b..75576dd 100644
43603--- a/drivers/infiniband/hw/cxgb4/mem.c
43604+++ b/drivers/infiniband/hw/cxgb4/mem.c
43605@@ -256,7 +256,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
43606 int err;
43607 struct fw_ri_tpte tpt;
43608 u32 stag_idx;
43609- static atomic_t key;
43610+ static atomic_unchecked_t key;
43611
43612 if (c4iw_fatal_error(rdev))
43613 return -EIO;
43614@@ -277,7 +277,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
43615 if (rdev->stats.stag.cur > rdev->stats.stag.max)
43616 rdev->stats.stag.max = rdev->stats.stag.cur;
43617 mutex_unlock(&rdev->stats.lock);
43618- *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
43619+ *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
43620 }
43621 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
43622 __func__, stag_state, type, pdid, stag_idx);
43623diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
43624index 79b3dbc..96e5fcc 100644
43625--- a/drivers/infiniband/hw/ipath/ipath_rc.c
43626+++ b/drivers/infiniband/hw/ipath/ipath_rc.c
43627@@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
43628 struct ib_atomic_eth *ateth;
43629 struct ipath_ack_entry *e;
43630 u64 vaddr;
43631- atomic64_t *maddr;
43632+ atomic64_unchecked_t *maddr;
43633 u64 sdata;
43634 u32 rkey;
43635 u8 next;
43636@@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
43637 IB_ACCESS_REMOTE_ATOMIC)))
43638 goto nack_acc_unlck;
43639 /* Perform atomic OP and save result. */
43640- maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
43641+ maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
43642 sdata = be64_to_cpu(ateth->swap_data);
43643 e = &qp->s_ack_queue[qp->r_head_ack_queue];
43644 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
43645- (u64) atomic64_add_return(sdata, maddr) - sdata :
43646+ (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
43647 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
43648 be64_to_cpu(ateth->compare_data),
43649 sdata);
43650diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
43651index 1f95bba..9530f87 100644
43652--- a/drivers/infiniband/hw/ipath/ipath_ruc.c
43653+++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
43654@@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
43655 unsigned long flags;
43656 struct ib_wc wc;
43657 u64 sdata;
43658- atomic64_t *maddr;
43659+ atomic64_unchecked_t *maddr;
43660 enum ib_wc_status send_status;
43661
43662 /*
43663@@ -382,11 +382,11 @@ again:
43664 IB_ACCESS_REMOTE_ATOMIC)))
43665 goto acc_err;
43666 /* Perform atomic OP and save result. */
43667- maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
43668+ maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
43669 sdata = wqe->wr.wr.atomic.compare_add;
43670 *(u64 *) sqp->s_sge.sge.vaddr =
43671 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
43672- (u64) atomic64_add_return(sdata, maddr) - sdata :
43673+ (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
43674 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
43675 sdata, wqe->wr.wr.atomic.swap);
43676 goto send_comp;
43677diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
43678index 9cd2b00..7486df4 100644
43679--- a/drivers/infiniband/hw/mlx4/mad.c
43680+++ b/drivers/infiniband/hw/mlx4/mad.c
43681@@ -106,7 +106,7 @@ __be64 mlx4_ib_gen_node_guid(void)
43682
43683 __be64 mlx4_ib_get_new_demux_tid(struct mlx4_ib_demux_ctx *ctx)
43684 {
43685- return cpu_to_be64(atomic_inc_return(&ctx->tid)) |
43686+ return cpu_to_be64(atomic_inc_return_unchecked(&ctx->tid)) |
43687 cpu_to_be64(0xff00000000000000LL);
43688 }
43689
43690diff --git a/drivers/infiniband/hw/mlx4/mcg.c b/drivers/infiniband/hw/mlx4/mcg.c
43691index ed327e6..ca1739e0 100644
43692--- a/drivers/infiniband/hw/mlx4/mcg.c
43693+++ b/drivers/infiniband/hw/mlx4/mcg.c
43694@@ -1041,7 +1041,7 @@ int mlx4_ib_mcg_port_init(struct mlx4_ib_demux_ctx *ctx)
43695 {
43696 char name[20];
43697
43698- atomic_set(&ctx->tid, 0);
43699+ atomic_set_unchecked(&ctx->tid, 0);
43700 sprintf(name, "mlx4_ib_mcg%d", ctx->port);
43701 ctx->mcg_wq = create_singlethread_workqueue(name);
43702 if (!ctx->mcg_wq)
43703diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
43704index fce39343..9d8fdff 100644
43705--- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
43706+++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
43707@@ -435,7 +435,7 @@ struct mlx4_ib_demux_ctx {
43708 struct list_head mcg_mgid0_list;
43709 struct workqueue_struct *mcg_wq;
43710 struct mlx4_ib_demux_pv_ctx **tun;
43711- atomic_t tid;
43712+ atomic_unchecked_t tid;
43713 int flushing; /* flushing the work queue */
43714 };
43715
43716diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
43717index 9d3e5c1..6f166df 100644
43718--- a/drivers/infiniband/hw/mthca/mthca_cmd.c
43719+++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
43720@@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
43721 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
43722 }
43723
43724-int mthca_QUERY_FW(struct mthca_dev *dev)
43725+int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
43726 {
43727 struct mthca_mailbox *mailbox;
43728 u32 *outbox;
43729@@ -1612,7 +1612,7 @@ int mthca_HW2SW_MPT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
43730 CMD_TIME_CLASS_B);
43731 }
43732
43733-int mthca_WRITE_MTT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
43734+int __intentional_overflow(-1) mthca_WRITE_MTT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
43735 int num_mtt)
43736 {
43737 return mthca_cmd(dev, mailbox->dma, num_mtt, 0, CMD_WRITE_MTT,
43738@@ -1634,7 +1634,7 @@ int mthca_MAP_EQ(struct mthca_dev *dev, u64 event_mask, int unmap,
43739 0, CMD_MAP_EQ, CMD_TIME_CLASS_B);
43740 }
43741
43742-int mthca_SW2HW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
43743+int __intentional_overflow(-1) mthca_SW2HW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
43744 int eq_num)
43745 {
43746 return mthca_cmd(dev, mailbox->dma, eq_num, 0, CMD_SW2HW_EQ,
43747@@ -1857,7 +1857,7 @@ int mthca_CONF_SPECIAL_QP(struct mthca_dev *dev, int type, u32 qpn)
43748 CMD_TIME_CLASS_B);
43749 }
43750
43751-int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
43752+int __intentional_overflow(-1) mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
43753 int port, struct ib_wc *in_wc, struct ib_grh *in_grh,
43754 void *in_mad, void *response_mad)
43755 {
43756diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c
43757index ded76c1..0cf0a08 100644
43758--- a/drivers/infiniband/hw/mthca/mthca_main.c
43759+++ b/drivers/infiniband/hw/mthca/mthca_main.c
43760@@ -692,7 +692,7 @@ err_close:
43761 return err;
43762 }
43763
43764-static int mthca_setup_hca(struct mthca_dev *dev)
43765+static int __intentional_overflow(-1) mthca_setup_hca(struct mthca_dev *dev)
43766 {
43767 int err;
43768
43769diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
43770index ed9a989..6aa5dc2 100644
43771--- a/drivers/infiniband/hw/mthca/mthca_mr.c
43772+++ b/drivers/infiniband/hw/mthca/mthca_mr.c
43773@@ -81,7 +81,7 @@ struct mthca_mpt_entry {
43774 * through the bitmaps)
43775 */
43776
43777-static u32 mthca_buddy_alloc(struct mthca_buddy *buddy, int order)
43778+static u32 __intentional_overflow(-1) mthca_buddy_alloc(struct mthca_buddy *buddy, int order)
43779 {
43780 int o;
43781 int m;
43782@@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
43783 return key;
43784 }
43785
43786-int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
43787+int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
43788 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
43789 {
43790 struct mthca_mailbox *mailbox;
43791@@ -516,7 +516,7 @@ int mthca_mr_alloc_notrans(struct mthca_dev *dev, u32 pd,
43792 return mthca_mr_alloc(dev, pd, 12, 0, ~0ULL, access, mr);
43793 }
43794
43795-int mthca_mr_alloc_phys(struct mthca_dev *dev, u32 pd,
43796+int __intentional_overflow(-1) mthca_mr_alloc_phys(struct mthca_dev *dev, u32 pd,
43797 u64 *buffer_list, int buffer_size_shift,
43798 int list_len, u64 iova, u64 total_size,
43799 u32 access, struct mthca_mr *mr)
43800diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c
43801index 415f8e1..e34214e 100644
43802--- a/drivers/infiniband/hw/mthca/mthca_provider.c
43803+++ b/drivers/infiniband/hw/mthca/mthca_provider.c
43804@@ -764,7 +764,7 @@ unlock:
43805 return 0;
43806 }
43807
43808-static int mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
43809+static int __intentional_overflow(-1) mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
43810 {
43811 struct mthca_dev *dev = to_mdev(ibcq->device);
43812 struct mthca_cq *cq = to_mcq(ibcq);
43813diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
43814index 9f9d5c5..3c19aac 100644
43815--- a/drivers/infiniband/hw/nes/nes.c
43816+++ b/drivers/infiniband/hw/nes/nes.c
43817@@ -97,7 +97,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
43818 LIST_HEAD(nes_adapter_list);
43819 static LIST_HEAD(nes_dev_list);
43820
43821-atomic_t qps_destroyed;
43822+atomic_unchecked_t qps_destroyed;
43823
43824 static unsigned int ee_flsh_adapter;
43825 static unsigned int sysfs_nonidx_addr;
43826@@ -279,7 +279,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
43827 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
43828 struct nes_adapter *nesadapter = nesdev->nesadapter;
43829
43830- atomic_inc(&qps_destroyed);
43831+ atomic_inc_unchecked(&qps_destroyed);
43832
43833 /* Free the control structures */
43834
43835diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
43836index bd9d132..70d84f4 100644
43837--- a/drivers/infiniband/hw/nes/nes.h
43838+++ b/drivers/infiniband/hw/nes/nes.h
43839@@ -180,17 +180,17 @@ extern unsigned int nes_debug_level;
43840 extern unsigned int wqm_quanta;
43841 extern struct list_head nes_adapter_list;
43842
43843-extern atomic_t cm_connects;
43844-extern atomic_t cm_accepts;
43845-extern atomic_t cm_disconnects;
43846-extern atomic_t cm_closes;
43847-extern atomic_t cm_connecteds;
43848-extern atomic_t cm_connect_reqs;
43849-extern atomic_t cm_rejects;
43850-extern atomic_t mod_qp_timouts;
43851-extern atomic_t qps_created;
43852-extern atomic_t qps_destroyed;
43853-extern atomic_t sw_qps_destroyed;
43854+extern atomic_unchecked_t cm_connects;
43855+extern atomic_unchecked_t cm_accepts;
43856+extern atomic_unchecked_t cm_disconnects;
43857+extern atomic_unchecked_t cm_closes;
43858+extern atomic_unchecked_t cm_connecteds;
43859+extern atomic_unchecked_t cm_connect_reqs;
43860+extern atomic_unchecked_t cm_rejects;
43861+extern atomic_unchecked_t mod_qp_timouts;
43862+extern atomic_unchecked_t qps_created;
43863+extern atomic_unchecked_t qps_destroyed;
43864+extern atomic_unchecked_t sw_qps_destroyed;
43865 extern u32 mh_detected;
43866 extern u32 mh_pauses_sent;
43867 extern u32 cm_packets_sent;
43868@@ -199,16 +199,16 @@ extern u32 cm_packets_created;
43869 extern u32 cm_packets_received;
43870 extern u32 cm_packets_dropped;
43871 extern u32 cm_packets_retrans;
43872-extern atomic_t cm_listens_created;
43873-extern atomic_t cm_listens_destroyed;
43874+extern atomic_unchecked_t cm_listens_created;
43875+extern atomic_unchecked_t cm_listens_destroyed;
43876 extern u32 cm_backlog_drops;
43877-extern atomic_t cm_loopbacks;
43878-extern atomic_t cm_nodes_created;
43879-extern atomic_t cm_nodes_destroyed;
43880-extern atomic_t cm_accel_dropped_pkts;
43881-extern atomic_t cm_resets_recvd;
43882-extern atomic_t pau_qps_created;
43883-extern atomic_t pau_qps_destroyed;
43884+extern atomic_unchecked_t cm_loopbacks;
43885+extern atomic_unchecked_t cm_nodes_created;
43886+extern atomic_unchecked_t cm_nodes_destroyed;
43887+extern atomic_unchecked_t cm_accel_dropped_pkts;
43888+extern atomic_unchecked_t cm_resets_recvd;
43889+extern atomic_unchecked_t pau_qps_created;
43890+extern atomic_unchecked_t pau_qps_destroyed;
43891
43892 extern u32 int_mod_timer_init;
43893 extern u32 int_mod_cq_depth_256;
43894diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
43895index 72b4341..2600332 100644
43896--- a/drivers/infiniband/hw/nes/nes_cm.c
43897+++ b/drivers/infiniband/hw/nes/nes_cm.c
43898@@ -69,14 +69,14 @@ u32 cm_packets_dropped;
43899 u32 cm_packets_retrans;
43900 u32 cm_packets_created;
43901 u32 cm_packets_received;
43902-atomic_t cm_listens_created;
43903-atomic_t cm_listens_destroyed;
43904+atomic_unchecked_t cm_listens_created;
43905+atomic_unchecked_t cm_listens_destroyed;
43906 u32 cm_backlog_drops;
43907-atomic_t cm_loopbacks;
43908-atomic_t cm_nodes_created;
43909-atomic_t cm_nodes_destroyed;
43910-atomic_t cm_accel_dropped_pkts;
43911-atomic_t cm_resets_recvd;
43912+atomic_unchecked_t cm_loopbacks;
43913+atomic_unchecked_t cm_nodes_created;
43914+atomic_unchecked_t cm_nodes_destroyed;
43915+atomic_unchecked_t cm_accel_dropped_pkts;
43916+atomic_unchecked_t cm_resets_recvd;
43917
43918 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
43919 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
43920@@ -135,28 +135,28 @@ static void record_ird_ord(struct nes_cm_node *, u16, u16);
43921 /* instance of function pointers for client API */
43922 /* set address of this instance to cm_core->cm_ops at cm_core alloc */
43923 static struct nes_cm_ops nes_cm_api = {
43924- mini_cm_accelerated,
43925- mini_cm_listen,
43926- mini_cm_del_listen,
43927- mini_cm_connect,
43928- mini_cm_close,
43929- mini_cm_accept,
43930- mini_cm_reject,
43931- mini_cm_recv_pkt,
43932- mini_cm_dealloc_core,
43933- mini_cm_get,
43934- mini_cm_set
43935+ .accelerated = mini_cm_accelerated,
43936+ .listen = mini_cm_listen,
43937+ .stop_listener = mini_cm_del_listen,
43938+ .connect = mini_cm_connect,
43939+ .close = mini_cm_close,
43940+ .accept = mini_cm_accept,
43941+ .reject = mini_cm_reject,
43942+ .recv_pkt = mini_cm_recv_pkt,
43943+ .destroy_cm_core = mini_cm_dealloc_core,
43944+ .get = mini_cm_get,
43945+ .set = mini_cm_set
43946 };
43947
43948 static struct nes_cm_core *g_cm_core;
43949
43950-atomic_t cm_connects;
43951-atomic_t cm_accepts;
43952-atomic_t cm_disconnects;
43953-atomic_t cm_closes;
43954-atomic_t cm_connecteds;
43955-atomic_t cm_connect_reqs;
43956-atomic_t cm_rejects;
43957+atomic_unchecked_t cm_connects;
43958+atomic_unchecked_t cm_accepts;
43959+atomic_unchecked_t cm_disconnects;
43960+atomic_unchecked_t cm_closes;
43961+atomic_unchecked_t cm_connecteds;
43962+atomic_unchecked_t cm_connect_reqs;
43963+atomic_unchecked_t cm_rejects;
43964
43965 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
43966 {
43967@@ -1461,7 +1461,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
43968 kfree(listener);
43969 listener = NULL;
43970 ret = 0;
43971- atomic_inc(&cm_listens_destroyed);
43972+ atomic_inc_unchecked(&cm_listens_destroyed);
43973 } else {
43974 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
43975 }
43976@@ -1667,7 +1667,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
43977 cm_node->rem_mac);
43978
43979 add_hte_node(cm_core, cm_node);
43980- atomic_inc(&cm_nodes_created);
43981+ atomic_inc_unchecked(&cm_nodes_created);
43982
43983 return cm_node;
43984 }
43985@@ -1728,7 +1728,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
43986 }
43987
43988 atomic_dec(&cm_core->node_cnt);
43989- atomic_inc(&cm_nodes_destroyed);
43990+ atomic_inc_unchecked(&cm_nodes_destroyed);
43991 nesqp = cm_node->nesqp;
43992 if (nesqp) {
43993 nesqp->cm_node = NULL;
43994@@ -1792,7 +1792,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
43995
43996 static void drop_packet(struct sk_buff *skb)
43997 {
43998- atomic_inc(&cm_accel_dropped_pkts);
43999+ atomic_inc_unchecked(&cm_accel_dropped_pkts);
44000 dev_kfree_skb_any(skb);
44001 }
44002
44003@@ -1855,7 +1855,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
44004 {
44005
44006 int reset = 0; /* whether to send reset in case of err.. */
44007- atomic_inc(&cm_resets_recvd);
44008+ atomic_inc_unchecked(&cm_resets_recvd);
44009 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
44010 " refcnt=%d\n", cm_node, cm_node->state,
44011 atomic_read(&cm_node->ref_count));
44012@@ -2523,7 +2523,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
44013 rem_ref_cm_node(cm_node->cm_core, cm_node);
44014 return NULL;
44015 }
44016- atomic_inc(&cm_loopbacks);
44017+ atomic_inc_unchecked(&cm_loopbacks);
44018 loopbackremotenode->loopbackpartner = cm_node;
44019 loopbackremotenode->tcp_cntxt.rcv_wscale =
44020 NES_CM_DEFAULT_RCV_WND_SCALE;
44021@@ -2804,7 +2804,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
44022 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
44023 else {
44024 rem_ref_cm_node(cm_core, cm_node);
44025- atomic_inc(&cm_accel_dropped_pkts);
44026+ atomic_inc_unchecked(&cm_accel_dropped_pkts);
44027 dev_kfree_skb_any(skb);
44028 }
44029 break;
44030@@ -3112,7 +3112,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
44031
44032 if ((cm_id) && (cm_id->event_handler)) {
44033 if (issue_disconn) {
44034- atomic_inc(&cm_disconnects);
44035+ atomic_inc_unchecked(&cm_disconnects);
44036 cm_event.event = IW_CM_EVENT_DISCONNECT;
44037 cm_event.status = disconn_status;
44038 cm_event.local_addr = cm_id->local_addr;
44039@@ -3134,7 +3134,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
44040 }
44041
44042 if (issue_close) {
44043- atomic_inc(&cm_closes);
44044+ atomic_inc_unchecked(&cm_closes);
44045 nes_disconnect(nesqp, 1);
44046
44047 cm_id->provider_data = nesqp;
44048@@ -3272,7 +3272,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
44049
44050 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
44051 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
44052- atomic_inc(&cm_accepts);
44053+ atomic_inc_unchecked(&cm_accepts);
44054
44055 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
44056 netdev_refcnt_read(nesvnic->netdev));
44057@@ -3470,7 +3470,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
44058 struct nes_cm_core *cm_core;
44059 u8 *start_buff;
44060
44061- atomic_inc(&cm_rejects);
44062+ atomic_inc_unchecked(&cm_rejects);
44063 cm_node = (struct nes_cm_node *)cm_id->provider_data;
44064 loopback = cm_node->loopbackpartner;
44065 cm_core = cm_node->cm_core;
44066@@ -3535,7 +3535,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
44067 ntohs(raddr->sin_port), ntohl(laddr->sin_addr.s_addr),
44068 ntohs(laddr->sin_port));
44069
44070- atomic_inc(&cm_connects);
44071+ atomic_inc_unchecked(&cm_connects);
44072 nesqp->active_conn = 1;
44073
44074 /* cache the cm_id in the qp */
44075@@ -3680,7 +3680,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
44076 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
44077 return err;
44078 }
44079- atomic_inc(&cm_listens_created);
44080+ atomic_inc_unchecked(&cm_listens_created);
44081 }
44082
44083 cm_id->add_ref(cm_id);
44084@@ -3787,7 +3787,7 @@ static void cm_event_connected(struct nes_cm_event *event)
44085
44086 if (nesqp->destroyed)
44087 return;
44088- atomic_inc(&cm_connecteds);
44089+ atomic_inc_unchecked(&cm_connecteds);
44090 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
44091 " local port 0x%04X. jiffies = %lu.\n",
44092 nesqp->hwqp.qp_id, ntohl(raddr->sin_addr.s_addr),
44093@@ -3972,7 +3972,7 @@ static void cm_event_reset(struct nes_cm_event *event)
44094
44095 cm_id->add_ref(cm_id);
44096 ret = cm_id->event_handler(cm_id, &cm_event);
44097- atomic_inc(&cm_closes);
44098+ atomic_inc_unchecked(&cm_closes);
44099 cm_event.event = IW_CM_EVENT_CLOSE;
44100 cm_event.status = 0;
44101 cm_event.provider_data = cm_id->provider_data;
44102@@ -4012,7 +4012,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
44103 return;
44104 cm_id = cm_node->cm_id;
44105
44106- atomic_inc(&cm_connect_reqs);
44107+ atomic_inc_unchecked(&cm_connect_reqs);
44108 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
44109 cm_node, cm_id, jiffies);
44110
44111@@ -4061,7 +4061,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
44112 return;
44113 cm_id = cm_node->cm_id;
44114
44115- atomic_inc(&cm_connect_reqs);
44116+ atomic_inc_unchecked(&cm_connect_reqs);
44117 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
44118 cm_node, cm_id, jiffies);
44119
44120diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
44121index 4166452..fc952c3 100644
44122--- a/drivers/infiniband/hw/nes/nes_mgt.c
44123+++ b/drivers/infiniband/hw/nes/nes_mgt.c
44124@@ -40,8 +40,8 @@
44125 #include "nes.h"
44126 #include "nes_mgt.h"
44127
44128-atomic_t pau_qps_created;
44129-atomic_t pau_qps_destroyed;
44130+atomic_unchecked_t pau_qps_created;
44131+atomic_unchecked_t pau_qps_destroyed;
44132
44133 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
44134 {
44135@@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
44136 {
44137 struct sk_buff *skb;
44138 unsigned long flags;
44139- atomic_inc(&pau_qps_destroyed);
44140+ atomic_inc_unchecked(&pau_qps_destroyed);
44141
44142 /* Free packets that have not yet been forwarded */
44143 /* Lock is acquired by skb_dequeue when removing the skb */
44144@@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
44145 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
44146 skb_queue_head_init(&nesqp->pau_list);
44147 spin_lock_init(&nesqp->pau_lock);
44148- atomic_inc(&pau_qps_created);
44149+ atomic_inc_unchecked(&pau_qps_created);
44150 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
44151 }
44152
44153diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
44154index 70acda9..a96de9d 100644
44155--- a/drivers/infiniband/hw/nes/nes_nic.c
44156+++ b/drivers/infiniband/hw/nes/nes_nic.c
44157@@ -1274,39 +1274,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
44158 target_stat_values[++index] = mh_detected;
44159 target_stat_values[++index] = mh_pauses_sent;
44160 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
44161- target_stat_values[++index] = atomic_read(&cm_connects);
44162- target_stat_values[++index] = atomic_read(&cm_accepts);
44163- target_stat_values[++index] = atomic_read(&cm_disconnects);
44164- target_stat_values[++index] = atomic_read(&cm_connecteds);
44165- target_stat_values[++index] = atomic_read(&cm_connect_reqs);
44166- target_stat_values[++index] = atomic_read(&cm_rejects);
44167- target_stat_values[++index] = atomic_read(&mod_qp_timouts);
44168- target_stat_values[++index] = atomic_read(&qps_created);
44169- target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
44170- target_stat_values[++index] = atomic_read(&qps_destroyed);
44171- target_stat_values[++index] = atomic_read(&cm_closes);
44172+ target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
44173+ target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
44174+ target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
44175+ target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
44176+ target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
44177+ target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
44178+ target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
44179+ target_stat_values[++index] = atomic_read_unchecked(&qps_created);
44180+ target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
44181+ target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
44182+ target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
44183 target_stat_values[++index] = cm_packets_sent;
44184 target_stat_values[++index] = cm_packets_bounced;
44185 target_stat_values[++index] = cm_packets_created;
44186 target_stat_values[++index] = cm_packets_received;
44187 target_stat_values[++index] = cm_packets_dropped;
44188 target_stat_values[++index] = cm_packets_retrans;
44189- target_stat_values[++index] = atomic_read(&cm_listens_created);
44190- target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
44191+ target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
44192+ target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
44193 target_stat_values[++index] = cm_backlog_drops;
44194- target_stat_values[++index] = atomic_read(&cm_loopbacks);
44195- target_stat_values[++index] = atomic_read(&cm_nodes_created);
44196- target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
44197- target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
44198- target_stat_values[++index] = atomic_read(&cm_resets_recvd);
44199+ target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
44200+ target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
44201+ target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
44202+ target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
44203+ target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
44204 target_stat_values[++index] = nesadapter->free_4kpbl;
44205 target_stat_values[++index] = nesadapter->free_256pbl;
44206 target_stat_values[++index] = int_mod_timer_init;
44207 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
44208 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
44209 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
44210- target_stat_values[++index] = atomic_read(&pau_qps_created);
44211- target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
44212+ target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
44213+ target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
44214 }
44215
44216 /**
44217diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
44218index c0d0296..3185f57 100644
44219--- a/drivers/infiniband/hw/nes/nes_verbs.c
44220+++ b/drivers/infiniband/hw/nes/nes_verbs.c
44221@@ -46,9 +46,9 @@
44222
44223 #include <rdma/ib_umem.h>
44224
44225-atomic_t mod_qp_timouts;
44226-atomic_t qps_created;
44227-atomic_t sw_qps_destroyed;
44228+atomic_unchecked_t mod_qp_timouts;
44229+atomic_unchecked_t qps_created;
44230+atomic_unchecked_t sw_qps_destroyed;
44231
44232 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
44233
44234@@ -1134,7 +1134,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
44235 if (init_attr->create_flags)
44236 return ERR_PTR(-EINVAL);
44237
44238- atomic_inc(&qps_created);
44239+ atomic_inc_unchecked(&qps_created);
44240 switch (init_attr->qp_type) {
44241 case IB_QPT_RC:
44242 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
44243@@ -1468,7 +1468,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
44244 struct iw_cm_event cm_event;
44245 int ret = 0;
44246
44247- atomic_inc(&sw_qps_destroyed);
44248+ atomic_inc_unchecked(&sw_qps_destroyed);
44249 nesqp->destroyed = 1;
44250
44251 /* Blow away the connection if it exists. */
44252diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
44253index 7df16f7..7e1b21e 100644
44254--- a/drivers/infiniband/hw/qib/qib.h
44255+++ b/drivers/infiniband/hw/qib/qib.h
44256@@ -52,6 +52,7 @@
44257 #include <linux/kref.h>
44258 #include <linux/sched.h>
44259 #include <linux/kthread.h>
44260+#include <linux/slab.h>
44261
44262 #include "qib_common.h"
44263 #include "qib_verbs.h"
44264diff --git a/drivers/infiniband/ulp/ipoib/ipoib_netlink.c b/drivers/infiniband/ulp/ipoib/ipoib_netlink.c
44265index cdc7df4..a2fdfdb 100644
44266--- a/drivers/infiniband/ulp/ipoib/ipoib_netlink.c
44267+++ b/drivers/infiniband/ulp/ipoib/ipoib_netlink.c
44268@@ -156,7 +156,7 @@ static size_t ipoib_get_size(const struct net_device *dev)
44269 nla_total_size(2); /* IFLA_IPOIB_UMCAST */
44270 }
44271
44272-static struct rtnl_link_ops ipoib_link_ops __read_mostly = {
44273+static struct rtnl_link_ops ipoib_link_ops = {
44274 .kind = "ipoib",
44275 .maxtype = IFLA_IPOIB_MAX,
44276 .policy = ipoib_policy,
44277diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
44278index e853a21..56fc5a8 100644
44279--- a/drivers/input/gameport/gameport.c
44280+++ b/drivers/input/gameport/gameport.c
44281@@ -527,14 +527,14 @@ EXPORT_SYMBOL(gameport_set_phys);
44282 */
44283 static void gameport_init_port(struct gameport *gameport)
44284 {
44285- static atomic_t gameport_no = ATOMIC_INIT(-1);
44286+ static atomic_unchecked_t gameport_no = ATOMIC_INIT(-1);
44287
44288 __module_get(THIS_MODULE);
44289
44290 mutex_init(&gameport->drv_mutex);
44291 device_initialize(&gameport->dev);
44292 dev_set_name(&gameport->dev, "gameport%lu",
44293- (unsigned long)atomic_inc_return(&gameport_no));
44294+ (unsigned long)atomic_inc_return_unchecked(&gameport_no));
44295 gameport->dev.bus = &gameport_bus;
44296 gameport->dev.release = gameport_release_port;
44297 if (gameport->parent)
44298diff --git a/drivers/input/input.c b/drivers/input/input.c
44299index cc357f1..ee42fbc 100644
44300--- a/drivers/input/input.c
44301+++ b/drivers/input/input.c
44302@@ -1781,7 +1781,7 @@ EXPORT_SYMBOL_GPL(input_class);
44303 */
44304 struct input_dev *input_allocate_device(void)
44305 {
44306- static atomic_t input_no = ATOMIC_INIT(-1);
44307+ static atomic_unchecked_t input_no = ATOMIC_INIT(-1);
44308 struct input_dev *dev;
44309
44310 dev = kzalloc(sizeof(struct input_dev), GFP_KERNEL);
44311@@ -1796,7 +1796,7 @@ struct input_dev *input_allocate_device(void)
44312 INIT_LIST_HEAD(&dev->node);
44313
44314 dev_set_name(&dev->dev, "input%lu",
44315- (unsigned long)atomic_inc_return(&input_no));
44316+ (unsigned long)atomic_inc_return_unchecked(&input_no));
44317
44318 __module_get(THIS_MODULE);
44319 }
44320diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
44321index 4a95b22..874c182 100644
44322--- a/drivers/input/joystick/sidewinder.c
44323+++ b/drivers/input/joystick/sidewinder.c
44324@@ -30,6 +30,7 @@
44325 #include <linux/kernel.h>
44326 #include <linux/module.h>
44327 #include <linux/slab.h>
44328+#include <linux/sched.h>
44329 #include <linux/input.h>
44330 #include <linux/gameport.h>
44331 #include <linux/jiffies.h>
44332diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
44333index 61c7611..e1bfa38 100644
44334--- a/drivers/input/joystick/xpad.c
44335+++ b/drivers/input/joystick/xpad.c
44336@@ -905,7 +905,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
44337
44338 static int xpad_led_probe(struct usb_xpad *xpad)
44339 {
44340- static atomic_t led_seq = ATOMIC_INIT(-1);
44341+ static atomic_unchecked_t led_seq = ATOMIC_INIT(-1);
44342 unsigned long led_no;
44343 struct xpad_led *led;
44344 struct led_classdev *led_cdev;
44345@@ -918,7 +918,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
44346 if (!led)
44347 return -ENOMEM;
44348
44349- led_no = atomic_inc_return(&led_seq);
44350+ led_no = atomic_inc_return_unchecked(&led_seq);
44351
44352 snprintf(led->name, sizeof(led->name), "xpad%lu", led_no);
44353 led->xpad = xpad;
44354diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c
44355index ac1fa5f..5f7502c 100644
44356--- a/drivers/input/misc/ims-pcu.c
44357+++ b/drivers/input/misc/ims-pcu.c
44358@@ -1851,7 +1851,7 @@ static int ims_pcu_identify_type(struct ims_pcu *pcu, u8 *device_id)
44359
44360 static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
44361 {
44362- static atomic_t device_no = ATOMIC_INIT(-1);
44363+ static atomic_unchecked_t device_no = ATOMIC_INIT(-1);
44364
44365 const struct ims_pcu_device_info *info;
44366 int error;
44367@@ -1882,7 +1882,7 @@ static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
44368 }
44369
44370 /* Device appears to be operable, complete initialization */
44371- pcu->device_no = atomic_inc_return(&device_no);
44372+ pcu->device_no = atomic_inc_return_unchecked(&device_no);
44373
44374 /*
44375 * PCU-B devices, both GEN_1 and GEN_2 do not have OFN sensor
44376diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
44377index ad5a5a1..5eac214 100644
44378--- a/drivers/input/mouse/psmouse.h
44379+++ b/drivers/input/mouse/psmouse.h
44380@@ -125,7 +125,7 @@ struct psmouse_attribute {
44381 ssize_t (*set)(struct psmouse *psmouse, void *data,
44382 const char *buf, size_t count);
44383 bool protect;
44384-};
44385+} __do_const;
44386 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
44387
44388 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
44389diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
44390index b604564..3f14ae4 100644
44391--- a/drivers/input/mousedev.c
44392+++ b/drivers/input/mousedev.c
44393@@ -744,7 +744,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
44394
44395 spin_unlock_irq(&client->packet_lock);
44396
44397- if (copy_to_user(buffer, data, count))
44398+ if (count > sizeof(data) || copy_to_user(buffer, data, count))
44399 return -EFAULT;
44400
44401 return count;
44402diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
44403index a05a517..323a2fd 100644
44404--- a/drivers/input/serio/serio.c
44405+++ b/drivers/input/serio/serio.c
44406@@ -514,7 +514,7 @@ static void serio_release_port(struct device *dev)
44407 */
44408 static void serio_init_port(struct serio *serio)
44409 {
44410- static atomic_t serio_no = ATOMIC_INIT(-1);
44411+ static atomic_unchecked_t serio_no = ATOMIC_INIT(-1);
44412
44413 __module_get(THIS_MODULE);
44414
44415@@ -525,7 +525,7 @@ static void serio_init_port(struct serio *serio)
44416 mutex_init(&serio->drv_mutex);
44417 device_initialize(&serio->dev);
44418 dev_set_name(&serio->dev, "serio%lu",
44419- (unsigned long)atomic_inc_return(&serio_no));
44420+ (unsigned long)atomic_inc_return_unchecked(&serio_no));
44421 serio->dev.bus = &serio_bus;
44422 serio->dev.release = serio_release_port;
44423 serio->dev.groups = serio_device_attr_groups;
44424diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
44425index 71ef5d6..93380a9 100644
44426--- a/drivers/input/serio/serio_raw.c
44427+++ b/drivers/input/serio/serio_raw.c
44428@@ -292,7 +292,7 @@ static irqreturn_t serio_raw_interrupt(struct serio *serio, unsigned char data,
44429
44430 static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
44431 {
44432- static atomic_t serio_raw_no = ATOMIC_INIT(-1);
44433+ static atomic_unchecked_t serio_raw_no = ATOMIC_INIT(-1);
44434 struct serio_raw *serio_raw;
44435 int err;
44436
44437@@ -303,7 +303,7 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
44438 }
44439
44440 snprintf(serio_raw->name, sizeof(serio_raw->name),
44441- "serio_raw%ld", (long)atomic_inc_return(&serio_raw_no));
44442+ "serio_raw%ld", (long)atomic_inc_return_unchecked(&serio_raw_no));
44443 kref_init(&serio_raw->kref);
44444 INIT_LIST_HEAD(&serio_raw->client_list);
44445 init_waitqueue_head(&serio_raw->wait);
44446diff --git a/drivers/input/touchscreen/htcpen.c b/drivers/input/touchscreen/htcpen.c
44447index 92e2243..8fd9092 100644
44448--- a/drivers/input/touchscreen/htcpen.c
44449+++ b/drivers/input/touchscreen/htcpen.c
44450@@ -219,7 +219,7 @@ static struct isa_driver htcpen_isa_driver = {
44451 }
44452 };
44453
44454-static struct dmi_system_id htcshift_dmi_table[] __initdata = {
44455+static const struct dmi_system_id htcshift_dmi_table[] __initconst = {
44456 {
44457 .ident = "Shift",
44458 .matches = {
44459diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
44460index ca9f4ed..b860ff1 100644
44461--- a/drivers/iommu/amd_iommu.c
44462+++ b/drivers/iommu/amd_iommu.c
44463@@ -829,11 +829,21 @@ static void copy_cmd_to_buffer(struct amd_iommu *iommu,
44464
44465 static void build_completion_wait(struct iommu_cmd *cmd, u64 address)
44466 {
44467+ phys_addr_t physaddr;
44468 WARN_ON(address & 0x7ULL);
44469
44470 memset(cmd, 0, sizeof(*cmd));
44471- cmd->data[0] = lower_32_bits(__pa(address)) | CMD_COMPL_WAIT_STORE_MASK;
44472- cmd->data[1] = upper_32_bits(__pa(address));
44473+
44474+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
44475+ if (object_starts_on_stack((void *)address)) {
44476+ void *adjbuf = (void *)address - current->stack + current->lowmem_stack;
44477+ physaddr = __pa((u64)adjbuf);
44478+ } else
44479+#endif
44480+ physaddr = __pa(address);
44481+
44482+ cmd->data[0] = lower_32_bits(physaddr) | CMD_COMPL_WAIT_STORE_MASK;
44483+ cmd->data[1] = upper_32_bits(physaddr);
44484 cmd->data[2] = 1;
44485 CMD_SET_TYPE(cmd, CMD_COMPL_WAIT);
44486 }
44487diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
44488index 65075ef..53823f9 100644
44489--- a/drivers/iommu/arm-smmu.c
44490+++ b/drivers/iommu/arm-smmu.c
44491@@ -331,7 +331,7 @@ enum arm_smmu_domain_stage {
44492
44493 struct arm_smmu_domain {
44494 struct arm_smmu_device *smmu;
44495- struct io_pgtable_ops *pgtbl_ops;
44496+ struct io_pgtable *pgtbl;
44497 spinlock_t pgtbl_lock;
44498 struct arm_smmu_cfg cfg;
44499 enum arm_smmu_domain_stage stage;
44500@@ -817,7 +817,7 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain,
44501 {
44502 int irq, start, ret = 0;
44503 unsigned long ias, oas;
44504- struct io_pgtable_ops *pgtbl_ops;
44505+ struct io_pgtable *pgtbl;
44506 struct io_pgtable_cfg pgtbl_cfg;
44507 enum io_pgtable_fmt fmt;
44508 struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
44509@@ -902,14 +902,16 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain,
44510 };
44511
44512 smmu_domain->smmu = smmu;
44513- pgtbl_ops = alloc_io_pgtable_ops(fmt, &pgtbl_cfg, smmu_domain);
44514- if (!pgtbl_ops) {
44515+ pgtbl = alloc_io_pgtable(fmt, &pgtbl_cfg, smmu_domain);
44516+ if (!pgtbl) {
44517 ret = -ENOMEM;
44518 goto out_clear_smmu;
44519 }
44520
44521 /* Update our support page sizes to reflect the page table format */
44522- arm_smmu_ops.pgsize_bitmap = pgtbl_cfg.pgsize_bitmap;
44523+ pax_open_kernel();
44524+ *(unsigned long *)&arm_smmu_ops.pgsize_bitmap = pgtbl_cfg.pgsize_bitmap;
44525+ pax_close_kernel();
44526
44527 /* Initialise the context bank with our page table cfg */
44528 arm_smmu_init_context_bank(smmu_domain, &pgtbl_cfg);
44529@@ -930,7 +932,7 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain,
44530 mutex_unlock(&smmu_domain->init_mutex);
44531
44532 /* Publish page table ops for map/unmap */
44533- smmu_domain->pgtbl_ops = pgtbl_ops;
44534+ smmu_domain->pgtbl = pgtbl;
44535 return 0;
44536
44537 out_clear_smmu:
44538@@ -963,8 +965,7 @@ static void arm_smmu_destroy_domain_context(struct iommu_domain *domain)
44539 free_irq(irq, domain);
44540 }
44541
44542- if (smmu_domain->pgtbl_ops)
44543- free_io_pgtable_ops(smmu_domain->pgtbl_ops);
44544+ free_io_pgtable(smmu_domain->pgtbl);
44545
44546 __arm_smmu_free_bitmap(smmu->context_map, cfg->cbndx);
44547 }
44548@@ -1190,13 +1191,13 @@ static int arm_smmu_map(struct iommu_domain *domain, unsigned long iova,
44549 int ret;
44550 unsigned long flags;
44551 struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
44552- struct io_pgtable_ops *ops= smmu_domain->pgtbl_ops;
44553+ struct io_pgtable *iop = smmu_domain->pgtbl;
44554
44555- if (!ops)
44556+ if (!iop)
44557 return -ENODEV;
44558
44559 spin_lock_irqsave(&smmu_domain->pgtbl_lock, flags);
44560- ret = ops->map(ops, iova, paddr, size, prot);
44561+ ret = iop->ops->map(iop, iova, paddr, size, prot);
44562 spin_unlock_irqrestore(&smmu_domain->pgtbl_lock, flags);
44563 return ret;
44564 }
44565@@ -1207,13 +1208,13 @@ static size_t arm_smmu_unmap(struct iommu_domain *domain, unsigned long iova,
44566 size_t ret;
44567 unsigned long flags;
44568 struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
44569- struct io_pgtable_ops *ops= smmu_domain->pgtbl_ops;
44570+ struct io_pgtable *iop = smmu_domain->pgtbl;
44571
44572- if (!ops)
44573+ if (!iop)
44574 return 0;
44575
44576 spin_lock_irqsave(&smmu_domain->pgtbl_lock, flags);
44577- ret = ops->unmap(ops, iova, size);
44578+ ret = iop->ops->unmap(iop, iova, size);
44579 spin_unlock_irqrestore(&smmu_domain->pgtbl_lock, flags);
44580 return ret;
44581 }
44582@@ -1224,7 +1225,7 @@ static phys_addr_t arm_smmu_iova_to_phys_hard(struct iommu_domain *domain,
44583 struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
44584 struct arm_smmu_device *smmu = smmu_domain->smmu;
44585 struct arm_smmu_cfg *cfg = &smmu_domain->cfg;
44586- struct io_pgtable_ops *ops= smmu_domain->pgtbl_ops;
44587+ struct io_pgtable *iop = smmu_domain->pgtbl;
44588 struct device *dev = smmu->dev;
44589 void __iomem *cb_base;
44590 u32 tmp;
44591@@ -1247,7 +1248,7 @@ static phys_addr_t arm_smmu_iova_to_phys_hard(struct iommu_domain *domain,
44592 dev_err(dev,
44593 "iova to phys timed out on 0x%pad. Falling back to software table walk.\n",
44594 &iova);
44595- return ops->iova_to_phys(ops, iova);
44596+ return iop->ops->iova_to_phys(iop, iova);
44597 }
44598
44599 phys = readl_relaxed(cb_base + ARM_SMMU_CB_PAR_LO);
44600@@ -1268,9 +1269,9 @@ static phys_addr_t arm_smmu_iova_to_phys(struct iommu_domain *domain,
44601 phys_addr_t ret;
44602 unsigned long flags;
44603 struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
44604- struct io_pgtable_ops *ops= smmu_domain->pgtbl_ops;
44605+ struct io_pgtable *iop = smmu_domain->pgtbl;
44606
44607- if (!ops)
44608+ if (!iop)
44609 return 0;
44610
44611 spin_lock_irqsave(&smmu_domain->pgtbl_lock, flags);
44612@@ -1278,7 +1279,7 @@ static phys_addr_t arm_smmu_iova_to_phys(struct iommu_domain *domain,
44613 smmu_domain->stage == ARM_SMMU_DOMAIN_S1) {
44614 ret = arm_smmu_iova_to_phys_hard(domain, iova);
44615 } else {
44616- ret = ops->iova_to_phys(ops, iova);
44617+ ret = iop->ops->iova_to_phys(iop, iova);
44618 }
44619
44620 spin_unlock_irqrestore(&smmu_domain->pgtbl_lock, flags);
44621@@ -1668,7 +1669,9 @@ static int arm_smmu_device_cfg_probe(struct arm_smmu_device *smmu)
44622 size |= SZ_64K | SZ_512M;
44623 }
44624
44625- arm_smmu_ops.pgsize_bitmap &= size;
44626+ pax_open_kernel();
44627+ *(unsigned long *)&arm_smmu_ops.pgsize_bitmap &= size;
44628+ pax_close_kernel();
44629 dev_notice(smmu->dev, "\tSupported page sizes: 0x%08lx\n", size);
44630
44631 if (smmu->features & ARM_SMMU_FEAT_TRANS_S1)
44632diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
44633index 5ecfaf2..c87c4b1 100644
44634--- a/drivers/iommu/intel-iommu.c
44635+++ b/drivers/iommu/intel-iommu.c
44636@@ -1756,8 +1756,9 @@ static int domain_init(struct dmar_domain *domain, int guest_width)
44637
44638 static void domain_exit(struct dmar_domain *domain)
44639 {
44640+ struct dmar_drhd_unit *drhd;
44641+ struct intel_iommu *iommu;
44642 struct page *freelist = NULL;
44643- int i;
44644
44645 /* Domain 0 is reserved, so dont process it */
44646 if (!domain)
44647@@ -1777,8 +1778,10 @@ static void domain_exit(struct dmar_domain *domain)
44648
44649 /* clear attached or cached domains */
44650 rcu_read_lock();
44651- for_each_set_bit(i, domain->iommu_bmp, g_num_of_iommus)
44652- iommu_detach_domain(domain, g_iommus[i]);
44653+ for_each_active_iommu(iommu, drhd)
44654+ if (domain_type_is_vm(domain) ||
44655+ test_bit(iommu->seq_id, domain->iommu_bmp))
44656+ iommu_detach_domain(domain, iommu);
44657 rcu_read_unlock();
44658
44659 dma_free_pagelist(freelist);
44660diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c
44661index 4e46021..f0a24fef 100644
44662--- a/drivers/iommu/io-pgtable-arm.c
44663+++ b/drivers/iommu/io-pgtable-arm.c
44664@@ -36,12 +36,6 @@
44665 #define io_pgtable_to_data(x) \
44666 container_of((x), struct arm_lpae_io_pgtable, iop)
44667
44668-#define io_pgtable_ops_to_pgtable(x) \
44669- container_of((x), struct io_pgtable, ops)
44670-
44671-#define io_pgtable_ops_to_data(x) \
44672- io_pgtable_to_data(io_pgtable_ops_to_pgtable(x))
44673-
44674 /*
44675 * For consistency with the architecture, we always consider
44676 * ARM_LPAE_MAX_LEVELS levels, with the walk starting at level n >=0
44677@@ -304,10 +298,10 @@ static arm_lpae_iopte arm_lpae_prot_to_pte(struct arm_lpae_io_pgtable *data,
44678 return pte;
44679 }
44680
44681-static int arm_lpae_map(struct io_pgtable_ops *ops, unsigned long iova,
44682+static int arm_lpae_map(struct io_pgtable *iop, unsigned long iova,
44683 phys_addr_t paddr, size_t size, int iommu_prot)
44684 {
44685- struct arm_lpae_io_pgtable *data = io_pgtable_ops_to_data(ops);
44686+ struct arm_lpae_io_pgtable *data = io_pgtable_to_data(iop);
44687 arm_lpae_iopte *ptep = data->pgd;
44688 int lvl = ARM_LPAE_START_LVL(data);
44689 arm_lpae_iopte prot;
44690@@ -447,12 +441,11 @@ static int __arm_lpae_unmap(struct arm_lpae_io_pgtable *data,
44691 return __arm_lpae_unmap(data, iova, size, lvl + 1, ptep);
44692 }
44693
44694-static int arm_lpae_unmap(struct io_pgtable_ops *ops, unsigned long iova,
44695+static int arm_lpae_unmap(struct io_pgtable *iop, unsigned long iova,
44696 size_t size)
44697 {
44698 size_t unmapped;
44699- struct arm_lpae_io_pgtable *data = io_pgtable_ops_to_data(ops);
44700- struct io_pgtable *iop = &data->iop;
44701+ struct arm_lpae_io_pgtable *data = io_pgtable_to_data(iop);
44702 arm_lpae_iopte *ptep = data->pgd;
44703 int lvl = ARM_LPAE_START_LVL(data);
44704
44705@@ -463,10 +456,10 @@ static int arm_lpae_unmap(struct io_pgtable_ops *ops, unsigned long iova,
44706 return unmapped;
44707 }
44708
44709-static phys_addr_t arm_lpae_iova_to_phys(struct io_pgtable_ops *ops,
44710+static phys_addr_t arm_lpae_iova_to_phys(struct io_pgtable *iop,
44711 unsigned long iova)
44712 {
44713- struct arm_lpae_io_pgtable *data = io_pgtable_ops_to_data(ops);
44714+ struct arm_lpae_io_pgtable *data = io_pgtable_to_data(iop);
44715 arm_lpae_iopte pte, *ptep = data->pgd;
44716 int lvl = ARM_LPAE_START_LVL(data);
44717
44718@@ -533,6 +526,12 @@ static void arm_lpae_restrict_pgsizes(struct io_pgtable_cfg *cfg)
44719 }
44720 }
44721
44722+static struct io_pgtable_ops arm_lpae_io_pgtable_ops = {
44723+ .map = arm_lpae_map,
44724+ .unmap = arm_lpae_unmap,
44725+ .iova_to_phys = arm_lpae_iova_to_phys,
44726+};
44727+
44728 static struct arm_lpae_io_pgtable *
44729 arm_lpae_alloc_pgtable(struct io_pgtable_cfg *cfg)
44730 {
44731@@ -564,11 +563,7 @@ arm_lpae_alloc_pgtable(struct io_pgtable_cfg *cfg)
44732 pgd_bits = va_bits - (data->bits_per_level * (data->levels - 1));
44733 data->pgd_size = 1UL << (pgd_bits + ilog2(sizeof(arm_lpae_iopte)));
44734
44735- data->iop.ops = (struct io_pgtable_ops) {
44736- .map = arm_lpae_map,
44737- .unmap = arm_lpae_unmap,
44738- .iova_to_phys = arm_lpae_iova_to_phys,
44739- };
44740+ data->iop.ops = &arm_lpae_io_pgtable_ops;
44741
44742 return data;
44743 }
44744@@ -830,9 +825,9 @@ static struct iommu_gather_ops dummy_tlb_ops __initdata = {
44745 .flush_pgtable = dummy_flush_pgtable,
44746 };
44747
44748-static void __init arm_lpae_dump_ops(struct io_pgtable_ops *ops)
44749+static void __init arm_lpae_dump_ops(struct io_pgtable *iop)
44750 {
44751- struct arm_lpae_io_pgtable *data = io_pgtable_ops_to_data(ops);
44752+ struct arm_lpae_io_pgtable *data = io_pgtable_to_data(iop);
44753 struct io_pgtable_cfg *cfg = &data->iop.cfg;
44754
44755 pr_err("cfg: pgsize_bitmap 0x%lx, ias %u-bit\n",
44756@@ -842,9 +837,9 @@ static void __init arm_lpae_dump_ops(struct io_pgtable_ops *ops)
44757 data->bits_per_level, data->pgd);
44758 }
44759
44760-#define __FAIL(ops, i) ({ \
44761+#define __FAIL(iop, i) ({ \
44762 WARN(1, "selftest: test failed for fmt idx %d\n", (i)); \
44763- arm_lpae_dump_ops(ops); \
44764+ arm_lpae_dump_ops(iop); \
44765 selftest_running = false; \
44766 -EFAULT; \
44767 })
44768@@ -859,30 +854,32 @@ static int __init arm_lpae_run_tests(struct io_pgtable_cfg *cfg)
44769 int i, j;
44770 unsigned long iova;
44771 size_t size;
44772- struct io_pgtable_ops *ops;
44773+ struct io_pgtable *iop;
44774+ const struct io_pgtable_ops *ops;
44775
44776 selftest_running = true;
44777
44778 for (i = 0; i < ARRAY_SIZE(fmts); ++i) {
44779 cfg_cookie = cfg;
44780- ops = alloc_io_pgtable_ops(fmts[i], cfg, cfg);
44781- if (!ops) {
44782+ iop = alloc_io_pgtable(fmts[i], cfg, cfg);
44783+ if (!iop) {
44784 pr_err("selftest: failed to allocate io pgtable ops\n");
44785 return -ENOMEM;
44786 }
44787+ ops = iop->ops;
44788
44789 /*
44790 * Initial sanity checks.
44791 * Empty page tables shouldn't provide any translations.
44792 */
44793- if (ops->iova_to_phys(ops, 42))
44794- return __FAIL(ops, i);
44795+ if (ops->iova_to_phys(iop, 42))
44796+ return __FAIL(iop, i);
44797
44798- if (ops->iova_to_phys(ops, SZ_1G + 42))
44799- return __FAIL(ops, i);
44800+ if (ops->iova_to_phys(iop, SZ_1G + 42))
44801+ return __FAIL(iop, i);
44802
44803- if (ops->iova_to_phys(ops, SZ_2G + 42))
44804- return __FAIL(ops, i);
44805+ if (ops->iova_to_phys(iop, SZ_2G + 42))
44806+ return __FAIL(iop, i);
44807
44808 /*
44809 * Distinct mappings of different granule sizes.
44810@@ -892,19 +889,19 @@ static int __init arm_lpae_run_tests(struct io_pgtable_cfg *cfg)
44811 while (j != BITS_PER_LONG) {
44812 size = 1UL << j;
44813
44814- if (ops->map(ops, iova, iova, size, IOMMU_READ |
44815+ if (ops->map(iop, iova, iova, size, IOMMU_READ |
44816 IOMMU_WRITE |
44817 IOMMU_NOEXEC |
44818 IOMMU_CACHE))
44819- return __FAIL(ops, i);
44820+ return __FAIL(iop, i);
44821
44822 /* Overlapping mappings */
44823- if (!ops->map(ops, iova, iova + size, size,
44824+ if (!ops->map(iop, iova, iova + size, size,
44825 IOMMU_READ | IOMMU_NOEXEC))
44826- return __FAIL(ops, i);
44827+ return __FAIL(iop, i);
44828
44829- if (ops->iova_to_phys(ops, iova + 42) != (iova + 42))
44830- return __FAIL(ops, i);
44831+ if (ops->iova_to_phys(iop, iova + 42) != (iova + 42))
44832+ return __FAIL(iop, i);
44833
44834 iova += SZ_1G;
44835 j++;
44836@@ -913,15 +910,15 @@ static int __init arm_lpae_run_tests(struct io_pgtable_cfg *cfg)
44837
44838 /* Partial unmap */
44839 size = 1UL << __ffs(cfg->pgsize_bitmap);
44840- if (ops->unmap(ops, SZ_1G + size, size) != size)
44841- return __FAIL(ops, i);
44842+ if (ops->unmap(iop, SZ_1G + size, size) != size)
44843+ return __FAIL(iop, i);
44844
44845 /* Remap of partial unmap */
44846- if (ops->map(ops, SZ_1G + size, size, size, IOMMU_READ))
44847- return __FAIL(ops, i);
44848+ if (ops->map(iop, SZ_1G + size, size, size, IOMMU_READ))
44849+ return __FAIL(iop, i);
44850
44851- if (ops->iova_to_phys(ops, SZ_1G + size + 42) != (size + 42))
44852- return __FAIL(ops, i);
44853+ if (ops->iova_to_phys(iop, SZ_1G + size + 42) != (size + 42))
44854+ return __FAIL(iop, i);
44855
44856 /* Full unmap */
44857 iova = 0;
44858@@ -929,25 +926,25 @@ static int __init arm_lpae_run_tests(struct io_pgtable_cfg *cfg)
44859 while (j != BITS_PER_LONG) {
44860 size = 1UL << j;
44861
44862- if (ops->unmap(ops, iova, size) != size)
44863- return __FAIL(ops, i);
44864+ if (ops->unmap(iop, iova, size) != size)
44865+ return __FAIL(iop, i);
44866
44867- if (ops->iova_to_phys(ops, iova + 42))
44868- return __FAIL(ops, i);
44869+ if (ops->iova_to_phys(iop, iova + 42))
44870+ return __FAIL(iop, i);
44871
44872 /* Remap full block */
44873- if (ops->map(ops, iova, iova, size, IOMMU_WRITE))
44874- return __FAIL(ops, i);
44875+ if (ops->map(iop, iova, iova, size, IOMMU_WRITE))
44876+ return __FAIL(iop, i);
44877
44878- if (ops->iova_to_phys(ops, iova + 42) != (iova + 42))
44879- return __FAIL(ops, i);
44880+ if (ops->iova_to_phys(iop, iova + 42) != (iova + 42))
44881+ return __FAIL(iop, i);
44882
44883 iova += SZ_1G;
44884 j++;
44885 j = find_next_bit(&cfg->pgsize_bitmap, BITS_PER_LONG, j);
44886 }
44887
44888- free_io_pgtable_ops(ops);
44889+ free_io_pgtable(iop);
44890 }
44891
44892 selftest_running = false;
44893diff --git a/drivers/iommu/io-pgtable.c b/drivers/iommu/io-pgtable.c
44894index 6436fe2..088c965 100644
44895--- a/drivers/iommu/io-pgtable.c
44896+++ b/drivers/iommu/io-pgtable.c
44897@@ -40,7 +40,7 @@ io_pgtable_init_table[IO_PGTABLE_NUM_FMTS] =
44898 #endif
44899 };
44900
44901-struct io_pgtable_ops *alloc_io_pgtable_ops(enum io_pgtable_fmt fmt,
44902+struct io_pgtable *alloc_io_pgtable(enum io_pgtable_fmt fmt,
44903 struct io_pgtable_cfg *cfg,
44904 void *cookie)
44905 {
44906@@ -62,21 +62,18 @@ struct io_pgtable_ops *alloc_io_pgtable_ops(enum io_pgtable_fmt fmt,
44907 iop->cookie = cookie;
44908 iop->cfg = *cfg;
44909
44910- return &iop->ops;
44911+ return iop;
44912 }
44913
44914 /*
44915 * It is the IOMMU driver's responsibility to ensure that the page table
44916 * is no longer accessible to the walker by this point.
44917 */
44918-void free_io_pgtable_ops(struct io_pgtable_ops *ops)
44919+void free_io_pgtable(struct io_pgtable *iop)
44920 {
44921- struct io_pgtable *iop;
44922-
44923- if (!ops)
44924+ if (!iop)
44925 return;
44926
44927- iop = container_of(ops, struct io_pgtable, ops);
44928 iop->cfg.tlb->tlb_flush_all(iop->cookie);
44929 io_pgtable_init_table[iop->fmt]->free(iop);
44930 }
44931diff --git a/drivers/iommu/io-pgtable.h b/drivers/iommu/io-pgtable.h
44932index 10e32f6..0b276c8 100644
44933--- a/drivers/iommu/io-pgtable.h
44934+++ b/drivers/iommu/io-pgtable.h
44935@@ -75,17 +75,18 @@ struct io_pgtable_cfg {
44936 * These functions map directly onto the iommu_ops member functions with
44937 * the same names.
44938 */
44939+struct io_pgtable;
44940 struct io_pgtable_ops {
44941- int (*map)(struct io_pgtable_ops *ops, unsigned long iova,
44942+ int (*map)(struct io_pgtable *iop, unsigned long iova,
44943 phys_addr_t paddr, size_t size, int prot);
44944- int (*unmap)(struct io_pgtable_ops *ops, unsigned long iova,
44945+ int (*unmap)(struct io_pgtable *iop, unsigned long iova,
44946 size_t size);
44947- phys_addr_t (*iova_to_phys)(struct io_pgtable_ops *ops,
44948+ phys_addr_t (*iova_to_phys)(struct io_pgtable *iop,
44949 unsigned long iova);
44950 };
44951
44952 /**
44953- * alloc_io_pgtable_ops() - Allocate a page table allocator for use by an IOMMU.
44954+ * alloc_io_pgtable() - Allocate a page table allocator for use by an IOMMU.
44955 *
44956 * @fmt: The page table format.
44957 * @cfg: The page table configuration. This will be modified to represent
44958@@ -94,9 +95,9 @@ struct io_pgtable_ops {
44959 * @cookie: An opaque token provided by the IOMMU driver and passed back to
44960 * the callback routines in cfg->tlb.
44961 */
44962-struct io_pgtable_ops *alloc_io_pgtable_ops(enum io_pgtable_fmt fmt,
44963- struct io_pgtable_cfg *cfg,
44964- void *cookie);
44965+struct io_pgtable *alloc_io_pgtable(enum io_pgtable_fmt fmt,
44966+ struct io_pgtable_cfg *cfg,
44967+ void *cookie);
44968
44969 /**
44970 * free_io_pgtable_ops() - Free an io_pgtable_ops structure. The caller
44971@@ -105,7 +106,7 @@ struct io_pgtable_ops *alloc_io_pgtable_ops(enum io_pgtable_fmt fmt,
44972 *
44973 * @ops: The ops returned from alloc_io_pgtable_ops.
44974 */
44975-void free_io_pgtable_ops(struct io_pgtable_ops *ops);
44976+void free_io_pgtable(struct io_pgtable *iop);
44977
44978
44979 /*
44980@@ -125,7 +126,7 @@ struct io_pgtable {
44981 enum io_pgtable_fmt fmt;
44982 void *cookie;
44983 struct io_pgtable_cfg cfg;
44984- struct io_pgtable_ops ops;
44985+ const struct io_pgtable_ops *ops;
44986 };
44987
44988 /**
44989diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
44990index d4f527e..8e4a4fd 100644
44991--- a/drivers/iommu/iommu.c
44992+++ b/drivers/iommu/iommu.c
44993@@ -802,7 +802,7 @@ static int iommu_bus_notifier(struct notifier_block *nb,
44994 static int iommu_bus_init(struct bus_type *bus, const struct iommu_ops *ops)
44995 {
44996 int err;
44997- struct notifier_block *nb;
44998+ notifier_block_no_const *nb;
44999 struct iommu_callback_data cb = {
45000 .ops = ops,
45001 };
45002diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
45003index 1a67c53..23181d8 100644
45004--- a/drivers/iommu/ipmmu-vmsa.c
45005+++ b/drivers/iommu/ipmmu-vmsa.c
45006@@ -41,7 +41,7 @@ struct ipmmu_vmsa_domain {
45007 struct iommu_domain io_domain;
45008
45009 struct io_pgtable_cfg cfg;
45010- struct io_pgtable_ops *iop;
45011+ struct io_pgtable *iop;
45012
45013 unsigned int context_id;
45014 spinlock_t lock; /* Protects mappings */
45015@@ -328,8 +328,7 @@ static int ipmmu_domain_init_context(struct ipmmu_vmsa_domain *domain)
45016 domain->cfg.oas = 40;
45017 domain->cfg.tlb = &ipmmu_gather_ops;
45018
45019- domain->iop = alloc_io_pgtable_ops(ARM_32_LPAE_S1, &domain->cfg,
45020- domain);
45021+ domain->iop = alloc_io_pgtable(ARM_32_LPAE_S1, &domain->cfg, domain);
45022 if (!domain->iop)
45023 return -EINVAL;
45024
45025@@ -487,7 +486,7 @@ static void ipmmu_domain_free(struct iommu_domain *io_domain)
45026 * been detached.
45027 */
45028 ipmmu_domain_destroy_context(domain);
45029- free_io_pgtable_ops(domain->iop);
45030+ free_io_pgtable(domain->iop);
45031 kfree(domain);
45032 }
45033
45034@@ -556,7 +555,7 @@ static int ipmmu_map(struct iommu_domain *io_domain, unsigned long iova,
45035 if (!domain)
45036 return -ENODEV;
45037
45038- return domain->iop->map(domain->iop, iova, paddr, size, prot);
45039+ return domain->iop->ops->map(domain->iop, iova, paddr, size, prot);
45040 }
45041
45042 static size_t ipmmu_unmap(struct iommu_domain *io_domain, unsigned long iova,
45043@@ -564,7 +563,7 @@ static size_t ipmmu_unmap(struct iommu_domain *io_domain, unsigned long iova,
45044 {
45045 struct ipmmu_vmsa_domain *domain = to_vmsa_domain(io_domain);
45046
45047- return domain->iop->unmap(domain->iop, iova, size);
45048+ return domain->iop->ops->unmap(domain->iop, iova, size);
45049 }
45050
45051 static phys_addr_t ipmmu_iova_to_phys(struct iommu_domain *io_domain,
45052@@ -574,7 +573,7 @@ static phys_addr_t ipmmu_iova_to_phys(struct iommu_domain *io_domain,
45053
45054 /* TODO: Is locking needed ? */
45055
45056- return domain->iop->iova_to_phys(domain->iop, iova);
45057+ return domain->iop->ops->iova_to_phys(domain->iop, iova);
45058 }
45059
45060 static int ipmmu_find_utlbs(struct ipmmu_vmsa_device *mmu, struct device *dev,
45061diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
45062index 390079e..1da9d6c 100644
45063--- a/drivers/iommu/irq_remapping.c
45064+++ b/drivers/iommu/irq_remapping.c
45065@@ -329,7 +329,7 @@ int setup_hpet_msi_remapped(unsigned int irq, unsigned int id)
45066 void panic_if_irq_remap(const char *msg)
45067 {
45068 if (irq_remapping_enabled)
45069- panic(msg);
45070+ panic("%s", msg);
45071 }
45072
45073 static void ir_ack_apic_edge(struct irq_data *data)
45074@@ -350,10 +350,12 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
45075
45076 void irq_remap_modify_chip_defaults(struct irq_chip *chip)
45077 {
45078- chip->irq_print_chip = ir_print_prefix;
45079- chip->irq_ack = ir_ack_apic_edge;
45080- chip->irq_eoi = ir_ack_apic_level;
45081- chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
45082+ pax_open_kernel();
45083+ *(void **)&chip->irq_print_chip = ir_print_prefix;
45084+ *(void **)&chip->irq_ack = ir_ack_apic_edge;
45085+ *(void **)&chip->irq_eoi = ir_ack_apic_level;
45086+ *(void **)&chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
45087+ pax_close_kernel();
45088 }
45089
45090 bool setup_remapped_irq(int irq, struct irq_cfg *cfg, struct irq_chip *chip)
45091diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
45092index 01999d7..4f14bb7 100644
45093--- a/drivers/irqchip/irq-gic.c
45094+++ b/drivers/irqchip/irq-gic.c
45095@@ -313,7 +313,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
45096 chained_irq_exit(chip, desc);
45097 }
45098
45099-static struct irq_chip gic_chip = {
45100+static irq_chip_no_const gic_chip __read_only = {
45101 .name = "GIC",
45102 .irq_mask = gic_mask_irq,
45103 .irq_unmask = gic_unmask_irq,
45104diff --git a/drivers/irqchip/irq-renesas-intc-irqpin.c b/drivers/irqchip/irq-renesas-intc-irqpin.c
45105index 9a0767b..5e5f86f 100644
45106--- a/drivers/irqchip/irq-renesas-intc-irqpin.c
45107+++ b/drivers/irqchip/irq-renesas-intc-irqpin.c
45108@@ -373,7 +373,7 @@ static int intc_irqpin_probe(struct platform_device *pdev)
45109 struct intc_irqpin_iomem *i;
45110 struct resource *io[INTC_IRQPIN_REG_NR];
45111 struct resource *irq;
45112- struct irq_chip *irq_chip;
45113+ irq_chip_no_const *irq_chip;
45114 void (*enable_fn)(struct irq_data *d);
45115 void (*disable_fn)(struct irq_data *d);
45116 const char *name = dev_name(dev);
45117diff --git a/drivers/irqchip/irq-renesas-irqc.c b/drivers/irqchip/irq-renesas-irqc.c
45118index cdf80b7..e5c3ade 100644
45119--- a/drivers/irqchip/irq-renesas-irqc.c
45120+++ b/drivers/irqchip/irq-renesas-irqc.c
45121@@ -179,7 +179,7 @@ static int irqc_probe(struct platform_device *pdev)
45122 struct irqc_priv *p;
45123 struct resource *io;
45124 struct resource *irq;
45125- struct irq_chip *irq_chip;
45126+ irq_chip_no_const *irq_chip;
45127 const char *name = dev_name(&pdev->dev);
45128 int ret;
45129 int k;
45130diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
45131index 6a2df32..dc962f1 100644
45132--- a/drivers/isdn/capi/capi.c
45133+++ b/drivers/isdn/capi/capi.c
45134@@ -81,8 +81,8 @@ struct capiminor {
45135
45136 struct capi20_appl *ap;
45137 u32 ncci;
45138- atomic_t datahandle;
45139- atomic_t msgid;
45140+ atomic_unchecked_t datahandle;
45141+ atomic_unchecked_t msgid;
45142
45143 struct tty_port port;
45144 int ttyinstop;
45145@@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
45146 capimsg_setu16(s, 2, mp->ap->applid);
45147 capimsg_setu8 (s, 4, CAPI_DATA_B3);
45148 capimsg_setu8 (s, 5, CAPI_RESP);
45149- capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
45150+ capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
45151 capimsg_setu32(s, 8, mp->ncci);
45152 capimsg_setu16(s, 12, datahandle);
45153 }
45154@@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
45155 mp->outbytes -= len;
45156 spin_unlock_bh(&mp->outlock);
45157
45158- datahandle = atomic_inc_return(&mp->datahandle);
45159+ datahandle = atomic_inc_return_unchecked(&mp->datahandle);
45160 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
45161 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
45162 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
45163 capimsg_setu16(skb->data, 2, mp->ap->applid);
45164 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
45165 capimsg_setu8 (skb->data, 5, CAPI_REQ);
45166- capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
45167+ capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
45168 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
45169 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
45170 capimsg_setu16(skb->data, 16, len); /* Data length */
45171diff --git a/drivers/isdn/gigaset/bas-gigaset.c b/drivers/isdn/gigaset/bas-gigaset.c
45172index aecec6d..11e13c5 100644
45173--- a/drivers/isdn/gigaset/bas-gigaset.c
45174+++ b/drivers/isdn/gigaset/bas-gigaset.c
45175@@ -2565,22 +2565,22 @@ static int gigaset_post_reset(struct usb_interface *intf)
45176
45177
45178 static const struct gigaset_ops gigops = {
45179- gigaset_write_cmd,
45180- gigaset_write_room,
45181- gigaset_chars_in_buffer,
45182- gigaset_brkchars,
45183- gigaset_init_bchannel,
45184- gigaset_close_bchannel,
45185- gigaset_initbcshw,
45186- gigaset_freebcshw,
45187- gigaset_reinitbcshw,
45188- gigaset_initcshw,
45189- gigaset_freecshw,
45190- gigaset_set_modem_ctrl,
45191- gigaset_baud_rate,
45192- gigaset_set_line_ctrl,
45193- gigaset_isoc_send_skb,
45194- gigaset_isoc_input,
45195+ .write_cmd = gigaset_write_cmd,
45196+ .write_room = gigaset_write_room,
45197+ .chars_in_buffer = gigaset_chars_in_buffer,
45198+ .brkchars = gigaset_brkchars,
45199+ .init_bchannel = gigaset_init_bchannel,
45200+ .close_bchannel = gigaset_close_bchannel,
45201+ .initbcshw = gigaset_initbcshw,
45202+ .freebcshw = gigaset_freebcshw,
45203+ .reinitbcshw = gigaset_reinitbcshw,
45204+ .initcshw = gigaset_initcshw,
45205+ .freecshw = gigaset_freecshw,
45206+ .set_modem_ctrl = gigaset_set_modem_ctrl,
45207+ .baud_rate = gigaset_baud_rate,
45208+ .set_line_ctrl = gigaset_set_line_ctrl,
45209+ .send_skb = gigaset_isoc_send_skb,
45210+ .handle_input = gigaset_isoc_input,
45211 };
45212
45213 /* bas_gigaset_init
45214diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
45215index 600c79b..3752bab 100644
45216--- a/drivers/isdn/gigaset/interface.c
45217+++ b/drivers/isdn/gigaset/interface.c
45218@@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
45219 }
45220 tty->driver_data = cs;
45221
45222- ++cs->port.count;
45223+ atomic_inc(&cs->port.count);
45224
45225- if (cs->port.count == 1) {
45226+ if (atomic_read(&cs->port.count) == 1) {
45227 tty_port_tty_set(&cs->port, tty);
45228 cs->port.low_latency = 1;
45229 }
45230@@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
45231
45232 if (!cs->connected)
45233 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
45234- else if (!cs->port.count)
45235+ else if (!atomic_read(&cs->port.count))
45236 dev_warn(cs->dev, "%s: device not opened\n", __func__);
45237- else if (!--cs->port.count)
45238+ else if (!atomic_dec_return(&cs->port.count))
45239 tty_port_tty_set(&cs->port, NULL);
45240
45241 mutex_unlock(&cs->mutex);
45242diff --git a/drivers/isdn/gigaset/ser-gigaset.c b/drivers/isdn/gigaset/ser-gigaset.c
45243index 8c91fd5..14f13ce 100644
45244--- a/drivers/isdn/gigaset/ser-gigaset.c
45245+++ b/drivers/isdn/gigaset/ser-gigaset.c
45246@@ -453,22 +453,22 @@ static int gigaset_set_line_ctrl(struct cardstate *cs, unsigned cflag)
45247 }
45248
45249 static const struct gigaset_ops ops = {
45250- gigaset_write_cmd,
45251- gigaset_write_room,
45252- gigaset_chars_in_buffer,
45253- gigaset_brkchars,
45254- gigaset_init_bchannel,
45255- gigaset_close_bchannel,
45256- gigaset_initbcshw,
45257- gigaset_freebcshw,
45258- gigaset_reinitbcshw,
45259- gigaset_initcshw,
45260- gigaset_freecshw,
45261- gigaset_set_modem_ctrl,
45262- gigaset_baud_rate,
45263- gigaset_set_line_ctrl,
45264- gigaset_m10x_send_skb, /* asyncdata.c */
45265- gigaset_m10x_input, /* asyncdata.c */
45266+ .write_cmd = gigaset_write_cmd,
45267+ .write_room = gigaset_write_room,
45268+ .chars_in_buffer = gigaset_chars_in_buffer,
45269+ .brkchars = gigaset_brkchars,
45270+ .init_bchannel = gigaset_init_bchannel,
45271+ .close_bchannel = gigaset_close_bchannel,
45272+ .initbcshw = gigaset_initbcshw,
45273+ .freebcshw = gigaset_freebcshw,
45274+ .reinitbcshw = gigaset_reinitbcshw,
45275+ .initcshw = gigaset_initcshw,
45276+ .freecshw = gigaset_freecshw,
45277+ .set_modem_ctrl = gigaset_set_modem_ctrl,
45278+ .baud_rate = gigaset_baud_rate,
45279+ .set_line_ctrl = gigaset_set_line_ctrl,
45280+ .send_skb = gigaset_m10x_send_skb, /* asyncdata.c */
45281+ .handle_input = gigaset_m10x_input, /* asyncdata.c */
45282 };
45283
45284
45285diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
45286index 5f306e2..5342f88 100644
45287--- a/drivers/isdn/gigaset/usb-gigaset.c
45288+++ b/drivers/isdn/gigaset/usb-gigaset.c
45289@@ -543,7 +543,7 @@ static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6])
45290 gigaset_dbg_buffer(DEBUG_USBREQ, "brkchars", 6, buf);
45291 memcpy(cs->hw.usb->bchars, buf, 6);
45292 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x19, 0x41,
45293- 0, 0, &buf, 6, 2000);
45294+ 0, 0, buf, 6, 2000);
45295 }
45296
45297 static void gigaset_freebcshw(struct bc_state *bcs)
45298@@ -862,22 +862,22 @@ static int gigaset_pre_reset(struct usb_interface *intf)
45299 }
45300
45301 static const struct gigaset_ops ops = {
45302- gigaset_write_cmd,
45303- gigaset_write_room,
45304- gigaset_chars_in_buffer,
45305- gigaset_brkchars,
45306- gigaset_init_bchannel,
45307- gigaset_close_bchannel,
45308- gigaset_initbcshw,
45309- gigaset_freebcshw,
45310- gigaset_reinitbcshw,
45311- gigaset_initcshw,
45312- gigaset_freecshw,
45313- gigaset_set_modem_ctrl,
45314- gigaset_baud_rate,
45315- gigaset_set_line_ctrl,
45316- gigaset_m10x_send_skb,
45317- gigaset_m10x_input,
45318+ .write_cmd = gigaset_write_cmd,
45319+ .write_room = gigaset_write_room,
45320+ .chars_in_buffer = gigaset_chars_in_buffer,
45321+ .brkchars = gigaset_brkchars,
45322+ .init_bchannel = gigaset_init_bchannel,
45323+ .close_bchannel = gigaset_close_bchannel,
45324+ .initbcshw = gigaset_initbcshw,
45325+ .freebcshw = gigaset_freebcshw,
45326+ .reinitbcshw = gigaset_reinitbcshw,
45327+ .initcshw = gigaset_initcshw,
45328+ .freecshw = gigaset_freecshw,
45329+ .set_modem_ctrl = gigaset_set_modem_ctrl,
45330+ .baud_rate = gigaset_baud_rate,
45331+ .set_line_ctrl = gigaset_set_line_ctrl,
45332+ .send_skb = gigaset_m10x_send_skb,
45333+ .handle_input = gigaset_m10x_input,
45334 };
45335
45336 /*
45337diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
45338index 4d9b195..455075c 100644
45339--- a/drivers/isdn/hardware/avm/b1.c
45340+++ b/drivers/isdn/hardware/avm/b1.c
45341@@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
45342 }
45343 if (left) {
45344 if (t4file->user) {
45345- if (copy_from_user(buf, dp, left))
45346+ if (left > sizeof buf || copy_from_user(buf, dp, left))
45347 return -EFAULT;
45348 } else {
45349 memcpy(buf, dp, left);
45350@@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
45351 }
45352 if (left) {
45353 if (config->user) {
45354- if (copy_from_user(buf, dp, left))
45355+ if (left > sizeof buf || copy_from_user(buf, dp, left))
45356 return -EFAULT;
45357 } else {
45358 memcpy(buf, dp, left);
45359diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
45360index 9b856e1..fa03c92 100644
45361--- a/drivers/isdn/i4l/isdn_common.c
45362+++ b/drivers/isdn/i4l/isdn_common.c
45363@@ -1654,6 +1654,8 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
45364 } else
45365 return -EINVAL;
45366 case IIOCDBGVAR:
45367+ if (!capable(CAP_SYS_RAWIO))
45368+ return -EPERM;
45369 if (arg) {
45370 if (copy_to_user(argp, &dev, sizeof(ulong)))
45371 return -EFAULT;
45372diff --git a/drivers/isdn/i4l/isdn_concap.c b/drivers/isdn/i4l/isdn_concap.c
45373index 91d5730..336523e 100644
45374--- a/drivers/isdn/i4l/isdn_concap.c
45375+++ b/drivers/isdn/i4l/isdn_concap.c
45376@@ -80,9 +80,9 @@ static int isdn_concap_dl_disconn_req(struct concap_proto *concap)
45377 }
45378
45379 struct concap_device_ops isdn_concap_reliable_dl_dops = {
45380- &isdn_concap_dl_data_req,
45381- &isdn_concap_dl_connect_req,
45382- &isdn_concap_dl_disconn_req
45383+ .data_req = &isdn_concap_dl_data_req,
45384+ .connect_req = &isdn_concap_dl_connect_req,
45385+ .disconn_req = &isdn_concap_dl_disconn_req
45386 };
45387
45388 /* The following should better go into a dedicated source file such that
45389diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
45390index bc91261..2ef7e36 100644
45391--- a/drivers/isdn/i4l/isdn_tty.c
45392+++ b/drivers/isdn/i4l/isdn_tty.c
45393@@ -1503,9 +1503,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
45394
45395 #ifdef ISDN_DEBUG_MODEM_OPEN
45396 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
45397- port->count);
45398+ atomic_read(&port->count));
45399 #endif
45400- port->count++;
45401+ atomic_inc(&port->count);
45402 port->tty = tty;
45403 /*
45404 * Start up serial port
45405@@ -1549,7 +1549,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
45406 #endif
45407 return;
45408 }
45409- if ((tty->count == 1) && (port->count != 1)) {
45410+ if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
45411 /*
45412 * Uh, oh. tty->count is 1, which means that the tty
45413 * structure will be freed. Info->count should always
45414@@ -1558,15 +1558,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
45415 * serial port won't be shutdown.
45416 */
45417 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
45418- "info->count is %d\n", port->count);
45419- port->count = 1;
45420+ "info->count is %d\n", atomic_read(&port->count));
45421+ atomic_set(&port->count, 1);
45422 }
45423- if (--port->count < 0) {
45424+ if (atomic_dec_return(&port->count) < 0) {
45425 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
45426- info->line, port->count);
45427- port->count = 0;
45428+ info->line, atomic_read(&port->count));
45429+ atomic_set(&port->count, 0);
45430 }
45431- if (port->count) {
45432+ if (atomic_read(&port->count)) {
45433 #ifdef ISDN_DEBUG_MODEM_OPEN
45434 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
45435 #endif
45436@@ -1620,7 +1620,7 @@ isdn_tty_hangup(struct tty_struct *tty)
45437 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
45438 return;
45439 isdn_tty_shutdown(info);
45440- port->count = 0;
45441+ atomic_set(&port->count, 0);
45442 port->flags &= ~ASYNC_NORMAL_ACTIVE;
45443 port->tty = NULL;
45444 wake_up_interruptible(&port->open_wait);
45445@@ -1965,7 +1965,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
45446 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
45447 modem_info *info = &dev->mdm.info[i];
45448
45449- if (info->port.count == 0)
45450+ if (atomic_read(&info->port.count) == 0)
45451 continue;
45452 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
45453 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
45454diff --git a/drivers/isdn/i4l/isdn_x25iface.c b/drivers/isdn/i4l/isdn_x25iface.c
45455index e2d4e58..40cd045 100644
45456--- a/drivers/isdn/i4l/isdn_x25iface.c
45457+++ b/drivers/isdn/i4l/isdn_x25iface.c
45458@@ -53,14 +53,14 @@ static int isdn_x25iface_disconn_ind(struct concap_proto *);
45459
45460
45461 static struct concap_proto_ops ix25_pops = {
45462- &isdn_x25iface_proto_new,
45463- &isdn_x25iface_proto_del,
45464- &isdn_x25iface_proto_restart,
45465- &isdn_x25iface_proto_close,
45466- &isdn_x25iface_xmit,
45467- &isdn_x25iface_receive,
45468- &isdn_x25iface_connect_ind,
45469- &isdn_x25iface_disconn_ind
45470+ .proto_new = &isdn_x25iface_proto_new,
45471+ .proto_del = &isdn_x25iface_proto_del,
45472+ .restart = &isdn_x25iface_proto_restart,
45473+ .close = &isdn_x25iface_proto_close,
45474+ .encap_and_xmit = &isdn_x25iface_xmit,
45475+ .data_ind = &isdn_x25iface_receive,
45476+ .connect_ind = &isdn_x25iface_connect_ind,
45477+ .disconn_ind = &isdn_x25iface_disconn_ind
45478 };
45479
45480 /* error message helper function */
45481diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
45482index 358a574..b4987ea 100644
45483--- a/drivers/isdn/icn/icn.c
45484+++ b/drivers/isdn/icn/icn.c
45485@@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
45486 if (count > len)
45487 count = len;
45488 if (user) {
45489- if (copy_from_user(msg, buf, count))
45490+ if (count > sizeof msg || copy_from_user(msg, buf, count))
45491 return -EFAULT;
45492 } else
45493 memcpy(msg, buf, count);
45494diff --git a/drivers/isdn/mISDN/dsp_cmx.c b/drivers/isdn/mISDN/dsp_cmx.c
45495index 52c4382..09e0c7c 100644
45496--- a/drivers/isdn/mISDN/dsp_cmx.c
45497+++ b/drivers/isdn/mISDN/dsp_cmx.c
45498@@ -1625,7 +1625,7 @@ unsigned long dsp_spl_jiffies; /* calculate the next time to fire */
45499 static u16 dsp_count; /* last sample count */
45500 static int dsp_count_valid; /* if we have last sample count */
45501
45502-void
45503+void __intentional_overflow(-1)
45504 dsp_cmx_send(void *arg)
45505 {
45506 struct dsp_conf *conf;
45507diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
45508index 312ffd3..9263d05 100644
45509--- a/drivers/lguest/core.c
45510+++ b/drivers/lguest/core.c
45511@@ -96,9 +96,17 @@ static __init int map_switcher(void)
45512 * The end address needs +1 because __get_vm_area allocates an
45513 * extra guard page, so we need space for that.
45514 */
45515+
45516+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
45517+ switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
45518+ VM_ALLOC | VM_KERNEXEC, switcher_addr, switcher_addr
45519+ + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
45520+#else
45521 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
45522 VM_ALLOC, switcher_addr, switcher_addr
45523 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
45524+#endif
45525+
45526 if (!switcher_vma) {
45527 err = -ENOMEM;
45528 printk("lguest: could not map switcher pages high\n");
45529@@ -121,7 +129,7 @@ static __init int map_switcher(void)
45530 * Now the Switcher is mapped at the right address, we can't fail!
45531 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
45532 */
45533- memcpy(switcher_vma->addr, start_switcher_text,
45534+ memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
45535 end_switcher_text - start_switcher_text);
45536
45537 printk(KERN_INFO "lguest: mapped switcher at %p\n",
45538diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
45539index e3abebc9..6a35328 100644
45540--- a/drivers/lguest/page_tables.c
45541+++ b/drivers/lguest/page_tables.c
45542@@ -585,7 +585,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
45543 /*:*/
45544
45545 #ifdef CONFIG_X86_PAE
45546-static void release_pmd(pmd_t *spmd)
45547+static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
45548 {
45549 /* If the entry's not present, there's nothing to release. */
45550 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
45551diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
45552index 30f2aef..391c748 100644
45553--- a/drivers/lguest/x86/core.c
45554+++ b/drivers/lguest/x86/core.c
45555@@ -60,7 +60,7 @@ static struct {
45556 /* Offset from where switcher.S was compiled to where we've copied it */
45557 static unsigned long switcher_offset(void)
45558 {
45559- return switcher_addr - (unsigned long)start_switcher_text;
45560+ return switcher_addr - (unsigned long)ktla_ktva(start_switcher_text);
45561 }
45562
45563 /* This cpu's struct lguest_pages (after the Switcher text page) */
45564@@ -100,7 +100,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
45565 * These copies are pretty cheap, so we do them unconditionally: */
45566 /* Save the current Host top-level page directory.
45567 */
45568+
45569+#ifdef CONFIG_PAX_PER_CPU_PGD
45570+ pages->state.host_cr3 = read_cr3();
45571+#else
45572 pages->state.host_cr3 = __pa(current->mm->pgd);
45573+#endif
45574+
45575 /*
45576 * Set up the Guest's page tables to see this CPU's pages (and no
45577 * other CPU's pages).
45578@@ -494,7 +500,7 @@ void __init lguest_arch_host_init(void)
45579 * compiled-in switcher code and the high-mapped copy we just made.
45580 */
45581 for (i = 0; i < IDT_ENTRIES; i++)
45582- default_idt_entries[i] += switcher_offset();
45583+ default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
45584
45585 /*
45586 * Set up the Switcher's per-cpu areas.
45587@@ -577,7 +583,7 @@ void __init lguest_arch_host_init(void)
45588 * it will be undisturbed when we switch. To change %cs and jump we
45589 * need this structure to feed to Intel's "lcall" instruction.
45590 */
45591- lguest_entry.offset = (long)switch_to_guest + switcher_offset();
45592+ lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
45593 lguest_entry.segment = LGUEST_CS;
45594
45595 /*
45596diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
45597index 40634b0..4f5855e 100644
45598--- a/drivers/lguest/x86/switcher_32.S
45599+++ b/drivers/lguest/x86/switcher_32.S
45600@@ -87,6 +87,7 @@
45601 #include <asm/page.h>
45602 #include <asm/segment.h>
45603 #include <asm/lguest.h>
45604+#include <asm/processor-flags.h>
45605
45606 // We mark the start of the code to copy
45607 // It's placed in .text tho it's never run here
45608@@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
45609 // Changes type when we load it: damn Intel!
45610 // For after we switch over our page tables
45611 // That entry will be read-only: we'd crash.
45612+
45613+#ifdef CONFIG_PAX_KERNEXEC
45614+ mov %cr0, %edx
45615+ xor $X86_CR0_WP, %edx
45616+ mov %edx, %cr0
45617+#endif
45618+
45619 movl $(GDT_ENTRY_TSS*8), %edx
45620 ltr %dx
45621
45622@@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
45623 // Let's clear it again for our return.
45624 // The GDT descriptor of the Host
45625 // Points to the table after two "size" bytes
45626- movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
45627+ movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
45628 // Clear "used" from type field (byte 5, bit 2)
45629- andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
45630+ andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
45631+
45632+#ifdef CONFIG_PAX_KERNEXEC
45633+ mov %cr0, %eax
45634+ xor $X86_CR0_WP, %eax
45635+ mov %eax, %cr0
45636+#endif
45637
45638 // Once our page table's switched, the Guest is live!
45639 // The Host fades as we run this final step.
45640@@ -295,13 +309,12 @@ deliver_to_host:
45641 // I consulted gcc, and it gave
45642 // These instructions, which I gladly credit:
45643 leal (%edx,%ebx,8), %eax
45644- movzwl (%eax),%edx
45645- movl 4(%eax), %eax
45646- xorw %ax, %ax
45647- orl %eax, %edx
45648+ movl 4(%eax), %edx
45649+ movw (%eax), %dx
45650 // Now the address of the handler's in %edx
45651 // We call it now: its "iret" drops us home.
45652- jmp *%edx
45653+ ljmp $__KERNEL_CS, $1f
45654+1: jmp *%edx
45655
45656 // Every interrupt can come to us here
45657 // But we must truly tell each apart.
45658diff --git a/drivers/md/bcache/closure.h b/drivers/md/bcache/closure.h
45659index a08e3ee..df8ade2 100644
45660--- a/drivers/md/bcache/closure.h
45661+++ b/drivers/md/bcache/closure.h
45662@@ -238,7 +238,7 @@ static inline void closure_set_stopped(struct closure *cl)
45663 static inline void set_closure_fn(struct closure *cl, closure_fn *fn,
45664 struct workqueue_struct *wq)
45665 {
45666- BUG_ON(object_is_on_stack(cl));
45667+ BUG_ON(object_starts_on_stack(cl));
45668 closure_set_ip(cl);
45669 cl->fn = fn;
45670 cl->wq = wq;
45671diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
45672index 135a090..f7872f6 100644
45673--- a/drivers/md/bitmap.c
45674+++ b/drivers/md/bitmap.c
45675@@ -1927,7 +1927,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
45676 chunk_kb ? "KB" : "B");
45677 if (bitmap->storage.file) {
45678 seq_printf(seq, ", file: ");
45679- seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
45680+ seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
45681 }
45682
45683 seq_printf(seq, "\n");
45684diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
45685index 720ceeb..030f1d4 100644
45686--- a/drivers/md/dm-ioctl.c
45687+++ b/drivers/md/dm-ioctl.c
45688@@ -1773,7 +1773,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
45689 cmd == DM_LIST_VERSIONS_CMD)
45690 return 0;
45691
45692- if ((cmd == DM_DEV_CREATE_CMD)) {
45693+ if (cmd == DM_DEV_CREATE_CMD) {
45694 if (!*param->name) {
45695 DMWARN("name not supplied when creating device");
45696 return -EINVAL;
45697diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
45698index 089d627..ef7352e 100644
45699--- a/drivers/md/dm-raid1.c
45700+++ b/drivers/md/dm-raid1.c
45701@@ -40,7 +40,7 @@ enum dm_raid1_error {
45702
45703 struct mirror {
45704 struct mirror_set *ms;
45705- atomic_t error_count;
45706+ atomic_unchecked_t error_count;
45707 unsigned long error_type;
45708 struct dm_dev *dev;
45709 sector_t offset;
45710@@ -186,7 +186,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
45711 struct mirror *m;
45712
45713 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
45714- if (!atomic_read(&m->error_count))
45715+ if (!atomic_read_unchecked(&m->error_count))
45716 return m;
45717
45718 return NULL;
45719@@ -218,7 +218,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
45720 * simple way to tell if a device has encountered
45721 * errors.
45722 */
45723- atomic_inc(&m->error_count);
45724+ atomic_inc_unchecked(&m->error_count);
45725
45726 if (test_and_set_bit(error_type, &m->error_type))
45727 return;
45728@@ -409,7 +409,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
45729 struct mirror *m = get_default_mirror(ms);
45730
45731 do {
45732- if (likely(!atomic_read(&m->error_count)))
45733+ if (likely(!atomic_read_unchecked(&m->error_count)))
45734 return m;
45735
45736 if (m-- == ms->mirror)
45737@@ -423,7 +423,7 @@ static int default_ok(struct mirror *m)
45738 {
45739 struct mirror *default_mirror = get_default_mirror(m->ms);
45740
45741- return !atomic_read(&default_mirror->error_count);
45742+ return !atomic_read_unchecked(&default_mirror->error_count);
45743 }
45744
45745 static int mirror_available(struct mirror_set *ms, struct bio *bio)
45746@@ -560,7 +560,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
45747 */
45748 if (likely(region_in_sync(ms, region, 1)))
45749 m = choose_mirror(ms, bio->bi_iter.bi_sector);
45750- else if (m && atomic_read(&m->error_count))
45751+ else if (m && atomic_read_unchecked(&m->error_count))
45752 m = NULL;
45753
45754 if (likely(m))
45755@@ -936,7 +936,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
45756 }
45757
45758 ms->mirror[mirror].ms = ms;
45759- atomic_set(&(ms->mirror[mirror].error_count), 0);
45760+ atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
45761 ms->mirror[mirror].error_type = 0;
45762 ms->mirror[mirror].offset = offset;
45763
45764@@ -1351,7 +1351,7 @@ static void mirror_resume(struct dm_target *ti)
45765 */
45766 static char device_status_char(struct mirror *m)
45767 {
45768- if (!atomic_read(&(m->error_count)))
45769+ if (!atomic_read_unchecked(&(m->error_count)))
45770 return 'A';
45771
45772 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
45773diff --git a/drivers/md/dm-stats.c b/drivers/md/dm-stats.c
45774index f478a4c..4b8e5ef 100644
45775--- a/drivers/md/dm-stats.c
45776+++ b/drivers/md/dm-stats.c
45777@@ -382,7 +382,7 @@ do_sync_free:
45778 synchronize_rcu_expedited();
45779 dm_stat_free(&s->rcu_head);
45780 } else {
45781- ACCESS_ONCE(dm_stat_need_rcu_barrier) = 1;
45782+ ACCESS_ONCE_RW(dm_stat_need_rcu_barrier) = 1;
45783 call_rcu(&s->rcu_head, dm_stat_free);
45784 }
45785 return 0;
45786@@ -554,8 +554,8 @@ void dm_stats_account_io(struct dm_stats *stats, unsigned long bi_rw,
45787 ((bi_rw & (REQ_WRITE | REQ_DISCARD)) ==
45788 (ACCESS_ONCE(last->last_rw) & (REQ_WRITE | REQ_DISCARD)))
45789 ));
45790- ACCESS_ONCE(last->last_sector) = end_sector;
45791- ACCESS_ONCE(last->last_rw) = bi_rw;
45792+ ACCESS_ONCE_RW(last->last_sector) = end_sector;
45793+ ACCESS_ONCE_RW(last->last_rw) = bi_rw;
45794 }
45795
45796 rcu_read_lock();
45797diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
45798index f8b37d4..5c5cafd 100644
45799--- a/drivers/md/dm-stripe.c
45800+++ b/drivers/md/dm-stripe.c
45801@@ -21,7 +21,7 @@ struct stripe {
45802 struct dm_dev *dev;
45803 sector_t physical_start;
45804
45805- atomic_t error_count;
45806+ atomic_unchecked_t error_count;
45807 };
45808
45809 struct stripe_c {
45810@@ -188,7 +188,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
45811 kfree(sc);
45812 return r;
45813 }
45814- atomic_set(&(sc->stripe[i].error_count), 0);
45815+ atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
45816 }
45817
45818 ti->private = sc;
45819@@ -332,7 +332,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
45820 DMEMIT("%d ", sc->stripes);
45821 for (i = 0; i < sc->stripes; i++) {
45822 DMEMIT("%s ", sc->stripe[i].dev->name);
45823- buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
45824+ buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
45825 'D' : 'A';
45826 }
45827 buffer[i] = '\0';
45828@@ -377,8 +377,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
45829 */
45830 for (i = 0; i < sc->stripes; i++)
45831 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
45832- atomic_inc(&(sc->stripe[i].error_count));
45833- if (atomic_read(&(sc->stripe[i].error_count)) <
45834+ atomic_inc_unchecked(&(sc->stripe[i].error_count));
45835+ if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
45836 DM_IO_ERROR_THRESHOLD)
45837 schedule_work(&sc->trigger_event);
45838 }
45839diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
45840index 16ba55a..31af906 100644
45841--- a/drivers/md/dm-table.c
45842+++ b/drivers/md/dm-table.c
45843@@ -305,7 +305,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
45844 if (!dev_size)
45845 return 0;
45846
45847- if ((start >= dev_size) || (start + len > dev_size)) {
45848+ if ((start >= dev_size) || (len > dev_size - start)) {
45849 DMWARN("%s: %s too small for target: "
45850 "start=%llu, len=%llu, dev_size=%llu",
45851 dm_device_name(ti->table->md), bdevname(bdev, b),
45852diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
45853index 79f6941..b33b4e0 100644
45854--- a/drivers/md/dm-thin-metadata.c
45855+++ b/drivers/md/dm-thin-metadata.c
45856@@ -404,7 +404,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
45857 {
45858 pmd->info.tm = pmd->tm;
45859 pmd->info.levels = 2;
45860- pmd->info.value_type.context = pmd->data_sm;
45861+ pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
45862 pmd->info.value_type.size = sizeof(__le64);
45863 pmd->info.value_type.inc = data_block_inc;
45864 pmd->info.value_type.dec = data_block_dec;
45865@@ -423,7 +423,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
45866
45867 pmd->bl_info.tm = pmd->tm;
45868 pmd->bl_info.levels = 1;
45869- pmd->bl_info.value_type.context = pmd->data_sm;
45870+ pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
45871 pmd->bl_info.value_type.size = sizeof(__le64);
45872 pmd->bl_info.value_type.inc = data_block_inc;
45873 pmd->bl_info.value_type.dec = data_block_dec;
45874diff --git a/drivers/md/dm.c b/drivers/md/dm.c
45875index 2caf492..0c0dcac 100644
45876--- a/drivers/md/dm.c
45877+++ b/drivers/md/dm.c
45878@@ -191,9 +191,9 @@ struct mapped_device {
45879 /*
45880 * Event handling.
45881 */
45882- atomic_t event_nr;
45883+ atomic_unchecked_t event_nr;
45884 wait_queue_head_t eventq;
45885- atomic_t uevent_seq;
45886+ atomic_unchecked_t uevent_seq;
45887 struct list_head uevent_list;
45888 spinlock_t uevent_lock; /* Protect access to uevent_list */
45889
45890@@ -2298,8 +2298,8 @@ static struct mapped_device *alloc_dev(int minor)
45891 spin_lock_init(&md->deferred_lock);
45892 atomic_set(&md->holders, 1);
45893 atomic_set(&md->open_count, 0);
45894- atomic_set(&md->event_nr, 0);
45895- atomic_set(&md->uevent_seq, 0);
45896+ atomic_set_unchecked(&md->event_nr, 0);
45897+ atomic_set_unchecked(&md->uevent_seq, 0);
45898 INIT_LIST_HEAD(&md->uevent_list);
45899 INIT_LIST_HEAD(&md->table_devices);
45900 spin_lock_init(&md->uevent_lock);
45901@@ -2466,7 +2466,7 @@ static void event_callback(void *context)
45902
45903 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
45904
45905- atomic_inc(&md->event_nr);
45906+ atomic_inc_unchecked(&md->event_nr);
45907 wake_up(&md->eventq);
45908 }
45909
45910@@ -3465,18 +3465,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
45911
45912 uint32_t dm_next_uevent_seq(struct mapped_device *md)
45913 {
45914- return atomic_add_return(1, &md->uevent_seq);
45915+ return atomic_add_return_unchecked(1, &md->uevent_seq);
45916 }
45917
45918 uint32_t dm_get_event_nr(struct mapped_device *md)
45919 {
45920- return atomic_read(&md->event_nr);
45921+ return atomic_read_unchecked(&md->event_nr);
45922 }
45923
45924 int dm_wait_event(struct mapped_device *md, int event_nr)
45925 {
45926 return wait_event_interruptible(md->eventq,
45927- (event_nr != atomic_read(&md->event_nr)));
45928+ (event_nr != atomic_read_unchecked(&md->event_nr)));
45929 }
45930
45931 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
45932diff --git a/drivers/md/md.c b/drivers/md/md.c
45933index 4dbed4a..150c3d6 100644
45934--- a/drivers/md/md.c
45935+++ b/drivers/md/md.c
45936@@ -197,10 +197,10 @@ EXPORT_SYMBOL_GPL(bio_clone_mddev);
45937 * start build, activate spare
45938 */
45939 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
45940-static atomic_t md_event_count;
45941+static atomic_unchecked_t md_event_count;
45942 void md_new_event(struct mddev *mddev)
45943 {
45944- atomic_inc(&md_event_count);
45945+ atomic_inc_unchecked(&md_event_count);
45946 wake_up(&md_event_waiters);
45947 }
45948 EXPORT_SYMBOL_GPL(md_new_event);
45949@@ -210,7 +210,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
45950 */
45951 static void md_new_event_inintr(struct mddev *mddev)
45952 {
45953- atomic_inc(&md_event_count);
45954+ atomic_inc_unchecked(&md_event_count);
45955 wake_up(&md_event_waiters);
45956 }
45957
45958@@ -1449,7 +1449,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
45959 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
45960 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
45961 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
45962- atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
45963+ atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
45964
45965 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
45966 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
45967@@ -1700,7 +1700,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
45968 else
45969 sb->resync_offset = cpu_to_le64(0);
45970
45971- sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
45972+ sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
45973
45974 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
45975 sb->size = cpu_to_le64(mddev->dev_sectors);
45976@@ -2624,7 +2624,7 @@ __ATTR_PREALLOC(state, S_IRUGO|S_IWUSR, state_show, state_store);
45977 static ssize_t
45978 errors_show(struct md_rdev *rdev, char *page)
45979 {
45980- return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
45981+ return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
45982 }
45983
45984 static ssize_t
45985@@ -2633,7 +2633,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
45986 char *e;
45987 unsigned long n = simple_strtoul(buf, &e, 10);
45988 if (*buf && (*e == 0 || *e == '\n')) {
45989- atomic_set(&rdev->corrected_errors, n);
45990+ atomic_set_unchecked(&rdev->corrected_errors, n);
45991 return len;
45992 }
45993 return -EINVAL;
45994@@ -3069,8 +3069,8 @@ int md_rdev_init(struct md_rdev *rdev)
45995 rdev->sb_loaded = 0;
45996 rdev->bb_page = NULL;
45997 atomic_set(&rdev->nr_pending, 0);
45998- atomic_set(&rdev->read_errors, 0);
45999- atomic_set(&rdev->corrected_errors, 0);
46000+ atomic_set_unchecked(&rdev->read_errors, 0);
46001+ atomic_set_unchecked(&rdev->corrected_errors, 0);
46002
46003 INIT_LIST_HEAD(&rdev->same_set);
46004 init_waitqueue_head(&rdev->blocked_wait);
46005@@ -5735,22 +5735,22 @@ static int get_bitmap_file(struct mddev *mddev, void __user * arg)
46006 char *ptr;
46007 int err;
46008
46009- file = kmalloc(sizeof(*file), GFP_NOIO);
46010+ file = kzalloc(sizeof(*file), GFP_NOIO);
46011 if (!file)
46012 return -ENOMEM;
46013
46014 err = 0;
46015 spin_lock(&mddev->lock);
46016- /* bitmap disabled, zero the first byte and copy out */
46017- if (!mddev->bitmap_info.file)
46018- file->pathname[0] = '\0';
46019- else if ((ptr = d_path(&mddev->bitmap_info.file->f_path,
46020- file->pathname, sizeof(file->pathname))),
46021- IS_ERR(ptr))
46022- err = PTR_ERR(ptr);
46023- else
46024- memmove(file->pathname, ptr,
46025- sizeof(file->pathname)-(ptr-file->pathname));
46026+ /* bitmap enabled */
46027+ if (mddev->bitmap_info.file) {
46028+ ptr = d_path(&mddev->bitmap_info.file->f_path,
46029+ file->pathname, sizeof(file->pathname));
46030+ if (IS_ERR(ptr))
46031+ err = PTR_ERR(ptr);
46032+ else
46033+ memmove(file->pathname, ptr,
46034+ sizeof(file->pathname)-(ptr-file->pathname));
46035+ }
46036 spin_unlock(&mddev->lock);
46037
46038 if (err == 0 &&
46039@@ -7232,7 +7232,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
46040
46041 spin_unlock(&pers_lock);
46042 seq_printf(seq, "\n");
46043- seq->poll_event = atomic_read(&md_event_count);
46044+ seq->poll_event = atomic_read_unchecked(&md_event_count);
46045 return 0;
46046 }
46047 if (v == (void*)2) {
46048@@ -7335,7 +7335,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
46049 return error;
46050
46051 seq = file->private_data;
46052- seq->poll_event = atomic_read(&md_event_count);
46053+ seq->poll_event = atomic_read_unchecked(&md_event_count);
46054 return error;
46055 }
46056
46057@@ -7352,7 +7352,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
46058 /* always allow read */
46059 mask = POLLIN | POLLRDNORM;
46060
46061- if (seq->poll_event != atomic_read(&md_event_count))
46062+ if (seq->poll_event != atomic_read_unchecked(&md_event_count))
46063 mask |= POLLERR | POLLPRI;
46064 return mask;
46065 }
46066@@ -7448,7 +7448,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
46067 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
46068 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
46069 (int)part_stat_read(&disk->part0, sectors[1]) -
46070- atomic_read(&disk->sync_io);
46071+ atomic_read_unchecked(&disk->sync_io);
46072 /* sync IO will cause sync_io to increase before the disk_stats
46073 * as sync_io is counted when a request starts, and
46074 * disk_stats is counted when it completes.
46075diff --git a/drivers/md/md.h b/drivers/md/md.h
46076index 4046a6c..e2f2997 100644
46077--- a/drivers/md/md.h
46078+++ b/drivers/md/md.h
46079@@ -95,13 +95,13 @@ struct md_rdev {
46080 * only maintained for arrays that
46081 * support hot removal
46082 */
46083- atomic_t read_errors; /* number of consecutive read errors that
46084+ atomic_unchecked_t read_errors; /* number of consecutive read errors that
46085 * we have tried to ignore.
46086 */
46087 struct timespec last_read_error; /* monotonic time since our
46088 * last read error
46089 */
46090- atomic_t corrected_errors; /* number of corrected read errors,
46091+ atomic_unchecked_t corrected_errors; /* number of corrected read errors,
46092 * for reporting to userspace and storing
46093 * in superblock.
46094 */
46095@@ -486,7 +486,7 @@ extern void mddev_unlock(struct mddev *mddev);
46096
46097 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
46098 {
46099- atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
46100+ atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
46101 }
46102
46103 struct md_personality
46104diff --git a/drivers/md/persistent-data/dm-space-map-metadata.c b/drivers/md/persistent-data/dm-space-map-metadata.c
46105index e8a9042..35bd145 100644
46106--- a/drivers/md/persistent-data/dm-space-map-metadata.c
46107+++ b/drivers/md/persistent-data/dm-space-map-metadata.c
46108@@ -683,7 +683,7 @@ static int sm_metadata_extend(struct dm_space_map *sm, dm_block_t extra_blocks)
46109 * Flick into a mode where all blocks get allocated in the new area.
46110 */
46111 smm->begin = old_len;
46112- memcpy(sm, &bootstrap_ops, sizeof(*sm));
46113+ memcpy((void *)sm, &bootstrap_ops, sizeof(*sm));
46114
46115 /*
46116 * Extend.
46117@@ -714,7 +714,7 @@ out:
46118 /*
46119 * Switch back to normal behaviour.
46120 */
46121- memcpy(sm, &ops, sizeof(*sm));
46122+ memcpy((void *)sm, &ops, sizeof(*sm));
46123 return r;
46124 }
46125
46126diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
46127index 3e6d115..ffecdeb 100644
46128--- a/drivers/md/persistent-data/dm-space-map.h
46129+++ b/drivers/md/persistent-data/dm-space-map.h
46130@@ -71,6 +71,7 @@ struct dm_space_map {
46131 dm_sm_threshold_fn fn,
46132 void *context);
46133 };
46134+typedef struct dm_space_map __no_const dm_space_map_no_const;
46135
46136 /*----------------------------------------------------------------*/
46137
46138diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
46139index 9157a29..0d462f0 100644
46140--- a/drivers/md/raid1.c
46141+++ b/drivers/md/raid1.c
46142@@ -1934,7 +1934,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
46143 if (r1_sync_page_io(rdev, sect, s,
46144 bio->bi_io_vec[idx].bv_page,
46145 READ) != 0)
46146- atomic_add(s, &rdev->corrected_errors);
46147+ atomic_add_unchecked(s, &rdev->corrected_errors);
46148 }
46149 sectors -= s;
46150 sect += s;
46151@@ -2167,7 +2167,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
46152 !test_bit(Faulty, &rdev->flags)) {
46153 if (r1_sync_page_io(rdev, sect, s,
46154 conf->tmppage, READ)) {
46155- atomic_add(s, &rdev->corrected_errors);
46156+ atomic_add_unchecked(s, &rdev->corrected_errors);
46157 printk(KERN_INFO
46158 "md/raid1:%s: read error corrected "
46159 "(%d sectors at %llu on %s)\n",
46160diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
46161index f55c3f3..4cca8c8 100644
46162--- a/drivers/md/raid10.c
46163+++ b/drivers/md/raid10.c
46164@@ -1934,7 +1934,7 @@ static void end_sync_read(struct bio *bio, int error)
46165 /* The write handler will notice the lack of
46166 * R10BIO_Uptodate and record any errors etc
46167 */
46168- atomic_add(r10_bio->sectors,
46169+ atomic_add_unchecked(r10_bio->sectors,
46170 &conf->mirrors[d].rdev->corrected_errors);
46171
46172 /* for reconstruct, we always reschedule after a read.
46173@@ -2291,7 +2291,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
46174 {
46175 struct timespec cur_time_mon;
46176 unsigned long hours_since_last;
46177- unsigned int read_errors = atomic_read(&rdev->read_errors);
46178+ unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
46179
46180 ktime_get_ts(&cur_time_mon);
46181
46182@@ -2313,9 +2313,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
46183 * overflowing the shift of read_errors by hours_since_last.
46184 */
46185 if (hours_since_last >= 8 * sizeof(read_errors))
46186- atomic_set(&rdev->read_errors, 0);
46187+ atomic_set_unchecked(&rdev->read_errors, 0);
46188 else
46189- atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
46190+ atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
46191 }
46192
46193 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
46194@@ -2369,8 +2369,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
46195 return;
46196
46197 check_decay_read_errors(mddev, rdev);
46198- atomic_inc(&rdev->read_errors);
46199- if (atomic_read(&rdev->read_errors) > max_read_errors) {
46200+ atomic_inc_unchecked(&rdev->read_errors);
46201+ if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
46202 char b[BDEVNAME_SIZE];
46203 bdevname(rdev->bdev, b);
46204
46205@@ -2378,7 +2378,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
46206 "md/raid10:%s: %s: Raid device exceeded "
46207 "read_error threshold [cur %d:max %d]\n",
46208 mdname(mddev), b,
46209- atomic_read(&rdev->read_errors), max_read_errors);
46210+ atomic_read_unchecked(&rdev->read_errors), max_read_errors);
46211 printk(KERN_NOTICE
46212 "md/raid10:%s: %s: Failing raid device\n",
46213 mdname(mddev), b);
46214@@ -2533,7 +2533,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
46215 sect +
46216 choose_data_offset(r10_bio, rdev)),
46217 bdevname(rdev->bdev, b));
46218- atomic_add(s, &rdev->corrected_errors);
46219+ atomic_add_unchecked(s, &rdev->corrected_errors);
46220 }
46221
46222 rdev_dec_pending(rdev, mddev);
46223diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
46224index b6793d2..92be2bc 100644
46225--- a/drivers/md/raid5.c
46226+++ b/drivers/md/raid5.c
46227@@ -1108,23 +1108,23 @@ async_copy_data(int frombio, struct bio *bio, struct page **page,
46228 struct bio_vec bvl;
46229 struct bvec_iter iter;
46230 struct page *bio_page;
46231- int page_offset;
46232+ s64 page_offset;
46233 struct async_submit_ctl submit;
46234 enum async_tx_flags flags = 0;
46235
46236 if (bio->bi_iter.bi_sector >= sector)
46237- page_offset = (signed)(bio->bi_iter.bi_sector - sector) * 512;
46238+ page_offset = (s64)(bio->bi_iter.bi_sector - sector) * 512;
46239 else
46240- page_offset = (signed)(sector - bio->bi_iter.bi_sector) * -512;
46241+ page_offset = (s64)(sector - bio->bi_iter.bi_sector) * -512;
46242
46243 if (frombio)
46244 flags |= ASYNC_TX_FENCE;
46245 init_async_submit(&submit, flags, tx, NULL, NULL, NULL);
46246
46247 bio_for_each_segment(bvl, bio, iter) {
46248- int len = bvl.bv_len;
46249- int clen;
46250- int b_offset = 0;
46251+ s64 len = bvl.bv_len;
46252+ s64 clen;
46253+ s64 b_offset = 0;
46254
46255 if (page_offset < 0) {
46256 b_offset = -page_offset;
46257@@ -2017,6 +2017,10 @@ static int grow_one_stripe(struct r5conf *conf, gfp_t gfp)
46258 return 1;
46259 }
46260
46261+#ifdef CONFIG_GRKERNSEC_HIDESYM
46262+static atomic_unchecked_t raid5_cache_id = ATOMIC_INIT(0);
46263+#endif
46264+
46265 static int grow_stripes(struct r5conf *conf, int num)
46266 {
46267 struct kmem_cache *sc;
46268@@ -2027,7 +2031,11 @@ static int grow_stripes(struct r5conf *conf, int num)
46269 "raid%d-%s", conf->level, mdname(conf->mddev));
46270 else
46271 sprintf(conf->cache_name[0],
46272+#ifdef CONFIG_GRKERNSEC_HIDESYM
46273+ "raid%d-%08lx", conf->level, atomic_inc_return_unchecked(&raid5_cache_id));
46274+#else
46275 "raid%d-%p", conf->level, conf->mddev);
46276+#endif
46277 sprintf(conf->cache_name[1], "%s-alt", conf->cache_name[0]);
46278
46279 conf->active_name = 0;
46280@@ -2315,21 +2323,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
46281 mdname(conf->mddev), STRIPE_SECTORS,
46282 (unsigned long long)s,
46283 bdevname(rdev->bdev, b));
46284- atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
46285+ atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
46286 clear_bit(R5_ReadError, &sh->dev[i].flags);
46287 clear_bit(R5_ReWrite, &sh->dev[i].flags);
46288 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
46289 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
46290
46291- if (atomic_read(&rdev->read_errors))
46292- atomic_set(&rdev->read_errors, 0);
46293+ if (atomic_read_unchecked(&rdev->read_errors))
46294+ atomic_set_unchecked(&rdev->read_errors, 0);
46295 } else {
46296 const char *bdn = bdevname(rdev->bdev, b);
46297 int retry = 0;
46298 int set_bad = 0;
46299
46300 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
46301- atomic_inc(&rdev->read_errors);
46302+ atomic_inc_unchecked(&rdev->read_errors);
46303 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
46304 printk_ratelimited(
46305 KERN_WARNING
46306@@ -2357,7 +2365,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
46307 mdname(conf->mddev),
46308 (unsigned long long)s,
46309 bdn);
46310- } else if (atomic_read(&rdev->read_errors)
46311+ } else if (atomic_read_unchecked(&rdev->read_errors)
46312 > conf->max_nr_stripes)
46313 printk(KERN_WARNING
46314 "md/raid:%s: Too many read errors, failing device %s.\n",
46315diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
46316index 13bb57f..0ca21b2 100644
46317--- a/drivers/media/dvb-core/dvbdev.c
46318+++ b/drivers/media/dvb-core/dvbdev.c
46319@@ -272,7 +272,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
46320 const struct dvb_device *template, void *priv, int type)
46321 {
46322 struct dvb_device *dvbdev;
46323- struct file_operations *dvbdevfops;
46324+ file_operations_no_const *dvbdevfops;
46325 struct device *clsdev;
46326 int minor;
46327 int id;
46328diff --git a/drivers/media/dvb-frontends/af9033.h b/drivers/media/dvb-frontends/af9033.h
46329index 6ad22b6..6e90e2a 100644
46330--- a/drivers/media/dvb-frontends/af9033.h
46331+++ b/drivers/media/dvb-frontends/af9033.h
46332@@ -96,6 +96,6 @@ struct af9033_ops {
46333 int (*pid_filter_ctrl)(struct dvb_frontend *fe, int onoff);
46334 int (*pid_filter)(struct dvb_frontend *fe, int index, u16 pid,
46335 int onoff);
46336-};
46337+} __no_const;
46338
46339 #endif /* AF9033_H */
46340diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
46341index 6ae9899..07d8543 100644
46342--- a/drivers/media/dvb-frontends/dib3000.h
46343+++ b/drivers/media/dvb-frontends/dib3000.h
46344@@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
46345 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
46346 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
46347 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
46348-};
46349+} __no_const;
46350
46351 #if IS_REACHABLE(CONFIG_DVB_DIB3000MB)
46352 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
46353diff --git a/drivers/media/dvb-frontends/dib7000p.h b/drivers/media/dvb-frontends/dib7000p.h
46354index baa2789..c8de7fe 100644
46355--- a/drivers/media/dvb-frontends/dib7000p.h
46356+++ b/drivers/media/dvb-frontends/dib7000p.h
46357@@ -64,7 +64,7 @@ struct dib7000p_ops {
46358 int (*get_adc_power)(struct dvb_frontend *fe);
46359 int (*slave_reset)(struct dvb_frontend *fe);
46360 struct dvb_frontend *(*init)(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib7000p_config *cfg);
46361-};
46362+} __no_const;
46363
46364 #if IS_REACHABLE(CONFIG_DVB_DIB7000P)
46365 void *dib7000p_attach(struct dib7000p_ops *ops);
46366diff --git a/drivers/media/dvb-frontends/dib8000.h b/drivers/media/dvb-frontends/dib8000.h
46367index 780c37b..50e2620 100644
46368--- a/drivers/media/dvb-frontends/dib8000.h
46369+++ b/drivers/media/dvb-frontends/dib8000.h
46370@@ -61,7 +61,7 @@ struct dib8000_ops {
46371 int (*pid_filter_ctrl)(struct dvb_frontend *fe, u8 onoff);
46372 int (*pid_filter)(struct dvb_frontend *fe, u8 id, u16 pid, u8 onoff);
46373 struct dvb_frontend *(*init)(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib8000_config *cfg);
46374-};
46375+} __no_const;
46376
46377 #if IS_REACHABLE(CONFIG_DVB_DIB8000)
46378 void *dib8000_attach(struct dib8000_ops *ops);
46379diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
46380index c9decd8..7849cec 100644
46381--- a/drivers/media/pci/cx88/cx88-video.c
46382+++ b/drivers/media/pci/cx88/cx88-video.c
46383@@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
46384
46385 /* ------------------------------------------------------------------ */
46386
46387-static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
46388-static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
46389-static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
46390+static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
46391+static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
46392+static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
46393
46394 module_param_array(video_nr, int, NULL, 0444);
46395 module_param_array(vbi_nr, int, NULL, 0444);
46396diff --git a/drivers/media/pci/ivtv/ivtv-driver.c b/drivers/media/pci/ivtv/ivtv-driver.c
46397index c2e60b4..5eeccc0 100644
46398--- a/drivers/media/pci/ivtv/ivtv-driver.c
46399+++ b/drivers/media/pci/ivtv/ivtv-driver.c
46400@@ -83,7 +83,7 @@ static struct pci_device_id ivtv_pci_tbl[] = {
46401 MODULE_DEVICE_TABLE(pci,ivtv_pci_tbl);
46402
46403 /* ivtv instance counter */
46404-static atomic_t ivtv_instance = ATOMIC_INIT(0);
46405+static atomic_unchecked_t ivtv_instance = ATOMIC_INIT(0);
46406
46407 /* Parameter declarations */
46408 static int cardtype[IVTV_MAX_CARDS];
46409diff --git a/drivers/media/pci/solo6x10/solo6x10-core.c b/drivers/media/pci/solo6x10/solo6x10-core.c
46410index 570d119..ed25830 100644
46411--- a/drivers/media/pci/solo6x10/solo6x10-core.c
46412+++ b/drivers/media/pci/solo6x10/solo6x10-core.c
46413@@ -424,7 +424,7 @@ static void solo_device_release(struct device *dev)
46414
46415 static int solo_sysfs_init(struct solo_dev *solo_dev)
46416 {
46417- struct bin_attribute *sdram_attr = &solo_dev->sdram_attr;
46418+ bin_attribute_no_const *sdram_attr = &solo_dev->sdram_attr;
46419 struct device *dev = &solo_dev->dev;
46420 const char *driver;
46421 int i;
46422diff --git a/drivers/media/pci/solo6x10/solo6x10-g723.c b/drivers/media/pci/solo6x10/solo6x10-g723.c
46423index 7ddc767..1c24361 100644
46424--- a/drivers/media/pci/solo6x10/solo6x10-g723.c
46425+++ b/drivers/media/pci/solo6x10/solo6x10-g723.c
46426@@ -351,7 +351,7 @@ static int solo_snd_pcm_init(struct solo_dev *solo_dev)
46427
46428 int solo_g723_init(struct solo_dev *solo_dev)
46429 {
46430- static struct snd_device_ops ops = { NULL };
46431+ static struct snd_device_ops ops = { };
46432 struct snd_card *card;
46433 struct snd_kcontrol_new kctl;
46434 char name[32];
46435diff --git a/drivers/media/pci/solo6x10/solo6x10-p2m.c b/drivers/media/pci/solo6x10/solo6x10-p2m.c
46436index 8c84846..27b4f83 100644
46437--- a/drivers/media/pci/solo6x10/solo6x10-p2m.c
46438+++ b/drivers/media/pci/solo6x10/solo6x10-p2m.c
46439@@ -73,7 +73,7 @@ int solo_p2m_dma_desc(struct solo_dev *solo_dev,
46440
46441 /* Get next ID. According to Softlogic, 6110 has problems on !=0 P2M */
46442 if (solo_dev->type != SOLO_DEV_6110 && multi_p2m) {
46443- p2m_id = atomic_inc_return(&solo_dev->p2m_count) % SOLO_NR_P2M;
46444+ p2m_id = atomic_inc_return_unchecked(&solo_dev->p2m_count) % SOLO_NR_P2M;
46445 if (p2m_id < 0)
46446 p2m_id = -p2m_id;
46447 }
46448diff --git a/drivers/media/pci/solo6x10/solo6x10.h b/drivers/media/pci/solo6x10/solo6x10.h
46449index 1ca54b0..7d7cb9a 100644
46450--- a/drivers/media/pci/solo6x10/solo6x10.h
46451+++ b/drivers/media/pci/solo6x10/solo6x10.h
46452@@ -218,7 +218,7 @@ struct solo_dev {
46453
46454 /* P2M DMA Engine */
46455 struct solo_p2m_dev p2m_dev[SOLO_NR_P2M];
46456- atomic_t p2m_count;
46457+ atomic_unchecked_t p2m_count;
46458 int p2m_jiffies;
46459 unsigned int p2m_timeouts;
46460
46461diff --git a/drivers/media/pci/tw68/tw68-core.c b/drivers/media/pci/tw68/tw68-core.c
46462index c135165..dc69499 100644
46463--- a/drivers/media/pci/tw68/tw68-core.c
46464+++ b/drivers/media/pci/tw68/tw68-core.c
46465@@ -60,7 +60,7 @@ static unsigned int card[] = {[0 ... (TW68_MAXBOARDS - 1)] = UNSET };
46466 module_param_array(card, int, NULL, 0444);
46467 MODULE_PARM_DESC(card, "card type");
46468
46469-static atomic_t tw68_instance = ATOMIC_INIT(0);
46470+static atomic_unchecked_t tw68_instance = ATOMIC_INIT(0);
46471
46472 /* ------------------------------------------------------------------ */
46473
46474diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
46475index 17b189a..b78aa6b 100644
46476--- a/drivers/media/platform/omap/omap_vout.c
46477+++ b/drivers/media/platform/omap/omap_vout.c
46478@@ -63,7 +63,6 @@ enum omap_vout_channels {
46479 OMAP_VIDEO2,
46480 };
46481
46482-static struct videobuf_queue_ops video_vbq_ops;
46483 /* Variables configurable through module params*/
46484 static u32 video1_numbuffers = 3;
46485 static u32 video2_numbuffers = 3;
46486@@ -1012,6 +1011,12 @@ static int omap_vout_open(struct file *file)
46487 {
46488 struct videobuf_queue *q;
46489 struct omap_vout_device *vout = NULL;
46490+ static struct videobuf_queue_ops video_vbq_ops = {
46491+ .buf_setup = omap_vout_buffer_setup,
46492+ .buf_prepare = omap_vout_buffer_prepare,
46493+ .buf_release = omap_vout_buffer_release,
46494+ .buf_queue = omap_vout_buffer_queue,
46495+ };
46496
46497 vout = video_drvdata(file);
46498 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
46499@@ -1029,10 +1034,6 @@ static int omap_vout_open(struct file *file)
46500 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
46501
46502 q = &vout->vbq;
46503- video_vbq_ops.buf_setup = omap_vout_buffer_setup;
46504- video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
46505- video_vbq_ops.buf_release = omap_vout_buffer_release;
46506- video_vbq_ops.buf_queue = omap_vout_buffer_queue;
46507 spin_lock_init(&vout->vbq_lock);
46508
46509 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
46510diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
46511index fb2acc5..a2fcbdc4 100644
46512--- a/drivers/media/platform/s5p-tv/mixer.h
46513+++ b/drivers/media/platform/s5p-tv/mixer.h
46514@@ -156,7 +156,7 @@ struct mxr_layer {
46515 /** layer index (unique identifier) */
46516 int idx;
46517 /** callbacks for layer methods */
46518- struct mxr_layer_ops ops;
46519+ struct mxr_layer_ops *ops;
46520 /** format array */
46521 const struct mxr_format **fmt_array;
46522 /** size of format array */
46523diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
46524index 74344c7..a39e70e 100644
46525--- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
46526+++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
46527@@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
46528 {
46529 struct mxr_layer *layer;
46530 int ret;
46531- struct mxr_layer_ops ops = {
46532+ static struct mxr_layer_ops ops = {
46533 .release = mxr_graph_layer_release,
46534 .buffer_set = mxr_graph_buffer_set,
46535 .stream_set = mxr_graph_stream_set,
46536diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
46537index b713403..53cb5ad 100644
46538--- a/drivers/media/platform/s5p-tv/mixer_reg.c
46539+++ b/drivers/media/platform/s5p-tv/mixer_reg.c
46540@@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
46541 layer->update_buf = next;
46542 }
46543
46544- layer->ops.buffer_set(layer, layer->update_buf);
46545+ layer->ops->buffer_set(layer, layer->update_buf);
46546
46547 if (done && done != layer->shadow_buf)
46548 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
46549diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
46550index 751f3b6..d829203 100644
46551--- a/drivers/media/platform/s5p-tv/mixer_video.c
46552+++ b/drivers/media/platform/s5p-tv/mixer_video.c
46553@@ -210,7 +210,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
46554 layer->geo.src.height = layer->geo.src.full_height;
46555
46556 mxr_geometry_dump(mdev, &layer->geo);
46557- layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
46558+ layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
46559 mxr_geometry_dump(mdev, &layer->geo);
46560 }
46561
46562@@ -228,7 +228,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
46563 layer->geo.dst.full_width = mbus_fmt.width;
46564 layer->geo.dst.full_height = mbus_fmt.height;
46565 layer->geo.dst.field = mbus_fmt.field;
46566- layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
46567+ layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
46568
46569 mxr_geometry_dump(mdev, &layer->geo);
46570 }
46571@@ -334,7 +334,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
46572 /* set source size to highest accepted value */
46573 geo->src.full_width = max(geo->dst.full_width, pix->width);
46574 geo->src.full_height = max(geo->dst.full_height, pix->height);
46575- layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
46576+ layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
46577 mxr_geometry_dump(mdev, &layer->geo);
46578 /* set cropping to total visible screen */
46579 geo->src.width = pix->width;
46580@@ -342,12 +342,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
46581 geo->src.x_offset = 0;
46582 geo->src.y_offset = 0;
46583 /* assure consistency of geometry */
46584- layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
46585+ layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
46586 mxr_geometry_dump(mdev, &layer->geo);
46587 /* set full size to lowest possible value */
46588 geo->src.full_width = 0;
46589 geo->src.full_height = 0;
46590- layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
46591+ layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
46592 mxr_geometry_dump(mdev, &layer->geo);
46593
46594 /* returning results */
46595@@ -474,7 +474,7 @@ static int mxr_s_selection(struct file *file, void *fh,
46596 target->width = s->r.width;
46597 target->height = s->r.height;
46598
46599- layer->ops.fix_geometry(layer, stage, s->flags);
46600+ layer->ops->fix_geometry(layer, stage, s->flags);
46601
46602 /* retrieve update selection rectangle */
46603 res.left = target->x_offset;
46604@@ -938,13 +938,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
46605 mxr_output_get(mdev);
46606
46607 mxr_layer_update_output(layer);
46608- layer->ops.format_set(layer);
46609+ layer->ops->format_set(layer);
46610 /* enabling layer in hardware */
46611 spin_lock_irqsave(&layer->enq_slock, flags);
46612 layer->state = MXR_LAYER_STREAMING;
46613 spin_unlock_irqrestore(&layer->enq_slock, flags);
46614
46615- layer->ops.stream_set(layer, MXR_ENABLE);
46616+ layer->ops->stream_set(layer, MXR_ENABLE);
46617 mxr_streamer_get(mdev);
46618
46619 return 0;
46620@@ -1014,7 +1014,7 @@ static void stop_streaming(struct vb2_queue *vq)
46621 spin_unlock_irqrestore(&layer->enq_slock, flags);
46622
46623 /* disabling layer in hardware */
46624- layer->ops.stream_set(layer, MXR_DISABLE);
46625+ layer->ops->stream_set(layer, MXR_DISABLE);
46626 /* remove one streamer */
46627 mxr_streamer_put(mdev);
46628 /* allow changes in output configuration */
46629@@ -1052,8 +1052,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
46630
46631 void mxr_layer_release(struct mxr_layer *layer)
46632 {
46633- if (layer->ops.release)
46634- layer->ops.release(layer);
46635+ if (layer->ops->release)
46636+ layer->ops->release(layer);
46637 }
46638
46639 void mxr_base_layer_release(struct mxr_layer *layer)
46640@@ -1079,7 +1079,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
46641
46642 layer->mdev = mdev;
46643 layer->idx = idx;
46644- layer->ops = *ops;
46645+ layer->ops = ops;
46646
46647 spin_lock_init(&layer->enq_slock);
46648 INIT_LIST_HEAD(&layer->enq_list);
46649diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
46650index c9388c4..ce71ece 100644
46651--- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
46652+++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
46653@@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
46654 {
46655 struct mxr_layer *layer;
46656 int ret;
46657- struct mxr_layer_ops ops = {
46658+ static struct mxr_layer_ops ops = {
46659 .release = mxr_vp_layer_release,
46660 .buffer_set = mxr_vp_buffer_set,
46661 .stream_set = mxr_vp_stream_set,
46662diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
46663index 82affae..42833ec 100644
46664--- a/drivers/media/radio/radio-cadet.c
46665+++ b/drivers/media/radio/radio-cadet.c
46666@@ -333,6 +333,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
46667 unsigned char readbuf[RDS_BUFFER];
46668 int i = 0;
46669
46670+ if (count > RDS_BUFFER)
46671+ return -EFAULT;
46672 mutex_lock(&dev->lock);
46673 if (dev->rdsstat == 0)
46674 cadet_start_rds(dev);
46675@@ -349,8 +351,9 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
46676 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
46677 mutex_unlock(&dev->lock);
46678
46679- if (i && copy_to_user(data, readbuf, i))
46680- return -EFAULT;
46681+ if (i > sizeof(readbuf) || (i && copy_to_user(data, readbuf, i)))
46682+ i = -EFAULT;
46683+
46684 return i;
46685 }
46686
46687diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
46688index 5236035..c622c74 100644
46689--- a/drivers/media/radio/radio-maxiradio.c
46690+++ b/drivers/media/radio/radio-maxiradio.c
46691@@ -61,7 +61,7 @@ MODULE_PARM_DESC(radio_nr, "Radio device number");
46692 /* TEA5757 pin mappings */
46693 static const int clk = 1, data = 2, wren = 4, mo_st = 8, power = 16;
46694
46695-static atomic_t maxiradio_instance = ATOMIC_INIT(0);
46696+static atomic_unchecked_t maxiradio_instance = ATOMIC_INIT(0);
46697
46698 #define PCI_VENDOR_ID_GUILLEMOT 0x5046
46699 #define PCI_DEVICE_ID_GUILLEMOT_MAXIRADIO 0x1001
46700diff --git a/drivers/media/radio/radio-shark.c b/drivers/media/radio/radio-shark.c
46701index 050b3bb..79f62b9 100644
46702--- a/drivers/media/radio/radio-shark.c
46703+++ b/drivers/media/radio/radio-shark.c
46704@@ -79,7 +79,7 @@ struct shark_device {
46705 u32 last_val;
46706 };
46707
46708-static atomic_t shark_instance = ATOMIC_INIT(0);
46709+static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
46710
46711 static void shark_write_val(struct snd_tea575x *tea, u32 val)
46712 {
46713diff --git a/drivers/media/radio/radio-shark2.c b/drivers/media/radio/radio-shark2.c
46714index 8654e0d..0608a64 100644
46715--- a/drivers/media/radio/radio-shark2.c
46716+++ b/drivers/media/radio/radio-shark2.c
46717@@ -74,7 +74,7 @@ struct shark_device {
46718 u8 *transfer_buffer;
46719 };
46720
46721-static atomic_t shark_instance = ATOMIC_INIT(0);
46722+static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
46723
46724 static int shark_write_reg(struct radio_tea5777 *tea, u64 reg)
46725 {
46726diff --git a/drivers/media/radio/radio-si476x.c b/drivers/media/radio/radio-si476x.c
46727index dccf586..d5db411 100644
46728--- a/drivers/media/radio/radio-si476x.c
46729+++ b/drivers/media/radio/radio-si476x.c
46730@@ -1445,7 +1445,7 @@ static int si476x_radio_probe(struct platform_device *pdev)
46731 struct si476x_radio *radio;
46732 struct v4l2_ctrl *ctrl;
46733
46734- static atomic_t instance = ATOMIC_INIT(0);
46735+ static atomic_unchecked_t instance = ATOMIC_INIT(0);
46736
46737 radio = devm_kzalloc(&pdev->dev, sizeof(*radio), GFP_KERNEL);
46738 if (!radio)
46739diff --git a/drivers/media/radio/wl128x/fmdrv_common.c b/drivers/media/radio/wl128x/fmdrv_common.c
46740index 704397f..4d05977 100644
46741--- a/drivers/media/radio/wl128x/fmdrv_common.c
46742+++ b/drivers/media/radio/wl128x/fmdrv_common.c
46743@@ -71,7 +71,7 @@ module_param(default_rds_buf, uint, 0444);
46744 MODULE_PARM_DESC(rds_buf, "RDS buffer entries");
46745
46746 /* Radio Nr */
46747-static u32 radio_nr = -1;
46748+static int radio_nr = -1;
46749 module_param(radio_nr, int, 0444);
46750 MODULE_PARM_DESC(radio_nr, "Radio Nr");
46751
46752diff --git a/drivers/media/usb/dvb-usb/cinergyT2-core.c b/drivers/media/usb/dvb-usb/cinergyT2-core.c
46753index 9fd1527..8927230 100644
46754--- a/drivers/media/usb/dvb-usb/cinergyT2-core.c
46755+++ b/drivers/media/usb/dvb-usb/cinergyT2-core.c
46756@@ -50,29 +50,73 @@ static struct dvb_usb_device_properties cinergyt2_properties;
46757
46758 static int cinergyt2_streaming_ctrl(struct dvb_usb_adapter *adap, int enable)
46759 {
46760- char buf[] = { CINERGYT2_EP1_CONTROL_STREAM_TRANSFER, enable ? 1 : 0 };
46761- char result[64];
46762- return dvb_usb_generic_rw(adap->dev, buf, sizeof(buf), result,
46763- sizeof(result), 0);
46764+ char *buf;
46765+ char *result;
46766+ int retval;
46767+
46768+ buf = kmalloc(2, GFP_KERNEL);
46769+ if (buf == NULL)
46770+ return -ENOMEM;
46771+ result = kmalloc(64, GFP_KERNEL);
46772+ if (result == NULL) {
46773+ kfree(buf);
46774+ return -ENOMEM;
46775+ }
46776+
46777+ buf[0] = CINERGYT2_EP1_CONTROL_STREAM_TRANSFER;
46778+ buf[1] = enable ? 1 : 0;
46779+
46780+ retval = dvb_usb_generic_rw(adap->dev, buf, 2, result, 64, 0);
46781+
46782+ kfree(buf);
46783+ kfree(result);
46784+ return retval;
46785 }
46786
46787 static int cinergyt2_power_ctrl(struct dvb_usb_device *d, int enable)
46788 {
46789- char buf[] = { CINERGYT2_EP1_SLEEP_MODE, enable ? 0 : 1 };
46790- char state[3];
46791- return dvb_usb_generic_rw(d, buf, sizeof(buf), state, sizeof(state), 0);
46792+ char *buf;
46793+ char *state;
46794+ int retval;
46795+
46796+ buf = kmalloc(2, GFP_KERNEL);
46797+ if (buf == NULL)
46798+ return -ENOMEM;
46799+ state = kmalloc(3, GFP_KERNEL);
46800+ if (state == NULL) {
46801+ kfree(buf);
46802+ return -ENOMEM;
46803+ }
46804+
46805+ buf[0] = CINERGYT2_EP1_SLEEP_MODE;
46806+ buf[1] = enable ? 1 : 0;
46807+
46808+ retval = dvb_usb_generic_rw(d, buf, 2, state, 3, 0);
46809+
46810+ kfree(buf);
46811+ kfree(state);
46812+ return retval;
46813 }
46814
46815 static int cinergyt2_frontend_attach(struct dvb_usb_adapter *adap)
46816 {
46817- char query[] = { CINERGYT2_EP1_GET_FIRMWARE_VERSION };
46818- char state[3];
46819+ char *query;
46820+ char *state;
46821 int ret;
46822+ query = kmalloc(1, GFP_KERNEL);
46823+ if (query == NULL)
46824+ return -ENOMEM;
46825+ state = kmalloc(3, GFP_KERNEL);
46826+ if (state == NULL) {
46827+ kfree(query);
46828+ return -ENOMEM;
46829+ }
46830+
46831+ query[0] = CINERGYT2_EP1_GET_FIRMWARE_VERSION;
46832
46833 adap->fe_adap[0].fe = cinergyt2_fe_attach(adap->dev);
46834
46835- ret = dvb_usb_generic_rw(adap->dev, query, sizeof(query), state,
46836- sizeof(state), 0);
46837+ ret = dvb_usb_generic_rw(adap->dev, query, 1, state, 3, 0);
46838 if (ret < 0) {
46839 deb_rc("cinergyt2_power_ctrl() Failed to retrieve sleep "
46840 "state info\n");
46841@@ -80,7 +124,8 @@ static int cinergyt2_frontend_attach(struct dvb_usb_adapter *adap)
46842
46843 /* Copy this pointer as we are gonna need it in the release phase */
46844 cinergyt2_usb_device = adap->dev;
46845-
46846+ kfree(query);
46847+ kfree(state);
46848 return 0;
46849 }
46850
46851@@ -141,12 +186,23 @@ static int repeatable_keys[] = {
46852 static int cinergyt2_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
46853 {
46854 struct cinergyt2_state *st = d->priv;
46855- u8 key[5] = {0, 0, 0, 0, 0}, cmd = CINERGYT2_EP1_GET_RC_EVENTS;
46856+ u8 *key, *cmd;
46857 int i;
46858
46859+ cmd = kmalloc(1, GFP_KERNEL);
46860+ if (cmd == NULL)
46861+ return -EINVAL;
46862+ key = kzalloc(5, GFP_KERNEL);
46863+ if (key == NULL) {
46864+ kfree(cmd);
46865+ return -EINVAL;
46866+ }
46867+
46868+ cmd[0] = CINERGYT2_EP1_GET_RC_EVENTS;
46869+
46870 *state = REMOTE_NO_KEY_PRESSED;
46871
46872- dvb_usb_generic_rw(d, &cmd, 1, key, sizeof(key), 0);
46873+ dvb_usb_generic_rw(d, cmd, 1, key, 5, 0);
46874 if (key[4] == 0xff) {
46875 /* key repeat */
46876 st->rc_counter++;
46877@@ -157,12 +213,12 @@ static int cinergyt2_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
46878 *event = d->last_event;
46879 deb_rc("repeat key, event %x\n",
46880 *event);
46881- return 0;
46882+ goto out;
46883 }
46884 }
46885 deb_rc("repeated key (non repeatable)\n");
46886 }
46887- return 0;
46888+ goto out;
46889 }
46890
46891 /* hack to pass checksum on the custom field */
46892@@ -174,6 +230,9 @@ static int cinergyt2_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
46893
46894 deb_rc("key: %*ph\n", 5, key);
46895 }
46896+out:
46897+ kfree(cmd);
46898+ kfree(key);
46899 return 0;
46900 }
46901
46902diff --git a/drivers/media/usb/dvb-usb/cinergyT2-fe.c b/drivers/media/usb/dvb-usb/cinergyT2-fe.c
46903index c890fe4..f9b2ae6 100644
46904--- a/drivers/media/usb/dvb-usb/cinergyT2-fe.c
46905+++ b/drivers/media/usb/dvb-usb/cinergyT2-fe.c
46906@@ -145,103 +145,176 @@ static int cinergyt2_fe_read_status(struct dvb_frontend *fe,
46907 fe_status_t *status)
46908 {
46909 struct cinergyt2_fe_state *state = fe->demodulator_priv;
46910- struct dvbt_get_status_msg result;
46911- u8 cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS };
46912+ struct dvbt_get_status_msg *result;
46913+ u8 *cmd;
46914 int ret;
46915
46916- ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (u8 *)&result,
46917- sizeof(result), 0);
46918+ cmd = kmalloc(1, GFP_KERNEL);
46919+ if (cmd == NULL)
46920+ return -ENOMEM;
46921+ result = kmalloc(sizeof(*result), GFP_KERNEL);
46922+ if (result == NULL) {
46923+ kfree(cmd);
46924+ return -ENOMEM;
46925+ }
46926+
46927+ cmd[0] = CINERGYT2_EP1_GET_TUNER_STATUS;
46928+
46929+ ret = dvb_usb_generic_rw(state->d, cmd, 1, (u8 *)result,
46930+ sizeof(*result), 0);
46931 if (ret < 0)
46932- return ret;
46933+ goto out;
46934
46935 *status = 0;
46936
46937- if (0xffff - le16_to_cpu(result.gain) > 30)
46938+ if (0xffff - le16_to_cpu(result->gain) > 30)
46939 *status |= FE_HAS_SIGNAL;
46940- if (result.lock_bits & (1 << 6))
46941+ if (result->lock_bits & (1 << 6))
46942 *status |= FE_HAS_LOCK;
46943- if (result.lock_bits & (1 << 5))
46944+ if (result->lock_bits & (1 << 5))
46945 *status |= FE_HAS_SYNC;
46946- if (result.lock_bits & (1 << 4))
46947+ if (result->lock_bits & (1 << 4))
46948 *status |= FE_HAS_CARRIER;
46949- if (result.lock_bits & (1 << 1))
46950+ if (result->lock_bits & (1 << 1))
46951 *status |= FE_HAS_VITERBI;
46952
46953 if ((*status & (FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC)) !=
46954 (FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC))
46955 *status &= ~FE_HAS_LOCK;
46956
46957- return 0;
46958+out:
46959+ kfree(cmd);
46960+ kfree(result);
46961+ return ret;
46962 }
46963
46964 static int cinergyt2_fe_read_ber(struct dvb_frontend *fe, u32 *ber)
46965 {
46966 struct cinergyt2_fe_state *state = fe->demodulator_priv;
46967- struct dvbt_get_status_msg status;
46968- char cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS };
46969+ struct dvbt_get_status_msg *status;
46970+ char *cmd;
46971 int ret;
46972
46973- ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (char *)&status,
46974- sizeof(status), 0);
46975+ cmd = kmalloc(1, GFP_KERNEL);
46976+ if (cmd == NULL)
46977+ return -ENOMEM;
46978+ status = kmalloc(sizeof(*status), GFP_KERNEL);
46979+ if (status == NULL) {
46980+ kfree(cmd);
46981+ return -ENOMEM;
46982+ }
46983+
46984+ cmd[0] = CINERGYT2_EP1_GET_TUNER_STATUS;
46985+
46986+ ret = dvb_usb_generic_rw(state->d, cmd, 1, (char *)status,
46987+ sizeof(*status), 0);
46988 if (ret < 0)
46989- return ret;
46990+ goto out;
46991
46992- *ber = le32_to_cpu(status.viterbi_error_rate);
46993+ *ber = le32_to_cpu(status->viterbi_error_rate);
46994+out:
46995+ kfree(cmd);
46996+ kfree(status);
46997 return 0;
46998 }
46999
47000 static int cinergyt2_fe_read_unc_blocks(struct dvb_frontend *fe, u32 *unc)
47001 {
47002 struct cinergyt2_fe_state *state = fe->demodulator_priv;
47003- struct dvbt_get_status_msg status;
47004- u8 cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS };
47005+ struct dvbt_get_status_msg *status;
47006+ u8 *cmd;
47007 int ret;
47008
47009- ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (u8 *)&status,
47010- sizeof(status), 0);
47011+ cmd = kmalloc(1, GFP_KERNEL);
47012+ if (cmd == NULL)
47013+ return -ENOMEM;
47014+ status = kmalloc(sizeof(*status), GFP_KERNEL);
47015+ if (status == NULL) {
47016+ kfree(cmd);
47017+ return -ENOMEM;
47018+ }
47019+
47020+ cmd[0] = CINERGYT2_EP1_GET_TUNER_STATUS;
47021+
47022+ ret = dvb_usb_generic_rw(state->d, cmd, 1, (u8 *)status,
47023+ sizeof(*status), 0);
47024 if (ret < 0) {
47025 err("cinergyt2_fe_read_unc_blocks() Failed! (Error=%d)\n",
47026 ret);
47027- return ret;
47028+ goto out;
47029 }
47030- *unc = le32_to_cpu(status.uncorrected_block_count);
47031- return 0;
47032+ *unc = le32_to_cpu(status->uncorrected_block_count);
47033+
47034+out:
47035+ kfree(cmd);
47036+ kfree(status);
47037+ return ret;
47038 }
47039
47040 static int cinergyt2_fe_read_signal_strength(struct dvb_frontend *fe,
47041 u16 *strength)
47042 {
47043 struct cinergyt2_fe_state *state = fe->demodulator_priv;
47044- struct dvbt_get_status_msg status;
47045- char cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS };
47046+ struct dvbt_get_status_msg *status;
47047+ char *cmd;
47048 int ret;
47049
47050- ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (char *)&status,
47051- sizeof(status), 0);
47052+ cmd = kmalloc(1, GFP_KERNEL);
47053+ if (cmd == NULL)
47054+ return -ENOMEM;
47055+ status = kmalloc(sizeof(*status), GFP_KERNEL);
47056+ if (status == NULL) {
47057+ kfree(cmd);
47058+ return -ENOMEM;
47059+ }
47060+
47061+ cmd[0] = CINERGYT2_EP1_GET_TUNER_STATUS;
47062+
47063+ ret = dvb_usb_generic_rw(state->d, cmd, 1, (char *)status,
47064+ sizeof(*status), 0);
47065 if (ret < 0) {
47066 err("cinergyt2_fe_read_signal_strength() Failed!"
47067 " (Error=%d)\n", ret);
47068- return ret;
47069+ goto out;
47070 }
47071- *strength = (0xffff - le16_to_cpu(status.gain));
47072+ *strength = (0xffff - le16_to_cpu(status->gain));
47073+
47074+out:
47075+ kfree(cmd);
47076+ kfree(status);
47077 return 0;
47078 }
47079
47080 static int cinergyt2_fe_read_snr(struct dvb_frontend *fe, u16 *snr)
47081 {
47082 struct cinergyt2_fe_state *state = fe->demodulator_priv;
47083- struct dvbt_get_status_msg status;
47084- char cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS };
47085+ struct dvbt_get_status_msg *status;
47086+ char *cmd;
47087 int ret;
47088
47089- ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (char *)&status,
47090- sizeof(status), 0);
47091+ cmd = kmalloc(1, GFP_KERNEL);
47092+ if (cmd == NULL)
47093+ return -ENOMEM;
47094+ status = kmalloc(sizeof(*status), GFP_KERNEL);
47095+ if (status == NULL) {
47096+ kfree(cmd);
47097+ return -ENOMEM;
47098+ }
47099+
47100+ cmd[0] = CINERGYT2_EP1_GET_TUNER_STATUS;
47101+
47102+ ret = dvb_usb_generic_rw(state->d, cmd, 1, (char *)status,
47103+ sizeof(*status), 0);
47104 if (ret < 0) {
47105 err("cinergyt2_fe_read_snr() Failed! (Error=%d)\n", ret);
47106- return ret;
47107+ goto out;
47108 }
47109- *snr = (status.snr << 8) | status.snr;
47110- return 0;
47111+ *snr = (status->snr << 8) | status->snr;
47112+
47113+out:
47114+ kfree(cmd);
47115+ kfree(status);
47116+ return ret;
47117 }
47118
47119 static int cinergyt2_fe_init(struct dvb_frontend *fe)
47120@@ -266,35 +339,46 @@ static int cinergyt2_fe_set_frontend(struct dvb_frontend *fe)
47121 {
47122 struct dtv_frontend_properties *fep = &fe->dtv_property_cache;
47123 struct cinergyt2_fe_state *state = fe->demodulator_priv;
47124- struct dvbt_set_parameters_msg param;
47125- char result[2];
47126+ struct dvbt_set_parameters_msg *param;
47127+ char *result;
47128 int err;
47129
47130- param.cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS;
47131- param.tps = cpu_to_le16(compute_tps(fep));
47132- param.freq = cpu_to_le32(fep->frequency / 1000);
47133- param.flags = 0;
47134+ result = kmalloc(2, GFP_KERNEL);
47135+ if (result == NULL)
47136+ return -ENOMEM;
47137+ param = kmalloc(sizeof(*param), GFP_KERNEL);
47138+ if (param == NULL) {
47139+ kfree(result);
47140+ return -ENOMEM;
47141+ }
47142+
47143+ param->cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS;
47144+ param->tps = cpu_to_le16(compute_tps(fep));
47145+ param->freq = cpu_to_le32(fep->frequency / 1000);
47146+ param->flags = 0;
47147
47148 switch (fep->bandwidth_hz) {
47149 default:
47150 case 8000000:
47151- param.bandwidth = 8;
47152+ param->bandwidth = 8;
47153 break;
47154 case 7000000:
47155- param.bandwidth = 7;
47156+ param->bandwidth = 7;
47157 break;
47158 case 6000000:
47159- param.bandwidth = 6;
47160+ param->bandwidth = 6;
47161 break;
47162 }
47163
47164 err = dvb_usb_generic_rw(state->d,
47165- (char *)&param, sizeof(param),
47166- result, sizeof(result), 0);
47167+ (char *)param, sizeof(*param),
47168+ result, 2, 0);
47169 if (err < 0)
47170 err("cinergyt2_fe_set_frontend() Failed! err=%d\n", err);
47171
47172- return (err < 0) ? err : 0;
47173+ kfree(result);
47174+ kfree(param);
47175+ return err;
47176 }
47177
47178 static void cinergyt2_fe_release(struct dvb_frontend *fe)
47179diff --git a/drivers/media/usb/dvb-usb/dvb-usb-firmware.c b/drivers/media/usb/dvb-usb/dvb-usb-firmware.c
47180index 733a7ff..f8b52e3 100644
47181--- a/drivers/media/usb/dvb-usb/dvb-usb-firmware.c
47182+++ b/drivers/media/usb/dvb-usb/dvb-usb-firmware.c
47183@@ -35,42 +35,57 @@ static int usb_cypress_writemem(struct usb_device *udev,u16 addr,u8 *data, u8 le
47184
47185 int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type)
47186 {
47187- struct hexline hx;
47188- u8 reset;
47189+ struct hexline *hx;
47190+ u8 *reset;
47191 int ret,pos=0;
47192
47193+ reset = kmalloc(1, GFP_KERNEL);
47194+ if (reset == NULL)
47195+ return -ENOMEM;
47196+
47197+ hx = kmalloc(sizeof(struct hexline), GFP_KERNEL);
47198+ if (hx == NULL) {
47199+ kfree(reset);
47200+ return -ENOMEM;
47201+ }
47202+
47203 /* stop the CPU */
47204- reset = 1;
47205- if ((ret = usb_cypress_writemem(udev,cypress[type].cpu_cs_register,&reset,1)) != 1)
47206+ reset[0] = 1;
47207+ if ((ret = usb_cypress_writemem(udev,cypress[type].cpu_cs_register,reset,1)) != 1)
47208 err("could not stop the USB controller CPU.");
47209
47210- while ((ret = dvb_usb_get_hexline(fw,&hx,&pos)) > 0) {
47211- deb_fw("writing to address 0x%04x (buffer: 0x%02x %02x)\n",hx.addr,hx.len,hx.chk);
47212- ret = usb_cypress_writemem(udev,hx.addr,hx.data,hx.len);
47213+ while ((ret = dvb_usb_get_hexline(fw,hx,&pos)) > 0) {
47214+ deb_fw("writing to address 0x%04x (buffer: 0x%02x %02x)\n",hx->addr,hx->len,hx->chk);
47215+ ret = usb_cypress_writemem(udev,hx->addr,hx->data,hx->len);
47216
47217- if (ret != hx.len) {
47218+ if (ret != hx->len) {
47219 err("error while transferring firmware "
47220 "(transferred size: %d, block size: %d)",
47221- ret,hx.len);
47222+ ret,hx->len);
47223 ret = -EINVAL;
47224 break;
47225 }
47226 }
47227 if (ret < 0) {
47228 err("firmware download failed at %d with %d",pos,ret);
47229+ kfree(reset);
47230+ kfree(hx);
47231 return ret;
47232 }
47233
47234 if (ret == 0) {
47235 /* restart the CPU */
47236- reset = 0;
47237- if (ret || usb_cypress_writemem(udev,cypress[type].cpu_cs_register,&reset,1) != 1) {
47238+ reset[0] = 0;
47239+ if (ret || usb_cypress_writemem(udev,cypress[type].cpu_cs_register,reset,1) != 1) {
47240 err("could not restart the USB controller CPU.");
47241 ret = -EINVAL;
47242 }
47243 } else
47244 ret = -EIO;
47245
47246+ kfree(reset);
47247+ kfree(hx);
47248+
47249 return ret;
47250 }
47251 EXPORT_SYMBOL(usb_cypress_load_firmware);
47252diff --git a/drivers/media/usb/dvb-usb/technisat-usb2.c b/drivers/media/usb/dvb-usb/technisat-usb2.c
47253index 5801ae7..83f71fa 100644
47254--- a/drivers/media/usb/dvb-usb/technisat-usb2.c
47255+++ b/drivers/media/usb/dvb-usb/technisat-usb2.c
47256@@ -87,8 +87,11 @@ struct technisat_usb2_state {
47257 static int technisat_usb2_i2c_access(struct usb_device *udev,
47258 u8 device_addr, u8 *tx, u8 txlen, u8 *rx, u8 rxlen)
47259 {
47260- u8 b[64];
47261- int ret, actual_length;
47262+ u8 *b = kmalloc(64, GFP_KERNEL);
47263+ int ret, actual_length, error = 0;
47264+
47265+ if (b == NULL)
47266+ return -ENOMEM;
47267
47268 deb_i2c("i2c-access: %02x, tx: ", device_addr);
47269 debug_dump(tx, txlen, deb_i2c);
47270@@ -121,7 +124,8 @@ static int technisat_usb2_i2c_access(struct usb_device *udev,
47271
47272 if (ret < 0) {
47273 err("i2c-error: out failed %02x = %d", device_addr, ret);
47274- return -ENODEV;
47275+ error = -ENODEV;
47276+ goto out;
47277 }
47278
47279 ret = usb_bulk_msg(udev,
47280@@ -129,7 +133,8 @@ static int technisat_usb2_i2c_access(struct usb_device *udev,
47281 b, 64, &actual_length, 1000);
47282 if (ret < 0) {
47283 err("i2c-error: in failed %02x = %d", device_addr, ret);
47284- return -ENODEV;
47285+ error = -ENODEV;
47286+ goto out;
47287 }
47288
47289 if (b[0] != I2C_STATUS_OK) {
47290@@ -137,8 +142,10 @@ static int technisat_usb2_i2c_access(struct usb_device *udev,
47291 /* handle tuner-i2c-nak */
47292 if (!(b[0] == I2C_STATUS_NAK &&
47293 device_addr == 0x60
47294- /* && device_is_technisat_usb2 */))
47295- return -ENODEV;
47296+ /* && device_is_technisat_usb2 */)) {
47297+ error = -ENODEV;
47298+ goto out;
47299+ }
47300 }
47301
47302 deb_i2c("status: %d, ", b[0]);
47303@@ -152,7 +159,9 @@ static int technisat_usb2_i2c_access(struct usb_device *udev,
47304
47305 deb_i2c("\n");
47306
47307- return 0;
47308+out:
47309+ kfree(b);
47310+ return error;
47311 }
47312
47313 static int technisat_usb2_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msg,
47314@@ -224,14 +233,16 @@ static int technisat_usb2_set_led(struct dvb_usb_device *d, int red, enum techni
47315 {
47316 int ret;
47317
47318- u8 led[8] = {
47319- red ? SET_RED_LED_VENDOR_REQUEST : SET_GREEN_LED_VENDOR_REQUEST,
47320- 0
47321- };
47322+ u8 *led = kzalloc(8, GFP_KERNEL);
47323+
47324+ if (led == NULL)
47325+ return -ENOMEM;
47326
47327 if (disable_led_control && state != TECH_LED_OFF)
47328 return 0;
47329
47330+ led[0] = red ? SET_RED_LED_VENDOR_REQUEST : SET_GREEN_LED_VENDOR_REQUEST;
47331+
47332 switch (state) {
47333 case TECH_LED_ON:
47334 led[1] = 0x82;
47335@@ -263,16 +274,22 @@ static int technisat_usb2_set_led(struct dvb_usb_device *d, int red, enum techni
47336 red ? SET_RED_LED_VENDOR_REQUEST : SET_GREEN_LED_VENDOR_REQUEST,
47337 USB_TYPE_VENDOR | USB_DIR_OUT,
47338 0, 0,
47339- led, sizeof(led), 500);
47340+ led, 8, 500);
47341
47342 mutex_unlock(&d->i2c_mutex);
47343+
47344+ kfree(led);
47345+
47346 return ret;
47347 }
47348
47349 static int technisat_usb2_set_led_timer(struct dvb_usb_device *d, u8 red, u8 green)
47350 {
47351 int ret;
47352- u8 b = 0;
47353+ u8 *b = kzalloc(1, GFP_KERNEL);
47354+
47355+ if (b == NULL)
47356+ return -ENOMEM;
47357
47358 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
47359 return -EAGAIN;
47360@@ -281,10 +298,12 @@ static int technisat_usb2_set_led_timer(struct dvb_usb_device *d, u8 red, u8 gre
47361 SET_LED_TIMER_DIVIDER_VENDOR_REQUEST,
47362 USB_TYPE_VENDOR | USB_DIR_OUT,
47363 (red << 8) | green, 0,
47364- &b, 1, 500);
47365+ b, 1, 500);
47366
47367 mutex_unlock(&d->i2c_mutex);
47368
47369+ kfree(b);
47370+
47371 return ret;
47372 }
47373
47374@@ -328,7 +347,7 @@ static int technisat_usb2_identify_state(struct usb_device *udev,
47375 struct dvb_usb_device_description **desc, int *cold)
47376 {
47377 int ret;
47378- u8 version[3];
47379+ u8 *version = kmalloc(3, GFP_KERNEL);
47380
47381 /* first select the interface */
47382 if (usb_set_interface(udev, 0, 1) != 0)
47383@@ -338,11 +357,14 @@ static int technisat_usb2_identify_state(struct usb_device *udev,
47384
47385 *cold = 0; /* by default do not download a firmware - just in case something is wrong */
47386
47387+ if (version == NULL)
47388+ return 0;
47389+
47390 ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
47391 GET_VERSION_INFO_VENDOR_REQUEST,
47392 USB_TYPE_VENDOR | USB_DIR_IN,
47393 0, 0,
47394- version, sizeof(version), 500);
47395+ version, 3, 500);
47396
47397 if (ret < 0)
47398 *cold = 1;
47399@@ -351,6 +373,8 @@ static int technisat_usb2_identify_state(struct usb_device *udev,
47400 *cold = 0;
47401 }
47402
47403+ kfree(version);
47404+
47405 return 0;
47406 }
47407
47408@@ -594,10 +618,15 @@ static int technisat_usb2_frontend_attach(struct dvb_usb_adapter *a)
47409
47410 static int technisat_usb2_get_ir(struct dvb_usb_device *d)
47411 {
47412- u8 buf[62], *b;
47413+ u8 *buf, *b;
47414 int ret;
47415 struct ir_raw_event ev;
47416
47417+ buf = kmalloc(62, GFP_KERNEL);
47418+
47419+ if (buf == NULL)
47420+ return -ENOMEM;
47421+
47422 buf[0] = GET_IR_DATA_VENDOR_REQUEST;
47423 buf[1] = 0x08;
47424 buf[2] = 0x8f;
47425@@ -620,16 +649,20 @@ static int technisat_usb2_get_ir(struct dvb_usb_device *d)
47426 GET_IR_DATA_VENDOR_REQUEST,
47427 USB_TYPE_VENDOR | USB_DIR_IN,
47428 0x8080, 0,
47429- buf, sizeof(buf), 500);
47430+ buf, 62, 500);
47431
47432 unlock:
47433 mutex_unlock(&d->i2c_mutex);
47434
47435- if (ret < 0)
47436+ if (ret < 0) {
47437+ kfree(buf);
47438 return ret;
47439+ }
47440
47441- if (ret == 1)
47442+ if (ret == 1) {
47443+ kfree(buf);
47444 return 0; /* no key pressed */
47445+ }
47446
47447 /* decoding */
47448 b = buf+1;
47449@@ -656,6 +689,8 @@ unlock:
47450
47451 ir_raw_event_handle(d->rc_dev);
47452
47453+ kfree(buf);
47454+
47455 return 1;
47456 }
47457
47458diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
47459index af63543..0436f20 100644
47460--- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
47461+++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
47462@@ -429,7 +429,7 @@ static int get_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user
47463 * by passing a very big num_planes value */
47464 uplane = compat_alloc_user_space(num_planes *
47465 sizeof(struct v4l2_plane));
47466- kp->m.planes = (__force struct v4l2_plane *)uplane;
47467+ kp->m.planes = (__force_kernel struct v4l2_plane *)uplane;
47468
47469 while (--num_planes >= 0) {
47470 ret = get_v4l2_plane32(uplane, uplane32, kp->memory);
47471@@ -500,7 +500,7 @@ static int put_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user
47472 if (num_planes == 0)
47473 return 0;
47474
47475- uplane = (__force struct v4l2_plane __user *)kp->m.planes;
47476+ uplane = (struct v4l2_plane __force_user *)kp->m.planes;
47477 if (get_user(p, &up->m.planes))
47478 return -EFAULT;
47479 uplane32 = compat_ptr(p);
47480@@ -564,7 +564,7 @@ static int get_v4l2_framebuffer32(struct v4l2_framebuffer *kp, struct v4l2_frame
47481 get_user(kp->flags, &up->flags) ||
47482 copy_from_user(&kp->fmt, &up->fmt, sizeof(up->fmt)))
47483 return -EFAULT;
47484- kp->base = (__force void *)compat_ptr(tmp);
47485+ kp->base = (__force_kernel void *)compat_ptr(tmp);
47486 return 0;
47487 }
47488
47489@@ -669,7 +669,7 @@ static int get_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct v4l2_ext
47490 n * sizeof(struct v4l2_ext_control32)))
47491 return -EFAULT;
47492 kcontrols = compat_alloc_user_space(n * sizeof(struct v4l2_ext_control));
47493- kp->controls = (__force struct v4l2_ext_control *)kcontrols;
47494+ kp->controls = (__force_kernel struct v4l2_ext_control *)kcontrols;
47495 while (--n >= 0) {
47496 u32 id;
47497
47498@@ -696,7 +696,7 @@ static int put_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct v4l2_ext
47499 {
47500 struct v4l2_ext_control32 __user *ucontrols;
47501 struct v4l2_ext_control __user *kcontrols =
47502- (__force struct v4l2_ext_control __user *)kp->controls;
47503+ (struct v4l2_ext_control __force_user *)kp->controls;
47504 int n = kp->count;
47505 compat_caddr_t p;
47506
47507@@ -780,7 +780,7 @@ static int get_v4l2_edid32(struct v4l2_edid *kp, struct v4l2_edid32 __user *up)
47508 get_user(tmp, &up->edid) ||
47509 copy_from_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
47510 return -EFAULT;
47511- kp->edid = (__force u8 *)compat_ptr(tmp);
47512+ kp->edid = (__force_kernel u8 *)compat_ptr(tmp);
47513 return 0;
47514 }
47515
47516diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
47517index 5b0a30b..1974b38 100644
47518--- a/drivers/media/v4l2-core/v4l2-device.c
47519+++ b/drivers/media/v4l2-core/v4l2-device.c
47520@@ -74,9 +74,9 @@ int v4l2_device_put(struct v4l2_device *v4l2_dev)
47521 EXPORT_SYMBOL_GPL(v4l2_device_put);
47522
47523 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
47524- atomic_t *instance)
47525+ atomic_unchecked_t *instance)
47526 {
47527- int num = atomic_inc_return(instance) - 1;
47528+ int num = atomic_inc_return_unchecked(instance) - 1;
47529 int len = strlen(basename);
47530
47531 if (basename[len - 1] >= '0' && basename[len - 1] <= '9')
47532diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
47533index aa407cb..ee847d4 100644
47534--- a/drivers/media/v4l2-core/v4l2-ioctl.c
47535+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
47536@@ -2151,7 +2151,8 @@ struct v4l2_ioctl_info {
47537 struct file *file, void *fh, void *p);
47538 } u;
47539 void (*debug)(const void *arg, bool write_only);
47540-};
47541+} __do_const;
47542+typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
47543
47544 /* This control needs a priority check */
47545 #define INFO_FL_PRIO (1 << 0)
47546@@ -2335,7 +2336,7 @@ static long __video_do_ioctl(struct file *file,
47547 struct video_device *vfd = video_devdata(file);
47548 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
47549 bool write_only = false;
47550- struct v4l2_ioctl_info default_info;
47551+ v4l2_ioctl_info_no_const default_info;
47552 const struct v4l2_ioctl_info *info;
47553 void *fh = file->private_data;
47554 struct v4l2_fh *vfh = NULL;
47555@@ -2426,7 +2427,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
47556 ret = -EINVAL;
47557 break;
47558 }
47559- *user_ptr = (void __user *)buf->m.planes;
47560+ *user_ptr = (void __force_user *)buf->m.planes;
47561 *kernel_ptr = (void **)&buf->m.planes;
47562 *array_size = sizeof(struct v4l2_plane) * buf->length;
47563 ret = 1;
47564@@ -2443,7 +2444,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
47565 ret = -EINVAL;
47566 break;
47567 }
47568- *user_ptr = (void __user *)edid->edid;
47569+ *user_ptr = (void __force_user *)edid->edid;
47570 *kernel_ptr = (void **)&edid->edid;
47571 *array_size = edid->blocks * 128;
47572 ret = 1;
47573@@ -2461,7 +2462,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
47574 ret = -EINVAL;
47575 break;
47576 }
47577- *user_ptr = (void __user *)ctrls->controls;
47578+ *user_ptr = (void __force_user *)ctrls->controls;
47579 *kernel_ptr = (void **)&ctrls->controls;
47580 *array_size = sizeof(struct v4l2_ext_control)
47581 * ctrls->count;
47582@@ -2562,7 +2563,7 @@ video_usercopy(struct file *file, unsigned int cmd, unsigned long arg,
47583 }
47584
47585 if (has_array_args) {
47586- *kernel_ptr = (void __force *)user_ptr;
47587+ *kernel_ptr = (void __force_kernel *)user_ptr;
47588 if (copy_to_user(user_ptr, mbuf, array_size))
47589 err = -EFAULT;
47590 goto out_array_args;
47591diff --git a/drivers/memory/omap-gpmc.c b/drivers/memory/omap-gpmc.c
47592index c94ea0d..b8a9f88 100644
47593--- a/drivers/memory/omap-gpmc.c
47594+++ b/drivers/memory/omap-gpmc.c
47595@@ -232,7 +232,6 @@ struct omap3_gpmc_regs {
47596 };
47597
47598 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
47599-static struct irq_chip gpmc_irq_chip;
47600 static int gpmc_irq_start;
47601
47602 static struct resource gpmc_mem_root;
47603@@ -1146,6 +1145,17 @@ static void gpmc_irq_noop(struct irq_data *data) { }
47604
47605 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
47606
47607+static struct irq_chip gpmc_irq_chip = {
47608+ .name = "gpmc",
47609+ .irq_startup = gpmc_irq_noop_ret,
47610+ .irq_enable = gpmc_irq_enable,
47611+ .irq_disable = gpmc_irq_disable,
47612+ .irq_shutdown = gpmc_irq_noop,
47613+ .irq_ack = gpmc_irq_noop,
47614+ .irq_mask = gpmc_irq_noop,
47615+ .irq_unmask = gpmc_irq_noop,
47616+};
47617+
47618 static int gpmc_setup_irq(void)
47619 {
47620 int i;
47621@@ -1160,15 +1170,6 @@ static int gpmc_setup_irq(void)
47622 return gpmc_irq_start;
47623 }
47624
47625- gpmc_irq_chip.name = "gpmc";
47626- gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
47627- gpmc_irq_chip.irq_enable = gpmc_irq_enable;
47628- gpmc_irq_chip.irq_disable = gpmc_irq_disable;
47629- gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
47630- gpmc_irq_chip.irq_ack = gpmc_irq_noop;
47631- gpmc_irq_chip.irq_mask = gpmc_irq_noop;
47632- gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
47633-
47634 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
47635 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
47636
47637diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
47638index 187f836..679544b 100644
47639--- a/drivers/message/fusion/mptbase.c
47640+++ b/drivers/message/fusion/mptbase.c
47641@@ -6746,8 +6746,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
47642 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
47643 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
47644
47645+#ifdef CONFIG_GRKERNSEC_HIDESYM
47646+ seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
47647+#else
47648 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
47649 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
47650+#endif
47651+
47652 /*
47653 * Rounding UP to nearest 4-kB boundary here...
47654 */
47655@@ -6760,7 +6765,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
47656 ioc->facts.GlobalCredits);
47657
47658 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
47659+#ifdef CONFIG_GRKERNSEC_HIDESYM
47660+ NULL, NULL);
47661+#else
47662 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
47663+#endif
47664 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
47665 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
47666 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
47667diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
47668index 5bdaae1..eced16f 100644
47669--- a/drivers/message/fusion/mptsas.c
47670+++ b/drivers/message/fusion/mptsas.c
47671@@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
47672 return 0;
47673 }
47674
47675+static inline void
47676+mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
47677+{
47678+ if (phy_info->port_details) {
47679+ phy_info->port_details->rphy = rphy;
47680+ dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
47681+ ioc->name, rphy));
47682+ }
47683+
47684+ if (rphy) {
47685+ dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
47686+ &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
47687+ dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
47688+ ioc->name, rphy, rphy->dev.release));
47689+ }
47690+}
47691+
47692 /* no mutex */
47693 static void
47694 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
47695@@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
47696 return NULL;
47697 }
47698
47699-static inline void
47700-mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
47701-{
47702- if (phy_info->port_details) {
47703- phy_info->port_details->rphy = rphy;
47704- dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
47705- ioc->name, rphy));
47706- }
47707-
47708- if (rphy) {
47709- dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
47710- &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
47711- dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
47712- ioc->name, rphy, rphy->dev.release));
47713- }
47714-}
47715-
47716 static inline struct sas_port *
47717 mptsas_get_port(struct mptsas_phyinfo *phy_info)
47718 {
47719diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c
47720index cdd6f3d..1907a98 100644
47721--- a/drivers/mfd/ab8500-debugfs.c
47722+++ b/drivers/mfd/ab8500-debugfs.c
47723@@ -100,7 +100,7 @@ static int irq_last;
47724 static u32 *irq_count;
47725 static int num_irqs;
47726
47727-static struct device_attribute **dev_attr;
47728+static device_attribute_no_const **dev_attr;
47729 static char **event_name;
47730
47731 static u8 avg_sample = SAMPLE_16;
47732diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
47733index 8057849..0550fdf 100644
47734--- a/drivers/mfd/kempld-core.c
47735+++ b/drivers/mfd/kempld-core.c
47736@@ -499,7 +499,7 @@ static struct platform_driver kempld_driver = {
47737 .remove = kempld_remove,
47738 };
47739
47740-static struct dmi_system_id kempld_dmi_table[] __initdata = {
47741+static const struct dmi_system_id kempld_dmi_table[] __initconst = {
47742 {
47743 .ident = "BHL6",
47744 .matches = {
47745diff --git a/drivers/mfd/max8925-i2c.c b/drivers/mfd/max8925-i2c.c
47746index c880c89..45a7c68 100644
47747--- a/drivers/mfd/max8925-i2c.c
47748+++ b/drivers/mfd/max8925-i2c.c
47749@@ -152,7 +152,7 @@ static int max8925_probe(struct i2c_client *client,
47750 const struct i2c_device_id *id)
47751 {
47752 struct max8925_platform_data *pdata = dev_get_platdata(&client->dev);
47753- static struct max8925_chip *chip;
47754+ struct max8925_chip *chip;
47755 struct device_node *node = client->dev.of_node;
47756
47757 if (node && !pdata) {
47758diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c
47759index 7612d89..70549c2 100644
47760--- a/drivers/mfd/tps65910.c
47761+++ b/drivers/mfd/tps65910.c
47762@@ -230,7 +230,7 @@ static int tps65910_irq_init(struct tps65910 *tps65910, int irq,
47763 struct tps65910_platform_data *pdata)
47764 {
47765 int ret = 0;
47766- static struct regmap_irq_chip *tps6591x_irqs_chip;
47767+ struct regmap_irq_chip *tps6591x_irqs_chip;
47768
47769 if (!irq) {
47770 dev_warn(tps65910->dev, "No interrupt support, no core IRQ\n");
47771diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
47772index 1b772ef..01e77d33 100644
47773--- a/drivers/mfd/twl4030-irq.c
47774+++ b/drivers/mfd/twl4030-irq.c
47775@@ -34,6 +34,7 @@
47776 #include <linux/of.h>
47777 #include <linux/irqdomain.h>
47778 #include <linux/i2c/twl.h>
47779+#include <asm/pgtable.h>
47780
47781 #include "twl-core.h"
47782
47783@@ -729,10 +730,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
47784 * Install an irq handler for each of the SIH modules;
47785 * clone dummy irq_chip since PIH can't *do* anything
47786 */
47787- twl4030_irq_chip = dummy_irq_chip;
47788- twl4030_irq_chip.name = "twl4030";
47789+ pax_open_kernel();
47790+ memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
47791+ *(const char **)&twl4030_irq_chip.name = "twl4030";
47792
47793- twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
47794+ *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
47795+ pax_close_kernel();
47796
47797 for (i = irq_base; i < irq_end; i++) {
47798 irq_set_chip_and_handler(i, &twl4030_irq_chip,
47799diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
47800index 464419b..64bae8d 100644
47801--- a/drivers/misc/c2port/core.c
47802+++ b/drivers/misc/c2port/core.c
47803@@ -922,7 +922,9 @@ struct c2port_device *c2port_device_register(char *name,
47804 goto error_idr_alloc;
47805 c2dev->id = ret;
47806
47807- bin_attr_flash_data.size = ops->blocks_num * ops->block_size;
47808+ pax_open_kernel();
47809+ *(size_t *)&bin_attr_flash_data.size = ops->blocks_num * ops->block_size;
47810+ pax_close_kernel();
47811
47812 c2dev->dev = device_create(c2port_class, NULL, 0, c2dev,
47813 "c2port%d", c2dev->id);
47814diff --git a/drivers/misc/eeprom/sunxi_sid.c b/drivers/misc/eeprom/sunxi_sid.c
47815index 8385177..2f54635 100644
47816--- a/drivers/misc/eeprom/sunxi_sid.c
47817+++ b/drivers/misc/eeprom/sunxi_sid.c
47818@@ -126,7 +126,9 @@ static int sunxi_sid_probe(struct platform_device *pdev)
47819
47820 platform_set_drvdata(pdev, sid_data);
47821
47822- sid_bin_attr.size = sid_data->keysize;
47823+ pax_open_kernel();
47824+ *(size_t *)&sid_bin_attr.size = sid_data->keysize;
47825+ pax_close_kernel();
47826 if (device_create_bin_file(&pdev->dev, &sid_bin_attr))
47827 return -ENODEV;
47828
47829diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
47830index 36f5d52..32311c3 100644
47831--- a/drivers/misc/kgdbts.c
47832+++ b/drivers/misc/kgdbts.c
47833@@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
47834 char before[BREAK_INSTR_SIZE];
47835 char after[BREAK_INSTR_SIZE];
47836
47837- probe_kernel_read(before, (char *)kgdbts_break_test,
47838+ probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
47839 BREAK_INSTR_SIZE);
47840 init_simple_test();
47841 ts.tst = plant_and_detach_test;
47842@@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
47843 /* Activate test with initial breakpoint */
47844 if (!is_early)
47845 kgdb_breakpoint();
47846- probe_kernel_read(after, (char *)kgdbts_break_test,
47847+ probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
47848 BREAK_INSTR_SIZE);
47849 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
47850 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
47851diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
47852index 4739689..8a52950 100644
47853--- a/drivers/misc/lis3lv02d/lis3lv02d.c
47854+++ b/drivers/misc/lis3lv02d/lis3lv02d.c
47855@@ -497,7 +497,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
47856 * the lid is closed. This leads to interrupts as soon as a little move
47857 * is done.
47858 */
47859- atomic_inc(&lis3->count);
47860+ atomic_inc_unchecked(&lis3->count);
47861
47862 wake_up_interruptible(&lis3->misc_wait);
47863 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
47864@@ -583,7 +583,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
47865 if (lis3->pm_dev)
47866 pm_runtime_get_sync(lis3->pm_dev);
47867
47868- atomic_set(&lis3->count, 0);
47869+ atomic_set_unchecked(&lis3->count, 0);
47870 return 0;
47871 }
47872
47873@@ -615,7 +615,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
47874 add_wait_queue(&lis3->misc_wait, &wait);
47875 while (true) {
47876 set_current_state(TASK_INTERRUPTIBLE);
47877- data = atomic_xchg(&lis3->count, 0);
47878+ data = atomic_xchg_unchecked(&lis3->count, 0);
47879 if (data)
47880 break;
47881
47882@@ -656,7 +656,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
47883 struct lis3lv02d, miscdev);
47884
47885 poll_wait(file, &lis3->misc_wait, wait);
47886- if (atomic_read(&lis3->count))
47887+ if (atomic_read_unchecked(&lis3->count))
47888 return POLLIN | POLLRDNORM;
47889 return 0;
47890 }
47891diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
47892index c439c82..1f20f57 100644
47893--- a/drivers/misc/lis3lv02d/lis3lv02d.h
47894+++ b/drivers/misc/lis3lv02d/lis3lv02d.h
47895@@ -297,7 +297,7 @@ struct lis3lv02d {
47896 struct input_polled_dev *idev; /* input device */
47897 struct platform_device *pdev; /* platform device */
47898 struct regulator_bulk_data regulators[2];
47899- atomic_t count; /* interrupt count after last read */
47900+ atomic_unchecked_t count; /* interrupt count after last read */
47901 union axis_conversion ac; /* hw -> logical axis */
47902 int mapped_btns[3];
47903
47904diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
47905index 3e29681..e40bcd03 100644
47906--- a/drivers/misc/mei/main.c
47907+++ b/drivers/misc/mei/main.c
47908@@ -685,7 +685,7 @@ int mei_register(struct mei_device *dev, struct device *parent)
47909 /* Fill in the data structures */
47910 devno = MKDEV(MAJOR(mei_devt), dev->minor);
47911 cdev_init(&dev->cdev, &mei_fops);
47912- dev->cdev.owner = mei_fops.owner;
47913+ dev->cdev.owner = parent->driver->owner;
47914
47915 /* Add the device */
47916 ret = cdev_add(&dev->cdev, devno, 1);
47917diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
47918index 2f30bad..c4c13d0 100644
47919--- a/drivers/misc/sgi-gru/gruhandles.c
47920+++ b/drivers/misc/sgi-gru/gruhandles.c
47921@@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
47922 unsigned long nsec;
47923
47924 nsec = CLKS2NSEC(clks);
47925- atomic_long_inc(&mcs_op_statistics[op].count);
47926- atomic_long_add(nsec, &mcs_op_statistics[op].total);
47927+ atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
47928+ atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
47929 if (mcs_op_statistics[op].max < nsec)
47930 mcs_op_statistics[op].max = nsec;
47931 }
47932diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
47933index 4f76359..cdfcb2e 100644
47934--- a/drivers/misc/sgi-gru/gruprocfs.c
47935+++ b/drivers/misc/sgi-gru/gruprocfs.c
47936@@ -32,9 +32,9 @@
47937
47938 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
47939
47940-static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
47941+static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
47942 {
47943- unsigned long val = atomic_long_read(v);
47944+ unsigned long val = atomic_long_read_unchecked(v);
47945
47946 seq_printf(s, "%16lu %s\n", val, id);
47947 }
47948@@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
47949
47950 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
47951 for (op = 0; op < mcsop_last; op++) {
47952- count = atomic_long_read(&mcs_op_statistics[op].count);
47953- total = atomic_long_read(&mcs_op_statistics[op].total);
47954+ count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
47955+ total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
47956 max = mcs_op_statistics[op].max;
47957 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
47958 count ? total / count : 0, max);
47959diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
47960index 5c3ce24..4915ccb 100644
47961--- a/drivers/misc/sgi-gru/grutables.h
47962+++ b/drivers/misc/sgi-gru/grutables.h
47963@@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
47964 * GRU statistics.
47965 */
47966 struct gru_stats_s {
47967- atomic_long_t vdata_alloc;
47968- atomic_long_t vdata_free;
47969- atomic_long_t gts_alloc;
47970- atomic_long_t gts_free;
47971- atomic_long_t gms_alloc;
47972- atomic_long_t gms_free;
47973- atomic_long_t gts_double_allocate;
47974- atomic_long_t assign_context;
47975- atomic_long_t assign_context_failed;
47976- atomic_long_t free_context;
47977- atomic_long_t load_user_context;
47978- atomic_long_t load_kernel_context;
47979- atomic_long_t lock_kernel_context;
47980- atomic_long_t unlock_kernel_context;
47981- atomic_long_t steal_user_context;
47982- atomic_long_t steal_kernel_context;
47983- atomic_long_t steal_context_failed;
47984- atomic_long_t nopfn;
47985- atomic_long_t asid_new;
47986- atomic_long_t asid_next;
47987- atomic_long_t asid_wrap;
47988- atomic_long_t asid_reuse;
47989- atomic_long_t intr;
47990- atomic_long_t intr_cbr;
47991- atomic_long_t intr_tfh;
47992- atomic_long_t intr_spurious;
47993- atomic_long_t intr_mm_lock_failed;
47994- atomic_long_t call_os;
47995- atomic_long_t call_os_wait_queue;
47996- atomic_long_t user_flush_tlb;
47997- atomic_long_t user_unload_context;
47998- atomic_long_t user_exception;
47999- atomic_long_t set_context_option;
48000- atomic_long_t check_context_retarget_intr;
48001- atomic_long_t check_context_unload;
48002- atomic_long_t tlb_dropin;
48003- atomic_long_t tlb_preload_page;
48004- atomic_long_t tlb_dropin_fail_no_asid;
48005- atomic_long_t tlb_dropin_fail_upm;
48006- atomic_long_t tlb_dropin_fail_invalid;
48007- atomic_long_t tlb_dropin_fail_range_active;
48008- atomic_long_t tlb_dropin_fail_idle;
48009- atomic_long_t tlb_dropin_fail_fmm;
48010- atomic_long_t tlb_dropin_fail_no_exception;
48011- atomic_long_t tfh_stale_on_fault;
48012- atomic_long_t mmu_invalidate_range;
48013- atomic_long_t mmu_invalidate_page;
48014- atomic_long_t flush_tlb;
48015- atomic_long_t flush_tlb_gru;
48016- atomic_long_t flush_tlb_gru_tgh;
48017- atomic_long_t flush_tlb_gru_zero_asid;
48018+ atomic_long_unchecked_t vdata_alloc;
48019+ atomic_long_unchecked_t vdata_free;
48020+ atomic_long_unchecked_t gts_alloc;
48021+ atomic_long_unchecked_t gts_free;
48022+ atomic_long_unchecked_t gms_alloc;
48023+ atomic_long_unchecked_t gms_free;
48024+ atomic_long_unchecked_t gts_double_allocate;
48025+ atomic_long_unchecked_t assign_context;
48026+ atomic_long_unchecked_t assign_context_failed;
48027+ atomic_long_unchecked_t free_context;
48028+ atomic_long_unchecked_t load_user_context;
48029+ atomic_long_unchecked_t load_kernel_context;
48030+ atomic_long_unchecked_t lock_kernel_context;
48031+ atomic_long_unchecked_t unlock_kernel_context;
48032+ atomic_long_unchecked_t steal_user_context;
48033+ atomic_long_unchecked_t steal_kernel_context;
48034+ atomic_long_unchecked_t steal_context_failed;
48035+ atomic_long_unchecked_t nopfn;
48036+ atomic_long_unchecked_t asid_new;
48037+ atomic_long_unchecked_t asid_next;
48038+ atomic_long_unchecked_t asid_wrap;
48039+ atomic_long_unchecked_t asid_reuse;
48040+ atomic_long_unchecked_t intr;
48041+ atomic_long_unchecked_t intr_cbr;
48042+ atomic_long_unchecked_t intr_tfh;
48043+ atomic_long_unchecked_t intr_spurious;
48044+ atomic_long_unchecked_t intr_mm_lock_failed;
48045+ atomic_long_unchecked_t call_os;
48046+ atomic_long_unchecked_t call_os_wait_queue;
48047+ atomic_long_unchecked_t user_flush_tlb;
48048+ atomic_long_unchecked_t user_unload_context;
48049+ atomic_long_unchecked_t user_exception;
48050+ atomic_long_unchecked_t set_context_option;
48051+ atomic_long_unchecked_t check_context_retarget_intr;
48052+ atomic_long_unchecked_t check_context_unload;
48053+ atomic_long_unchecked_t tlb_dropin;
48054+ atomic_long_unchecked_t tlb_preload_page;
48055+ atomic_long_unchecked_t tlb_dropin_fail_no_asid;
48056+ atomic_long_unchecked_t tlb_dropin_fail_upm;
48057+ atomic_long_unchecked_t tlb_dropin_fail_invalid;
48058+ atomic_long_unchecked_t tlb_dropin_fail_range_active;
48059+ atomic_long_unchecked_t tlb_dropin_fail_idle;
48060+ atomic_long_unchecked_t tlb_dropin_fail_fmm;
48061+ atomic_long_unchecked_t tlb_dropin_fail_no_exception;
48062+ atomic_long_unchecked_t tfh_stale_on_fault;
48063+ atomic_long_unchecked_t mmu_invalidate_range;
48064+ atomic_long_unchecked_t mmu_invalidate_page;
48065+ atomic_long_unchecked_t flush_tlb;
48066+ atomic_long_unchecked_t flush_tlb_gru;
48067+ atomic_long_unchecked_t flush_tlb_gru_tgh;
48068+ atomic_long_unchecked_t flush_tlb_gru_zero_asid;
48069
48070- atomic_long_t copy_gpa;
48071- atomic_long_t read_gpa;
48072+ atomic_long_unchecked_t copy_gpa;
48073+ atomic_long_unchecked_t read_gpa;
48074
48075- atomic_long_t mesq_receive;
48076- atomic_long_t mesq_receive_none;
48077- atomic_long_t mesq_send;
48078- atomic_long_t mesq_send_failed;
48079- atomic_long_t mesq_noop;
48080- atomic_long_t mesq_send_unexpected_error;
48081- atomic_long_t mesq_send_lb_overflow;
48082- atomic_long_t mesq_send_qlimit_reached;
48083- atomic_long_t mesq_send_amo_nacked;
48084- atomic_long_t mesq_send_put_nacked;
48085- atomic_long_t mesq_page_overflow;
48086- atomic_long_t mesq_qf_locked;
48087- atomic_long_t mesq_qf_noop_not_full;
48088- atomic_long_t mesq_qf_switch_head_failed;
48089- atomic_long_t mesq_qf_unexpected_error;
48090- atomic_long_t mesq_noop_unexpected_error;
48091- atomic_long_t mesq_noop_lb_overflow;
48092- atomic_long_t mesq_noop_qlimit_reached;
48093- atomic_long_t mesq_noop_amo_nacked;
48094- atomic_long_t mesq_noop_put_nacked;
48095- atomic_long_t mesq_noop_page_overflow;
48096+ atomic_long_unchecked_t mesq_receive;
48097+ atomic_long_unchecked_t mesq_receive_none;
48098+ atomic_long_unchecked_t mesq_send;
48099+ atomic_long_unchecked_t mesq_send_failed;
48100+ atomic_long_unchecked_t mesq_noop;
48101+ atomic_long_unchecked_t mesq_send_unexpected_error;
48102+ atomic_long_unchecked_t mesq_send_lb_overflow;
48103+ atomic_long_unchecked_t mesq_send_qlimit_reached;
48104+ atomic_long_unchecked_t mesq_send_amo_nacked;
48105+ atomic_long_unchecked_t mesq_send_put_nacked;
48106+ atomic_long_unchecked_t mesq_page_overflow;
48107+ atomic_long_unchecked_t mesq_qf_locked;
48108+ atomic_long_unchecked_t mesq_qf_noop_not_full;
48109+ atomic_long_unchecked_t mesq_qf_switch_head_failed;
48110+ atomic_long_unchecked_t mesq_qf_unexpected_error;
48111+ atomic_long_unchecked_t mesq_noop_unexpected_error;
48112+ atomic_long_unchecked_t mesq_noop_lb_overflow;
48113+ atomic_long_unchecked_t mesq_noop_qlimit_reached;
48114+ atomic_long_unchecked_t mesq_noop_amo_nacked;
48115+ atomic_long_unchecked_t mesq_noop_put_nacked;
48116+ atomic_long_unchecked_t mesq_noop_page_overflow;
48117
48118 };
48119
48120@@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
48121 tghop_invalidate, mcsop_last};
48122
48123 struct mcs_op_statistic {
48124- atomic_long_t count;
48125- atomic_long_t total;
48126+ atomic_long_unchecked_t count;
48127+ atomic_long_unchecked_t total;
48128 unsigned long max;
48129 };
48130
48131@@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
48132
48133 #define STAT(id) do { \
48134 if (gru_options & OPT_STATS) \
48135- atomic_long_inc(&gru_stats.id); \
48136+ atomic_long_inc_unchecked(&gru_stats.id); \
48137 } while (0)
48138
48139 #ifdef CONFIG_SGI_GRU_DEBUG
48140diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
48141index c862cd4..0d176fe 100644
48142--- a/drivers/misc/sgi-xp/xp.h
48143+++ b/drivers/misc/sgi-xp/xp.h
48144@@ -288,7 +288,7 @@ struct xpc_interface {
48145 xpc_notify_func, void *);
48146 void (*received) (short, int, void *);
48147 enum xp_retval (*partid_to_nasids) (short, void *);
48148-};
48149+} __no_const;
48150
48151 extern struct xpc_interface xpc_interface;
48152
48153diff --git a/drivers/misc/sgi-xp/xp_main.c b/drivers/misc/sgi-xp/xp_main.c
48154index 01be66d..e3a0c7e 100644
48155--- a/drivers/misc/sgi-xp/xp_main.c
48156+++ b/drivers/misc/sgi-xp/xp_main.c
48157@@ -78,13 +78,13 @@ xpc_notloaded(void)
48158 }
48159
48160 struct xpc_interface xpc_interface = {
48161- (void (*)(int))xpc_notloaded,
48162- (void (*)(int))xpc_notloaded,
48163- (enum xp_retval(*)(short, int, u32, void *, u16))xpc_notloaded,
48164- (enum xp_retval(*)(short, int, u32, void *, u16, xpc_notify_func,
48165+ .connect = (void (*)(int))xpc_notloaded,
48166+ .disconnect = (void (*)(int))xpc_notloaded,
48167+ .send = (enum xp_retval(*)(short, int, u32, void *, u16))xpc_notloaded,
48168+ .send_notify = (enum xp_retval(*)(short, int, u32, void *, u16, xpc_notify_func,
48169 void *))xpc_notloaded,
48170- (void (*)(short, int, void *))xpc_notloaded,
48171- (enum xp_retval(*)(short, void *))xpc_notloaded
48172+ .received = (void (*)(short, int, void *))xpc_notloaded,
48173+ .partid_to_nasids = (enum xp_retval(*)(short, void *))xpc_notloaded
48174 };
48175 EXPORT_SYMBOL_GPL(xpc_interface);
48176
48177diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
48178index b94d5f7..7f494c5 100644
48179--- a/drivers/misc/sgi-xp/xpc.h
48180+++ b/drivers/misc/sgi-xp/xpc.h
48181@@ -835,6 +835,7 @@ struct xpc_arch_operations {
48182 void (*received_payload) (struct xpc_channel *, void *);
48183 void (*notify_senders_of_disconnect) (struct xpc_channel *);
48184 };
48185+typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
48186
48187 /* struct xpc_partition act_state values (for XPC HB) */
48188
48189@@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
48190 /* found in xpc_main.c */
48191 extern struct device *xpc_part;
48192 extern struct device *xpc_chan;
48193-extern struct xpc_arch_operations xpc_arch_ops;
48194+extern xpc_arch_operations_no_const xpc_arch_ops;
48195 extern int xpc_disengage_timelimit;
48196 extern int xpc_disengage_timedout;
48197 extern int xpc_activate_IRQ_rcvd;
48198diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
48199index 7f32712..8539ab2 100644
48200--- a/drivers/misc/sgi-xp/xpc_main.c
48201+++ b/drivers/misc/sgi-xp/xpc_main.c
48202@@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
48203 .notifier_call = xpc_system_die,
48204 };
48205
48206-struct xpc_arch_operations xpc_arch_ops;
48207+xpc_arch_operations_no_const xpc_arch_ops;
48208
48209 /*
48210 * Timer function to enforce the timelimit on the partition disengage.
48211diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
48212index 60f7141..ba97c1a 100644
48213--- a/drivers/mmc/card/block.c
48214+++ b/drivers/mmc/card/block.c
48215@@ -577,7 +577,7 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev,
48216 if (idata->ic.postsleep_min_us)
48217 usleep_range(idata->ic.postsleep_min_us, idata->ic.postsleep_max_us);
48218
48219- if (copy_to_user(&(ic_ptr->response), cmd.resp, sizeof(cmd.resp))) {
48220+ if (copy_to_user(ic_ptr->response, cmd.resp, sizeof(cmd.resp))) {
48221 err = -EFAULT;
48222 goto cmd_rel_host;
48223 }
48224diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
48225index f45ab91..9f50d8f 100644
48226--- a/drivers/mmc/host/dw_mmc.h
48227+++ b/drivers/mmc/host/dw_mmc.h
48228@@ -287,5 +287,5 @@ struct dw_mci_drv_data {
48229 int (*execute_tuning)(struct dw_mci_slot *slot);
48230 int (*prepare_hs400_tuning)(struct dw_mci *host,
48231 struct mmc_ios *ios);
48232-};
48233+} __do_const;
48234 #endif /* _DW_MMC_H_ */
48235diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
48236index fb26674..3172c2b 100644
48237--- a/drivers/mmc/host/mmci.c
48238+++ b/drivers/mmc/host/mmci.c
48239@@ -1633,7 +1633,9 @@ static int mmci_probe(struct amba_device *dev,
48240 mmc->caps |= MMC_CAP_CMD23;
48241
48242 if (variant->busy_detect) {
48243- mmci_ops.card_busy = mmci_card_busy;
48244+ pax_open_kernel();
48245+ *(void **)&mmci_ops.card_busy = mmci_card_busy;
48246+ pax_close_kernel();
48247 mmci_write_datactrlreg(host, MCI_ST_DPSM_BUSYMODE);
48248 mmc->caps |= MMC_CAP_WAIT_WHILE_BUSY;
48249 mmc->max_busy_timeout = 0;
48250diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
48251index 9df2b68..6d5ed1a 100644
48252--- a/drivers/mmc/host/omap_hsmmc.c
48253+++ b/drivers/mmc/host/omap_hsmmc.c
48254@@ -2004,7 +2004,9 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
48255
48256 if (host->pdata->controller_flags & OMAP_HSMMC_BROKEN_MULTIBLOCK_READ) {
48257 dev_info(&pdev->dev, "multiblock reads disabled due to 35xx erratum 2.1.1.128; MMC read performance may suffer\n");
48258- omap_hsmmc_ops.multi_io_quirk = omap_hsmmc_multi_io_quirk;
48259+ pax_open_kernel();
48260+ *(void **)&omap_hsmmc_ops.multi_io_quirk = omap_hsmmc_multi_io_quirk;
48261+ pax_close_kernel();
48262 }
48263
48264 pm_runtime_enable(host->dev);
48265diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
48266index 82f512d..5a228bb 100644
48267--- a/drivers/mmc/host/sdhci-esdhc-imx.c
48268+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
48269@@ -993,9 +993,12 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
48270 host->mmc->caps |= MMC_CAP_1_8V_DDR;
48271 }
48272
48273- if (imx_data->socdata->flags & ESDHC_FLAG_MAN_TUNING)
48274- sdhci_esdhc_ops.platform_execute_tuning =
48275+ if (imx_data->socdata->flags & ESDHC_FLAG_MAN_TUNING) {
48276+ pax_open_kernel();
48277+ *(void **)&sdhci_esdhc_ops.platform_execute_tuning =
48278 esdhc_executing_tuning;
48279+ pax_close_kernel();
48280+ }
48281
48282 if (imx_data->socdata->flags & ESDHC_FLAG_STD_TUNING)
48283 writel(readl(host->ioaddr + ESDHC_TUNING_CTRL) |
48284diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
48285index c6d2dd7..81b1ca3 100644
48286--- a/drivers/mmc/host/sdhci-s3c.c
48287+++ b/drivers/mmc/host/sdhci-s3c.c
48288@@ -598,9 +598,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
48289 * we can use overriding functions instead of default.
48290 */
48291 if (sc->no_divider) {
48292- sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
48293- sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
48294- sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
48295+ pax_open_kernel();
48296+ *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
48297+ *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
48298+ *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
48299+ pax_close_kernel();
48300 }
48301
48302 /* It supports additional host capabilities if needed */
48303diff --git a/drivers/mtd/chips/cfi_cmdset_0020.c b/drivers/mtd/chips/cfi_cmdset_0020.c
48304index 9a1a6ff..b8f1a57 100644
48305--- a/drivers/mtd/chips/cfi_cmdset_0020.c
48306+++ b/drivers/mtd/chips/cfi_cmdset_0020.c
48307@@ -666,7 +666,7 @@ cfi_staa_writev(struct mtd_info *mtd, const struct kvec *vecs,
48308 size_t totlen = 0, thislen;
48309 int ret = 0;
48310 size_t buflen = 0;
48311- static char *buffer;
48312+ char *buffer;
48313
48314 if (!ECCBUF_SIZE) {
48315 /* We should fall back to a general writev implementation.
48316diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
48317index 870c7fc..c7d6440 100644
48318--- a/drivers/mtd/nand/denali.c
48319+++ b/drivers/mtd/nand/denali.c
48320@@ -24,6 +24,7 @@
48321 #include <linux/slab.h>
48322 #include <linux/mtd/mtd.h>
48323 #include <linux/module.h>
48324+#include <linux/slab.h>
48325
48326 #include "denali.h"
48327
48328diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
48329index 1b8f350..990f2e9 100644
48330--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
48331+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
48332@@ -386,7 +386,7 @@ void prepare_data_dma(struct gpmi_nand_data *this, enum dma_data_direction dr)
48333
48334 /* first try to map the upper buffer directly */
48335 if (virt_addr_valid(this->upper_buf) &&
48336- !object_is_on_stack(this->upper_buf)) {
48337+ !object_starts_on_stack(this->upper_buf)) {
48338 sg_init_one(sgl, this->upper_buf, this->upper_len);
48339 ret = dma_map_sg(this->dev, sgl, 1, dr);
48340 if (ret == 0)
48341diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
48342index a5dfbfb..8042ab4 100644
48343--- a/drivers/mtd/nftlmount.c
48344+++ b/drivers/mtd/nftlmount.c
48345@@ -24,6 +24,7 @@
48346 #include <asm/errno.h>
48347 #include <linux/delay.h>
48348 #include <linux/slab.h>
48349+#include <linux/sched.h>
48350 #include <linux/mtd/mtd.h>
48351 #include <linux/mtd/nand.h>
48352 #include <linux/mtd/nftl.h>
48353diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
48354index c23184a..4115c41 100644
48355--- a/drivers/mtd/sm_ftl.c
48356+++ b/drivers/mtd/sm_ftl.c
48357@@ -56,7 +56,7 @@ static ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
48358 #define SM_CIS_VENDOR_OFFSET 0x59
48359 static struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
48360 {
48361- struct attribute_group *attr_group;
48362+ attribute_group_no_const *attr_group;
48363 struct attribute **attributes;
48364 struct sm_sysfs_attribute *vendor_attribute;
48365 char *vendor;
48366diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c
48367index 7b11243..b3278a3 100644
48368--- a/drivers/net/bonding/bond_netlink.c
48369+++ b/drivers/net/bonding/bond_netlink.c
48370@@ -585,7 +585,7 @@ nla_put_failure:
48371 return -EMSGSIZE;
48372 }
48373
48374-struct rtnl_link_ops bond_link_ops __read_mostly = {
48375+struct rtnl_link_ops bond_link_ops = {
48376 .kind = "bond",
48377 .priv_size = sizeof(struct bonding),
48378 .setup = bond_setup,
48379diff --git a/drivers/net/caif/caif_hsi.c b/drivers/net/caif/caif_hsi.c
48380index b3b922a..80bba38 100644
48381--- a/drivers/net/caif/caif_hsi.c
48382+++ b/drivers/net/caif/caif_hsi.c
48383@@ -1444,7 +1444,7 @@ err:
48384 return -ENODEV;
48385 }
48386
48387-static struct rtnl_link_ops caif_hsi_link_ops __read_mostly = {
48388+static struct rtnl_link_ops caif_hsi_link_ops = {
48389 .kind = "cfhsi",
48390 .priv_size = sizeof(struct cfhsi),
48391 .setup = cfhsi_setup,
48392diff --git a/drivers/net/can/Kconfig b/drivers/net/can/Kconfig
48393index e8c96b8..516a96c 100644
48394--- a/drivers/net/can/Kconfig
48395+++ b/drivers/net/can/Kconfig
48396@@ -98,7 +98,7 @@ config CAN_JANZ_ICAN3
48397
48398 config CAN_FLEXCAN
48399 tristate "Support for Freescale FLEXCAN based chips"
48400- depends on ARM || PPC
48401+ depends on (ARM && CPU_LITTLE_ENDIAN) || PPC
48402 ---help---
48403 Say Y here if you want to support for Freescale FlexCAN.
48404
48405diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
48406index e9b1810..5c2f3f9 100644
48407--- a/drivers/net/can/dev.c
48408+++ b/drivers/net/can/dev.c
48409@@ -964,7 +964,7 @@ static int can_newlink(struct net *src_net, struct net_device *dev,
48410 return -EOPNOTSUPP;
48411 }
48412
48413-static struct rtnl_link_ops can_link_ops __read_mostly = {
48414+static struct rtnl_link_ops can_link_ops = {
48415 .kind = "can",
48416 .maxtype = IFLA_CAN_MAX,
48417 .policy = can_policy,
48418diff --git a/drivers/net/can/vcan.c b/drivers/net/can/vcan.c
48419index 0ce868d..e5dc8bd 100644
48420--- a/drivers/net/can/vcan.c
48421+++ b/drivers/net/can/vcan.c
48422@@ -166,7 +166,7 @@ static void vcan_setup(struct net_device *dev)
48423 dev->destructor = free_netdev;
48424 }
48425
48426-static struct rtnl_link_ops vcan_link_ops __read_mostly = {
48427+static struct rtnl_link_ops vcan_link_ops = {
48428 .kind = "vcan",
48429 .setup = vcan_setup,
48430 };
48431diff --git a/drivers/net/dummy.c b/drivers/net/dummy.c
48432index 49adbf1..fff7ff8 100644
48433--- a/drivers/net/dummy.c
48434+++ b/drivers/net/dummy.c
48435@@ -164,7 +164,7 @@ static int dummy_validate(struct nlattr *tb[], struct nlattr *data[])
48436 return 0;
48437 }
48438
48439-static struct rtnl_link_ops dummy_link_ops __read_mostly = {
48440+static struct rtnl_link_ops dummy_link_ops = {
48441 .kind = DRV_NAME,
48442 .setup = dummy_setup,
48443 .validate = dummy_validate,
48444diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
48445index 0443654..4f0aa18 100644
48446--- a/drivers/net/ethernet/8390/ax88796.c
48447+++ b/drivers/net/ethernet/8390/ax88796.c
48448@@ -889,9 +889,11 @@ static int ax_probe(struct platform_device *pdev)
48449 if (ax->plat->reg_offsets)
48450 ei_local->reg_offset = ax->plat->reg_offsets;
48451 else {
48452+ resource_size_t _mem_size = mem_size;
48453+ do_div(_mem_size, 0x18);
48454 ei_local->reg_offset = ax->reg_offsets;
48455 for (ret = 0; ret < 0x18; ret++)
48456- ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
48457+ ax->reg_offsets[ret] = _mem_size * ret;
48458 }
48459
48460 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
48461diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c
48462index da48e66..2dbec80 100644
48463--- a/drivers/net/ethernet/altera/altera_tse_main.c
48464+++ b/drivers/net/ethernet/altera/altera_tse_main.c
48465@@ -1256,7 +1256,7 @@ static int tse_shutdown(struct net_device *dev)
48466 return 0;
48467 }
48468
48469-static struct net_device_ops altera_tse_netdev_ops = {
48470+static net_device_ops_no_const altera_tse_netdev_ops __read_only = {
48471 .ndo_open = tse_open,
48472 .ndo_stop = tse_shutdown,
48473 .ndo_start_xmit = tse_start_xmit,
48474@@ -1493,11 +1493,13 @@ static int altera_tse_probe(struct platform_device *pdev)
48475 ndev->netdev_ops = &altera_tse_netdev_ops;
48476 altera_tse_set_ethtool_ops(ndev);
48477
48478+ pax_open_kernel();
48479 altera_tse_netdev_ops.ndo_set_rx_mode = tse_set_rx_mode;
48480
48481 if (priv->hash_filter)
48482 altera_tse_netdev_ops.ndo_set_rx_mode =
48483 tse_set_rx_mode_hashfilter;
48484+ pax_close_kernel();
48485
48486 /* Scatter/gather IO is not supported,
48487 * so it is turned off
48488diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-common.h b/drivers/net/ethernet/amd/xgbe/xgbe-common.h
48489index 34c28aa..5e06567 100644
48490--- a/drivers/net/ethernet/amd/xgbe/xgbe-common.h
48491+++ b/drivers/net/ethernet/amd/xgbe/xgbe-common.h
48492@@ -1124,14 +1124,14 @@ do { \
48493 * operations, everything works on mask values.
48494 */
48495 #define XMDIO_READ(_pdata, _mmd, _reg) \
48496- ((_pdata)->hw_if.read_mmd_regs((_pdata), 0, \
48497+ ((_pdata)->hw_if->read_mmd_regs((_pdata), 0, \
48498 MII_ADDR_C45 | (_mmd << 16) | ((_reg) & 0xffff)))
48499
48500 #define XMDIO_READ_BITS(_pdata, _mmd, _reg, _mask) \
48501 (XMDIO_READ((_pdata), _mmd, _reg) & _mask)
48502
48503 #define XMDIO_WRITE(_pdata, _mmd, _reg, _val) \
48504- ((_pdata)->hw_if.write_mmd_regs((_pdata), 0, \
48505+ ((_pdata)->hw_if->write_mmd_regs((_pdata), 0, \
48506 MII_ADDR_C45 | (_mmd << 16) | ((_reg) & 0xffff), (_val)))
48507
48508 #define XMDIO_WRITE_BITS(_pdata, _mmd, _reg, _mask, _val) \
48509diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-dcb.c b/drivers/net/ethernet/amd/xgbe/xgbe-dcb.c
48510index 8a50b01..39c1ad0 100644
48511--- a/drivers/net/ethernet/amd/xgbe/xgbe-dcb.c
48512+++ b/drivers/net/ethernet/amd/xgbe/xgbe-dcb.c
48513@@ -187,7 +187,7 @@ static int xgbe_dcb_ieee_setets(struct net_device *netdev,
48514
48515 memcpy(pdata->ets, ets, sizeof(*pdata->ets));
48516
48517- pdata->hw_if.config_dcb_tc(pdata);
48518+ pdata->hw_if->config_dcb_tc(pdata);
48519
48520 return 0;
48521 }
48522@@ -226,7 +226,7 @@ static int xgbe_dcb_ieee_setpfc(struct net_device *netdev,
48523
48524 memcpy(pdata->pfc, pfc, sizeof(*pdata->pfc));
48525
48526- pdata->hw_if.config_dcb_pfc(pdata);
48527+ pdata->hw_if->config_dcb_pfc(pdata);
48528
48529 return 0;
48530 }
48531diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-desc.c b/drivers/net/ethernet/amd/xgbe/xgbe-desc.c
48532index 5c92fb7..08be735 100644
48533--- a/drivers/net/ethernet/amd/xgbe/xgbe-desc.c
48534+++ b/drivers/net/ethernet/amd/xgbe/xgbe-desc.c
48535@@ -347,7 +347,7 @@ static int xgbe_map_rx_buffer(struct xgbe_prv_data *pdata,
48536
48537 static void xgbe_wrapper_tx_descriptor_init(struct xgbe_prv_data *pdata)
48538 {
48539- struct xgbe_hw_if *hw_if = &pdata->hw_if;
48540+ struct xgbe_hw_if *hw_if = pdata->hw_if;
48541 struct xgbe_channel *channel;
48542 struct xgbe_ring *ring;
48543 struct xgbe_ring_data *rdata;
48544@@ -388,7 +388,7 @@ static void xgbe_wrapper_tx_descriptor_init(struct xgbe_prv_data *pdata)
48545
48546 static void xgbe_wrapper_rx_descriptor_init(struct xgbe_prv_data *pdata)
48547 {
48548- struct xgbe_hw_if *hw_if = &pdata->hw_if;
48549+ struct xgbe_hw_if *hw_if = pdata->hw_if;
48550 struct xgbe_channel *channel;
48551 struct xgbe_ring *ring;
48552 struct xgbe_ring_desc *rdesc;
48553@@ -620,17 +620,12 @@ err_out:
48554 return 0;
48555 }
48556
48557-void xgbe_init_function_ptrs_desc(struct xgbe_desc_if *desc_if)
48558-{
48559- DBGPR("-->xgbe_init_function_ptrs_desc\n");
48560-
48561- desc_if->alloc_ring_resources = xgbe_alloc_ring_resources;
48562- desc_if->free_ring_resources = xgbe_free_ring_resources;
48563- desc_if->map_tx_skb = xgbe_map_tx_skb;
48564- desc_if->map_rx_buffer = xgbe_map_rx_buffer;
48565- desc_if->unmap_rdata = xgbe_unmap_rdata;
48566- desc_if->wrapper_tx_desc_init = xgbe_wrapper_tx_descriptor_init;
48567- desc_if->wrapper_rx_desc_init = xgbe_wrapper_rx_descriptor_init;
48568-
48569- DBGPR("<--xgbe_init_function_ptrs_desc\n");
48570-}
48571+struct xgbe_desc_if default_xgbe_desc_if = {
48572+ .alloc_ring_resources = xgbe_alloc_ring_resources,
48573+ .free_ring_resources = xgbe_free_ring_resources,
48574+ .map_tx_skb = xgbe_map_tx_skb,
48575+ .map_rx_buffer = xgbe_map_rx_buffer,
48576+ .unmap_rdata = xgbe_unmap_rdata,
48577+ .wrapper_tx_desc_init = xgbe_wrapper_tx_descriptor_init,
48578+ .wrapper_rx_desc_init = xgbe_wrapper_rx_descriptor_init,
48579+};
48580diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-dev.c b/drivers/net/ethernet/amd/xgbe/xgbe-dev.c
48581index 21d9497..c74b40f 100644
48582--- a/drivers/net/ethernet/amd/xgbe/xgbe-dev.c
48583+++ b/drivers/net/ethernet/amd/xgbe/xgbe-dev.c
48584@@ -2772,7 +2772,7 @@ static void xgbe_powerdown_rx(struct xgbe_prv_data *pdata)
48585
48586 static int xgbe_init(struct xgbe_prv_data *pdata)
48587 {
48588- struct xgbe_desc_if *desc_if = &pdata->desc_if;
48589+ struct xgbe_desc_if *desc_if = pdata->desc_if;
48590 int ret;
48591
48592 DBGPR("-->xgbe_init\n");
48593@@ -2838,106 +2838,101 @@ static int xgbe_init(struct xgbe_prv_data *pdata)
48594 return 0;
48595 }
48596
48597-void xgbe_init_function_ptrs_dev(struct xgbe_hw_if *hw_if)
48598-{
48599- DBGPR("-->xgbe_init_function_ptrs\n");
48600-
48601- hw_if->tx_complete = xgbe_tx_complete;
48602-
48603- hw_if->set_mac_address = xgbe_set_mac_address;
48604- hw_if->config_rx_mode = xgbe_config_rx_mode;
48605-
48606- hw_if->enable_rx_csum = xgbe_enable_rx_csum;
48607- hw_if->disable_rx_csum = xgbe_disable_rx_csum;
48608-
48609- hw_if->enable_rx_vlan_stripping = xgbe_enable_rx_vlan_stripping;
48610- hw_if->disable_rx_vlan_stripping = xgbe_disable_rx_vlan_stripping;
48611- hw_if->enable_rx_vlan_filtering = xgbe_enable_rx_vlan_filtering;
48612- hw_if->disable_rx_vlan_filtering = xgbe_disable_rx_vlan_filtering;
48613- hw_if->update_vlan_hash_table = xgbe_update_vlan_hash_table;
48614-
48615- hw_if->read_mmd_regs = xgbe_read_mmd_regs;
48616- hw_if->write_mmd_regs = xgbe_write_mmd_regs;
48617-
48618- hw_if->set_gmii_speed = xgbe_set_gmii_speed;
48619- hw_if->set_gmii_2500_speed = xgbe_set_gmii_2500_speed;
48620- hw_if->set_xgmii_speed = xgbe_set_xgmii_speed;
48621-
48622- hw_if->enable_tx = xgbe_enable_tx;
48623- hw_if->disable_tx = xgbe_disable_tx;
48624- hw_if->enable_rx = xgbe_enable_rx;
48625- hw_if->disable_rx = xgbe_disable_rx;
48626-
48627- hw_if->powerup_tx = xgbe_powerup_tx;
48628- hw_if->powerdown_tx = xgbe_powerdown_tx;
48629- hw_if->powerup_rx = xgbe_powerup_rx;
48630- hw_if->powerdown_rx = xgbe_powerdown_rx;
48631-
48632- hw_if->dev_xmit = xgbe_dev_xmit;
48633- hw_if->dev_read = xgbe_dev_read;
48634- hw_if->enable_int = xgbe_enable_int;
48635- hw_if->disable_int = xgbe_disable_int;
48636- hw_if->init = xgbe_init;
48637- hw_if->exit = xgbe_exit;
48638+struct xgbe_hw_if default_xgbe_hw_if = {
48639+ .tx_complete = xgbe_tx_complete,
48640+
48641+ .set_mac_address = xgbe_set_mac_address,
48642+ .config_rx_mode = xgbe_config_rx_mode,
48643+
48644+ .enable_rx_csum = xgbe_enable_rx_csum,
48645+ .disable_rx_csum = xgbe_disable_rx_csum,
48646+
48647+ .enable_rx_vlan_stripping = xgbe_enable_rx_vlan_stripping,
48648+ .disable_rx_vlan_stripping = xgbe_disable_rx_vlan_stripping,
48649+ .enable_rx_vlan_filtering = xgbe_enable_rx_vlan_filtering,
48650+ .disable_rx_vlan_filtering = xgbe_disable_rx_vlan_filtering,
48651+ .update_vlan_hash_table = xgbe_update_vlan_hash_table,
48652+
48653+ .read_mmd_regs = xgbe_read_mmd_regs,
48654+ .write_mmd_regs = xgbe_write_mmd_regs,
48655+
48656+ .set_gmii_speed = xgbe_set_gmii_speed,
48657+ .set_gmii_2500_speed = xgbe_set_gmii_2500_speed,
48658+ .set_xgmii_speed = xgbe_set_xgmii_speed,
48659+
48660+ .enable_tx = xgbe_enable_tx,
48661+ .disable_tx = xgbe_disable_tx,
48662+ .enable_rx = xgbe_enable_rx,
48663+ .disable_rx = xgbe_disable_rx,
48664+
48665+ .powerup_tx = xgbe_powerup_tx,
48666+ .powerdown_tx = xgbe_powerdown_tx,
48667+ .powerup_rx = xgbe_powerup_rx,
48668+ .powerdown_rx = xgbe_powerdown_rx,
48669+
48670+ .dev_xmit = xgbe_dev_xmit,
48671+ .dev_read = xgbe_dev_read,
48672+ .enable_int = xgbe_enable_int,
48673+ .disable_int = xgbe_disable_int,
48674+ .init = xgbe_init,
48675+ .exit = xgbe_exit,
48676
48677 /* Descriptor related Sequences have to be initialized here */
48678- hw_if->tx_desc_init = xgbe_tx_desc_init;
48679- hw_if->rx_desc_init = xgbe_rx_desc_init;
48680- hw_if->tx_desc_reset = xgbe_tx_desc_reset;
48681- hw_if->rx_desc_reset = xgbe_rx_desc_reset;
48682- hw_if->is_last_desc = xgbe_is_last_desc;
48683- hw_if->is_context_desc = xgbe_is_context_desc;
48684- hw_if->tx_start_xmit = xgbe_tx_start_xmit;
48685+ .tx_desc_init = xgbe_tx_desc_init,
48686+ .rx_desc_init = xgbe_rx_desc_init,
48687+ .tx_desc_reset = xgbe_tx_desc_reset,
48688+ .rx_desc_reset = xgbe_rx_desc_reset,
48689+ .is_last_desc = xgbe_is_last_desc,
48690+ .is_context_desc = xgbe_is_context_desc,
48691+ .tx_start_xmit = xgbe_tx_start_xmit,
48692
48693 /* For FLOW ctrl */
48694- hw_if->config_tx_flow_control = xgbe_config_tx_flow_control;
48695- hw_if->config_rx_flow_control = xgbe_config_rx_flow_control;
48696+ .config_tx_flow_control = xgbe_config_tx_flow_control,
48697+ .config_rx_flow_control = xgbe_config_rx_flow_control,
48698
48699 /* For RX coalescing */
48700- hw_if->config_rx_coalesce = xgbe_config_rx_coalesce;
48701- hw_if->config_tx_coalesce = xgbe_config_tx_coalesce;
48702- hw_if->usec_to_riwt = xgbe_usec_to_riwt;
48703- hw_if->riwt_to_usec = xgbe_riwt_to_usec;
48704+ .config_rx_coalesce = xgbe_config_rx_coalesce,
48705+ .config_tx_coalesce = xgbe_config_tx_coalesce,
48706+ .usec_to_riwt = xgbe_usec_to_riwt,
48707+ .riwt_to_usec = xgbe_riwt_to_usec,
48708
48709 /* For RX and TX threshold config */
48710- hw_if->config_rx_threshold = xgbe_config_rx_threshold;
48711- hw_if->config_tx_threshold = xgbe_config_tx_threshold;
48712+ .config_rx_threshold = xgbe_config_rx_threshold,
48713+ .config_tx_threshold = xgbe_config_tx_threshold,
48714
48715 /* For RX and TX Store and Forward Mode config */
48716- hw_if->config_rsf_mode = xgbe_config_rsf_mode;
48717- hw_if->config_tsf_mode = xgbe_config_tsf_mode;
48718+ .config_rsf_mode = xgbe_config_rsf_mode,
48719+ .config_tsf_mode = xgbe_config_tsf_mode,
48720
48721 /* For TX DMA Operating on Second Frame config */
48722- hw_if->config_osp_mode = xgbe_config_osp_mode;
48723+ .config_osp_mode = xgbe_config_osp_mode,
48724
48725 /* For RX and TX PBL config */
48726- hw_if->config_rx_pbl_val = xgbe_config_rx_pbl_val;
48727- hw_if->get_rx_pbl_val = xgbe_get_rx_pbl_val;
48728- hw_if->config_tx_pbl_val = xgbe_config_tx_pbl_val;
48729- hw_if->get_tx_pbl_val = xgbe_get_tx_pbl_val;
48730- hw_if->config_pblx8 = xgbe_config_pblx8;
48731+ .config_rx_pbl_val = xgbe_config_rx_pbl_val,
48732+ .get_rx_pbl_val = xgbe_get_rx_pbl_val,
48733+ .config_tx_pbl_val = xgbe_config_tx_pbl_val,
48734+ .get_tx_pbl_val = xgbe_get_tx_pbl_val,
48735+ .config_pblx8 = xgbe_config_pblx8,
48736
48737 /* For MMC statistics support */
48738- hw_if->tx_mmc_int = xgbe_tx_mmc_int;
48739- hw_if->rx_mmc_int = xgbe_rx_mmc_int;
48740- hw_if->read_mmc_stats = xgbe_read_mmc_stats;
48741+ .tx_mmc_int = xgbe_tx_mmc_int,
48742+ .rx_mmc_int = xgbe_rx_mmc_int,
48743+ .read_mmc_stats = xgbe_read_mmc_stats,
48744
48745 /* For PTP config */
48746- hw_if->config_tstamp = xgbe_config_tstamp;
48747- hw_if->update_tstamp_addend = xgbe_update_tstamp_addend;
48748- hw_if->set_tstamp_time = xgbe_set_tstamp_time;
48749- hw_if->get_tstamp_time = xgbe_get_tstamp_time;
48750- hw_if->get_tx_tstamp = xgbe_get_tx_tstamp;
48751+ .config_tstamp = xgbe_config_tstamp,
48752+ .update_tstamp_addend = xgbe_update_tstamp_addend,
48753+ .set_tstamp_time = xgbe_set_tstamp_time,
48754+ .get_tstamp_time = xgbe_get_tstamp_time,
48755+ .get_tx_tstamp = xgbe_get_tx_tstamp,
48756
48757 /* For Data Center Bridging config */
48758- hw_if->config_dcb_tc = xgbe_config_dcb_tc;
48759- hw_if->config_dcb_pfc = xgbe_config_dcb_pfc;
48760+ .config_dcb_tc = xgbe_config_dcb_tc,
48761+ .config_dcb_pfc = xgbe_config_dcb_pfc,
48762
48763 /* For Receive Side Scaling */
48764- hw_if->enable_rss = xgbe_enable_rss;
48765- hw_if->disable_rss = xgbe_disable_rss;
48766- hw_if->set_rss_hash_key = xgbe_set_rss_hash_key;
48767- hw_if->set_rss_lookup_table = xgbe_set_rss_lookup_table;
48768-
48769- DBGPR("<--xgbe_init_function_ptrs\n");
48770-}
48771+ .enable_rss = xgbe_enable_rss,
48772+ .disable_rss = xgbe_disable_rss,
48773+ .set_rss_hash_key = xgbe_set_rss_hash_key,
48774+ .set_rss_lookup_table = xgbe_set_rss_lookup_table,
48775+};
48776diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
48777index 9fd6c69..588ff02 100644
48778--- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
48779+++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
48780@@ -243,7 +243,7 @@ static int xgbe_maybe_stop_tx_queue(struct xgbe_channel *channel,
48781 * support, tell it now
48782 */
48783 if (ring->tx.xmit_more)
48784- pdata->hw_if.tx_start_xmit(channel, ring);
48785+ pdata->hw_if->tx_start_xmit(channel, ring);
48786
48787 return NETDEV_TX_BUSY;
48788 }
48789@@ -271,7 +271,7 @@ static int xgbe_calc_rx_buf_size(struct net_device *netdev, unsigned int mtu)
48790
48791 static void xgbe_enable_rx_tx_ints(struct xgbe_prv_data *pdata)
48792 {
48793- struct xgbe_hw_if *hw_if = &pdata->hw_if;
48794+ struct xgbe_hw_if *hw_if = pdata->hw_if;
48795 struct xgbe_channel *channel;
48796 enum xgbe_int int_id;
48797 unsigned int i;
48798@@ -293,7 +293,7 @@ static void xgbe_enable_rx_tx_ints(struct xgbe_prv_data *pdata)
48799
48800 static void xgbe_disable_rx_tx_ints(struct xgbe_prv_data *pdata)
48801 {
48802- struct xgbe_hw_if *hw_if = &pdata->hw_if;
48803+ struct xgbe_hw_if *hw_if = pdata->hw_if;
48804 struct xgbe_channel *channel;
48805 enum xgbe_int int_id;
48806 unsigned int i;
48807@@ -316,7 +316,7 @@ static void xgbe_disable_rx_tx_ints(struct xgbe_prv_data *pdata)
48808 static irqreturn_t xgbe_isr(int irq, void *data)
48809 {
48810 struct xgbe_prv_data *pdata = data;
48811- struct xgbe_hw_if *hw_if = &pdata->hw_if;
48812+ struct xgbe_hw_if *hw_if = pdata->hw_if;
48813 struct xgbe_channel *channel;
48814 unsigned int dma_isr, dma_ch_isr;
48815 unsigned int mac_isr, mac_tssr;
48816@@ -682,7 +682,7 @@ static void xgbe_free_irqs(struct xgbe_prv_data *pdata)
48817
48818 void xgbe_init_tx_coalesce(struct xgbe_prv_data *pdata)
48819 {
48820- struct xgbe_hw_if *hw_if = &pdata->hw_if;
48821+ struct xgbe_hw_if *hw_if = pdata->hw_if;
48822
48823 DBGPR("-->xgbe_init_tx_coalesce\n");
48824
48825@@ -696,7 +696,7 @@ void xgbe_init_tx_coalesce(struct xgbe_prv_data *pdata)
48826
48827 void xgbe_init_rx_coalesce(struct xgbe_prv_data *pdata)
48828 {
48829- struct xgbe_hw_if *hw_if = &pdata->hw_if;
48830+ struct xgbe_hw_if *hw_if = pdata->hw_if;
48831
48832 DBGPR("-->xgbe_init_rx_coalesce\n");
48833
48834@@ -711,7 +711,7 @@ void xgbe_init_rx_coalesce(struct xgbe_prv_data *pdata)
48835
48836 static void xgbe_free_tx_data(struct xgbe_prv_data *pdata)
48837 {
48838- struct xgbe_desc_if *desc_if = &pdata->desc_if;
48839+ struct xgbe_desc_if *desc_if = pdata->desc_if;
48840 struct xgbe_channel *channel;
48841 struct xgbe_ring *ring;
48842 struct xgbe_ring_data *rdata;
48843@@ -736,7 +736,7 @@ static void xgbe_free_tx_data(struct xgbe_prv_data *pdata)
48844
48845 static void xgbe_free_rx_data(struct xgbe_prv_data *pdata)
48846 {
48847- struct xgbe_desc_if *desc_if = &pdata->desc_if;
48848+ struct xgbe_desc_if *desc_if = pdata->desc_if;
48849 struct xgbe_channel *channel;
48850 struct xgbe_ring *ring;
48851 struct xgbe_ring_data *rdata;
48852@@ -762,7 +762,7 @@ static void xgbe_free_rx_data(struct xgbe_prv_data *pdata)
48853 static void xgbe_adjust_link(struct net_device *netdev)
48854 {
48855 struct xgbe_prv_data *pdata = netdev_priv(netdev);
48856- struct xgbe_hw_if *hw_if = &pdata->hw_if;
48857+ struct xgbe_hw_if *hw_if = pdata->hw_if;
48858 struct phy_device *phydev = pdata->phydev;
48859 int new_state = 0;
48860
48861@@ -870,7 +870,7 @@ static void xgbe_phy_exit(struct xgbe_prv_data *pdata)
48862 int xgbe_powerdown(struct net_device *netdev, unsigned int caller)
48863 {
48864 struct xgbe_prv_data *pdata = netdev_priv(netdev);
48865- struct xgbe_hw_if *hw_if = &pdata->hw_if;
48866+ struct xgbe_hw_if *hw_if = pdata->hw_if;
48867 unsigned long flags;
48868
48869 DBGPR("-->xgbe_powerdown\n");
48870@@ -908,7 +908,7 @@ int xgbe_powerdown(struct net_device *netdev, unsigned int caller)
48871 int xgbe_powerup(struct net_device *netdev, unsigned int caller)
48872 {
48873 struct xgbe_prv_data *pdata = netdev_priv(netdev);
48874- struct xgbe_hw_if *hw_if = &pdata->hw_if;
48875+ struct xgbe_hw_if *hw_if = pdata->hw_if;
48876 unsigned long flags;
48877
48878 DBGPR("-->xgbe_powerup\n");
48879@@ -945,7 +945,7 @@ int xgbe_powerup(struct net_device *netdev, unsigned int caller)
48880
48881 static int xgbe_start(struct xgbe_prv_data *pdata)
48882 {
48883- struct xgbe_hw_if *hw_if = &pdata->hw_if;
48884+ struct xgbe_hw_if *hw_if = pdata->hw_if;
48885 struct net_device *netdev = pdata->netdev;
48886 int ret;
48887
48888@@ -984,7 +984,7 @@ err_napi:
48889
48890 static void xgbe_stop(struct xgbe_prv_data *pdata)
48891 {
48892- struct xgbe_hw_if *hw_if = &pdata->hw_if;
48893+ struct xgbe_hw_if *hw_if = pdata->hw_if;
48894 struct xgbe_channel *channel;
48895 struct net_device *netdev = pdata->netdev;
48896 struct netdev_queue *txq;
48897@@ -1211,7 +1211,7 @@ static int xgbe_set_hwtstamp_settings(struct xgbe_prv_data *pdata,
48898 return -ERANGE;
48899 }
48900
48901- pdata->hw_if.config_tstamp(pdata, mac_tscr);
48902+ pdata->hw_if->config_tstamp(pdata, mac_tscr);
48903
48904 memcpy(&pdata->tstamp_config, &config, sizeof(config));
48905
48906@@ -1360,7 +1360,7 @@ static void xgbe_packet_info(struct xgbe_prv_data *pdata,
48907 static int xgbe_open(struct net_device *netdev)
48908 {
48909 struct xgbe_prv_data *pdata = netdev_priv(netdev);
48910- struct xgbe_desc_if *desc_if = &pdata->desc_if;
48911+ struct xgbe_desc_if *desc_if = pdata->desc_if;
48912 int ret;
48913
48914 DBGPR("-->xgbe_open\n");
48915@@ -1432,7 +1432,7 @@ err_phy_init:
48916 static int xgbe_close(struct net_device *netdev)
48917 {
48918 struct xgbe_prv_data *pdata = netdev_priv(netdev);
48919- struct xgbe_desc_if *desc_if = &pdata->desc_if;
48920+ struct xgbe_desc_if *desc_if = pdata->desc_if;
48921
48922 DBGPR("-->xgbe_close\n");
48923
48924@@ -1460,8 +1460,8 @@ static int xgbe_close(struct net_device *netdev)
48925 static int xgbe_xmit(struct sk_buff *skb, struct net_device *netdev)
48926 {
48927 struct xgbe_prv_data *pdata = netdev_priv(netdev);
48928- struct xgbe_hw_if *hw_if = &pdata->hw_if;
48929- struct xgbe_desc_if *desc_if = &pdata->desc_if;
48930+ struct xgbe_hw_if *hw_if = pdata->hw_if;
48931+ struct xgbe_desc_if *desc_if = pdata->desc_if;
48932 struct xgbe_channel *channel;
48933 struct xgbe_ring *ring;
48934 struct xgbe_packet_data *packet;
48935@@ -1529,7 +1529,7 @@ tx_netdev_return:
48936 static void xgbe_set_rx_mode(struct net_device *netdev)
48937 {
48938 struct xgbe_prv_data *pdata = netdev_priv(netdev);
48939- struct xgbe_hw_if *hw_if = &pdata->hw_if;
48940+ struct xgbe_hw_if *hw_if = pdata->hw_if;
48941
48942 DBGPR("-->xgbe_set_rx_mode\n");
48943
48944@@ -1541,7 +1541,7 @@ static void xgbe_set_rx_mode(struct net_device *netdev)
48945 static int xgbe_set_mac_address(struct net_device *netdev, void *addr)
48946 {
48947 struct xgbe_prv_data *pdata = netdev_priv(netdev);
48948- struct xgbe_hw_if *hw_if = &pdata->hw_if;
48949+ struct xgbe_hw_if *hw_if = pdata->hw_if;
48950 struct sockaddr *saddr = addr;
48951
48952 DBGPR("-->xgbe_set_mac_address\n");
48953@@ -1616,7 +1616,7 @@ static struct rtnl_link_stats64 *xgbe_get_stats64(struct net_device *netdev,
48954
48955 DBGPR("-->%s\n", __func__);
48956
48957- pdata->hw_if.read_mmc_stats(pdata);
48958+ pdata->hw_if->read_mmc_stats(pdata);
48959
48960 s->rx_packets = pstats->rxframecount_gb;
48961 s->rx_bytes = pstats->rxoctetcount_gb;
48962@@ -1643,7 +1643,7 @@ static int xgbe_vlan_rx_add_vid(struct net_device *netdev, __be16 proto,
48963 u16 vid)
48964 {
48965 struct xgbe_prv_data *pdata = netdev_priv(netdev);
48966- struct xgbe_hw_if *hw_if = &pdata->hw_if;
48967+ struct xgbe_hw_if *hw_if = pdata->hw_if;
48968
48969 DBGPR("-->%s\n", __func__);
48970
48971@@ -1659,7 +1659,7 @@ static int xgbe_vlan_rx_kill_vid(struct net_device *netdev, __be16 proto,
48972 u16 vid)
48973 {
48974 struct xgbe_prv_data *pdata = netdev_priv(netdev);
48975- struct xgbe_hw_if *hw_if = &pdata->hw_if;
48976+ struct xgbe_hw_if *hw_if = pdata->hw_if;
48977
48978 DBGPR("-->%s\n", __func__);
48979
48980@@ -1725,7 +1725,7 @@ static int xgbe_set_features(struct net_device *netdev,
48981 netdev_features_t features)
48982 {
48983 struct xgbe_prv_data *pdata = netdev_priv(netdev);
48984- struct xgbe_hw_if *hw_if = &pdata->hw_if;
48985+ struct xgbe_hw_if *hw_if = pdata->hw_if;
48986 netdev_features_t rxhash, rxcsum, rxvlan, rxvlan_filter;
48987 int ret = 0;
48988
48989@@ -1791,8 +1791,8 @@ struct net_device_ops *xgbe_get_netdev_ops(void)
48990 static void xgbe_rx_refresh(struct xgbe_channel *channel)
48991 {
48992 struct xgbe_prv_data *pdata = channel->pdata;
48993- struct xgbe_hw_if *hw_if = &pdata->hw_if;
48994- struct xgbe_desc_if *desc_if = &pdata->desc_if;
48995+ struct xgbe_hw_if *hw_if = pdata->hw_if;
48996+ struct xgbe_desc_if *desc_if = pdata->desc_if;
48997 struct xgbe_ring *ring = channel->rx_ring;
48998 struct xgbe_ring_data *rdata;
48999
49000@@ -1847,8 +1847,8 @@ static struct sk_buff *xgbe_create_skb(struct napi_struct *napi,
49001 static int xgbe_tx_poll(struct xgbe_channel *channel)
49002 {
49003 struct xgbe_prv_data *pdata = channel->pdata;
49004- struct xgbe_hw_if *hw_if = &pdata->hw_if;
49005- struct xgbe_desc_if *desc_if = &pdata->desc_if;
49006+ struct xgbe_hw_if *hw_if = pdata->hw_if;
49007+ struct xgbe_desc_if *desc_if = pdata->desc_if;
49008 struct xgbe_ring *ring = channel->tx_ring;
49009 struct xgbe_ring_data *rdata;
49010 struct xgbe_ring_desc *rdesc;
49011@@ -1913,7 +1913,7 @@ static int xgbe_tx_poll(struct xgbe_channel *channel)
49012 static int xgbe_rx_poll(struct xgbe_channel *channel, int budget)
49013 {
49014 struct xgbe_prv_data *pdata = channel->pdata;
49015- struct xgbe_hw_if *hw_if = &pdata->hw_if;
49016+ struct xgbe_hw_if *hw_if = pdata->hw_if;
49017 struct xgbe_ring *ring = channel->rx_ring;
49018 struct xgbe_ring_data *rdata;
49019 struct xgbe_packet_data *packet;
49020diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c b/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
49021index 5f149e8..6736bf4 100644
49022--- a/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
49023+++ b/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
49024@@ -203,7 +203,7 @@ static void xgbe_get_ethtool_stats(struct net_device *netdev,
49025
49026 DBGPR("-->%s\n", __func__);
49027
49028- pdata->hw_if.read_mmc_stats(pdata);
49029+ pdata->hw_if->read_mmc_stats(pdata);
49030 for (i = 0; i < XGBE_STATS_COUNT; i++) {
49031 stat = (u8 *)pdata + xgbe_gstring_stats[i].stat_offset;
49032 *data++ = *(u64 *)stat;
49033@@ -396,7 +396,7 @@ static int xgbe_set_coalesce(struct net_device *netdev,
49034 struct ethtool_coalesce *ec)
49035 {
49036 struct xgbe_prv_data *pdata = netdev_priv(netdev);
49037- struct xgbe_hw_if *hw_if = &pdata->hw_if;
49038+ struct xgbe_hw_if *hw_if = pdata->hw_if;
49039 unsigned int rx_frames, rx_riwt, rx_usecs;
49040 unsigned int tx_frames;
49041
49042@@ -521,7 +521,7 @@ static int xgbe_set_rxfh(struct net_device *netdev, const u32 *indir,
49043 const u8 *key, const u8 hfunc)
49044 {
49045 struct xgbe_prv_data *pdata = netdev_priv(netdev);
49046- struct xgbe_hw_if *hw_if = &pdata->hw_if;
49047+ struct xgbe_hw_if *hw_if = pdata->hw_if;
49048 unsigned int ret;
49049
49050 if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP)
49051diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-main.c b/drivers/net/ethernet/amd/xgbe/xgbe-main.c
49052index 7149053..889c5492 100644
49053--- a/drivers/net/ethernet/amd/xgbe/xgbe-main.c
49054+++ b/drivers/net/ethernet/amd/xgbe/xgbe-main.c
49055@@ -159,12 +159,6 @@ static void xgbe_default_config(struct xgbe_prv_data *pdata)
49056 DBGPR("<--xgbe_default_config\n");
49057 }
49058
49059-static void xgbe_init_all_fptrs(struct xgbe_prv_data *pdata)
49060-{
49061- xgbe_init_function_ptrs_dev(&pdata->hw_if);
49062- xgbe_init_function_ptrs_desc(&pdata->desc_if);
49063-}
49064-
49065 #ifdef CONFIG_ACPI
49066 static int xgbe_acpi_support(struct xgbe_prv_data *pdata)
49067 {
49068@@ -387,9 +381,8 @@ static int xgbe_probe(struct platform_device *pdev)
49069 memcpy(netdev->dev_addr, pdata->mac_addr, netdev->addr_len);
49070
49071 /* Set all the function pointers */
49072- xgbe_init_all_fptrs(pdata);
49073- hw_if = &pdata->hw_if;
49074- desc_if = &pdata->desc_if;
49075+ hw_if = pdata->hw_if = &default_xgbe_hw_if;
49076+ desc_if = pdata->desc_if = &default_xgbe_desc_if;
49077
49078 /* Issue software reset to device */
49079 hw_if->exit(pdata);
49080diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c b/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c
49081index 59e267f..0842a88 100644
49082--- a/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c
49083+++ b/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c
49084@@ -126,7 +126,7 @@
49085 static int xgbe_mdio_read(struct mii_bus *mii, int prtad, int mmd_reg)
49086 {
49087 struct xgbe_prv_data *pdata = mii->priv;
49088- struct xgbe_hw_if *hw_if = &pdata->hw_if;
49089+ struct xgbe_hw_if *hw_if = pdata->hw_if;
49090 int mmd_data;
49091
49092 DBGPR_MDIO("-->xgbe_mdio_read: prtad=%#x mmd_reg=%#x\n",
49093@@ -143,7 +143,7 @@ static int xgbe_mdio_write(struct mii_bus *mii, int prtad, int mmd_reg,
49094 u16 mmd_val)
49095 {
49096 struct xgbe_prv_data *pdata = mii->priv;
49097- struct xgbe_hw_if *hw_if = &pdata->hw_if;
49098+ struct xgbe_hw_if *hw_if = pdata->hw_if;
49099 int mmd_data = mmd_val;
49100
49101 DBGPR_MDIO("-->xgbe_mdio_write: prtad=%#x mmd_reg=%#x mmd_data=%#x\n",
49102diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-ptp.c b/drivers/net/ethernet/amd/xgbe/xgbe-ptp.c
49103index b03e4f5..78e4cc4 100644
49104--- a/drivers/net/ethernet/amd/xgbe/xgbe-ptp.c
49105+++ b/drivers/net/ethernet/amd/xgbe/xgbe-ptp.c
49106@@ -129,7 +129,7 @@ static cycle_t xgbe_cc_read(const struct cyclecounter *cc)
49107 tstamp_cc);
49108 u64 nsec;
49109
49110- nsec = pdata->hw_if.get_tstamp_time(pdata);
49111+ nsec = pdata->hw_if->get_tstamp_time(pdata);
49112
49113 return nsec;
49114 }
49115@@ -158,7 +158,7 @@ static int xgbe_adjfreq(struct ptp_clock_info *info, s32 delta)
49116
49117 spin_lock_irqsave(&pdata->tstamp_lock, flags);
49118
49119- pdata->hw_if.update_tstamp_addend(pdata, addend);
49120+ pdata->hw_if->update_tstamp_addend(pdata, addend);
49121
49122 spin_unlock_irqrestore(&pdata->tstamp_lock, flags);
49123
49124diff --git a/drivers/net/ethernet/amd/xgbe/xgbe.h b/drivers/net/ethernet/amd/xgbe/xgbe.h
49125index e62dfa2..7df28d5 100644
49126--- a/drivers/net/ethernet/amd/xgbe/xgbe.h
49127+++ b/drivers/net/ethernet/amd/xgbe/xgbe.h
49128@@ -673,8 +673,8 @@ struct xgbe_prv_data {
49129 int dev_irq;
49130 unsigned int per_channel_irq;
49131
49132- struct xgbe_hw_if hw_if;
49133- struct xgbe_desc_if desc_if;
49134+ struct xgbe_hw_if *hw_if;
49135+ struct xgbe_desc_if *desc_if;
49136
49137 /* AXI DMA settings */
49138 unsigned int coherent;
49139@@ -797,6 +797,9 @@ struct xgbe_prv_data {
49140 #endif
49141 };
49142
49143+extern struct xgbe_hw_if default_xgbe_hw_if;
49144+extern struct xgbe_desc_if default_xgbe_desc_if;
49145+
49146 /* Function prototypes*/
49147
49148 void xgbe_init_function_ptrs_dev(struct xgbe_hw_if *);
49149diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
49150index 783543a..a472348 100644
49151--- a/drivers/net/ethernet/broadcom/bcmsysport.c
49152+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
49153@@ -1721,7 +1721,7 @@ static int bcm_sysport_probe(struct platform_device *pdev)
49154 macaddr = of_get_mac_address(dn);
49155 if (!macaddr || !is_valid_ether_addr(macaddr)) {
49156 dev_warn(&pdev->dev, "using random Ethernet MAC\n");
49157- random_ether_addr(dev->dev_addr);
49158+ eth_hw_addr_random(dev);
49159 } else {
49160 ether_addr_copy(dev->dev_addr, macaddr);
49161 }
49162diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
49163index d7a7175..7011194 100644
49164--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
49165+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
49166@@ -1065,7 +1065,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
49167 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
49168 {
49169 /* RX_MODE controlling object */
49170- bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
49171+ bnx2x_init_rx_mode_obj(bp);
49172
49173 /* multicast configuration controlling object */
49174 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
49175diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
49176index 07cdf9b..b08ecc7 100644
49177--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
49178+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
49179@@ -2329,15 +2329,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
49180 return rc;
49181 }
49182
49183-void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
49184- struct bnx2x_rx_mode_obj *o)
49185+void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
49186 {
49187 if (CHIP_IS_E1x(bp)) {
49188- o->wait_comp = bnx2x_empty_rx_mode_wait;
49189- o->config_rx_mode = bnx2x_set_rx_mode_e1x;
49190+ bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
49191+ bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
49192 } else {
49193- o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
49194- o->config_rx_mode = bnx2x_set_rx_mode_e2;
49195+ bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
49196+ bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
49197 }
49198 }
49199
49200diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
49201index 86baecb..ff3bb46 100644
49202--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
49203+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
49204@@ -1411,8 +1411,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
49205
49206 /********************* RX MODE ****************/
49207
49208-void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
49209- struct bnx2x_rx_mode_obj *o);
49210+void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
49211
49212 /**
49213 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
49214diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
49215index 31c9f82..e65e986 100644
49216--- a/drivers/net/ethernet/broadcom/tg3.h
49217+++ b/drivers/net/ethernet/broadcom/tg3.h
49218@@ -150,6 +150,7 @@
49219 #define CHIPREV_ID_5750_A0 0x4000
49220 #define CHIPREV_ID_5750_A1 0x4001
49221 #define CHIPREV_ID_5750_A3 0x4003
49222+#define CHIPREV_ID_5750_C1 0x4201
49223 #define CHIPREV_ID_5750_C2 0x4202
49224 #define CHIPREV_ID_5752_A0_HW 0x5000
49225 #define CHIPREV_ID_5752_A0 0x6000
49226diff --git a/drivers/net/ethernet/brocade/bna/bna_enet.c b/drivers/net/ethernet/brocade/bna/bna_enet.c
49227index deb8da6..45d473b 100644
49228--- a/drivers/net/ethernet/brocade/bna/bna_enet.c
49229+++ b/drivers/net/ethernet/brocade/bna/bna_enet.c
49230@@ -1694,10 +1694,10 @@ bna_cb_ioceth_reset(void *arg)
49231 }
49232
49233 static struct bfa_ioc_cbfn bna_ioceth_cbfn = {
49234- bna_cb_ioceth_enable,
49235- bna_cb_ioceth_disable,
49236- bna_cb_ioceth_hbfail,
49237- bna_cb_ioceth_reset
49238+ .enable_cbfn = bna_cb_ioceth_enable,
49239+ .disable_cbfn = bna_cb_ioceth_disable,
49240+ .hbfail_cbfn = bna_cb_ioceth_hbfail,
49241+ .reset_cbfn = bna_cb_ioceth_reset
49242 };
49243
49244 static void bna_attr_init(struct bna_ioceth *ioceth)
49245diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
49246index 8cffcdf..aadf043 100644
49247--- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
49248+++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
49249@@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
49250 */
49251 struct l2t_skb_cb {
49252 arp_failure_handler_func arp_failure_handler;
49253-};
49254+} __no_const;
49255
49256 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
49257
49258diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
49259index badff18..e15c4ec 100644
49260--- a/drivers/net/ethernet/dec/tulip/de4x5.c
49261+++ b/drivers/net/ethernet/dec/tulip/de4x5.c
49262@@ -5373,7 +5373,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
49263 for (i=0; i<ETH_ALEN; i++) {
49264 tmp.addr[i] = dev->dev_addr[i];
49265 }
49266- if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
49267+ if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
49268 break;
49269
49270 case DE4X5_SET_HWADDR: /* Set the hardware address */
49271@@ -5413,7 +5413,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
49272 spin_lock_irqsave(&lp->lock, flags);
49273 memcpy(&statbuf, &lp->pktStats, ioc->len);
49274 spin_unlock_irqrestore(&lp->lock, flags);
49275- if (copy_to_user(ioc->data, &statbuf, ioc->len))
49276+ if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
49277 return -EFAULT;
49278 break;
49279 }
49280diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
49281index e43cc8a..f1cf67c 100644
49282--- a/drivers/net/ethernet/emulex/benet/be_main.c
49283+++ b/drivers/net/ethernet/emulex/benet/be_main.c
49284@@ -539,7 +539,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
49285
49286 if (wrapped)
49287 newacc += 65536;
49288- ACCESS_ONCE(*acc) = newacc;
49289+ ACCESS_ONCE_RW(*acc) = newacc;
49290 }
49291
49292 static void populate_erx_stats(struct be_adapter *adapter,
49293diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
49294index 6d0c5d5..55be363 100644
49295--- a/drivers/net/ethernet/faraday/ftgmac100.c
49296+++ b/drivers/net/ethernet/faraday/ftgmac100.c
49297@@ -30,6 +30,8 @@
49298 #include <linux/netdevice.h>
49299 #include <linux/phy.h>
49300 #include <linux/platform_device.h>
49301+#include <linux/interrupt.h>
49302+#include <linux/irqreturn.h>
49303 #include <net/ip.h>
49304
49305 #include "ftgmac100.h"
49306diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
49307index dce5f7b..2433466 100644
49308--- a/drivers/net/ethernet/faraday/ftmac100.c
49309+++ b/drivers/net/ethernet/faraday/ftmac100.c
49310@@ -31,6 +31,8 @@
49311 #include <linux/module.h>
49312 #include <linux/netdevice.h>
49313 #include <linux/platform_device.h>
49314+#include <linux/interrupt.h>
49315+#include <linux/irqreturn.h>
49316
49317 #include "ftmac100.h"
49318
49319diff --git a/drivers/net/ethernet/intel/i40e/i40e_ptp.c b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
49320index a92b772..250fe69 100644
49321--- a/drivers/net/ethernet/intel/i40e/i40e_ptp.c
49322+++ b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
49323@@ -419,7 +419,7 @@ void i40e_ptp_set_increment(struct i40e_pf *pf)
49324 wr32(hw, I40E_PRTTSYN_INC_H, incval >> 32);
49325
49326 /* Update the base adjustement value. */
49327- ACCESS_ONCE(pf->ptp_base_adj) = incval;
49328+ ACCESS_ONCE_RW(pf->ptp_base_adj) = incval;
49329 smp_mb(); /* Force the above update. */
49330 }
49331
49332diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
49333index e5ba040..d47531c 100644
49334--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
49335+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
49336@@ -782,7 +782,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
49337 }
49338
49339 /* update the base incval used to calculate frequency adjustment */
49340- ACCESS_ONCE(adapter->base_incval) = incval;
49341+ ACCESS_ONCE_RW(adapter->base_incval) = incval;
49342 smp_mb();
49343
49344 /* need lock to prevent incorrect read while modifying cyclecounter */
49345diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
49346index 74d0389..086ac03 100644
49347--- a/drivers/net/ethernet/marvell/mvneta.c
49348+++ b/drivers/net/ethernet/marvell/mvneta.c
49349@@ -1462,7 +1462,7 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo,
49350 struct mvneta_rx_queue *rxq)
49351 {
49352 struct net_device *dev = pp->dev;
49353- int rx_done, rx_filled;
49354+ int rx_done;
49355 u32 rcvd_pkts = 0;
49356 u32 rcvd_bytes = 0;
49357
49358@@ -1473,7 +1473,6 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo,
49359 rx_todo = rx_done;
49360
49361 rx_done = 0;
49362- rx_filled = 0;
49363
49364 /* Fairness NAPI loop */
49365 while (rx_done < rx_todo) {
49366@@ -1484,7 +1483,6 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo,
49367 int rx_bytes, err;
49368
49369 rx_done++;
49370- rx_filled++;
49371 rx_status = rx_desc->status;
49372 rx_bytes = rx_desc->data_size - (ETH_FCS_LEN + MVNETA_MH_SIZE);
49373 data = (unsigned char *)rx_desc->buf_cookie;
49374@@ -1524,6 +1522,14 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo,
49375 continue;
49376 }
49377
49378+ /* Refill processing */
49379+ err = mvneta_rx_refill(pp, rx_desc);
49380+ if (err) {
49381+ netdev_err(dev, "Linux processing - Can't refill\n");
49382+ rxq->missed++;
49383+ goto err_drop_frame;
49384+ }
49385+
49386 skb = build_skb(data, pp->frag_size > PAGE_SIZE ? 0 : pp->frag_size);
49387 if (!skb)
49388 goto err_drop_frame;
49389@@ -1543,14 +1549,6 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo,
49390 mvneta_rx_csum(pp, rx_status, skb);
49391
49392 napi_gro_receive(&pp->napi, skb);
49393-
49394- /* Refill processing */
49395- err = mvneta_rx_refill(pp, rx_desc);
49396- if (err) {
49397- netdev_err(dev, "Linux processing - Can't refill\n");
49398- rxq->missed++;
49399- rx_filled--;
49400- }
49401 }
49402
49403 if (rcvd_pkts) {
49404@@ -1563,7 +1561,7 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo,
49405 }
49406
49407 /* Update rxq management counters */
49408- mvneta_rxq_desc_num_update(pp, rxq, rx_done, rx_filled);
49409+ mvneta_rxq_desc_num_update(pp, rxq, rx_done, rx_done);
49410
49411 return rx_done;
49412 }
49413diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
49414index c10d98f..72914c6 100644
49415--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
49416+++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
49417@@ -475,8 +475,8 @@ static bool mlx4_en_process_tx_cq(struct net_device *dev,
49418 wmb();
49419
49420 /* we want to dirty this cache line once */
49421- ACCESS_ONCE(ring->last_nr_txbb) = last_nr_txbb;
49422- ACCESS_ONCE(ring->cons) = ring_cons + txbbs_skipped;
49423+ ACCESS_ONCE_RW(ring->last_nr_txbb) = last_nr_txbb;
49424+ ACCESS_ONCE_RW(ring->cons) = ring_cons + txbbs_skipped;
49425
49426 netdev_tx_completed_queue(ring->tx_queue, packets, bytes);
49427
49428diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
49429index 6223930..975033d 100644
49430--- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
49431+++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
49432@@ -3457,7 +3457,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
49433 struct __vxge_hw_fifo *fifo;
49434 struct vxge_hw_fifo_config *config;
49435 u32 txdl_size, txdl_per_memblock;
49436- struct vxge_hw_mempool_cbs fifo_mp_callback;
49437+ static struct vxge_hw_mempool_cbs fifo_mp_callback = {
49438+ .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
49439+ };
49440+
49441 struct __vxge_hw_virtualpath *vpath;
49442
49443 if ((vp == NULL) || (attr == NULL)) {
49444@@ -3540,8 +3543,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
49445 goto exit;
49446 }
49447
49448- fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
49449-
49450 fifo->mempool =
49451 __vxge_hw_mempool_create(vpath->hldev,
49452 fifo->config->memblock_size,
49453diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
49454index 33669c2..674c39a 100644
49455--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
49456+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
49457@@ -1415,7 +1415,7 @@ static int qlcnic_83xx_copy_fw_file(struct qlcnic_adapter *adapter)
49458 if (fw->size & 0xF) {
49459 addr = dest + size;
49460 for (i = 0; i < (fw->size & 0xF); i++)
49461- data[i] = temp[size + i];
49462+ data[i] = ((u8 *)temp)[size + i];
49463 for (; i < 16; i++)
49464 data[i] = 0;
49465 ret = qlcnic_ms_mem_write128(adapter, addr,
49466@@ -2324,7 +2324,9 @@ int qlcnic_83xx_configure_opmode(struct qlcnic_adapter *adapter)
49467 max_tx_rings = QLCNIC_MAX_VNIC_TX_RINGS;
49468 } else if (ret == QLC_83XX_DEFAULT_OPMODE) {
49469 ahw->nic_mode = QLCNIC_DEFAULT_MODE;
49470- adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
49471+ pax_open_kernel();
49472+ *(void **)&adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
49473+ pax_close_kernel();
49474 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
49475 max_sds_rings = QLCNIC_MAX_SDS_RINGS;
49476 max_tx_rings = QLCNIC_MAX_TX_RINGS;
49477diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
49478index be7d7a6..a8983f8 100644
49479--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
49480+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
49481@@ -207,17 +207,23 @@ int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
49482 case QLCNIC_NON_PRIV_FUNC:
49483 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
49484 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
49485- nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
49486+ pax_open_kernel();
49487+ *(void **)&nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
49488+ pax_close_kernel();
49489 break;
49490 case QLCNIC_PRIV_FUNC:
49491 ahw->op_mode = QLCNIC_PRIV_FUNC;
49492 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
49493- nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
49494+ pax_open_kernel();
49495+ *(void **)&nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
49496+ pax_close_kernel();
49497 break;
49498 case QLCNIC_MGMT_FUNC:
49499 ahw->op_mode = QLCNIC_MGMT_FUNC;
49500 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
49501- nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
49502+ pax_open_kernel();
49503+ *(void **)&nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
49504+ pax_close_kernel();
49505 break;
49506 default:
49507 dev_err(&adapter->pdev->dev, "Invalid Virtual NIC opmode\n");
49508diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
49509index 332bb8a..e6adcd1 100644
49510--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
49511+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
49512@@ -1285,7 +1285,7 @@ flash_temp:
49513 int qlcnic_dump_fw(struct qlcnic_adapter *adapter)
49514 {
49515 struct qlcnic_fw_dump *fw_dump = &adapter->ahw->fw_dump;
49516- static const struct qlcnic_dump_operations *fw_dump_ops;
49517+ const struct qlcnic_dump_operations *fw_dump_ops;
49518 struct qlcnic_83xx_dump_template_hdr *hdr_83xx;
49519 u32 entry_offset, dump, no_entries, buf_offset = 0;
49520 int i, k, ops_cnt, ops_index, dump_size = 0;
49521diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
49522index 3df51fa..e9b517f 100644
49523--- a/drivers/net/ethernet/realtek/r8169.c
49524+++ b/drivers/net/ethernet/realtek/r8169.c
49525@@ -788,22 +788,22 @@ struct rtl8169_private {
49526 struct mdio_ops {
49527 void (*write)(struct rtl8169_private *, int, int);
49528 int (*read)(struct rtl8169_private *, int);
49529- } mdio_ops;
49530+ } __no_const mdio_ops;
49531
49532 struct pll_power_ops {
49533 void (*down)(struct rtl8169_private *);
49534 void (*up)(struct rtl8169_private *);
49535- } pll_power_ops;
49536+ } __no_const pll_power_ops;
49537
49538 struct jumbo_ops {
49539 void (*enable)(struct rtl8169_private *);
49540 void (*disable)(struct rtl8169_private *);
49541- } jumbo_ops;
49542+ } __no_const jumbo_ops;
49543
49544 struct csi_ops {
49545 void (*write)(struct rtl8169_private *, int, int);
49546 u32 (*read)(struct rtl8169_private *, int);
49547- } csi_ops;
49548+ } __no_const csi_ops;
49549
49550 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
49551 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
49552diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
49553index a2e9aee..af41a0e 100644
49554--- a/drivers/net/ethernet/sfc/ptp.c
49555+++ b/drivers/net/ethernet/sfc/ptp.c
49556@@ -822,7 +822,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
49557 ptp->start.dma_addr);
49558
49559 /* Clear flag that signals MC ready */
49560- ACCESS_ONCE(*start) = 0;
49561+ ACCESS_ONCE_RW(*start) = 0;
49562 rc = efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
49563 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
49564 EFX_BUG_ON_PARANOID(rc);
49565diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
49566index 08c483b..2c4a553 100644
49567--- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
49568+++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
49569@@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
49570
49571 writel(value, ioaddr + MMC_CNTRL);
49572
49573- pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
49574- MMC_CNTRL, value);
49575+// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
49576+// MMC_CNTRL, value);
49577 }
49578
49579 /* To mask all all interrupts.*/
49580diff --git a/drivers/net/ethernet/via/via-rhine.c b/drivers/net/ethernet/via/via-rhine.c
49581index de28504..7f1c1cd 100644
49582--- a/drivers/net/ethernet/via/via-rhine.c
49583+++ b/drivers/net/ethernet/via/via-rhine.c
49584@@ -2525,7 +2525,7 @@ static struct platform_driver rhine_driver_platform = {
49585 }
49586 };
49587
49588-static struct dmi_system_id rhine_dmi_table[] __initdata = {
49589+static const struct dmi_system_id rhine_dmi_table[] __initconst = {
49590 {
49591 .ident = "EPIA-M",
49592 .matches = {
49593diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
49594index 41071d3..6e362e1 100644
49595--- a/drivers/net/hyperv/hyperv_net.h
49596+++ b/drivers/net/hyperv/hyperv_net.h
49597@@ -176,7 +176,7 @@ struct rndis_device {
49598 enum rndis_device_state state;
49599 bool link_state;
49600 bool link_change;
49601- atomic_t new_req_id;
49602+ atomic_unchecked_t new_req_id;
49603
49604 spinlock_t request_lock;
49605 struct list_head req_list;
49606diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
49607index 9118cea..1a8e06a 100644
49608--- a/drivers/net/hyperv/rndis_filter.c
49609+++ b/drivers/net/hyperv/rndis_filter.c
49610@@ -100,7 +100,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
49611 * template
49612 */
49613 set = &rndis_msg->msg.set_req;
49614- set->req_id = atomic_inc_return(&dev->new_req_id);
49615+ set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
49616
49617 /* Add to the request list */
49618 spin_lock_irqsave(&dev->request_lock, flags);
49619@@ -923,7 +923,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
49620
49621 /* Setup the rndis set */
49622 halt = &request->request_msg.msg.halt_req;
49623- halt->req_id = atomic_inc_return(&dev->new_req_id);
49624+ halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
49625
49626 /* Ignore return since this msg is optional. */
49627 rndis_filter_send_request(dev, request);
49628diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c
49629index 94570aa..1a798e1 100644
49630--- a/drivers/net/ifb.c
49631+++ b/drivers/net/ifb.c
49632@@ -253,7 +253,7 @@ static int ifb_validate(struct nlattr *tb[], struct nlattr *data[])
49633 return 0;
49634 }
49635
49636-static struct rtnl_link_ops ifb_link_ops __read_mostly = {
49637+static struct rtnl_link_ops ifb_link_ops = {
49638 .kind = "ifb",
49639 .priv_size = sizeof(struct ifb_private),
49640 .setup = ifb_setup,
49641diff --git a/drivers/net/ipvlan/ipvlan.h b/drivers/net/ipvlan/ipvlan.h
49642index 54549a6..0799442 100644
49643--- a/drivers/net/ipvlan/ipvlan.h
49644+++ b/drivers/net/ipvlan/ipvlan.h
49645@@ -102,6 +102,11 @@ static inline struct ipvl_port *ipvlan_port_get_rcu(const struct net_device *d)
49646 return rcu_dereference(d->rx_handler_data);
49647 }
49648
49649+static inline struct ipvl_port *ipvlan_port_get_rcu_bh(const struct net_device *d)
49650+{
49651+ return rcu_dereference_bh(d->rx_handler_data);
49652+}
49653+
49654 static inline struct ipvl_port *ipvlan_port_get_rtnl(const struct net_device *d)
49655 {
49656 return rtnl_dereference(d->rx_handler_data);
49657diff --git a/drivers/net/ipvlan/ipvlan_core.c b/drivers/net/ipvlan/ipvlan_core.c
49658index c30b5c3..b349dad 100644
49659--- a/drivers/net/ipvlan/ipvlan_core.c
49660+++ b/drivers/net/ipvlan/ipvlan_core.c
49661@@ -507,7 +507,7 @@ static int ipvlan_xmit_mode_l2(struct sk_buff *skb, struct net_device *dev)
49662 int ipvlan_queue_xmit(struct sk_buff *skb, struct net_device *dev)
49663 {
49664 struct ipvl_dev *ipvlan = netdev_priv(dev);
49665- struct ipvl_port *port = ipvlan_port_get_rcu(ipvlan->phy_dev);
49666+ struct ipvl_port *port = ipvlan_port_get_rcu_bh(ipvlan->phy_dev);
49667
49668 if (!port)
49669 goto out;
49670diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
49671index 9f59f17..52cb38f 100644
49672--- a/drivers/net/macvlan.c
49673+++ b/drivers/net/macvlan.c
49674@@ -335,7 +335,7 @@ static void macvlan_broadcast_enqueue(struct macvlan_port *port,
49675 free_nskb:
49676 kfree_skb(nskb);
49677 err:
49678- atomic_long_inc(&skb->dev->rx_dropped);
49679+ atomic_long_inc_unchecked(&skb->dev->rx_dropped);
49680 }
49681
49682 static void macvlan_flush_sources(struct macvlan_port *port,
49683@@ -1480,13 +1480,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
49684 int macvlan_link_register(struct rtnl_link_ops *ops)
49685 {
49686 /* common fields */
49687- ops->priv_size = sizeof(struct macvlan_dev);
49688- ops->validate = macvlan_validate;
49689- ops->maxtype = IFLA_MACVLAN_MAX;
49690- ops->policy = macvlan_policy;
49691- ops->changelink = macvlan_changelink;
49692- ops->get_size = macvlan_get_size;
49693- ops->fill_info = macvlan_fill_info;
49694+ pax_open_kernel();
49695+ *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
49696+ *(void **)&ops->validate = macvlan_validate;
49697+ *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
49698+ *(const void **)&ops->policy = macvlan_policy;
49699+ *(void **)&ops->changelink = macvlan_changelink;
49700+ *(void **)&ops->get_size = macvlan_get_size;
49701+ *(void **)&ops->fill_info = macvlan_fill_info;
49702+ pax_close_kernel();
49703
49704 return rtnl_link_register(ops);
49705 };
49706@@ -1572,7 +1574,7 @@ static int macvlan_device_event(struct notifier_block *unused,
49707 return NOTIFY_DONE;
49708 }
49709
49710-static struct notifier_block macvlan_notifier_block __read_mostly = {
49711+static struct notifier_block macvlan_notifier_block = {
49712 .notifier_call = macvlan_device_event,
49713 };
49714
49715diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
49716index 8c350c5..30fdc98 100644
49717--- a/drivers/net/macvtap.c
49718+++ b/drivers/net/macvtap.c
49719@@ -436,7 +436,7 @@ static void macvtap_setup(struct net_device *dev)
49720 dev->tx_queue_len = TUN_READQ_SIZE;
49721 }
49722
49723-static struct rtnl_link_ops macvtap_link_ops __read_mostly = {
49724+static struct rtnl_link_ops macvtap_link_ops = {
49725 .kind = "macvtap",
49726 .setup = macvtap_setup,
49727 .newlink = macvtap_newlink,
49728@@ -1033,7 +1033,7 @@ static long macvtap_ioctl(struct file *file, unsigned int cmd,
49729
49730 ret = 0;
49731 u = q->flags;
49732- if (copy_to_user(&ifr->ifr_name, vlan->dev->name, IFNAMSIZ) ||
49733+ if (copy_to_user(ifr->ifr_name, vlan->dev->name, IFNAMSIZ) ||
49734 put_user(u, &ifr->ifr_flags))
49735 ret = -EFAULT;
49736 macvtap_put_vlan(vlan);
49737@@ -1214,7 +1214,7 @@ static int macvtap_device_event(struct notifier_block *unused,
49738 return NOTIFY_DONE;
49739 }
49740
49741-static struct notifier_block macvtap_notifier_block __read_mostly = {
49742+static struct notifier_block macvtap_notifier_block = {
49743 .notifier_call = macvtap_device_event,
49744 };
49745
49746@@ -1268,6 +1268,7 @@ static void macvtap_exit(void)
49747 class_unregister(macvtap_class);
49748 cdev_del(&macvtap_cdev);
49749 unregister_chrdev_region(macvtap_major, MACVTAP_NUM_DEVS);
49750+ idr_destroy(&minor_idr);
49751 }
49752 module_exit(macvtap_exit);
49753
49754diff --git a/drivers/net/nlmon.c b/drivers/net/nlmon.c
49755index 34924df..a747360 100644
49756--- a/drivers/net/nlmon.c
49757+++ b/drivers/net/nlmon.c
49758@@ -154,7 +154,7 @@ static int nlmon_validate(struct nlattr *tb[], struct nlattr *data[])
49759 return 0;
49760 }
49761
49762-static struct rtnl_link_ops nlmon_link_ops __read_mostly = {
49763+static struct rtnl_link_ops nlmon_link_ops = {
49764 .kind = "nlmon",
49765 .priv_size = sizeof(struct nlmon),
49766 .setup = nlmon_setup,
49767diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
49768index d551df6..fa4c2df 100644
49769--- a/drivers/net/phy/phy_device.c
49770+++ b/drivers/net/phy/phy_device.c
49771@@ -218,7 +218,7 @@ EXPORT_SYMBOL(phy_device_create);
49772 * zero on success.
49773 *
49774 */
49775-static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id,
49776+static int get_phy_c45_ids(struct mii_bus *bus, int addr, int *phy_id,
49777 struct phy_c45_device_ids *c45_ids) {
49778 int phy_reg;
49779 int i, reg_addr;
49780@@ -288,7 +288,7 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id,
49781 * its return value is in turn returned.
49782 *
49783 */
49784-static int get_phy_id(struct mii_bus *bus, int addr, u32 *phy_id,
49785+static int get_phy_id(struct mii_bus *bus, int addr, int *phy_id,
49786 bool is_c45, struct phy_c45_device_ids *c45_ids)
49787 {
49788 int phy_reg;
49789@@ -326,7 +326,7 @@ static int get_phy_id(struct mii_bus *bus, int addr, u32 *phy_id,
49790 struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45)
49791 {
49792 struct phy_c45_device_ids c45_ids = {0};
49793- u32 phy_id = 0;
49794+ int phy_id = 0;
49795 int r;
49796
49797 r = get_phy_id(bus, addr, &phy_id, is_c45, &c45_ids);
49798diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
49799index 9d15566..5ad4ef6 100644
49800--- a/drivers/net/ppp/ppp_generic.c
49801+++ b/drivers/net/ppp/ppp_generic.c
49802@@ -1022,7 +1022,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
49803 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
49804 struct ppp_stats stats;
49805 struct ppp_comp_stats cstats;
49806- char *vers;
49807
49808 switch (cmd) {
49809 case SIOCGPPPSTATS:
49810@@ -1044,8 +1043,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
49811 break;
49812
49813 case SIOCGPPPVER:
49814- vers = PPP_VERSION;
49815- if (copy_to_user(addr, vers, strlen(vers) + 1))
49816+ if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
49817 break;
49818 err = 0;
49819 break;
49820diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
49821index 079f7ad..b2a2bfa7 100644
49822--- a/drivers/net/slip/slhc.c
49823+++ b/drivers/net/slip/slhc.c
49824@@ -487,7 +487,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
49825 register struct tcphdr *thp;
49826 register struct iphdr *ip;
49827 register struct cstate *cs;
49828- int len, hdrlen;
49829+ long len, hdrlen;
49830 unsigned char *cp = icp;
49831
49832 /* We've got a compressed packet; read the change byte */
49833diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
49834index 6928448..e30c57f 100644
49835--- a/drivers/net/team/team.c
49836+++ b/drivers/net/team/team.c
49837@@ -2103,7 +2103,7 @@ static unsigned int team_get_num_rx_queues(void)
49838 return TEAM_DEFAULT_NUM_RX_QUEUES;
49839 }
49840
49841-static struct rtnl_link_ops team_link_ops __read_mostly = {
49842+static struct rtnl_link_ops team_link_ops = {
49843 .kind = DRV_NAME,
49844 .priv_size = sizeof(struct team),
49845 .setup = team_setup,
49846@@ -2893,7 +2893,7 @@ static int team_device_event(struct notifier_block *unused,
49847 return NOTIFY_DONE;
49848 }
49849
49850-static struct notifier_block team_notifier_block __read_mostly = {
49851+static struct notifier_block team_notifier_block = {
49852 .notifier_call = team_device_event,
49853 };
49854
49855diff --git a/drivers/net/tun.c b/drivers/net/tun.c
49856index e470ae5..e812f5e 100644
49857--- a/drivers/net/tun.c
49858+++ b/drivers/net/tun.c
49859@@ -1421,7 +1421,7 @@ static int tun_validate(struct nlattr *tb[], struct nlattr *data[])
49860 return -EINVAL;
49861 }
49862
49863-static struct rtnl_link_ops tun_link_ops __read_mostly = {
49864+static struct rtnl_link_ops tun_link_ops = {
49865 .kind = DRV_NAME,
49866 .priv_size = sizeof(struct tun_struct),
49867 .setup = tun_setup,
49868@@ -1828,7 +1828,7 @@ unlock:
49869 }
49870
49871 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
49872- unsigned long arg, int ifreq_len)
49873+ unsigned long arg, size_t ifreq_len)
49874 {
49875 struct tun_file *tfile = file->private_data;
49876 struct tun_struct *tun;
49877@@ -1842,6 +1842,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
49878 int le;
49879 int ret;
49880
49881+ if (ifreq_len > sizeof ifr)
49882+ return -EFAULT;
49883+
49884 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
49885 if (copy_from_user(&ifr, argp, ifreq_len))
49886 return -EFAULT;
49887diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
49888index 111d907..1ee643e 100644
49889--- a/drivers/net/usb/hso.c
49890+++ b/drivers/net/usb/hso.c
49891@@ -70,7 +70,7 @@
49892 #include <asm/byteorder.h>
49893 #include <linux/serial_core.h>
49894 #include <linux/serial.h>
49895-
49896+#include <asm/local.h>
49897
49898 #define MOD_AUTHOR "Option Wireless"
49899 #define MOD_DESCRIPTION "USB High Speed Option driver"
49900@@ -1183,7 +1183,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
49901 struct urb *urb;
49902
49903 urb = serial->rx_urb[0];
49904- if (serial->port.count > 0) {
49905+ if (atomic_read(&serial->port.count) > 0) {
49906 count = put_rxbuf_data(urb, serial);
49907 if (count == -1)
49908 return;
49909@@ -1221,7 +1221,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
49910 DUMP1(urb->transfer_buffer, urb->actual_length);
49911
49912 /* Anyone listening? */
49913- if (serial->port.count == 0)
49914+ if (atomic_read(&serial->port.count) == 0)
49915 return;
49916
49917 if (serial->parent->port_spec & HSO_INFO_CRC_BUG)
49918@@ -1282,8 +1282,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
49919 tty_port_tty_set(&serial->port, tty);
49920
49921 /* check for port already opened, if not set the termios */
49922- serial->port.count++;
49923- if (serial->port.count == 1) {
49924+ if (atomic_inc_return(&serial->port.count) == 1) {
49925 serial->rx_state = RX_IDLE;
49926 /* Force default termio settings */
49927 _hso_serial_set_termios(tty, NULL);
49928@@ -1293,7 +1292,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
49929 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
49930 if (result) {
49931 hso_stop_serial_device(serial->parent);
49932- serial->port.count--;
49933+ atomic_dec(&serial->port.count);
49934 } else {
49935 kref_get(&serial->parent->ref);
49936 }
49937@@ -1331,10 +1330,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
49938
49939 /* reset the rts and dtr */
49940 /* do the actual close */
49941- serial->port.count--;
49942+ atomic_dec(&serial->port.count);
49943
49944- if (serial->port.count <= 0) {
49945- serial->port.count = 0;
49946+ if (atomic_read(&serial->port.count) <= 0) {
49947+ atomic_set(&serial->port.count, 0);
49948 tty_port_tty_set(&serial->port, NULL);
49949 if (!usb_gone)
49950 hso_stop_serial_device(serial->parent);
49951@@ -1417,7 +1416,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
49952
49953 /* the actual setup */
49954 spin_lock_irqsave(&serial->serial_lock, flags);
49955- if (serial->port.count)
49956+ if (atomic_read(&serial->port.count))
49957 _hso_serial_set_termios(tty, old);
49958 else
49959 tty->termios = *old;
49960@@ -1891,7 +1890,7 @@ static void intr_callback(struct urb *urb)
49961 D1("Pending read interrupt on port %d\n", i);
49962 spin_lock(&serial->serial_lock);
49963 if (serial->rx_state == RX_IDLE &&
49964- serial->port.count > 0) {
49965+ atomic_read(&serial->port.count) > 0) {
49966 /* Setup and send a ctrl req read on
49967 * port i */
49968 if (!serial->rx_urb_filled[0]) {
49969@@ -3058,7 +3057,7 @@ static int hso_resume(struct usb_interface *iface)
49970 /* Start all serial ports */
49971 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
49972 if (serial_table[i] && (serial_table[i]->interface == iface)) {
49973- if (dev2ser(serial_table[i])->port.count) {
49974+ if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
49975 result =
49976 hso_start_serial_device(serial_table[i], GFP_NOIO);
49977 hso_kick_transmit(dev2ser(serial_table[i]));
49978diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
49979index aafa1a1..f59c651 100644
49980--- a/drivers/net/usb/r8152.c
49981+++ b/drivers/net/usb/r8152.c
49982@@ -602,7 +602,7 @@ struct r8152 {
49983 void (*unload)(struct r8152 *);
49984 int (*eee_get)(struct r8152 *, struct ethtool_eee *);
49985 int (*eee_set)(struct r8152 *, struct ethtool_eee *);
49986- } rtl_ops;
49987+ } __no_const rtl_ops;
49988
49989 int intr_interval;
49990 u32 saved_wolopts;
49991diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
49992index a2515887..6d13233 100644
49993--- a/drivers/net/usb/sierra_net.c
49994+++ b/drivers/net/usb/sierra_net.c
49995@@ -51,7 +51,7 @@ static const char driver_name[] = "sierra_net";
49996 /* atomic counter partially included in MAC address to make sure 2 devices
49997 * do not end up with the same MAC - concept breaks in case of > 255 ifaces
49998 */
49999-static atomic_t iface_counter = ATOMIC_INIT(0);
50000+static atomic_unchecked_t iface_counter = ATOMIC_INIT(0);
50001
50002 /*
50003 * SYNC Timer Delay definition used to set the expiry time
50004@@ -697,7 +697,7 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
50005 dev->net->netdev_ops = &sierra_net_device_ops;
50006
50007 /* change MAC addr to include, ifacenum, and to be unique */
50008- dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return(&iface_counter);
50009+ dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return_unchecked(&iface_counter);
50010 dev->net->dev_addr[ETH_ALEN-1] = ifacenum;
50011
50012 /* we will have to manufacture ethernet headers, prepare template */
50013diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
50014index 63c7810..4ad33aa 100644
50015--- a/drivers/net/virtio_net.c
50016+++ b/drivers/net/virtio_net.c
50017@@ -48,7 +48,7 @@ module_param(gso, bool, 0444);
50018 #define RECEIVE_AVG_WEIGHT 64
50019
50020 /* Minimum alignment for mergeable packet buffers. */
50021-#define MERGEABLE_BUFFER_ALIGN max(L1_CACHE_BYTES, 256)
50022+#define MERGEABLE_BUFFER_ALIGN max(L1_CACHE_BYTES, 256UL)
50023
50024 #define VIRTNET_DRIVER_VERSION "1.0.0"
50025
50026diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
50027index 61c0840..92e7f7e 100644
50028--- a/drivers/net/vmxnet3/vmxnet3_drv.c
50029+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
50030@@ -1167,7 +1167,7 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
50031 static const u32 rxprod_reg[2] = {
50032 VMXNET3_REG_RXPROD, VMXNET3_REG_RXPROD2
50033 };
50034- u32 num_rxd = 0;
50035+ u32 num_pkts = 0;
50036 bool skip_page_frags = false;
50037 struct Vmxnet3_RxCompDesc *rcd;
50038 struct vmxnet3_rx_ctx *ctx = &rq->rx_ctx;
50039@@ -1185,13 +1185,12 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
50040 struct Vmxnet3_RxDesc *rxd;
50041 u32 idx, ring_idx;
50042 struct vmxnet3_cmd_ring *ring = NULL;
50043- if (num_rxd >= quota) {
50044+ if (num_pkts >= quota) {
50045 /* we may stop even before we see the EOP desc of
50046 * the current pkt
50047 */
50048 break;
50049 }
50050- num_rxd++;
50051 BUG_ON(rcd->rqID != rq->qid && rcd->rqID != rq->qid2);
50052 idx = rcd->rxdIdx;
50053 ring_idx = rcd->rqID < adapter->num_rx_queues ? 0 : 1;
50054@@ -1323,6 +1322,7 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
50055 napi_gro_receive(&rq->napi, skb);
50056
50057 ctx->skb = NULL;
50058+ num_pkts++;
50059 }
50060
50061 rcd_done:
50062@@ -1353,7 +1353,7 @@ rcd_done:
50063 &rq->comp_ring.base[rq->comp_ring.next2proc].rcd, &rxComp);
50064 }
50065
50066- return num_rxd;
50067+ return num_pkts;
50068 }
50069
50070
50071diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
50072index 21a0fbf..055b54f 100644
50073--- a/drivers/net/vxlan.c
50074+++ b/drivers/net/vxlan.c
50075@@ -2878,7 +2878,7 @@ static struct net *vxlan_get_link_net(const struct net_device *dev)
50076 return vxlan->net;
50077 }
50078
50079-static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
50080+static struct rtnl_link_ops vxlan_link_ops = {
50081 .kind = "vxlan",
50082 .maxtype = IFLA_VXLAN_MAX,
50083 .policy = vxlan_policy,
50084@@ -2926,7 +2926,7 @@ static int vxlan_lowerdev_event(struct notifier_block *unused,
50085 return NOTIFY_DONE;
50086 }
50087
50088-static struct notifier_block vxlan_notifier_block __read_mostly = {
50089+static struct notifier_block vxlan_notifier_block = {
50090 .notifier_call = vxlan_lowerdev_event,
50091 };
50092
50093diff --git a/drivers/net/wan/lmc/lmc_media.c b/drivers/net/wan/lmc/lmc_media.c
50094index 5920c99..ff2e4a5 100644
50095--- a/drivers/net/wan/lmc/lmc_media.c
50096+++ b/drivers/net/wan/lmc/lmc_media.c
50097@@ -95,62 +95,63 @@ static inline void write_av9110_bit (lmc_softc_t *, int);
50098 static void write_av9110(lmc_softc_t *, u32, u32, u32, u32, u32);
50099
50100 lmc_media_t lmc_ds3_media = {
50101- lmc_ds3_init, /* special media init stuff */
50102- lmc_ds3_default, /* reset to default state */
50103- lmc_ds3_set_status, /* reset status to state provided */
50104- lmc_dummy_set_1, /* set clock source */
50105- lmc_dummy_set2_1, /* set line speed */
50106- lmc_ds3_set_100ft, /* set cable length */
50107- lmc_ds3_set_scram, /* set scrambler */
50108- lmc_ds3_get_link_status, /* get link status */
50109- lmc_dummy_set_1, /* set link status */
50110- lmc_ds3_set_crc_length, /* set CRC length */
50111- lmc_dummy_set_1, /* set T1 or E1 circuit type */
50112- lmc_ds3_watchdog
50113+ .init = lmc_ds3_init, /* special media init stuff */
50114+ .defaults = lmc_ds3_default, /* reset to default state */
50115+ .set_status = lmc_ds3_set_status, /* reset status to state provided */
50116+ .set_clock_source = lmc_dummy_set_1, /* set clock source */
50117+ .set_speed = lmc_dummy_set2_1, /* set line speed */
50118+ .set_cable_length = lmc_ds3_set_100ft, /* set cable length */
50119+ .set_scrambler = lmc_ds3_set_scram, /* set scrambler */
50120+ .get_link_status = lmc_ds3_get_link_status, /* get link status */
50121+ .set_link_status = lmc_dummy_set_1, /* set link status */
50122+ .set_crc_length = lmc_ds3_set_crc_length, /* set CRC length */
50123+ .set_circuit_type = lmc_dummy_set_1, /* set T1 or E1 circuit type */
50124+ .watchdog = lmc_ds3_watchdog
50125 };
50126
50127 lmc_media_t lmc_hssi_media = {
50128- lmc_hssi_init, /* special media init stuff */
50129- lmc_hssi_default, /* reset to default state */
50130- lmc_hssi_set_status, /* reset status to state provided */
50131- lmc_hssi_set_clock, /* set clock source */
50132- lmc_dummy_set2_1, /* set line speed */
50133- lmc_dummy_set_1, /* set cable length */
50134- lmc_dummy_set_1, /* set scrambler */
50135- lmc_hssi_get_link_status, /* get link status */
50136- lmc_hssi_set_link_status, /* set link status */
50137- lmc_hssi_set_crc_length, /* set CRC length */
50138- lmc_dummy_set_1, /* set T1 or E1 circuit type */
50139- lmc_hssi_watchdog
50140+ .init = lmc_hssi_init, /* special media init stuff */
50141+ .defaults = lmc_hssi_default, /* reset to default state */
50142+ .set_status = lmc_hssi_set_status, /* reset status to state provided */
50143+ .set_clock_source = lmc_hssi_set_clock, /* set clock source */
50144+ .set_speed = lmc_dummy_set2_1, /* set line speed */
50145+ .set_cable_length = lmc_dummy_set_1, /* set cable length */
50146+ .set_scrambler = lmc_dummy_set_1, /* set scrambler */
50147+ .get_link_status = lmc_hssi_get_link_status, /* get link status */
50148+ .set_link_status = lmc_hssi_set_link_status, /* set link status */
50149+ .set_crc_length = lmc_hssi_set_crc_length, /* set CRC length */
50150+ .set_circuit_type = lmc_dummy_set_1, /* set T1 or E1 circuit type */
50151+ .watchdog = lmc_hssi_watchdog
50152 };
50153
50154-lmc_media_t lmc_ssi_media = { lmc_ssi_init, /* special media init stuff */
50155- lmc_ssi_default, /* reset to default state */
50156- lmc_ssi_set_status, /* reset status to state provided */
50157- lmc_ssi_set_clock, /* set clock source */
50158- lmc_ssi_set_speed, /* set line speed */
50159- lmc_dummy_set_1, /* set cable length */
50160- lmc_dummy_set_1, /* set scrambler */
50161- lmc_ssi_get_link_status, /* get link status */
50162- lmc_ssi_set_link_status, /* set link status */
50163- lmc_ssi_set_crc_length, /* set CRC length */
50164- lmc_dummy_set_1, /* set T1 or E1 circuit type */
50165- lmc_ssi_watchdog
50166+lmc_media_t lmc_ssi_media = {
50167+ .init = lmc_ssi_init, /* special media init stuff */
50168+ .defaults = lmc_ssi_default, /* reset to default state */
50169+ .set_status = lmc_ssi_set_status, /* reset status to state provided */
50170+ .set_clock_source = lmc_ssi_set_clock, /* set clock source */
50171+ .set_speed = lmc_ssi_set_speed, /* set line speed */
50172+ .set_cable_length = lmc_dummy_set_1, /* set cable length */
50173+ .set_scrambler = lmc_dummy_set_1, /* set scrambler */
50174+ .get_link_status = lmc_ssi_get_link_status, /* get link status */
50175+ .set_link_status = lmc_ssi_set_link_status, /* set link status */
50176+ .set_crc_length = lmc_ssi_set_crc_length, /* set CRC length */
50177+ .set_circuit_type = lmc_dummy_set_1, /* set T1 or E1 circuit type */
50178+ .watchdog = lmc_ssi_watchdog
50179 };
50180
50181 lmc_media_t lmc_t1_media = {
50182- lmc_t1_init, /* special media init stuff */
50183- lmc_t1_default, /* reset to default state */
50184- lmc_t1_set_status, /* reset status to state provided */
50185- lmc_t1_set_clock, /* set clock source */
50186- lmc_dummy_set2_1, /* set line speed */
50187- lmc_dummy_set_1, /* set cable length */
50188- lmc_dummy_set_1, /* set scrambler */
50189- lmc_t1_get_link_status, /* get link status */
50190- lmc_dummy_set_1, /* set link status */
50191- lmc_t1_set_crc_length, /* set CRC length */
50192- lmc_t1_set_circuit_type, /* set T1 or E1 circuit type */
50193- lmc_t1_watchdog
50194+ .init = lmc_t1_init, /* special media init stuff */
50195+ .defaults = lmc_t1_default, /* reset to default state */
50196+ .set_status = lmc_t1_set_status, /* reset status to state provided */
50197+ .set_clock_source = lmc_t1_set_clock, /* set clock source */
50198+ .set_speed = lmc_dummy_set2_1, /* set line speed */
50199+ .set_cable_length = lmc_dummy_set_1, /* set cable length */
50200+ .set_scrambler = lmc_dummy_set_1, /* set scrambler */
50201+ .get_link_status = lmc_t1_get_link_status, /* get link status */
50202+ .set_link_status = lmc_dummy_set_1, /* set link status */
50203+ .set_crc_length = lmc_t1_set_crc_length, /* set CRC length */
50204+ .set_circuit_type = lmc_t1_set_circuit_type, /* set T1 or E1 circuit type */
50205+ .watchdog = lmc_t1_watchdog
50206 };
50207
50208 static void
50209diff --git a/drivers/net/wan/z85230.c b/drivers/net/wan/z85230.c
50210index feacc3b..5bac0de 100644
50211--- a/drivers/net/wan/z85230.c
50212+++ b/drivers/net/wan/z85230.c
50213@@ -485,9 +485,9 @@ static void z8530_status(struct z8530_channel *chan)
50214
50215 struct z8530_irqhandler z8530_sync =
50216 {
50217- z8530_rx,
50218- z8530_tx,
50219- z8530_status
50220+ .rx = z8530_rx,
50221+ .tx = z8530_tx,
50222+ .status = z8530_status
50223 };
50224
50225 EXPORT_SYMBOL(z8530_sync);
50226@@ -605,15 +605,15 @@ static void z8530_dma_status(struct z8530_channel *chan)
50227 }
50228
50229 static struct z8530_irqhandler z8530_dma_sync = {
50230- z8530_dma_rx,
50231- z8530_dma_tx,
50232- z8530_dma_status
50233+ .rx = z8530_dma_rx,
50234+ .tx = z8530_dma_tx,
50235+ .status = z8530_dma_status
50236 };
50237
50238 static struct z8530_irqhandler z8530_txdma_sync = {
50239- z8530_rx,
50240- z8530_dma_tx,
50241- z8530_dma_status
50242+ .rx = z8530_rx,
50243+ .tx = z8530_dma_tx,
50244+ .status = z8530_dma_status
50245 };
50246
50247 /**
50248@@ -680,9 +680,9 @@ static void z8530_status_clear(struct z8530_channel *chan)
50249
50250 struct z8530_irqhandler z8530_nop=
50251 {
50252- z8530_rx_clear,
50253- z8530_tx_clear,
50254- z8530_status_clear
50255+ .rx = z8530_rx_clear,
50256+ .tx = z8530_tx_clear,
50257+ .status = z8530_status_clear
50258 };
50259
50260
50261diff --git a/drivers/net/wimax/i2400m/rx.c b/drivers/net/wimax/i2400m/rx.c
50262index 0b60295..b8bfa5b 100644
50263--- a/drivers/net/wimax/i2400m/rx.c
50264+++ b/drivers/net/wimax/i2400m/rx.c
50265@@ -1359,7 +1359,7 @@ int i2400m_rx_setup(struct i2400m *i2400m)
50266 if (i2400m->rx_roq == NULL)
50267 goto error_roq_alloc;
50268
50269- rd = kcalloc(I2400M_RO_CIN + 1, sizeof(*i2400m->rx_roq[0].log),
50270+ rd = kcalloc(sizeof(*i2400m->rx_roq[0].log), I2400M_RO_CIN + 1,
50271 GFP_KERNEL);
50272 if (rd == NULL) {
50273 result = -ENOMEM;
50274diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
50275index d0c97c2..108f59b 100644
50276--- a/drivers/net/wireless/airo.c
50277+++ b/drivers/net/wireless/airo.c
50278@@ -7846,7 +7846,7 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) {
50279 struct airo_info *ai = dev->ml_priv;
50280 int ridcode;
50281 int enabled;
50282- static int (* writer)(struct airo_info *, u16 rid, const void *, int, int);
50283+ int (* writer)(struct airo_info *, u16 rid, const void *, int, int);
50284 unsigned char *iobuf;
50285
50286 /* Only super-user can write RIDs */
50287diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
50288index 49219c5..3625441 100644
50289--- a/drivers/net/wireless/at76c50x-usb.c
50290+++ b/drivers/net/wireless/at76c50x-usb.c
50291@@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
50292 }
50293
50294 /* Convert timeout from the DFU status to jiffies */
50295-static inline unsigned long at76_get_timeout(struct dfu_status *s)
50296+static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
50297 {
50298 return msecs_to_jiffies((s->poll_timeout[2] << 16)
50299 | (s->poll_timeout[1] << 8)
50300diff --git a/drivers/net/wireless/ath/ath10k/htc.c b/drivers/net/wireless/ath/ath10k/htc.c
50301index 2fd9e18..3f55bdd 100644
50302--- a/drivers/net/wireless/ath/ath10k/htc.c
50303+++ b/drivers/net/wireless/ath/ath10k/htc.c
50304@@ -849,7 +849,10 @@ int ath10k_htc_start(struct ath10k_htc *htc)
50305 /* registered target arrival callback from the HIF layer */
50306 int ath10k_htc_init(struct ath10k *ar)
50307 {
50308- struct ath10k_hif_cb htc_callbacks;
50309+ static struct ath10k_hif_cb htc_callbacks = {
50310+ .rx_completion = ath10k_htc_rx_completion_handler,
50311+ .tx_completion = ath10k_htc_tx_completion_handler,
50312+ };
50313 struct ath10k_htc_ep *ep = NULL;
50314 struct ath10k_htc *htc = &ar->htc;
50315
50316@@ -858,8 +861,6 @@ int ath10k_htc_init(struct ath10k *ar)
50317 ath10k_htc_reset_endpoint_states(htc);
50318
50319 /* setup HIF layer callbacks */
50320- htc_callbacks.rx_completion = ath10k_htc_rx_completion_handler;
50321- htc_callbacks.tx_completion = ath10k_htc_tx_completion_handler;
50322 htc->ar = ar;
50323
50324 /* Get HIF default pipe for HTC message exchange */
50325diff --git a/drivers/net/wireless/ath/ath10k/htc.h b/drivers/net/wireless/ath/ath10k/htc.h
50326index 527179c..a890150 100644
50327--- a/drivers/net/wireless/ath/ath10k/htc.h
50328+++ b/drivers/net/wireless/ath/ath10k/htc.h
50329@@ -270,13 +270,13 @@ enum ath10k_htc_ep_id {
50330
50331 struct ath10k_htc_ops {
50332 void (*target_send_suspend_complete)(struct ath10k *ar);
50333-};
50334+} __no_const;
50335
50336 struct ath10k_htc_ep_ops {
50337 void (*ep_tx_complete)(struct ath10k *, struct sk_buff *);
50338 void (*ep_rx_complete)(struct ath10k *, struct sk_buff *);
50339 void (*ep_tx_credits)(struct ath10k *);
50340-};
50341+} __no_const;
50342
50343 /* service connection information */
50344 struct ath10k_htc_svc_conn_req {
50345diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
50346index f816909..e56cd8b 100644
50347--- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
50348+++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
50349@@ -220,8 +220,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
50350 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
50351 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
50352
50353- ACCESS_ONCE(ads->ds_link) = i->link;
50354- ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
50355+ ACCESS_ONCE_RW(ads->ds_link) = i->link;
50356+ ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
50357
50358 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
50359 ctl6 = SM(i->keytype, AR_EncrType);
50360@@ -235,26 +235,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
50361
50362 if ((i->is_first || i->is_last) &&
50363 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
50364- ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
50365+ ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
50366 | set11nTries(i->rates, 1)
50367 | set11nTries(i->rates, 2)
50368 | set11nTries(i->rates, 3)
50369 | (i->dur_update ? AR_DurUpdateEna : 0)
50370 | SM(0, AR_BurstDur);
50371
50372- ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
50373+ ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
50374 | set11nRate(i->rates, 1)
50375 | set11nRate(i->rates, 2)
50376 | set11nRate(i->rates, 3);
50377 } else {
50378- ACCESS_ONCE(ads->ds_ctl2) = 0;
50379- ACCESS_ONCE(ads->ds_ctl3) = 0;
50380+ ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
50381+ ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
50382 }
50383
50384 if (!i->is_first) {
50385- ACCESS_ONCE(ads->ds_ctl0) = 0;
50386- ACCESS_ONCE(ads->ds_ctl1) = ctl1;
50387- ACCESS_ONCE(ads->ds_ctl6) = ctl6;
50388+ ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
50389+ ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
50390+ ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
50391 return;
50392 }
50393
50394@@ -279,7 +279,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
50395 break;
50396 }
50397
50398- ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
50399+ ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
50400 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
50401 | SM(i->txpower[0], AR_XmitPower0)
50402 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
50403@@ -289,27 +289,27 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
50404 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
50405 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
50406
50407- ACCESS_ONCE(ads->ds_ctl1) = ctl1;
50408- ACCESS_ONCE(ads->ds_ctl6) = ctl6;
50409+ ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
50410+ ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
50411
50412 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
50413 return;
50414
50415- ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
50416+ ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
50417 | set11nPktDurRTSCTS(i->rates, 1);
50418
50419- ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
50420+ ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
50421 | set11nPktDurRTSCTS(i->rates, 3);
50422
50423- ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
50424+ ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
50425 | set11nRateFlags(i->rates, 1)
50426 | set11nRateFlags(i->rates, 2)
50427 | set11nRateFlags(i->rates, 3)
50428 | SM(i->rtscts_rate, AR_RTSCTSRate);
50429
50430- ACCESS_ONCE(ads->ds_ctl9) = SM(i->txpower[1], AR_XmitPower1);
50431- ACCESS_ONCE(ads->ds_ctl10) = SM(i->txpower[2], AR_XmitPower2);
50432- ACCESS_ONCE(ads->ds_ctl11) = SM(i->txpower[3], AR_XmitPower3);
50433+ ACCESS_ONCE_RW(ads->ds_ctl9) = SM(i->txpower[1], AR_XmitPower1);
50434+ ACCESS_ONCE_RW(ads->ds_ctl10) = SM(i->txpower[2], AR_XmitPower2);
50435+ ACCESS_ONCE_RW(ads->ds_ctl11) = SM(i->txpower[3], AR_XmitPower3);
50436 }
50437
50438 static int ar9002_hw_proc_txdesc(struct ath_hw *ah, void *ds,
50439diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
50440index da84b70..83e4978 100644
50441--- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
50442+++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
50443@@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
50444 (i->qcu << AR_TxQcuNum_S) | desc_len;
50445
50446 checksum += val;
50447- ACCESS_ONCE(ads->info) = val;
50448+ ACCESS_ONCE_RW(ads->info) = val;
50449
50450 checksum += i->link;
50451- ACCESS_ONCE(ads->link) = i->link;
50452+ ACCESS_ONCE_RW(ads->link) = i->link;
50453
50454 checksum += i->buf_addr[0];
50455- ACCESS_ONCE(ads->data0) = i->buf_addr[0];
50456+ ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
50457 checksum += i->buf_addr[1];
50458- ACCESS_ONCE(ads->data1) = i->buf_addr[1];
50459+ ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
50460 checksum += i->buf_addr[2];
50461- ACCESS_ONCE(ads->data2) = i->buf_addr[2];
50462+ ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
50463 checksum += i->buf_addr[3];
50464- ACCESS_ONCE(ads->data3) = i->buf_addr[3];
50465+ ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
50466
50467 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
50468- ACCESS_ONCE(ads->ctl3) = val;
50469+ ACCESS_ONCE_RW(ads->ctl3) = val;
50470 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
50471- ACCESS_ONCE(ads->ctl5) = val;
50472+ ACCESS_ONCE_RW(ads->ctl5) = val;
50473 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
50474- ACCESS_ONCE(ads->ctl7) = val;
50475+ ACCESS_ONCE_RW(ads->ctl7) = val;
50476 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
50477- ACCESS_ONCE(ads->ctl9) = val;
50478+ ACCESS_ONCE_RW(ads->ctl9) = val;
50479
50480 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
50481- ACCESS_ONCE(ads->ctl10) = checksum;
50482+ ACCESS_ONCE_RW(ads->ctl10) = checksum;
50483
50484 if (i->is_first || i->is_last) {
50485- ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
50486+ ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
50487 | set11nTries(i->rates, 1)
50488 | set11nTries(i->rates, 2)
50489 | set11nTries(i->rates, 3)
50490 | (i->dur_update ? AR_DurUpdateEna : 0)
50491 | SM(0, AR_BurstDur);
50492
50493- ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
50494+ ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
50495 | set11nRate(i->rates, 1)
50496 | set11nRate(i->rates, 2)
50497 | set11nRate(i->rates, 3);
50498 } else {
50499- ACCESS_ONCE(ads->ctl13) = 0;
50500- ACCESS_ONCE(ads->ctl14) = 0;
50501+ ACCESS_ONCE_RW(ads->ctl13) = 0;
50502+ ACCESS_ONCE_RW(ads->ctl14) = 0;
50503 }
50504
50505 ads->ctl20 = 0;
50506@@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
50507
50508 ctl17 = SM(i->keytype, AR_EncrType);
50509 if (!i->is_first) {
50510- ACCESS_ONCE(ads->ctl11) = 0;
50511- ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
50512- ACCESS_ONCE(ads->ctl15) = 0;
50513- ACCESS_ONCE(ads->ctl16) = 0;
50514- ACCESS_ONCE(ads->ctl17) = ctl17;
50515- ACCESS_ONCE(ads->ctl18) = 0;
50516- ACCESS_ONCE(ads->ctl19) = 0;
50517+ ACCESS_ONCE_RW(ads->ctl11) = 0;
50518+ ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
50519+ ACCESS_ONCE_RW(ads->ctl15) = 0;
50520+ ACCESS_ONCE_RW(ads->ctl16) = 0;
50521+ ACCESS_ONCE_RW(ads->ctl17) = ctl17;
50522+ ACCESS_ONCE_RW(ads->ctl18) = 0;
50523+ ACCESS_ONCE_RW(ads->ctl19) = 0;
50524 return;
50525 }
50526
50527- ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
50528+ ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
50529 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
50530 | SM(i->txpower[0], AR_XmitPower0)
50531 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
50532@@ -135,26 +135,26 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
50533 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
50534 ctl12 |= SM(val, AR_PAPRDChainMask);
50535
50536- ACCESS_ONCE(ads->ctl12) = ctl12;
50537- ACCESS_ONCE(ads->ctl17) = ctl17;
50538+ ACCESS_ONCE_RW(ads->ctl12) = ctl12;
50539+ ACCESS_ONCE_RW(ads->ctl17) = ctl17;
50540
50541- ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
50542+ ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
50543 | set11nPktDurRTSCTS(i->rates, 1);
50544
50545- ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
50546+ ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
50547 | set11nPktDurRTSCTS(i->rates, 3);
50548
50549- ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
50550+ ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
50551 | set11nRateFlags(i->rates, 1)
50552 | set11nRateFlags(i->rates, 2)
50553 | set11nRateFlags(i->rates, 3)
50554 | SM(i->rtscts_rate, AR_RTSCTSRate);
50555
50556- ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
50557+ ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
50558
50559- ACCESS_ONCE(ads->ctl20) = SM(i->txpower[1], AR_XmitPower1);
50560- ACCESS_ONCE(ads->ctl21) = SM(i->txpower[2], AR_XmitPower2);
50561- ACCESS_ONCE(ads->ctl22) = SM(i->txpower[3], AR_XmitPower3);
50562+ ACCESS_ONCE_RW(ads->ctl20) = SM(i->txpower[1], AR_XmitPower1);
50563+ ACCESS_ONCE_RW(ads->ctl21) = SM(i->txpower[2], AR_XmitPower2);
50564+ ACCESS_ONCE_RW(ads->ctl22) = SM(i->txpower[3], AR_XmitPower3);
50565 }
50566
50567 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
50568diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
50569index c1d2d03..08352db 100644
50570--- a/drivers/net/wireless/ath/ath9k/hw.h
50571+++ b/drivers/net/wireless/ath/ath9k/hw.h
50572@@ -671,7 +671,7 @@ struct ath_hw_private_ops {
50573 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
50574 bool (*is_aic_enabled)(struct ath_hw *ah);
50575 #endif /* CONFIG_ATH9K_BTCOEX_SUPPORT */
50576-};
50577+} __no_const;
50578
50579 /**
50580 * struct ath_spec_scan - parameters for Atheros spectral scan
50581@@ -747,7 +747,7 @@ struct ath_hw_ops {
50582 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
50583 void (*set_bt_ant_diversity)(struct ath_hw *hw, bool enable);
50584 #endif
50585-};
50586+} __no_const;
50587
50588 struct ath_nf_limits {
50589 s16 max;
50590diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
50591index b0badef..3e3464c 100644
50592--- a/drivers/net/wireless/ath/ath9k/main.c
50593+++ b/drivers/net/wireless/ath/ath9k/main.c
50594@@ -2573,16 +2573,18 @@ void ath9k_fill_chanctx_ops(void)
50595 if (!ath9k_is_chanctx_enabled())
50596 return;
50597
50598- ath9k_ops.hw_scan = ath9k_hw_scan;
50599- ath9k_ops.cancel_hw_scan = ath9k_cancel_hw_scan;
50600- ath9k_ops.remain_on_channel = ath9k_remain_on_channel;
50601- ath9k_ops.cancel_remain_on_channel = ath9k_cancel_remain_on_channel;
50602- ath9k_ops.add_chanctx = ath9k_add_chanctx;
50603- ath9k_ops.remove_chanctx = ath9k_remove_chanctx;
50604- ath9k_ops.change_chanctx = ath9k_change_chanctx;
50605- ath9k_ops.assign_vif_chanctx = ath9k_assign_vif_chanctx;
50606- ath9k_ops.unassign_vif_chanctx = ath9k_unassign_vif_chanctx;
50607- ath9k_ops.mgd_prepare_tx = ath9k_mgd_prepare_tx;
50608+ pax_open_kernel();
50609+ *(void **)&ath9k_ops.hw_scan = ath9k_hw_scan;
50610+ *(void **)&ath9k_ops.cancel_hw_scan = ath9k_cancel_hw_scan;
50611+ *(void **)&ath9k_ops.remain_on_channel = ath9k_remain_on_channel;
50612+ *(void **)&ath9k_ops.cancel_remain_on_channel = ath9k_cancel_remain_on_channel;
50613+ *(void **)&ath9k_ops.add_chanctx = ath9k_add_chanctx;
50614+ *(void **)&ath9k_ops.remove_chanctx = ath9k_remove_chanctx;
50615+ *(void **)&ath9k_ops.change_chanctx = ath9k_change_chanctx;
50616+ *(void **)&ath9k_ops.assign_vif_chanctx = ath9k_assign_vif_chanctx;
50617+ *(void **)&ath9k_ops.unassign_vif_chanctx = ath9k_unassign_vif_chanctx;
50618+ *(void **)&ath9k_ops.mgd_prepare_tx = ath9k_mgd_prepare_tx;
50619+ pax_close_kernel();
50620 }
50621
50622 #endif
50623diff --git a/drivers/net/wireless/b43/phy_lp.c b/drivers/net/wireless/b43/phy_lp.c
50624index 058a9f2..d5cb1ba 100644
50625--- a/drivers/net/wireless/b43/phy_lp.c
50626+++ b/drivers/net/wireless/b43/phy_lp.c
50627@@ -2502,7 +2502,7 @@ static int lpphy_b2063_tune(struct b43_wldev *dev,
50628 {
50629 struct ssb_bus *bus = dev->dev->sdev->bus;
50630
50631- static const struct b206x_channel *chandata = NULL;
50632+ const struct b206x_channel *chandata = NULL;
50633 u32 crystal_freq = bus->chipco.pmu.crystalfreq * 1000;
50634 u32 freqref, vco_freq, val1, val2, val3, timeout, timeoutref, count;
50635 u16 old_comm15, scale;
50636diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
50637index e566580..2c218ca 100644
50638--- a/drivers/net/wireless/iwlegacy/3945-mac.c
50639+++ b/drivers/net/wireless/iwlegacy/3945-mac.c
50640@@ -3631,7 +3631,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
50641 */
50642 if (il3945_mod_params.disable_hw_scan) {
50643 D_INFO("Disabling hw_scan\n");
50644- il3945_mac_ops.hw_scan = NULL;
50645+ pax_open_kernel();
50646+ *(void **)&il3945_mac_ops.hw_scan = NULL;
50647+ pax_close_kernel();
50648 }
50649
50650 D_INFO("*** LOAD DRIVER ***\n");
50651diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
50652index 0ffb6ff..c0b7f0e 100644
50653--- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
50654+++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
50655@@ -188,7 +188,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
50656 {
50657 struct iwl_priv *priv = file->private_data;
50658 char buf[64];
50659- int buf_size;
50660+ size_t buf_size;
50661 u32 offset, len;
50662
50663 memset(buf, 0, sizeof(buf));
50664@@ -458,7 +458,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
50665 struct iwl_priv *priv = file->private_data;
50666
50667 char buf[8];
50668- int buf_size;
50669+ size_t buf_size;
50670 u32 reset_flag;
50671
50672 memset(buf, 0, sizeof(buf));
50673@@ -539,7 +539,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
50674 {
50675 struct iwl_priv *priv = file->private_data;
50676 char buf[8];
50677- int buf_size;
50678+ size_t buf_size;
50679 int ht40;
50680
50681 memset(buf, 0, sizeof(buf));
50682@@ -591,7 +591,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
50683 {
50684 struct iwl_priv *priv = file->private_data;
50685 char buf[8];
50686- int buf_size;
50687+ size_t buf_size;
50688 int value;
50689
50690 memset(buf, 0, sizeof(buf));
50691@@ -683,10 +683,10 @@ DEBUGFS_READ_FILE_OPS(temperature);
50692 DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
50693 DEBUGFS_READ_FILE_OPS(current_sleep_command);
50694
50695-static const char *fmt_value = " %-30s %10u\n";
50696-static const char *fmt_hex = " %-30s 0x%02X\n";
50697-static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
50698-static const char *fmt_header =
50699+static const char fmt_value[] = " %-30s %10u\n";
50700+static const char fmt_hex[] = " %-30s 0x%02X\n";
50701+static const char fmt_table[] = " %-30s %10u %10u %10u %10u\n";
50702+static const char fmt_header[] =
50703 "%-32s current cumulative delta max\n";
50704
50705 static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
50706@@ -1856,7 +1856,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
50707 {
50708 struct iwl_priv *priv = file->private_data;
50709 char buf[8];
50710- int buf_size;
50711+ size_t buf_size;
50712 int clear;
50713
50714 memset(buf, 0, sizeof(buf));
50715@@ -1901,7 +1901,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
50716 {
50717 struct iwl_priv *priv = file->private_data;
50718 char buf[8];
50719- int buf_size;
50720+ size_t buf_size;
50721 int trace;
50722
50723 memset(buf, 0, sizeof(buf));
50724@@ -1972,7 +1972,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
50725 {
50726 struct iwl_priv *priv = file->private_data;
50727 char buf[8];
50728- int buf_size;
50729+ size_t buf_size;
50730 int missed;
50731
50732 memset(buf, 0, sizeof(buf));
50733@@ -2013,7 +2013,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
50734
50735 struct iwl_priv *priv = file->private_data;
50736 char buf[8];
50737- int buf_size;
50738+ size_t buf_size;
50739 int plcp;
50740
50741 memset(buf, 0, sizeof(buf));
50742@@ -2073,7 +2073,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
50743
50744 struct iwl_priv *priv = file->private_data;
50745 char buf[8];
50746- int buf_size;
50747+ size_t buf_size;
50748 int flush;
50749
50750 memset(buf, 0, sizeof(buf));
50751@@ -2163,7 +2163,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
50752
50753 struct iwl_priv *priv = file->private_data;
50754 char buf[8];
50755- int buf_size;
50756+ size_t buf_size;
50757 int rts;
50758
50759 if (!priv->cfg->ht_params)
50760@@ -2204,7 +2204,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
50761 {
50762 struct iwl_priv *priv = file->private_data;
50763 char buf[8];
50764- int buf_size;
50765+ size_t buf_size;
50766
50767 memset(buf, 0, sizeof(buf));
50768 buf_size = min(count, sizeof(buf) - 1);
50769@@ -2238,7 +2238,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
50770 struct iwl_priv *priv = file->private_data;
50771 u32 event_log_flag;
50772 char buf[8];
50773- int buf_size;
50774+ size_t buf_size;
50775
50776 /* check that the interface is up */
50777 if (!iwl_is_ready(priv))
50778@@ -2292,7 +2292,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
50779 struct iwl_priv *priv = file->private_data;
50780 char buf[8];
50781 u32 calib_disabled;
50782- int buf_size;
50783+ size_t buf_size;
50784
50785 memset(buf, 0, sizeof(buf));
50786 buf_size = min(count, sizeof(buf) - 1);
50787diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
50788index dc17909..989c9fb 100644
50789--- a/drivers/net/wireless/iwlwifi/pcie/trans.c
50790+++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
50791@@ -1919,7 +1919,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
50792 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
50793
50794 char buf[8];
50795- int buf_size;
50796+ size_t buf_size;
50797 u32 reset_flag;
50798
50799 memset(buf, 0, sizeof(buf));
50800@@ -1940,7 +1940,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
50801 {
50802 struct iwl_trans *trans = file->private_data;
50803 char buf[8];
50804- int buf_size;
50805+ size_t buf_size;
50806 int csr;
50807
50808 memset(buf, 0, sizeof(buf));
50809diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
50810index d5c0a1a..d056b20 100644
50811--- a/drivers/net/wireless/mac80211_hwsim.c
50812+++ b/drivers/net/wireless/mac80211_hwsim.c
50813@@ -3149,20 +3149,20 @@ static int __init init_mac80211_hwsim(void)
50814 if (channels < 1)
50815 return -EINVAL;
50816
50817- mac80211_hwsim_mchan_ops = mac80211_hwsim_ops;
50818- mac80211_hwsim_mchan_ops.hw_scan = mac80211_hwsim_hw_scan;
50819- mac80211_hwsim_mchan_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
50820- mac80211_hwsim_mchan_ops.sw_scan_start = NULL;
50821- mac80211_hwsim_mchan_ops.sw_scan_complete = NULL;
50822- mac80211_hwsim_mchan_ops.remain_on_channel = mac80211_hwsim_roc;
50823- mac80211_hwsim_mchan_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
50824- mac80211_hwsim_mchan_ops.add_chanctx = mac80211_hwsim_add_chanctx;
50825- mac80211_hwsim_mchan_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
50826- mac80211_hwsim_mchan_ops.change_chanctx = mac80211_hwsim_change_chanctx;
50827- mac80211_hwsim_mchan_ops.assign_vif_chanctx =
50828- mac80211_hwsim_assign_vif_chanctx;
50829- mac80211_hwsim_mchan_ops.unassign_vif_chanctx =
50830- mac80211_hwsim_unassign_vif_chanctx;
50831+ pax_open_kernel();
50832+ memcpy((void *)&mac80211_hwsim_mchan_ops, &mac80211_hwsim_ops, sizeof mac80211_hwsim_mchan_ops);
50833+ *(void **)&mac80211_hwsim_mchan_ops.hw_scan = mac80211_hwsim_hw_scan;
50834+ *(void **)&mac80211_hwsim_mchan_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
50835+ *(void **)&mac80211_hwsim_mchan_ops.sw_scan_start = NULL;
50836+ *(void **)&mac80211_hwsim_mchan_ops.sw_scan_complete = NULL;
50837+ *(void **)&mac80211_hwsim_mchan_ops.remain_on_channel = mac80211_hwsim_roc;
50838+ *(void **)&mac80211_hwsim_mchan_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
50839+ *(void **)&mac80211_hwsim_mchan_ops.add_chanctx = mac80211_hwsim_add_chanctx;
50840+ *(void **)&mac80211_hwsim_mchan_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
50841+ *(void **)&mac80211_hwsim_mchan_ops.change_chanctx = mac80211_hwsim_change_chanctx;
50842+ *(void **)&mac80211_hwsim_mchan_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
50843+ *(void **)&mac80211_hwsim_mchan_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
50844+ pax_close_kernel();
50845
50846 spin_lock_init(&hwsim_radio_lock);
50847 INIT_LIST_HEAD(&hwsim_radios);
50848diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
50849index d72ff8e..c209a45 100644
50850--- a/drivers/net/wireless/rndis_wlan.c
50851+++ b/drivers/net/wireless/rndis_wlan.c
50852@@ -1236,7 +1236,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
50853
50854 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
50855
50856- if (rts_threshold < 0 || rts_threshold > 2347)
50857+ if (rts_threshold > 2347)
50858 rts_threshold = 2347;
50859
50860 tmp = cpu_to_le32(rts_threshold);
50861diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
50862index 9bb398b..b0cc047 100644
50863--- a/drivers/net/wireless/rt2x00/rt2x00.h
50864+++ b/drivers/net/wireless/rt2x00/rt2x00.h
50865@@ -375,7 +375,7 @@ struct rt2x00_intf {
50866 * for hardware which doesn't support hardware
50867 * sequence counting.
50868 */
50869- atomic_t seqno;
50870+ atomic_unchecked_t seqno;
50871 };
50872
50873 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
50874diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
50875index 68b620b..92ecd9e 100644
50876--- a/drivers/net/wireless/rt2x00/rt2x00queue.c
50877+++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
50878@@ -224,9 +224,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
50879 * sequence counter given by mac80211.
50880 */
50881 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
50882- seqno = atomic_add_return(0x10, &intf->seqno);
50883+ seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
50884 else
50885- seqno = atomic_read(&intf->seqno);
50886+ seqno = atomic_read_unchecked(&intf->seqno);
50887
50888 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
50889 hdr->seq_ctrl |= cpu_to_le16(seqno);
50890diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
50891index b661f896..ddf7d2b 100644
50892--- a/drivers/net/wireless/ti/wl1251/sdio.c
50893+++ b/drivers/net/wireless/ti/wl1251/sdio.c
50894@@ -282,13 +282,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
50895
50896 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
50897
50898- wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
50899- wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
50900+ pax_open_kernel();
50901+ *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
50902+ *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
50903+ pax_close_kernel();
50904
50905 wl1251_info("using dedicated interrupt line");
50906 } else {
50907- wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
50908- wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
50909+ pax_open_kernel();
50910+ *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
50911+ *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
50912+ pax_close_kernel();
50913
50914 wl1251_info("using SDIO interrupt");
50915 }
50916diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
50917index af0fe2e..d04986b 100644
50918--- a/drivers/net/wireless/ti/wl12xx/main.c
50919+++ b/drivers/net/wireless/ti/wl12xx/main.c
50920@@ -655,7 +655,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
50921 sizeof(wl->conf.mem));
50922
50923 /* read data preparation is only needed by wl127x */
50924- wl->ops->prepare_read = wl127x_prepare_read;
50925+ pax_open_kernel();
50926+ *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
50927+ pax_close_kernel();
50928
50929 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
50930 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
50931@@ -680,7 +682,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
50932 sizeof(wl->conf.mem));
50933
50934 /* read data preparation is only needed by wl127x */
50935- wl->ops->prepare_read = wl127x_prepare_read;
50936+ pax_open_kernel();
50937+ *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
50938+ pax_close_kernel();
50939
50940 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
50941 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
50942diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
50943index 717c4f5..a813aeb 100644
50944--- a/drivers/net/wireless/ti/wl18xx/main.c
50945+++ b/drivers/net/wireless/ti/wl18xx/main.c
50946@@ -1923,8 +1923,10 @@ static int wl18xx_setup(struct wl1271 *wl)
50947 }
50948
50949 if (!checksum_param) {
50950- wl18xx_ops.set_rx_csum = NULL;
50951- wl18xx_ops.init_vif = NULL;
50952+ pax_open_kernel();
50953+ *(void **)&wl18xx_ops.set_rx_csum = NULL;
50954+ *(void **)&wl18xx_ops.init_vif = NULL;
50955+ pax_close_kernel();
50956 }
50957
50958 /* Enable 11a Band only if we have 5G antennas */
50959diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
50960index a912dc0..a8225ba 100644
50961--- a/drivers/net/wireless/zd1211rw/zd_usb.c
50962+++ b/drivers/net/wireless/zd1211rw/zd_usb.c
50963@@ -385,7 +385,7 @@ static inline void handle_regs_int(struct urb *urb)
50964 {
50965 struct zd_usb *usb = urb->context;
50966 struct zd_usb_interrupt *intr = &usb->intr;
50967- int len;
50968+ unsigned int len;
50969 u16 int_num;
50970
50971 ZD_ASSERT(in_interrupt());
50972diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c
50973index 0d25943..0866c5d 100644
50974--- a/drivers/net/xen-netback/netback.c
50975+++ b/drivers/net/xen-netback/netback.c
50976@@ -1571,13 +1571,13 @@ static inline void xenvif_tx_dealloc_action(struct xenvif_queue *queue)
50977 smp_rmb();
50978
50979 while (dc != dp) {
50980- BUG_ON(gop - queue->tx_unmap_ops > MAX_PENDING_REQS);
50981+ BUG_ON(gop - queue->tx_unmap_ops >= MAX_PENDING_REQS);
50982 pending_idx =
50983 queue->dealloc_ring[pending_index(dc++)];
50984
50985- pending_idx_release[gop-queue->tx_unmap_ops] =
50986+ pending_idx_release[gop - queue->tx_unmap_ops] =
50987 pending_idx;
50988- queue->pages_to_unmap[gop-queue->tx_unmap_ops] =
50989+ queue->pages_to_unmap[gop - queue->tx_unmap_ops] =
50990 queue->mmap_pages[pending_idx];
50991 gnttab_set_unmap_op(gop,
50992 idx_to_kaddr(queue, pending_idx),
50993diff --git a/drivers/nfc/nfcwilink.c b/drivers/nfc/nfcwilink.c
50994index ce2e2cf..f81e500 100644
50995--- a/drivers/nfc/nfcwilink.c
50996+++ b/drivers/nfc/nfcwilink.c
50997@@ -497,7 +497,7 @@ static struct nci_ops nfcwilink_ops = {
50998
50999 static int nfcwilink_probe(struct platform_device *pdev)
51000 {
51001- static struct nfcwilink *drv;
51002+ struct nfcwilink *drv;
51003 int rc;
51004 __u32 protocols;
51005
51006diff --git a/drivers/nfc/st21nfca/st21nfca.c b/drivers/nfc/st21nfca/st21nfca.c
51007index d251f72..0512865 100644
51008--- a/drivers/nfc/st21nfca/st21nfca.c
51009+++ b/drivers/nfc/st21nfca/st21nfca.c
51010@@ -148,14 +148,14 @@ static int st21nfca_hci_load_session(struct nfc_hci_dev *hdev)
51011 ST21NFCA_DEVICE_MGNT_GATE,
51012 ST21NFCA_DEVICE_MGNT_PIPE);
51013 if (r < 0)
51014- goto free_info;
51015+ return r;
51016
51017 /* Get pipe list */
51018 r = nfc_hci_send_cmd(hdev, ST21NFCA_DEVICE_MGNT_GATE,
51019 ST21NFCA_DM_GETINFO, pipe_list, sizeof(pipe_list),
51020 &skb_pipe_list);
51021 if (r < 0)
51022- goto free_info;
51023+ return r;
51024
51025 /* Complete the existing gate_pipe table */
51026 for (i = 0; i < skb_pipe_list->len; i++) {
51027@@ -181,6 +181,7 @@ static int st21nfca_hci_load_session(struct nfc_hci_dev *hdev)
51028 info->src_host_id != ST21NFCA_ESE_HOST_ID) {
51029 pr_err("Unexpected apdu_reader pipe on host %x\n",
51030 info->src_host_id);
51031+ kfree_skb(skb_pipe_info);
51032 continue;
51033 }
51034
51035@@ -200,6 +201,7 @@ static int st21nfca_hci_load_session(struct nfc_hci_dev *hdev)
51036 hdev->pipes[st21nfca_gates[j].pipe].dest_host =
51037 info->src_host_id;
51038 }
51039+ kfree_skb(skb_pipe_info);
51040 }
51041
51042 /*
51043@@ -214,13 +216,12 @@ static int st21nfca_hci_load_session(struct nfc_hci_dev *hdev)
51044 st21nfca_gates[i].gate,
51045 st21nfca_gates[i].pipe);
51046 if (r < 0)
51047- goto free_info;
51048+ goto free_list;
51049 }
51050 }
51051
51052 memcpy(hdev->init_data.gates, st21nfca_gates, sizeof(st21nfca_gates));
51053-free_info:
51054- kfree_skb(skb_pipe_info);
51055+free_list:
51056 kfree_skb(skb_pipe_list);
51057 return r;
51058 }
51059diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
51060index cde35c5d01..2dbfdbbf 100644
51061--- a/drivers/of/fdt.c
51062+++ b/drivers/of/fdt.c
51063@@ -1136,7 +1136,9 @@ static int __init of_fdt_raw_init(void)
51064 pr_warn("fdt: not creating '/sys/firmware/fdt': CRC check failed\n");
51065 return 0;
51066 }
51067- of_fdt_raw_attr.size = fdt_totalsize(initial_boot_params);
51068+ pax_open_kernel();
51069+ *(size_t *)&of_fdt_raw_attr.size = fdt_totalsize(initial_boot_params);
51070+ pax_close_kernel();
51071 return sysfs_create_bin_file(firmware_kobj, &of_fdt_raw_attr);
51072 }
51073 late_initcall(of_fdt_raw_init);
51074diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
51075index 82f7000..d6d0447 100644
51076--- a/drivers/oprofile/buffer_sync.c
51077+++ b/drivers/oprofile/buffer_sync.c
51078@@ -345,7 +345,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
51079 if (cookie == NO_COOKIE)
51080 offset = pc;
51081 if (cookie == INVALID_COOKIE) {
51082- atomic_inc(&oprofile_stats.sample_lost_no_mapping);
51083+ atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
51084 offset = pc;
51085 }
51086 if (cookie != last_cookie) {
51087@@ -389,14 +389,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
51088 /* add userspace sample */
51089
51090 if (!mm) {
51091- atomic_inc(&oprofile_stats.sample_lost_no_mm);
51092+ atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
51093 return 0;
51094 }
51095
51096 cookie = lookup_dcookie(mm, s->eip, &offset);
51097
51098 if (cookie == INVALID_COOKIE) {
51099- atomic_inc(&oprofile_stats.sample_lost_no_mapping);
51100+ atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
51101 return 0;
51102 }
51103
51104@@ -554,7 +554,7 @@ void sync_buffer(int cpu)
51105 /* ignore backtraces if failed to add a sample */
51106 if (state == sb_bt_start) {
51107 state = sb_bt_ignore;
51108- atomic_inc(&oprofile_stats.bt_lost_no_mapping);
51109+ atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
51110 }
51111 }
51112 release_mm(mm);
51113diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
51114index c0cc4e7..44d4e54 100644
51115--- a/drivers/oprofile/event_buffer.c
51116+++ b/drivers/oprofile/event_buffer.c
51117@@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
51118 }
51119
51120 if (buffer_pos == buffer_size) {
51121- atomic_inc(&oprofile_stats.event_lost_overflow);
51122+ atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
51123 return;
51124 }
51125
51126diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
51127index ed2c3ec..deda85a 100644
51128--- a/drivers/oprofile/oprof.c
51129+++ b/drivers/oprofile/oprof.c
51130@@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
51131 if (oprofile_ops.switch_events())
51132 return;
51133
51134- atomic_inc(&oprofile_stats.multiplex_counter);
51135+ atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
51136 start_switch_worker();
51137 }
51138
51139diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
51140index ee2cfce..7f8f699 100644
51141--- a/drivers/oprofile/oprofile_files.c
51142+++ b/drivers/oprofile/oprofile_files.c
51143@@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
51144
51145 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
51146
51147-static ssize_t timeout_read(struct file *file, char __user *buf,
51148+static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
51149 size_t count, loff_t *offset)
51150 {
51151 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
51152diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
51153index 59659ce..6c860a0 100644
51154--- a/drivers/oprofile/oprofile_stats.c
51155+++ b/drivers/oprofile/oprofile_stats.c
51156@@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
51157 cpu_buf->sample_invalid_eip = 0;
51158 }
51159
51160- atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
51161- atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
51162- atomic_set(&oprofile_stats.event_lost_overflow, 0);
51163- atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
51164- atomic_set(&oprofile_stats.multiplex_counter, 0);
51165+ atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
51166+ atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
51167+ atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
51168+ atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
51169+ atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
51170 }
51171
51172
51173diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
51174index 1fc622b..8c48fc3 100644
51175--- a/drivers/oprofile/oprofile_stats.h
51176+++ b/drivers/oprofile/oprofile_stats.h
51177@@ -13,11 +13,11 @@
51178 #include <linux/atomic.h>
51179
51180 struct oprofile_stat_struct {
51181- atomic_t sample_lost_no_mm;
51182- atomic_t sample_lost_no_mapping;
51183- atomic_t bt_lost_no_mapping;
51184- atomic_t event_lost_overflow;
51185- atomic_t multiplex_counter;
51186+ atomic_unchecked_t sample_lost_no_mm;
51187+ atomic_unchecked_t sample_lost_no_mapping;
51188+ atomic_unchecked_t bt_lost_no_mapping;
51189+ atomic_unchecked_t event_lost_overflow;
51190+ atomic_unchecked_t multiplex_counter;
51191 };
51192
51193 extern struct oprofile_stat_struct oprofile_stats;
51194diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
51195index dd92c5e..dfc04b5 100644
51196--- a/drivers/oprofile/oprofilefs.c
51197+++ b/drivers/oprofile/oprofilefs.c
51198@@ -176,8 +176,8 @@ int oprofilefs_create_ro_ulong(struct dentry *root,
51199
51200 static ssize_t atomic_read_file(struct file *file, char __user *buf, size_t count, loff_t *offset)
51201 {
51202- atomic_t *val = file->private_data;
51203- return oprofilefs_ulong_to_user(atomic_read(val), buf, count, offset);
51204+ atomic_unchecked_t *val = file->private_data;
51205+ return oprofilefs_ulong_to_user(atomic_read_unchecked(val), buf, count, offset);
51206 }
51207
51208
51209@@ -189,7 +189,7 @@ static const struct file_operations atomic_ro_fops = {
51210
51211
51212 int oprofilefs_create_ro_atomic(struct dentry *root,
51213- char const *name, atomic_t *val)
51214+ char const *name, atomic_unchecked_t *val)
51215 {
51216 return __oprofilefs_create_file(root, name,
51217 &atomic_ro_fops, 0444, val);
51218diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
51219index bdef916..88c7dee 100644
51220--- a/drivers/oprofile/timer_int.c
51221+++ b/drivers/oprofile/timer_int.c
51222@@ -93,7 +93,7 @@ static int oprofile_cpu_notify(struct notifier_block *self,
51223 return NOTIFY_OK;
51224 }
51225
51226-static struct notifier_block __refdata oprofile_cpu_notifier = {
51227+static struct notifier_block oprofile_cpu_notifier = {
51228 .notifier_call = oprofile_cpu_notify,
51229 };
51230
51231diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
51232index 3b47080..6cd05dd 100644
51233--- a/drivers/parport/procfs.c
51234+++ b/drivers/parport/procfs.c
51235@@ -64,7 +64,7 @@ static int do_active_device(struct ctl_table *table, int write,
51236
51237 *ppos += len;
51238
51239- return copy_to_user(result, buffer, len) ? -EFAULT : 0;
51240+ return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
51241 }
51242
51243 #ifdef CONFIG_PARPORT_1284
51244@@ -106,7 +106,7 @@ static int do_autoprobe(struct ctl_table *table, int write,
51245
51246 *ppos += len;
51247
51248- return copy_to_user (result, buffer, len) ? -EFAULT : 0;
51249+ return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
51250 }
51251 #endif /* IEEE1284.3 support. */
51252
51253diff --git a/drivers/pci/host/pci-host-generic.c b/drivers/pci/host/pci-host-generic.c
51254index ba46e58..90cfc24 100644
51255--- a/drivers/pci/host/pci-host-generic.c
51256+++ b/drivers/pci/host/pci-host-generic.c
51257@@ -26,9 +26,9 @@
51258 #include <linux/platform_device.h>
51259
51260 struct gen_pci_cfg_bus_ops {
51261+ struct pci_ops ops;
51262 u32 bus_shift;
51263- void __iomem *(*map_bus)(struct pci_bus *, unsigned int, int);
51264-};
51265+} __do_const;
51266
51267 struct gen_pci_cfg_windows {
51268 struct resource res;
51269@@ -56,8 +56,12 @@ static void __iomem *gen_pci_map_cfg_bus_cam(struct pci_bus *bus,
51270 }
51271
51272 static struct gen_pci_cfg_bus_ops gen_pci_cfg_cam_bus_ops = {
51273+ .ops = {
51274+ .map_bus = gen_pci_map_cfg_bus_cam,
51275+ .read = pci_generic_config_read,
51276+ .write = pci_generic_config_write,
51277+ },
51278 .bus_shift = 16,
51279- .map_bus = gen_pci_map_cfg_bus_cam,
51280 };
51281
51282 static void __iomem *gen_pci_map_cfg_bus_ecam(struct pci_bus *bus,
51283@@ -72,13 +76,12 @@ static void __iomem *gen_pci_map_cfg_bus_ecam(struct pci_bus *bus,
51284 }
51285
51286 static struct gen_pci_cfg_bus_ops gen_pci_cfg_ecam_bus_ops = {
51287+ .ops = {
51288+ .map_bus = gen_pci_map_cfg_bus_ecam,
51289+ .read = pci_generic_config_read,
51290+ .write = pci_generic_config_write,
51291+ },
51292 .bus_shift = 20,
51293- .map_bus = gen_pci_map_cfg_bus_ecam,
51294-};
51295-
51296-static struct pci_ops gen_pci_ops = {
51297- .read = pci_generic_config_read,
51298- .write = pci_generic_config_write,
51299 };
51300
51301 static const struct of_device_id gen_pci_of_match[] = {
51302@@ -219,7 +222,6 @@ static int gen_pci_probe(struct platform_device *pdev)
51303 .private_data = (void **)&pci,
51304 .setup = gen_pci_setup,
51305 .map_irq = of_irq_parse_and_map_pci,
51306- .ops = &gen_pci_ops,
51307 };
51308
51309 if (!pci)
51310@@ -241,7 +243,7 @@ static int gen_pci_probe(struct platform_device *pdev)
51311
51312 of_id = of_match_node(gen_pci_of_match, np);
51313 pci->cfg.ops = of_id->data;
51314- gen_pci_ops.map_bus = pci->cfg.ops->map_bus;
51315+ hw.ops = &pci->cfg.ops->ops;
51316 pci->host.dev.parent = dev;
51317 INIT_LIST_HEAD(&pci->host.windows);
51318 INIT_LIST_HEAD(&pci->resources);
51319diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
51320index 6ca2399..68d866b 100644
51321--- a/drivers/pci/hotplug/acpiphp_ibm.c
51322+++ b/drivers/pci/hotplug/acpiphp_ibm.c
51323@@ -452,7 +452,9 @@ static int __init ibm_acpiphp_init(void)
51324 goto init_cleanup;
51325 }
51326
51327- ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
51328+ pax_open_kernel();
51329+ *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
51330+ pax_close_kernel();
51331 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
51332
51333 return retval;
51334diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
51335index 66b7bbe..26bee78 100644
51336--- a/drivers/pci/hotplug/cpcihp_generic.c
51337+++ b/drivers/pci/hotplug/cpcihp_generic.c
51338@@ -73,7 +73,6 @@ static u16 port;
51339 static unsigned int enum_bit;
51340 static u8 enum_mask;
51341
51342-static struct cpci_hp_controller_ops generic_hpc_ops;
51343 static struct cpci_hp_controller generic_hpc;
51344
51345 static int __init validate_parameters(void)
51346@@ -139,6 +138,10 @@ static int query_enum(void)
51347 return ((value & enum_mask) == enum_mask);
51348 }
51349
51350+static struct cpci_hp_controller_ops generic_hpc_ops = {
51351+ .query_enum = query_enum,
51352+};
51353+
51354 static int __init cpcihp_generic_init(void)
51355 {
51356 int status;
51357@@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
51358 pci_dev_put(dev);
51359
51360 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
51361- generic_hpc_ops.query_enum = query_enum;
51362 generic_hpc.ops = &generic_hpc_ops;
51363
51364 status = cpci_hp_register_controller(&generic_hpc);
51365diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
51366index 7ecf34e..effed62 100644
51367--- a/drivers/pci/hotplug/cpcihp_zt5550.c
51368+++ b/drivers/pci/hotplug/cpcihp_zt5550.c
51369@@ -59,7 +59,6 @@
51370 /* local variables */
51371 static bool debug;
51372 static bool poll;
51373-static struct cpci_hp_controller_ops zt5550_hpc_ops;
51374 static struct cpci_hp_controller zt5550_hpc;
51375
51376 /* Primary cPCI bus bridge device */
51377@@ -204,6 +203,10 @@ static int zt5550_hc_disable_irq(void)
51378 return 0;
51379 }
51380
51381+static struct cpci_hp_controller_ops zt5550_hpc_ops = {
51382+ .query_enum = zt5550_hc_query_enum,
51383+};
51384+
51385 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
51386 {
51387 int status;
51388@@ -215,16 +218,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
51389 dbg("returned from zt5550_hc_config");
51390
51391 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
51392- zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
51393 zt5550_hpc.ops = &zt5550_hpc_ops;
51394 if (!poll) {
51395 zt5550_hpc.irq = hc_dev->irq;
51396 zt5550_hpc.irq_flags = IRQF_SHARED;
51397 zt5550_hpc.dev_id = hc_dev;
51398
51399- zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
51400- zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
51401- zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
51402+ pax_open_kernel();
51403+ *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
51404+ *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
51405+ *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
51406+ pax_open_kernel();
51407 } else {
51408 info("using ENUM# polling mode");
51409 }
51410diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
51411index 1e08ff8c..3cd145f 100644
51412--- a/drivers/pci/hotplug/cpqphp_nvram.c
51413+++ b/drivers/pci/hotplug/cpqphp_nvram.c
51414@@ -425,8 +425,10 @@ static u32 store_HRT (void __iomem *rom_start)
51415
51416 void compaq_nvram_init (void __iomem *rom_start)
51417 {
51418+#ifndef CONFIG_PAX_KERNEXEC
51419 if (rom_start)
51420 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
51421+#endif
51422
51423 dbg("int15 entry = %p\n", compaq_int15_entry_point);
51424
51425diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
51426index 56d8486..f26113f 100644
51427--- a/drivers/pci/hotplug/pci_hotplug_core.c
51428+++ b/drivers/pci/hotplug/pci_hotplug_core.c
51429@@ -436,8 +436,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
51430 return -EINVAL;
51431 }
51432
51433- slot->ops->owner = owner;
51434- slot->ops->mod_name = mod_name;
51435+ pax_open_kernel();
51436+ *(struct module **)&slot->ops->owner = owner;
51437+ *(const char **)&slot->ops->mod_name = mod_name;
51438+ pax_close_kernel();
51439
51440 mutex_lock(&pci_hp_mutex);
51441 /*
51442diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
51443index 07aa722..84514b4 100644
51444--- a/drivers/pci/hotplug/pciehp_core.c
51445+++ b/drivers/pci/hotplug/pciehp_core.c
51446@@ -92,7 +92,7 @@ static int init_slot(struct controller *ctrl)
51447 struct slot *slot = ctrl->slot;
51448 struct hotplug_slot *hotplug = NULL;
51449 struct hotplug_slot_info *info = NULL;
51450- struct hotplug_slot_ops *ops = NULL;
51451+ hotplug_slot_ops_no_const *ops = NULL;
51452 char name[SLOT_NAME_SIZE];
51453 int retval = -ENOMEM;
51454
51455diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
51456index c3e7dfc..cbd9625 100644
51457--- a/drivers/pci/msi.c
51458+++ b/drivers/pci/msi.c
51459@@ -513,8 +513,8 @@ static int populate_msi_sysfs(struct pci_dev *pdev)
51460 {
51461 struct attribute **msi_attrs;
51462 struct attribute *msi_attr;
51463- struct device_attribute *msi_dev_attr;
51464- struct attribute_group *msi_irq_group;
51465+ device_attribute_no_const *msi_dev_attr;
51466+ attribute_group_no_const *msi_irq_group;
51467 const struct attribute_group **msi_irq_groups;
51468 struct msi_desc *entry;
51469 int ret = -ENOMEM;
51470@@ -573,7 +573,7 @@ error_attrs:
51471 count = 0;
51472 msi_attr = msi_attrs[count];
51473 while (msi_attr) {
51474- msi_dev_attr = container_of(msi_attr, struct device_attribute, attr);
51475+ msi_dev_attr = container_of(msi_attr, device_attribute_no_const, attr);
51476 kfree(msi_attr->name);
51477 kfree(msi_dev_attr);
51478 ++count;
51479diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
51480index 312f23a..d21181c 100644
51481--- a/drivers/pci/pci-sysfs.c
51482+++ b/drivers/pci/pci-sysfs.c
51483@@ -1140,7 +1140,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
51484 {
51485 /* allocate attribute structure, piggyback attribute name */
51486 int name_len = write_combine ? 13 : 10;
51487- struct bin_attribute *res_attr;
51488+ bin_attribute_no_const *res_attr;
51489 int retval;
51490
51491 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
51492@@ -1317,7 +1317,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
51493 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
51494 {
51495 int retval;
51496- struct bin_attribute *attr;
51497+ bin_attribute_no_const *attr;
51498
51499 /* If the device has VPD, try to expose it in sysfs. */
51500 if (dev->vpd) {
51501@@ -1364,7 +1364,7 @@ int __must_check pci_create_sysfs_dev_files(struct pci_dev *pdev)
51502 {
51503 int retval;
51504 int rom_size = 0;
51505- struct bin_attribute *attr;
51506+ bin_attribute_no_const *attr;
51507
51508 if (!sysfs_initialized)
51509 return -EACCES;
51510diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
51511index 9bd762c2..6fb9504 100644
51512--- a/drivers/pci/pci.h
51513+++ b/drivers/pci/pci.h
51514@@ -99,7 +99,7 @@ struct pci_vpd_ops {
51515 struct pci_vpd {
51516 unsigned int len;
51517 const struct pci_vpd_ops *ops;
51518- struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
51519+ bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
51520 };
51521
51522 int pci_vpd_pci22_init(struct pci_dev *dev);
51523diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
51524index 7d4fcdc..2f6d8f8 100644
51525--- a/drivers/pci/pcie/aspm.c
51526+++ b/drivers/pci/pcie/aspm.c
51527@@ -27,9 +27,9 @@
51528 #define MODULE_PARAM_PREFIX "pcie_aspm."
51529
51530 /* Note: those are not register definitions */
51531-#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
51532-#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
51533-#define ASPM_STATE_L1 (4) /* L1 state */
51534+#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
51535+#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
51536+#define ASPM_STATE_L1 (4U) /* L1 state */
51537 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
51538 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
51539
51540diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c
51541index be35da2..ec16cdb 100644
51542--- a/drivers/pci/pcie/portdrv_pci.c
51543+++ b/drivers/pci/pcie/portdrv_pci.c
51544@@ -324,7 +324,7 @@ static int __init dmi_pcie_pme_disable_msi(const struct dmi_system_id *d)
51545 return 0;
51546 }
51547
51548-static struct dmi_system_id __initdata pcie_portdrv_dmi_table[] = {
51549+static const struct dmi_system_id __initconst pcie_portdrv_dmi_table[] = {
51550 /*
51551 * Boxes that should not use MSI for PCIe PME signaling.
51552 */
51553diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
51554index c911857..56f3f9d 100644
51555--- a/drivers/pci/probe.c
51556+++ b/drivers/pci/probe.c
51557@@ -176,7 +176,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
51558 u16 orig_cmd;
51559 struct pci_bus_region region, inverted_region;
51560
51561- mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
51562+ mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
51563
51564 /* No printks while decoding is disabled! */
51565 if (!dev->mmio_always_on) {
51566diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
51567index 3f155e7..0f4b1f0 100644
51568--- a/drivers/pci/proc.c
51569+++ b/drivers/pci/proc.c
51570@@ -434,7 +434,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
51571 static int __init pci_proc_init(void)
51572 {
51573 struct pci_dev *dev = NULL;
51574+
51575+#ifdef CONFIG_GRKERNSEC_PROC_ADD
51576+#ifdef CONFIG_GRKERNSEC_PROC_USER
51577+ proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
51578+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
51579+ proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
51580+#endif
51581+#else
51582 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
51583+#endif
51584 proc_create("devices", 0, proc_bus_pci_dir,
51585 &proc_bus_pci_dev_operations);
51586 proc_initialized = 1;
51587diff --git a/drivers/platform/chrome/chromeos_pstore.c b/drivers/platform/chrome/chromeos_pstore.c
51588index 3474920..acc9581 100644
51589--- a/drivers/platform/chrome/chromeos_pstore.c
51590+++ b/drivers/platform/chrome/chromeos_pstore.c
51591@@ -13,7 +13,7 @@
51592 #include <linux/platform_device.h>
51593 #include <linux/pstore_ram.h>
51594
51595-static struct dmi_system_id chromeos_pstore_dmi_table[] __initdata = {
51596+static const struct dmi_system_id chromeos_pstore_dmi_table[] __initconst = {
51597 {
51598 /*
51599 * Today all Chromebooks/boxes ship with Google_* as version and
51600diff --git a/drivers/platform/x86/alienware-wmi.c b/drivers/platform/x86/alienware-wmi.c
51601index 1e1e594..8fe59c5 100644
51602--- a/drivers/platform/x86/alienware-wmi.c
51603+++ b/drivers/platform/x86/alienware-wmi.c
51604@@ -150,7 +150,7 @@ struct wmax_led_args {
51605 } __packed;
51606
51607 static struct platform_device *platform_device;
51608-static struct device_attribute *zone_dev_attrs;
51609+static device_attribute_no_const *zone_dev_attrs;
51610 static struct attribute **zone_attrs;
51611 static struct platform_zone *zone_data;
51612
51613@@ -160,7 +160,7 @@ static struct platform_driver platform_driver = {
51614 }
51615 };
51616
51617-static struct attribute_group zone_attribute_group = {
51618+static attribute_group_no_const zone_attribute_group = {
51619 .name = "rgb_zones",
51620 };
51621
51622diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
51623index 7543a56..367ca8ed 100644
51624--- a/drivers/platform/x86/asus-wmi.c
51625+++ b/drivers/platform/x86/asus-wmi.c
51626@@ -1589,6 +1589,10 @@ static int show_dsts(struct seq_file *m, void *data)
51627 int err;
51628 u32 retval = -1;
51629
51630+#ifdef CONFIG_GRKERNSEC_KMEM
51631+ return -EPERM;
51632+#endif
51633+
51634 err = asus_wmi_get_devstate(asus, asus->debug.dev_id, &retval);
51635
51636 if (err < 0)
51637@@ -1605,6 +1609,10 @@ static int show_devs(struct seq_file *m, void *data)
51638 int err;
51639 u32 retval = -1;
51640
51641+#ifdef CONFIG_GRKERNSEC_KMEM
51642+ return -EPERM;
51643+#endif
51644+
51645 err = asus_wmi_set_devstate(asus->debug.dev_id, asus->debug.ctrl_param,
51646 &retval);
51647
51648@@ -1629,6 +1637,10 @@ static int show_call(struct seq_file *m, void *data)
51649 union acpi_object *obj;
51650 acpi_status status;
51651
51652+#ifdef CONFIG_GRKERNSEC_KMEM
51653+ return -EPERM;
51654+#endif
51655+
51656 status = wmi_evaluate_method(ASUS_WMI_MGMT_GUID,
51657 1, asus->debug.method_id,
51658 &input, &output);
51659diff --git a/drivers/platform/x86/compal-laptop.c b/drivers/platform/x86/compal-laptop.c
51660index b4e9447..9dc6ec34 100644
51661--- a/drivers/platform/x86/compal-laptop.c
51662+++ b/drivers/platform/x86/compal-laptop.c
51663@@ -765,7 +765,7 @@ static int dmi_check_cb_extra(const struct dmi_system_id *id)
51664 return 1;
51665 }
51666
51667-static struct dmi_system_id __initdata compal_dmi_table[] = {
51668+static const struct dmi_system_id __initconst compal_dmi_table[] = {
51669 {
51670 .ident = "FL90/IFL90",
51671 .matches = {
51672diff --git a/drivers/platform/x86/hdaps.c b/drivers/platform/x86/hdaps.c
51673index 458e6c9..089aee7 100644
51674--- a/drivers/platform/x86/hdaps.c
51675+++ b/drivers/platform/x86/hdaps.c
51676@@ -514,7 +514,7 @@ static int __init hdaps_dmi_match_invert(const struct dmi_system_id *id)
51677 "ThinkPad T42p", so the order of the entries matters.
51678 If your ThinkPad is not recognized, please update to latest
51679 BIOS. This is especially the case for some R52 ThinkPads. */
51680-static struct dmi_system_id __initdata hdaps_whitelist[] = {
51681+static const struct dmi_system_id __initconst hdaps_whitelist[] = {
51682 HDAPS_DMI_MATCH_INVERT("IBM", "ThinkPad R50p", HDAPS_BOTH_AXES),
51683 HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad R50"),
51684 HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad R51"),
51685diff --git a/drivers/platform/x86/ibm_rtl.c b/drivers/platform/x86/ibm_rtl.c
51686index 97c2be1..2ee50ce 100644
51687--- a/drivers/platform/x86/ibm_rtl.c
51688+++ b/drivers/platform/x86/ibm_rtl.c
51689@@ -227,7 +227,7 @@ static void rtl_teardown_sysfs(void) {
51690 }
51691
51692
51693-static struct dmi_system_id __initdata ibm_rtl_dmi_table[] = {
51694+static const struct dmi_system_id __initconst ibm_rtl_dmi_table[] = {
51695 { \
51696 .matches = { \
51697 DMI_MATCH(DMI_SYS_VENDOR, "IBM"), \
51698diff --git a/drivers/platform/x86/intel_oaktrail.c b/drivers/platform/x86/intel_oaktrail.c
51699index 8037c8b..f88445c 100644
51700--- a/drivers/platform/x86/intel_oaktrail.c
51701+++ b/drivers/platform/x86/intel_oaktrail.c
51702@@ -298,7 +298,7 @@ static int dmi_check_cb(const struct dmi_system_id *id)
51703 return 0;
51704 }
51705
51706-static struct dmi_system_id __initdata oaktrail_dmi_table[] = {
51707+static const struct dmi_system_id __initconst oaktrail_dmi_table[] = {
51708 {
51709 .ident = "OakTrail platform",
51710 .matches = {
51711diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
51712index 0859877..59d596d 100644
51713--- a/drivers/platform/x86/msi-laptop.c
51714+++ b/drivers/platform/x86/msi-laptop.c
51715@@ -604,7 +604,7 @@ static int dmi_check_cb(const struct dmi_system_id *dmi)
51716 return 1;
51717 }
51718
51719-static struct dmi_system_id __initdata msi_dmi_table[] = {
51720+static const struct dmi_system_id __initconst msi_dmi_table[] = {
51721 {
51722 .ident = "MSI S270",
51723 .matches = {
51724@@ -999,12 +999,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
51725
51726 if (!quirks->ec_read_only) {
51727 /* allow userland write sysfs file */
51728- dev_attr_bluetooth.store = store_bluetooth;
51729- dev_attr_wlan.store = store_wlan;
51730- dev_attr_threeg.store = store_threeg;
51731- dev_attr_bluetooth.attr.mode |= S_IWUSR;
51732- dev_attr_wlan.attr.mode |= S_IWUSR;
51733- dev_attr_threeg.attr.mode |= S_IWUSR;
51734+ pax_open_kernel();
51735+ *(void **)&dev_attr_bluetooth.store = store_bluetooth;
51736+ *(void **)&dev_attr_wlan.store = store_wlan;
51737+ *(void **)&dev_attr_threeg.store = store_threeg;
51738+ *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
51739+ *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
51740+ *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
51741+ pax_close_kernel();
51742 }
51743
51744 /* disable hardware control by fn key */
51745diff --git a/drivers/platform/x86/msi-wmi.c b/drivers/platform/x86/msi-wmi.c
51746index 6d2bac0..ec2b029 100644
51747--- a/drivers/platform/x86/msi-wmi.c
51748+++ b/drivers/platform/x86/msi-wmi.c
51749@@ -183,7 +183,7 @@ static const struct backlight_ops msi_backlight_ops = {
51750 static void msi_wmi_notify(u32 value, void *context)
51751 {
51752 struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
51753- static struct key_entry *key;
51754+ struct key_entry *key;
51755 union acpi_object *obj;
51756 acpi_status status;
51757
51758diff --git a/drivers/platform/x86/samsung-laptop.c b/drivers/platform/x86/samsung-laptop.c
51759index 9e701b2..c68a7b5 100644
51760--- a/drivers/platform/x86/samsung-laptop.c
51761+++ b/drivers/platform/x86/samsung-laptop.c
51762@@ -1567,7 +1567,7 @@ static int __init samsung_dmi_matched(const struct dmi_system_id *d)
51763 return 0;
51764 }
51765
51766-static struct dmi_system_id __initdata samsung_dmi_table[] = {
51767+static const struct dmi_system_id __initconst samsung_dmi_table[] = {
51768 {
51769 .matches = {
51770 DMI_MATCH(DMI_SYS_VENDOR,
51771diff --git a/drivers/platform/x86/samsung-q10.c b/drivers/platform/x86/samsung-q10.c
51772index e6aac72..e11ff24 100644
51773--- a/drivers/platform/x86/samsung-q10.c
51774+++ b/drivers/platform/x86/samsung-q10.c
51775@@ -95,7 +95,7 @@ static int __init dmi_check_callback(const struct dmi_system_id *id)
51776 return 1;
51777 }
51778
51779-static struct dmi_system_id __initdata samsungq10_dmi_table[] = {
51780+static const struct dmi_system_id __initconst samsungq10_dmi_table[] = {
51781 {
51782 .ident = "Samsung Q10",
51783 .matches = {
51784diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
51785index e51c1e7..71bb385 100644
51786--- a/drivers/platform/x86/sony-laptop.c
51787+++ b/drivers/platform/x86/sony-laptop.c
51788@@ -2526,7 +2526,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
51789 }
51790
51791 /* High speed charging function */
51792-static struct device_attribute *hsc_handle;
51793+static device_attribute_no_const *hsc_handle;
51794
51795 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
51796 struct device_attribute *attr,
51797@@ -2600,7 +2600,7 @@ static void sony_nc_highspeed_charging_cleanup(struct platform_device *pd)
51798 }
51799
51800 /* low battery function */
51801-static struct device_attribute *lowbatt_handle;
51802+static device_attribute_no_const *lowbatt_handle;
51803
51804 static ssize_t sony_nc_lowbatt_store(struct device *dev,
51805 struct device_attribute *attr,
51806@@ -2666,7 +2666,7 @@ static void sony_nc_lowbatt_cleanup(struct platform_device *pd)
51807 }
51808
51809 /* fan speed function */
51810-static struct device_attribute *fan_handle, *hsf_handle;
51811+static device_attribute_no_const *fan_handle, *hsf_handle;
51812
51813 static ssize_t sony_nc_hsfan_store(struct device *dev,
51814 struct device_attribute *attr,
51815@@ -2773,7 +2773,7 @@ static void sony_nc_fanspeed_cleanup(struct platform_device *pd)
51816 }
51817
51818 /* USB charge function */
51819-static struct device_attribute *uc_handle;
51820+static device_attribute_no_const *uc_handle;
51821
51822 static ssize_t sony_nc_usb_charge_store(struct device *dev,
51823 struct device_attribute *attr,
51824@@ -2847,7 +2847,7 @@ static void sony_nc_usb_charge_cleanup(struct platform_device *pd)
51825 }
51826
51827 /* Panel ID function */
51828-static struct device_attribute *panel_handle;
51829+static device_attribute_no_const *panel_handle;
51830
51831 static ssize_t sony_nc_panelid_show(struct device *dev,
51832 struct device_attribute *attr, char *buffer)
51833@@ -2894,7 +2894,7 @@ static void sony_nc_panelid_cleanup(struct platform_device *pd)
51834 }
51835
51836 /* smart connect function */
51837-static struct device_attribute *sc_handle;
51838+static device_attribute_no_const *sc_handle;
51839
51840 static ssize_t sony_nc_smart_conn_store(struct device *dev,
51841 struct device_attribute *attr,
51842@@ -4854,7 +4854,7 @@ static struct acpi_driver sony_pic_driver = {
51843 .drv.pm = &sony_pic_pm,
51844 };
51845
51846-static struct dmi_system_id __initdata sonypi_dmi_table[] = {
51847+static const struct dmi_system_id __initconst sonypi_dmi_table[] = {
51848 {
51849 .ident = "Sony Vaio",
51850 .matches = {
51851diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
51852index 28f3281..171d8c3 100644
51853--- a/drivers/platform/x86/thinkpad_acpi.c
51854+++ b/drivers/platform/x86/thinkpad_acpi.c
51855@@ -2459,10 +2459,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
51856 && !tp_features.bright_unkfw)
51857 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
51858 }
51859+}
51860
51861 #undef TPACPI_COMPARE_KEY
51862 #undef TPACPI_MAY_SEND_KEY
51863-}
51864
51865 /*
51866 * Polling driver
51867diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
51868index 438d4c7..ca8a2fb 100644
51869--- a/drivers/pnp/pnpbios/bioscalls.c
51870+++ b/drivers/pnp/pnpbios/bioscalls.c
51871@@ -59,7 +59,7 @@ do { \
51872 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
51873 } while(0)
51874
51875-static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
51876+static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
51877 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
51878
51879 /*
51880@@ -96,7 +96,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
51881
51882 cpu = get_cpu();
51883 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
51884+
51885+ pax_open_kernel();
51886 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
51887+ pax_close_kernel();
51888
51889 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
51890 spin_lock_irqsave(&pnp_bios_lock, flags);
51891@@ -134,7 +137,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
51892 :"memory");
51893 spin_unlock_irqrestore(&pnp_bios_lock, flags);
51894
51895+ pax_open_kernel();
51896 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
51897+ pax_close_kernel();
51898+
51899 put_cpu();
51900
51901 /* If we get here and this is set then the PnP BIOS faulted on us. */
51902@@ -468,7 +474,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
51903 return status;
51904 }
51905
51906-void pnpbios_calls_init(union pnp_bios_install_struct *header)
51907+void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
51908 {
51909 int i;
51910
51911@@ -476,6 +482,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
51912 pnp_bios_callpoint.offset = header->fields.pm16offset;
51913 pnp_bios_callpoint.segment = PNP_CS16;
51914
51915+ pax_open_kernel();
51916+
51917 for_each_possible_cpu(i) {
51918 struct desc_struct *gdt = get_cpu_gdt_table(i);
51919 if (!gdt)
51920@@ -487,4 +495,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
51921 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
51922 (unsigned long)__va(header->fields.pm16dseg));
51923 }
51924+
51925+ pax_close_kernel();
51926 }
51927diff --git a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c
51928index facd43b..b291260 100644
51929--- a/drivers/pnp/pnpbios/core.c
51930+++ b/drivers/pnp/pnpbios/core.c
51931@@ -494,7 +494,7 @@ static int __init exploding_pnp_bios(const struct dmi_system_id *d)
51932 return 0;
51933 }
51934
51935-static struct dmi_system_id pnpbios_dmi_table[] __initdata = {
51936+static const struct dmi_system_id pnpbios_dmi_table[] __initconst = {
51937 { /* PnPBIOS GPF on boot */
51938 .callback = exploding_pnp_bios,
51939 .ident = "Higraded P14H",
51940diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
51941index dfe1ee8..67e820c 100644
51942--- a/drivers/power/pda_power.c
51943+++ b/drivers/power/pda_power.c
51944@@ -38,7 +38,11 @@ static struct power_supply *pda_psy_ac, *pda_psy_usb;
51945
51946 #if IS_ENABLED(CONFIG_USB_PHY)
51947 static struct usb_phy *transceiver;
51948-static struct notifier_block otg_nb;
51949+static int otg_handle_notification(struct notifier_block *nb,
51950+ unsigned long event, void *unused);
51951+static struct notifier_block otg_nb = {
51952+ .notifier_call = otg_handle_notification
51953+};
51954 #endif
51955
51956 static struct regulator *ac_draw;
51957@@ -373,7 +377,6 @@ static int pda_power_probe(struct platform_device *pdev)
51958
51959 #if IS_ENABLED(CONFIG_USB_PHY)
51960 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
51961- otg_nb.notifier_call = otg_handle_notification;
51962 ret = usb_register_notifier(transceiver, &otg_nb);
51963 if (ret) {
51964 dev_err(dev, "failure to register otg notifier\n");
51965diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
51966index cc439fd..8fa30df 100644
51967--- a/drivers/power/power_supply.h
51968+++ b/drivers/power/power_supply.h
51969@@ -16,12 +16,12 @@ struct power_supply;
51970
51971 #ifdef CONFIG_SYSFS
51972
51973-extern void power_supply_init_attrs(struct device_type *dev_type);
51974+extern void power_supply_init_attrs(void);
51975 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
51976
51977 #else
51978
51979-static inline void power_supply_init_attrs(struct device_type *dev_type) {}
51980+static inline void power_supply_init_attrs(void) {}
51981 #define power_supply_uevent NULL
51982
51983 #endif /* CONFIG_SYSFS */
51984diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
51985index 4bc0c7f..198c99d 100644
51986--- a/drivers/power/power_supply_core.c
51987+++ b/drivers/power/power_supply_core.c
51988@@ -28,7 +28,10 @@ EXPORT_SYMBOL_GPL(power_supply_class);
51989 ATOMIC_NOTIFIER_HEAD(power_supply_notifier);
51990 EXPORT_SYMBOL_GPL(power_supply_notifier);
51991
51992-static struct device_type power_supply_dev_type;
51993+extern const struct attribute_group *power_supply_attr_groups[];
51994+static struct device_type power_supply_dev_type = {
51995+ .groups = power_supply_attr_groups,
51996+};
51997
51998 #define POWER_SUPPLY_DEFERRED_REGISTER_TIME msecs_to_jiffies(10)
51999
52000@@ -921,7 +924,7 @@ static int __init power_supply_class_init(void)
52001 return PTR_ERR(power_supply_class);
52002
52003 power_supply_class->dev_uevent = power_supply_uevent;
52004- power_supply_init_attrs(&power_supply_dev_type);
52005+ power_supply_init_attrs();
52006
52007 return 0;
52008 }
52009diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
52010index 9134e3d..45eee1e 100644
52011--- a/drivers/power/power_supply_sysfs.c
52012+++ b/drivers/power/power_supply_sysfs.c
52013@@ -238,17 +238,15 @@ static struct attribute_group power_supply_attr_group = {
52014 .is_visible = power_supply_attr_is_visible,
52015 };
52016
52017-static const struct attribute_group *power_supply_attr_groups[] = {
52018+const struct attribute_group *power_supply_attr_groups[] = {
52019 &power_supply_attr_group,
52020 NULL,
52021 };
52022
52023-void power_supply_init_attrs(struct device_type *dev_type)
52024+void power_supply_init_attrs(void)
52025 {
52026 int i;
52027
52028- dev_type->groups = power_supply_attr_groups;
52029-
52030 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
52031 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
52032 }
52033diff --git a/drivers/powercap/powercap_sys.c b/drivers/powercap/powercap_sys.c
52034index 84419af..268ede8 100644
52035--- a/drivers/powercap/powercap_sys.c
52036+++ b/drivers/powercap/powercap_sys.c
52037@@ -154,8 +154,77 @@ struct powercap_constraint_attr {
52038 struct device_attribute name_attr;
52039 };
52040
52041+static ssize_t show_constraint_name(struct device *dev,
52042+ struct device_attribute *dev_attr,
52043+ char *buf);
52044+
52045 static struct powercap_constraint_attr
52046- constraint_attrs[MAX_CONSTRAINTS_PER_ZONE];
52047+ constraint_attrs[MAX_CONSTRAINTS_PER_ZONE] = {
52048+ [0 ... MAX_CONSTRAINTS_PER_ZONE - 1] = {
52049+ .power_limit_attr = {
52050+ .attr = {
52051+ .name = NULL,
52052+ .mode = S_IWUSR | S_IRUGO
52053+ },
52054+ .show = show_constraint_power_limit_uw,
52055+ .store = store_constraint_power_limit_uw
52056+ },
52057+
52058+ .time_window_attr = {
52059+ .attr = {
52060+ .name = NULL,
52061+ .mode = S_IWUSR | S_IRUGO
52062+ },
52063+ .show = show_constraint_time_window_us,
52064+ .store = store_constraint_time_window_us
52065+ },
52066+
52067+ .max_power_attr = {
52068+ .attr = {
52069+ .name = NULL,
52070+ .mode = S_IRUGO
52071+ },
52072+ .show = show_constraint_max_power_uw,
52073+ .store = NULL
52074+ },
52075+
52076+ .min_power_attr = {
52077+ .attr = {
52078+ .name = NULL,
52079+ .mode = S_IRUGO
52080+ },
52081+ .show = show_constraint_min_power_uw,
52082+ .store = NULL
52083+ },
52084+
52085+ .max_time_window_attr = {
52086+ .attr = {
52087+ .name = NULL,
52088+ .mode = S_IRUGO
52089+ },
52090+ .show = show_constraint_max_time_window_us,
52091+ .store = NULL
52092+ },
52093+
52094+ .min_time_window_attr = {
52095+ .attr = {
52096+ .name = NULL,
52097+ .mode = S_IRUGO
52098+ },
52099+ .show = show_constraint_min_time_window_us,
52100+ .store = NULL
52101+ },
52102+
52103+ .name_attr = {
52104+ .attr = {
52105+ .name = NULL,
52106+ .mode = S_IRUGO
52107+ },
52108+ .show = show_constraint_name,
52109+ .store = NULL
52110+ }
52111+ }
52112+};
52113
52114 /* A list of powercap control_types */
52115 static LIST_HEAD(powercap_cntrl_list);
52116@@ -193,23 +262,16 @@ static ssize_t show_constraint_name(struct device *dev,
52117 }
52118
52119 static int create_constraint_attribute(int id, const char *name,
52120- int mode,
52121- struct device_attribute *dev_attr,
52122- ssize_t (*show)(struct device *,
52123- struct device_attribute *, char *),
52124- ssize_t (*store)(struct device *,
52125- struct device_attribute *,
52126- const char *, size_t)
52127- )
52128+ struct device_attribute *dev_attr)
52129 {
52130+ name = kasprintf(GFP_KERNEL, "constraint_%d_%s", id, name);
52131
52132- dev_attr->attr.name = kasprintf(GFP_KERNEL, "constraint_%d_%s",
52133- id, name);
52134- if (!dev_attr->attr.name)
52135+ if (!name)
52136 return -ENOMEM;
52137- dev_attr->attr.mode = mode;
52138- dev_attr->show = show;
52139- dev_attr->store = store;
52140+
52141+ pax_open_kernel();
52142+ *(const char **)&dev_attr->attr.name = name;
52143+ pax_close_kernel();
52144
52145 return 0;
52146 }
52147@@ -236,49 +298,31 @@ static int seed_constraint_attributes(void)
52148
52149 for (i = 0; i < MAX_CONSTRAINTS_PER_ZONE; ++i) {
52150 ret = create_constraint_attribute(i, "power_limit_uw",
52151- S_IWUSR | S_IRUGO,
52152- &constraint_attrs[i].power_limit_attr,
52153- show_constraint_power_limit_uw,
52154- store_constraint_power_limit_uw);
52155+ &constraint_attrs[i].power_limit_attr);
52156 if (ret)
52157 goto err_alloc;
52158 ret = create_constraint_attribute(i, "time_window_us",
52159- S_IWUSR | S_IRUGO,
52160- &constraint_attrs[i].time_window_attr,
52161- show_constraint_time_window_us,
52162- store_constraint_time_window_us);
52163+ &constraint_attrs[i].time_window_attr);
52164 if (ret)
52165 goto err_alloc;
52166- ret = create_constraint_attribute(i, "name", S_IRUGO,
52167- &constraint_attrs[i].name_attr,
52168- show_constraint_name,
52169- NULL);
52170+ ret = create_constraint_attribute(i, "name",
52171+ &constraint_attrs[i].name_attr);
52172 if (ret)
52173 goto err_alloc;
52174- ret = create_constraint_attribute(i, "max_power_uw", S_IRUGO,
52175- &constraint_attrs[i].max_power_attr,
52176- show_constraint_max_power_uw,
52177- NULL);
52178+ ret = create_constraint_attribute(i, "max_power_uw",
52179+ &constraint_attrs[i].max_power_attr);
52180 if (ret)
52181 goto err_alloc;
52182- ret = create_constraint_attribute(i, "min_power_uw", S_IRUGO,
52183- &constraint_attrs[i].min_power_attr,
52184- show_constraint_min_power_uw,
52185- NULL);
52186+ ret = create_constraint_attribute(i, "min_power_uw",
52187+ &constraint_attrs[i].min_power_attr);
52188 if (ret)
52189 goto err_alloc;
52190 ret = create_constraint_attribute(i, "max_time_window_us",
52191- S_IRUGO,
52192- &constraint_attrs[i].max_time_window_attr,
52193- show_constraint_max_time_window_us,
52194- NULL);
52195+ &constraint_attrs[i].max_time_window_attr);
52196 if (ret)
52197 goto err_alloc;
52198 ret = create_constraint_attribute(i, "min_time_window_us",
52199- S_IRUGO,
52200- &constraint_attrs[i].min_time_window_attr,
52201- show_constraint_min_time_window_us,
52202- NULL);
52203+ &constraint_attrs[i].min_time_window_attr);
52204 if (ret)
52205 goto err_alloc;
52206
52207@@ -378,10 +422,12 @@ static void create_power_zone_common_attributes(
52208 power_zone->zone_dev_attrs[count++] =
52209 &dev_attr_max_energy_range_uj.attr;
52210 if (power_zone->ops->get_energy_uj) {
52211+ pax_open_kernel();
52212 if (power_zone->ops->reset_energy_uj)
52213- dev_attr_energy_uj.attr.mode = S_IWUSR | S_IRUGO;
52214+ *(umode_t *)&dev_attr_energy_uj.attr.mode = S_IWUSR | S_IRUGO;
52215 else
52216- dev_attr_energy_uj.attr.mode = S_IRUGO;
52217+ *(umode_t *)&dev_attr_energy_uj.attr.mode = S_IRUGO;
52218+ pax_close_kernel();
52219 power_zone->zone_dev_attrs[count++] =
52220 &dev_attr_energy_uj.attr;
52221 }
52222diff --git a/drivers/ptp/ptp_private.h b/drivers/ptp/ptp_private.h
52223index 9c5d414..c7900ce 100644
52224--- a/drivers/ptp/ptp_private.h
52225+++ b/drivers/ptp/ptp_private.h
52226@@ -51,7 +51,7 @@ struct ptp_clock {
52227 struct mutex pincfg_mux; /* protect concurrent info->pin_config access */
52228 wait_queue_head_t tsev_wq;
52229 int defunct; /* tells readers to go away when clock is being removed */
52230- struct device_attribute *pin_dev_attr;
52231+ device_attribute_no_const *pin_dev_attr;
52232 struct attribute **pin_attr;
52233 struct attribute_group pin_attr_group;
52234 };
52235diff --git a/drivers/ptp/ptp_sysfs.c b/drivers/ptp/ptp_sysfs.c
52236index 302e626..12579af 100644
52237--- a/drivers/ptp/ptp_sysfs.c
52238+++ b/drivers/ptp/ptp_sysfs.c
52239@@ -280,7 +280,7 @@ static int ptp_populate_pins(struct ptp_clock *ptp)
52240 goto no_pin_attr;
52241
52242 for (i = 0; i < n_pins; i++) {
52243- struct device_attribute *da = &ptp->pin_dev_attr[i];
52244+ device_attribute_no_const *da = &ptp->pin_dev_attr[i];
52245 sysfs_attr_init(&da->attr);
52246 da->attr.name = info->pin_config[i].name;
52247 da->attr.mode = 0644;
52248diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
52249index 8a28116..05b0ad5 100644
52250--- a/drivers/regulator/core.c
52251+++ b/drivers/regulator/core.c
52252@@ -3603,7 +3603,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
52253 const struct regulation_constraints *constraints = NULL;
52254 const struct regulator_init_data *init_data;
52255 struct regulator_config *config = NULL;
52256- static atomic_t regulator_no = ATOMIC_INIT(-1);
52257+ static atomic_unchecked_t regulator_no = ATOMIC_INIT(-1);
52258 struct regulator_dev *rdev;
52259 struct device *dev;
52260 int ret, i;
52261@@ -3686,7 +3686,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
52262 rdev->dev.class = &regulator_class;
52263 rdev->dev.parent = dev;
52264 dev_set_name(&rdev->dev, "regulator.%lu",
52265- (unsigned long) atomic_inc_return(&regulator_no));
52266+ (unsigned long) atomic_inc_return_unchecked(&regulator_no));
52267 ret = device_register(&rdev->dev);
52268 if (ret != 0) {
52269 put_device(&rdev->dev);
52270diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
52271index 4071d74..260b15a 100644
52272--- a/drivers/regulator/max8660.c
52273+++ b/drivers/regulator/max8660.c
52274@@ -423,8 +423,10 @@ static int max8660_probe(struct i2c_client *client,
52275 max8660->shadow_regs[MAX8660_OVER1] = 5;
52276 } else {
52277 /* Otherwise devices can be toggled via software */
52278- max8660_dcdc_ops.enable = max8660_dcdc_enable;
52279- max8660_dcdc_ops.disable = max8660_dcdc_disable;
52280+ pax_open_kernel();
52281+ *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
52282+ *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
52283+ pax_close_kernel();
52284 }
52285
52286 /*
52287diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
52288index c3d55c2..0dddfe6 100644
52289--- a/drivers/regulator/max8973-regulator.c
52290+++ b/drivers/regulator/max8973-regulator.c
52291@@ -403,9 +403,11 @@ static int max8973_probe(struct i2c_client *client,
52292 if (!pdata || !pdata->enable_ext_control) {
52293 max->desc.enable_reg = MAX8973_VOUT;
52294 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
52295- max->ops.enable = regulator_enable_regmap;
52296- max->ops.disable = regulator_disable_regmap;
52297- max->ops.is_enabled = regulator_is_enabled_regmap;
52298+ pax_open_kernel();
52299+ *(void **)&max->ops.enable = regulator_enable_regmap;
52300+ *(void **)&max->ops.disable = regulator_disable_regmap;
52301+ *(void **)&max->ops.is_enabled = regulator_is_enabled_regmap;
52302+ pax_close_kernel();
52303 }
52304
52305 if (pdata) {
52306diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
52307index 0d17c92..a29f627 100644
52308--- a/drivers/regulator/mc13892-regulator.c
52309+++ b/drivers/regulator/mc13892-regulator.c
52310@@ -584,10 +584,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
52311 mc13xxx_unlock(mc13892);
52312
52313 /* update mc13892_vcam ops */
52314- memcpy(&mc13892_vcam_ops, mc13892_regulators[MC13892_VCAM].desc.ops,
52315+ pax_open_kernel();
52316+ memcpy((void *)&mc13892_vcam_ops, mc13892_regulators[MC13892_VCAM].desc.ops,
52317 sizeof(struct regulator_ops));
52318- mc13892_vcam_ops.set_mode = mc13892_vcam_set_mode,
52319- mc13892_vcam_ops.get_mode = mc13892_vcam_get_mode,
52320+ *(void **)&mc13892_vcam_ops.set_mode = mc13892_vcam_set_mode,
52321+ *(void **)&mc13892_vcam_ops.get_mode = mc13892_vcam_get_mode,
52322+ pax_close_kernel();
52323 mc13892_regulators[MC13892_VCAM].desc.ops = &mc13892_vcam_ops;
52324
52325 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
52326diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
52327index a82556a0..e842923 100644
52328--- a/drivers/rtc/rtc-cmos.c
52329+++ b/drivers/rtc/rtc-cmos.c
52330@@ -793,7 +793,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
52331 hpet_rtc_timer_init();
52332
52333 /* export at least the first block of NVRAM */
52334- nvram.size = address_space - NVRAM_OFFSET;
52335+ pax_open_kernel();
52336+ *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
52337+ pax_close_kernel();
52338 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
52339 if (retval < 0) {
52340 dev_dbg(dev, "can't create nvram file? %d\n", retval);
52341diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
52342index 799c34b..8e9786a 100644
52343--- a/drivers/rtc/rtc-dev.c
52344+++ b/drivers/rtc/rtc-dev.c
52345@@ -16,6 +16,7 @@
52346 #include <linux/module.h>
52347 #include <linux/rtc.h>
52348 #include <linux/sched.h>
52349+#include <linux/grsecurity.h>
52350 #include "rtc-core.h"
52351
52352 static dev_t rtc_devt;
52353@@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
52354 if (copy_from_user(&tm, uarg, sizeof(tm)))
52355 return -EFAULT;
52356
52357+ gr_log_timechange();
52358+
52359 return rtc_set_time(rtc, &tm);
52360
52361 case RTC_PIE_ON:
52362diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
52363index 4ffabb3..1f87fca 100644
52364--- a/drivers/rtc/rtc-ds1307.c
52365+++ b/drivers/rtc/rtc-ds1307.c
52366@@ -107,7 +107,7 @@ struct ds1307 {
52367 u8 offset; /* register's offset */
52368 u8 regs[11];
52369 u16 nvram_offset;
52370- struct bin_attribute *nvram;
52371+ bin_attribute_no_const *nvram;
52372 enum ds_type type;
52373 unsigned long flags;
52374 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
52375diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
52376index 90abb5b..e0bf6dd 100644
52377--- a/drivers/rtc/rtc-m48t59.c
52378+++ b/drivers/rtc/rtc-m48t59.c
52379@@ -483,7 +483,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
52380 if (IS_ERR(m48t59->rtc))
52381 return PTR_ERR(m48t59->rtc);
52382
52383- m48t59_nvram_attr.size = pdata->offset;
52384+ pax_open_kernel();
52385+ *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
52386+ pax_close_kernel();
52387
52388 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
52389 if (ret)
52390diff --git a/drivers/rtc/rtc-test.c b/drivers/rtc/rtc-test.c
52391index 3a2da4c..e88493c 100644
52392--- a/drivers/rtc/rtc-test.c
52393+++ b/drivers/rtc/rtc-test.c
52394@@ -112,8 +112,10 @@ static int test_probe(struct platform_device *plat_dev)
52395 struct rtc_device *rtc;
52396
52397 if (test_mmss64) {
52398- test_rtc_ops.set_mmss64 = test_rtc_set_mmss64;
52399- test_rtc_ops.set_mmss = NULL;
52400+ pax_open_kernel();
52401+ *(void **)&test_rtc_ops.set_mmss64 = test_rtc_set_mmss64;
52402+ *(void **)&test_rtc_ops.set_mmss = NULL;
52403+ pax_close_kernel();
52404 }
52405
52406 rtc = devm_rtc_device_register(&plat_dev->dev, "test",
52407diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
52408index 1f74760..8e00a89 100644
52409--- a/drivers/scsi/be2iscsi/be_main.c
52410+++ b/drivers/scsi/be2iscsi/be_main.c
52411@@ -3165,7 +3165,7 @@ be_sgl_create_contiguous(void *virtual_address,
52412 {
52413 WARN_ON(!virtual_address);
52414 WARN_ON(!physical_address);
52415- WARN_ON(!length > 0);
52416+ WARN_ON(!length);
52417 WARN_ON(!sgl);
52418
52419 sgl->va = virtual_address;
52420diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
52421index e693af6..2e525b6 100644
52422--- a/drivers/scsi/bfa/bfa_fcpim.h
52423+++ b/drivers/scsi/bfa/bfa_fcpim.h
52424@@ -36,7 +36,7 @@ struct bfa_iotag_s {
52425
52426 struct bfa_itn_s {
52427 bfa_isr_func_t isr;
52428-};
52429+} __no_const;
52430
52431 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
52432 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
52433diff --git a/drivers/scsi/bfa/bfa_fcs.c b/drivers/scsi/bfa/bfa_fcs.c
52434index 0f19455..ef7adb5 100644
52435--- a/drivers/scsi/bfa/bfa_fcs.c
52436+++ b/drivers/scsi/bfa/bfa_fcs.c
52437@@ -38,10 +38,21 @@ struct bfa_fcs_mod_s {
52438 #define BFA_FCS_MODULE(_mod) { _mod ## _modinit, _mod ## _modexit }
52439
52440 static struct bfa_fcs_mod_s fcs_modules[] = {
52441- { bfa_fcs_port_attach, NULL, NULL },
52442- { bfa_fcs_uf_attach, NULL, NULL },
52443- { bfa_fcs_fabric_attach, bfa_fcs_fabric_modinit,
52444- bfa_fcs_fabric_modexit },
52445+ {
52446+ .attach = bfa_fcs_port_attach,
52447+ .modinit = NULL,
52448+ .modexit = NULL
52449+ },
52450+ {
52451+ .attach = bfa_fcs_uf_attach,
52452+ .modinit = NULL,
52453+ .modexit = NULL
52454+ },
52455+ {
52456+ .attach = bfa_fcs_fabric_attach,
52457+ .modinit = bfa_fcs_fabric_modinit,
52458+ .modexit = bfa_fcs_fabric_modexit
52459+ },
52460 };
52461
52462 /*
52463diff --git a/drivers/scsi/bfa/bfa_fcs_lport.c b/drivers/scsi/bfa/bfa_fcs_lport.c
52464index ff75ef8..2dfe00a 100644
52465--- a/drivers/scsi/bfa/bfa_fcs_lport.c
52466+++ b/drivers/scsi/bfa/bfa_fcs_lport.c
52467@@ -89,15 +89,26 @@ static struct {
52468 void (*offline) (struct bfa_fcs_lport_s *port);
52469 } __port_action[] = {
52470 {
52471- bfa_fcs_lport_unknown_init, bfa_fcs_lport_unknown_online,
52472- bfa_fcs_lport_unknown_offline}, {
52473- bfa_fcs_lport_fab_init, bfa_fcs_lport_fab_online,
52474- bfa_fcs_lport_fab_offline}, {
52475- bfa_fcs_lport_n2n_init, bfa_fcs_lport_n2n_online,
52476- bfa_fcs_lport_n2n_offline}, {
52477- bfa_fcs_lport_loop_init, bfa_fcs_lport_loop_online,
52478- bfa_fcs_lport_loop_offline},
52479- };
52480+ .init = bfa_fcs_lport_unknown_init,
52481+ .online = bfa_fcs_lport_unknown_online,
52482+ .offline = bfa_fcs_lport_unknown_offline
52483+ },
52484+ {
52485+ .init = bfa_fcs_lport_fab_init,
52486+ .online = bfa_fcs_lport_fab_online,
52487+ .offline = bfa_fcs_lport_fab_offline
52488+ },
52489+ {
52490+ .init = bfa_fcs_lport_n2n_init,
52491+ .online = bfa_fcs_lport_n2n_online,
52492+ .offline = bfa_fcs_lport_n2n_offline
52493+ },
52494+ {
52495+ .init = bfa_fcs_lport_loop_init,
52496+ .online = bfa_fcs_lport_loop_online,
52497+ .offline = bfa_fcs_lport_loop_offline
52498+ },
52499+};
52500
52501 /*
52502 * fcs_port_sm FCS logical port state machine
52503diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
52504index a38aafa0..fe8f03b 100644
52505--- a/drivers/scsi/bfa/bfa_ioc.h
52506+++ b/drivers/scsi/bfa/bfa_ioc.h
52507@@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
52508 bfa_ioc_disable_cbfn_t disable_cbfn;
52509 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
52510 bfa_ioc_reset_cbfn_t reset_cbfn;
52511-};
52512+} __no_const;
52513
52514 /*
52515 * IOC event notification mechanism.
52516@@ -352,7 +352,7 @@ struct bfa_ioc_hwif_s {
52517 void (*ioc_set_alt_fwstate) (struct bfa_ioc_s *ioc,
52518 enum bfi_ioc_state fwstate);
52519 enum bfi_ioc_state (*ioc_get_alt_fwstate) (struct bfa_ioc_s *ioc);
52520-};
52521+} __no_const;
52522
52523 /*
52524 * Queue element to wait for room in request queue. FIFO order is
52525diff --git a/drivers/scsi/bfa/bfa_modules.h b/drivers/scsi/bfa/bfa_modules.h
52526index a14c784..6de6790 100644
52527--- a/drivers/scsi/bfa/bfa_modules.h
52528+++ b/drivers/scsi/bfa/bfa_modules.h
52529@@ -78,12 +78,12 @@ enum {
52530 \
52531 extern struct bfa_module_s hal_mod_ ## __mod; \
52532 struct bfa_module_s hal_mod_ ## __mod = { \
52533- bfa_ ## __mod ## _meminfo, \
52534- bfa_ ## __mod ## _attach, \
52535- bfa_ ## __mod ## _detach, \
52536- bfa_ ## __mod ## _start, \
52537- bfa_ ## __mod ## _stop, \
52538- bfa_ ## __mod ## _iocdisable, \
52539+ .meminfo = bfa_ ## __mod ## _meminfo, \
52540+ .attach = bfa_ ## __mod ## _attach, \
52541+ .detach = bfa_ ## __mod ## _detach, \
52542+ .start = bfa_ ## __mod ## _start, \
52543+ .stop = bfa_ ## __mod ## _stop, \
52544+ .iocdisable = bfa_ ## __mod ## _iocdisable, \
52545 }
52546
52547 #define BFA_CACHELINE_SZ (256)
52548diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c
52549index 045c4e1..13de803 100644
52550--- a/drivers/scsi/fcoe/fcoe_sysfs.c
52551+++ b/drivers/scsi/fcoe/fcoe_sysfs.c
52552@@ -33,8 +33,8 @@
52553 */
52554 #include "libfcoe.h"
52555
52556-static atomic_t ctlr_num;
52557-static atomic_t fcf_num;
52558+static atomic_unchecked_t ctlr_num;
52559+static atomic_unchecked_t fcf_num;
52560
52561 /*
52562 * fcoe_fcf_dev_loss_tmo: the default number of seconds that fcoe sysfs
52563@@ -685,7 +685,7 @@ struct fcoe_ctlr_device *fcoe_ctlr_device_add(struct device *parent,
52564 if (!ctlr)
52565 goto out;
52566
52567- ctlr->id = atomic_inc_return(&ctlr_num) - 1;
52568+ ctlr->id = atomic_inc_return_unchecked(&ctlr_num) - 1;
52569 ctlr->f = f;
52570 ctlr->mode = FIP_CONN_TYPE_FABRIC;
52571 INIT_LIST_HEAD(&ctlr->fcfs);
52572@@ -902,7 +902,7 @@ struct fcoe_fcf_device *fcoe_fcf_device_add(struct fcoe_ctlr_device *ctlr,
52573 fcf->dev.parent = &ctlr->dev;
52574 fcf->dev.bus = &fcoe_bus_type;
52575 fcf->dev.type = &fcoe_fcf_device_type;
52576- fcf->id = atomic_inc_return(&fcf_num) - 1;
52577+ fcf->id = atomic_inc_return_unchecked(&fcf_num) - 1;
52578 fcf->state = FCOE_FCF_STATE_UNKNOWN;
52579
52580 fcf->dev_loss_tmo = ctlr->fcf_dev_loss_tmo;
52581@@ -938,8 +938,8 @@ int __init fcoe_sysfs_setup(void)
52582 {
52583 int error;
52584
52585- atomic_set(&ctlr_num, 0);
52586- atomic_set(&fcf_num, 0);
52587+ atomic_set_unchecked(&ctlr_num, 0);
52588+ atomic_set_unchecked(&fcf_num, 0);
52589
52590 error = bus_register(&fcoe_bus_type);
52591 if (error)
52592diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
52593index 8bb173e..20236b4 100644
52594--- a/drivers/scsi/hosts.c
52595+++ b/drivers/scsi/hosts.c
52596@@ -42,7 +42,7 @@
52597 #include "scsi_logging.h"
52598
52599
52600-static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
52601+static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
52602
52603
52604 static void scsi_host_cls_release(struct device *dev)
52605@@ -392,7 +392,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
52606 * subtract one because we increment first then return, but we need to
52607 * know what the next host number was before increment
52608 */
52609- shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
52610+ shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
52611 shost->dma_channel = 0xff;
52612
52613 /* These three are default values which can be overridden */
52614diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
52615index 8eab107..599cd79 100644
52616--- a/drivers/scsi/hpsa.c
52617+++ b/drivers/scsi/hpsa.c
52618@@ -697,10 +697,10 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
52619 struct reply_queue_buffer *rq = &h->reply_queue[q];
52620
52621 if (h->transMethod & CFGTBL_Trans_io_accel1)
52622- return h->access.command_completed(h, q);
52623+ return h->access->command_completed(h, q);
52624
52625 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
52626- return h->access.command_completed(h, q);
52627+ return h->access->command_completed(h, q);
52628
52629 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
52630 a = rq->head[rq->current_entry];
52631@@ -837,7 +837,7 @@ static void enqueue_cmd_and_start_io(struct ctlr_info *h,
52632 break;
52633 default:
52634 set_performant_mode(h, c);
52635- h->access.submit_command(h, c);
52636+ h->access->submit_command(h, c);
52637 }
52638 }
52639
52640@@ -5369,17 +5369,17 @@ static void __iomem *remap_pci_mem(ulong base, ulong size)
52641
52642 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
52643 {
52644- return h->access.command_completed(h, q);
52645+ return h->access->command_completed(h, q);
52646 }
52647
52648 static inline bool interrupt_pending(struct ctlr_info *h)
52649 {
52650- return h->access.intr_pending(h);
52651+ return h->access->intr_pending(h);
52652 }
52653
52654 static inline long interrupt_not_for_us(struct ctlr_info *h)
52655 {
52656- return (h->access.intr_pending(h) == 0) ||
52657+ return (h->access->intr_pending(h) == 0) ||
52658 (h->interrupts_enabled == 0);
52659 }
52660
52661@@ -6270,7 +6270,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
52662 if (prod_index < 0)
52663 return prod_index;
52664 h->product_name = products[prod_index].product_name;
52665- h->access = *(products[prod_index].access);
52666+ h->access = products[prod_index].access;
52667
52668 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
52669 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
52670@@ -6647,7 +6647,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
52671 unsigned long flags;
52672 u32 lockup_detected;
52673
52674- h->access.set_intr_mask(h, HPSA_INTR_OFF);
52675+ h->access->set_intr_mask(h, HPSA_INTR_OFF);
52676 spin_lock_irqsave(&h->lock, flags);
52677 lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
52678 if (!lockup_detected) {
52679@@ -6922,7 +6922,7 @@ reinit_after_soft_reset:
52680 }
52681
52682 /* make sure the board interrupts are off */
52683- h->access.set_intr_mask(h, HPSA_INTR_OFF);
52684+ h->access->set_intr_mask(h, HPSA_INTR_OFF);
52685
52686 if (hpsa_request_irqs(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
52687 goto clean2;
52688@@ -6958,7 +6958,7 @@ reinit_after_soft_reset:
52689 * fake ones to scoop up any residual completions.
52690 */
52691 spin_lock_irqsave(&h->lock, flags);
52692- h->access.set_intr_mask(h, HPSA_INTR_OFF);
52693+ h->access->set_intr_mask(h, HPSA_INTR_OFF);
52694 spin_unlock_irqrestore(&h->lock, flags);
52695 hpsa_free_irqs(h);
52696 rc = hpsa_request_irqs(h, hpsa_msix_discard_completions,
52697@@ -6977,9 +6977,9 @@ reinit_after_soft_reset:
52698 dev_info(&h->pdev->dev, "Board READY.\n");
52699 dev_info(&h->pdev->dev,
52700 "Waiting for stale completions to drain.\n");
52701- h->access.set_intr_mask(h, HPSA_INTR_ON);
52702+ h->access->set_intr_mask(h, HPSA_INTR_ON);
52703 msleep(10000);
52704- h->access.set_intr_mask(h, HPSA_INTR_OFF);
52705+ h->access->set_intr_mask(h, HPSA_INTR_OFF);
52706
52707 rc = controller_reset_failed(h->cfgtable);
52708 if (rc)
52709@@ -7004,7 +7004,7 @@ reinit_after_soft_reset:
52710
52711
52712 /* Turn the interrupts on so we can service requests */
52713- h->access.set_intr_mask(h, HPSA_INTR_ON);
52714+ h->access->set_intr_mask(h, HPSA_INTR_ON);
52715
52716 hpsa_hba_inquiry(h);
52717 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
52718@@ -7077,7 +7077,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
52719 * To write all data in the battery backed cache to disks
52720 */
52721 hpsa_flush_cache(h);
52722- h->access.set_intr_mask(h, HPSA_INTR_OFF);
52723+ h->access->set_intr_mask(h, HPSA_INTR_OFF);
52724 hpsa_free_irqs_and_disable_msix(h);
52725 }
52726
52727@@ -7198,7 +7198,7 @@ static int hpsa_enter_performant_mode(struct ctlr_info *h, u32 trans_support)
52728 CFGTBL_Trans_enable_directed_msix |
52729 (trans_support & (CFGTBL_Trans_io_accel1 |
52730 CFGTBL_Trans_io_accel2));
52731- struct access_method access = SA5_performant_access;
52732+ struct access_method *access = &SA5_performant_access;
52733
52734 /* This is a bit complicated. There are 8 registers on
52735 * the controller which we write to to tell it 8 different
52736@@ -7240,7 +7240,7 @@ static int hpsa_enter_performant_mode(struct ctlr_info *h, u32 trans_support)
52737 * perform the superfluous readl() after each command submission.
52738 */
52739 if (trans_support & (CFGTBL_Trans_io_accel1 | CFGTBL_Trans_io_accel2))
52740- access = SA5_performant_access_no_read;
52741+ access = &SA5_performant_access_no_read;
52742
52743 /* Controller spec: zero out this buffer. */
52744 for (i = 0; i < h->nreply_queues; i++)
52745@@ -7270,12 +7270,12 @@ static int hpsa_enter_performant_mode(struct ctlr_info *h, u32 trans_support)
52746 * enable outbound interrupt coalescing in accelerator mode;
52747 */
52748 if (trans_support & CFGTBL_Trans_io_accel1) {
52749- access = SA5_ioaccel_mode1_access;
52750+ access = &SA5_ioaccel_mode1_access;
52751 writel(10, &h->cfgtable->HostWrite.CoalIntDelay);
52752 writel(4, &h->cfgtable->HostWrite.CoalIntCount);
52753 } else {
52754 if (trans_support & CFGTBL_Trans_io_accel2) {
52755- access = SA5_ioaccel_mode2_access;
52756+ access = &SA5_ioaccel_mode2_access;
52757 writel(10, &h->cfgtable->HostWrite.CoalIntDelay);
52758 writel(4, &h->cfgtable->HostWrite.CoalIntCount);
52759 }
52760diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
52761index 6577130..955f9a4 100644
52762--- a/drivers/scsi/hpsa.h
52763+++ b/drivers/scsi/hpsa.h
52764@@ -143,7 +143,7 @@ struct ctlr_info {
52765 unsigned int msix_vector;
52766 unsigned int msi_vector;
52767 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
52768- struct access_method access;
52769+ struct access_method *access;
52770 char hba_mode_enabled;
52771
52772 /* queue and queue Info */
52773@@ -525,38 +525,38 @@ static unsigned long SA5_ioaccel_mode1_completed(struct ctlr_info *h, u8 q)
52774 }
52775
52776 static struct access_method SA5_access = {
52777- SA5_submit_command,
52778- SA5_intr_mask,
52779- SA5_intr_pending,
52780- SA5_completed,
52781+ .submit_command = SA5_submit_command,
52782+ .set_intr_mask = SA5_intr_mask,
52783+ .intr_pending = SA5_intr_pending,
52784+ .command_completed = SA5_completed,
52785 };
52786
52787 static struct access_method SA5_ioaccel_mode1_access = {
52788- SA5_submit_command,
52789- SA5_performant_intr_mask,
52790- SA5_ioaccel_mode1_intr_pending,
52791- SA5_ioaccel_mode1_completed,
52792+ .submit_command = SA5_submit_command,
52793+ .set_intr_mask = SA5_performant_intr_mask,
52794+ .intr_pending = SA5_ioaccel_mode1_intr_pending,
52795+ .command_completed = SA5_ioaccel_mode1_completed,
52796 };
52797
52798 static struct access_method SA5_ioaccel_mode2_access = {
52799- SA5_submit_command_ioaccel2,
52800- SA5_performant_intr_mask,
52801- SA5_performant_intr_pending,
52802- SA5_performant_completed,
52803+ .submit_command = SA5_submit_command_ioaccel2,
52804+ .set_intr_mask = SA5_performant_intr_mask,
52805+ .intr_pending = SA5_performant_intr_pending,
52806+ .command_completed = SA5_performant_completed,
52807 };
52808
52809 static struct access_method SA5_performant_access = {
52810- SA5_submit_command,
52811- SA5_performant_intr_mask,
52812- SA5_performant_intr_pending,
52813- SA5_performant_completed,
52814+ .submit_command = SA5_submit_command,
52815+ .set_intr_mask = SA5_performant_intr_mask,
52816+ .intr_pending = SA5_performant_intr_pending,
52817+ .command_completed = SA5_performant_completed,
52818 };
52819
52820 static struct access_method SA5_performant_access_no_read = {
52821- SA5_submit_command_no_read,
52822- SA5_performant_intr_mask,
52823- SA5_performant_intr_pending,
52824- SA5_performant_completed,
52825+ .submit_command = SA5_submit_command_no_read,
52826+ .set_intr_mask = SA5_performant_intr_mask,
52827+ .intr_pending = SA5_performant_intr_pending,
52828+ .command_completed = SA5_performant_completed,
52829 };
52830
52831 struct board_type {
52832diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
52833index 1b3a094..068e683 100644
52834--- a/drivers/scsi/libfc/fc_exch.c
52835+++ b/drivers/scsi/libfc/fc_exch.c
52836@@ -101,12 +101,12 @@ struct fc_exch_mgr {
52837 u16 pool_max_index;
52838
52839 struct {
52840- atomic_t no_free_exch;
52841- atomic_t no_free_exch_xid;
52842- atomic_t xid_not_found;
52843- atomic_t xid_busy;
52844- atomic_t seq_not_found;
52845- atomic_t non_bls_resp;
52846+ atomic_unchecked_t no_free_exch;
52847+ atomic_unchecked_t no_free_exch_xid;
52848+ atomic_unchecked_t xid_not_found;
52849+ atomic_unchecked_t xid_busy;
52850+ atomic_unchecked_t seq_not_found;
52851+ atomic_unchecked_t non_bls_resp;
52852 } stats;
52853 };
52854
52855@@ -811,7 +811,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
52856 /* allocate memory for exchange */
52857 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
52858 if (!ep) {
52859- atomic_inc(&mp->stats.no_free_exch);
52860+ atomic_inc_unchecked(&mp->stats.no_free_exch);
52861 goto out;
52862 }
52863 memset(ep, 0, sizeof(*ep));
52864@@ -874,7 +874,7 @@ out:
52865 return ep;
52866 err:
52867 spin_unlock_bh(&pool->lock);
52868- atomic_inc(&mp->stats.no_free_exch_xid);
52869+ atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
52870 mempool_free(ep, mp->ep_pool);
52871 return NULL;
52872 }
52873@@ -1023,7 +1023,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
52874 xid = ntohs(fh->fh_ox_id); /* we originated exch */
52875 ep = fc_exch_find(mp, xid);
52876 if (!ep) {
52877- atomic_inc(&mp->stats.xid_not_found);
52878+ atomic_inc_unchecked(&mp->stats.xid_not_found);
52879 reject = FC_RJT_OX_ID;
52880 goto out;
52881 }
52882@@ -1053,7 +1053,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
52883 ep = fc_exch_find(mp, xid);
52884 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
52885 if (ep) {
52886- atomic_inc(&mp->stats.xid_busy);
52887+ atomic_inc_unchecked(&mp->stats.xid_busy);
52888 reject = FC_RJT_RX_ID;
52889 goto rel;
52890 }
52891@@ -1064,7 +1064,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
52892 }
52893 xid = ep->xid; /* get our XID */
52894 } else if (!ep) {
52895- atomic_inc(&mp->stats.xid_not_found);
52896+ atomic_inc_unchecked(&mp->stats.xid_not_found);
52897 reject = FC_RJT_RX_ID; /* XID not found */
52898 goto out;
52899 }
52900@@ -1082,7 +1082,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
52901 } else {
52902 sp = &ep->seq;
52903 if (sp->id != fh->fh_seq_id) {
52904- atomic_inc(&mp->stats.seq_not_found);
52905+ atomic_inc_unchecked(&mp->stats.seq_not_found);
52906 if (f_ctl & FC_FC_END_SEQ) {
52907 /*
52908 * Update sequence_id based on incoming last
52909@@ -1533,22 +1533,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
52910
52911 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
52912 if (!ep) {
52913- atomic_inc(&mp->stats.xid_not_found);
52914+ atomic_inc_unchecked(&mp->stats.xid_not_found);
52915 goto out;
52916 }
52917 if (ep->esb_stat & ESB_ST_COMPLETE) {
52918- atomic_inc(&mp->stats.xid_not_found);
52919+ atomic_inc_unchecked(&mp->stats.xid_not_found);
52920 goto rel;
52921 }
52922 if (ep->rxid == FC_XID_UNKNOWN)
52923 ep->rxid = ntohs(fh->fh_rx_id);
52924 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
52925- atomic_inc(&mp->stats.xid_not_found);
52926+ atomic_inc_unchecked(&mp->stats.xid_not_found);
52927 goto rel;
52928 }
52929 if (ep->did != ntoh24(fh->fh_s_id) &&
52930 ep->did != FC_FID_FLOGI) {
52931- atomic_inc(&mp->stats.xid_not_found);
52932+ atomic_inc_unchecked(&mp->stats.xid_not_found);
52933 goto rel;
52934 }
52935 sof = fr_sof(fp);
52936@@ -1557,7 +1557,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
52937 sp->ssb_stat |= SSB_ST_RESP;
52938 sp->id = fh->fh_seq_id;
52939 } else if (sp->id != fh->fh_seq_id) {
52940- atomic_inc(&mp->stats.seq_not_found);
52941+ atomic_inc_unchecked(&mp->stats.seq_not_found);
52942 goto rel;
52943 }
52944
52945@@ -1619,9 +1619,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
52946 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
52947
52948 if (!sp)
52949- atomic_inc(&mp->stats.xid_not_found);
52950+ atomic_inc_unchecked(&mp->stats.xid_not_found);
52951 else
52952- atomic_inc(&mp->stats.non_bls_resp);
52953+ atomic_inc_unchecked(&mp->stats.non_bls_resp);
52954
52955 fc_frame_free(fp);
52956 }
52957@@ -2261,13 +2261,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
52958
52959 list_for_each_entry(ema, &lport->ema_list, ema_list) {
52960 mp = ema->mp;
52961- st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
52962+ st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
52963 st->fc_no_free_exch_xid +=
52964- atomic_read(&mp->stats.no_free_exch_xid);
52965- st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
52966- st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
52967- st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
52968- st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
52969+ atomic_read_unchecked(&mp->stats.no_free_exch_xid);
52970+ st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
52971+ st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
52972+ st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
52973+ st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
52974 }
52975 }
52976 EXPORT_SYMBOL(fc_exch_update_stats);
52977diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
52978index 9c706d8..d3e3ed2 100644
52979--- a/drivers/scsi/libsas/sas_ata.c
52980+++ b/drivers/scsi/libsas/sas_ata.c
52981@@ -535,7 +535,7 @@ static struct ata_port_operations sas_sata_ops = {
52982 .postreset = ata_std_postreset,
52983 .error_handler = ata_std_error_handler,
52984 .post_internal_cmd = sas_ata_post_internal,
52985- .qc_defer = ata_std_qc_defer,
52986+ .qc_defer = ata_std_qc_defer,
52987 .qc_prep = ata_noop_qc_prep,
52988 .qc_issue = sas_ata_qc_issue,
52989 .qc_fill_rtf = sas_ata_qc_fill_rtf,
52990diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
52991index 9b81a34..a9b7b8c 100644
52992--- a/drivers/scsi/lpfc/lpfc.h
52993+++ b/drivers/scsi/lpfc/lpfc.h
52994@@ -433,7 +433,7 @@ struct lpfc_vport {
52995 struct dentry *debug_nodelist;
52996 struct dentry *vport_debugfs_root;
52997 struct lpfc_debugfs_trc *disc_trc;
52998- atomic_t disc_trc_cnt;
52999+ atomic_unchecked_t disc_trc_cnt;
53000 #endif
53001 uint8_t stat_data_enabled;
53002 uint8_t stat_data_blocked;
53003@@ -883,8 +883,8 @@ struct lpfc_hba {
53004 struct timer_list fabric_block_timer;
53005 unsigned long bit_flags;
53006 #define FABRIC_COMANDS_BLOCKED 0
53007- atomic_t num_rsrc_err;
53008- atomic_t num_cmd_success;
53009+ atomic_unchecked_t num_rsrc_err;
53010+ atomic_unchecked_t num_cmd_success;
53011 unsigned long last_rsrc_error_time;
53012 unsigned long last_ramp_down_time;
53013 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
53014@@ -919,7 +919,7 @@ struct lpfc_hba {
53015
53016 struct dentry *debug_slow_ring_trc;
53017 struct lpfc_debugfs_trc *slow_ring_trc;
53018- atomic_t slow_ring_trc_cnt;
53019+ atomic_unchecked_t slow_ring_trc_cnt;
53020 /* iDiag debugfs sub-directory */
53021 struct dentry *idiag_root;
53022 struct dentry *idiag_pci_cfg;
53023diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
53024index 513edcb..805c6a8 100644
53025--- a/drivers/scsi/lpfc/lpfc_debugfs.c
53026+++ b/drivers/scsi/lpfc/lpfc_debugfs.c
53027@@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
53028
53029 #include <linux/debugfs.h>
53030
53031-static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
53032+static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
53033 static unsigned long lpfc_debugfs_start_time = 0L;
53034
53035 /* iDiag */
53036@@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
53037 lpfc_debugfs_enable = 0;
53038
53039 len = 0;
53040- index = (atomic_read(&vport->disc_trc_cnt) + 1) &
53041+ index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
53042 (lpfc_debugfs_max_disc_trc - 1);
53043 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
53044 dtp = vport->disc_trc + i;
53045@@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
53046 lpfc_debugfs_enable = 0;
53047
53048 len = 0;
53049- index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
53050+ index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
53051 (lpfc_debugfs_max_slow_ring_trc - 1);
53052 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
53053 dtp = phba->slow_ring_trc + i;
53054@@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
53055 !vport || !vport->disc_trc)
53056 return;
53057
53058- index = atomic_inc_return(&vport->disc_trc_cnt) &
53059+ index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
53060 (lpfc_debugfs_max_disc_trc - 1);
53061 dtp = vport->disc_trc + index;
53062 dtp->fmt = fmt;
53063 dtp->data1 = data1;
53064 dtp->data2 = data2;
53065 dtp->data3 = data3;
53066- dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
53067+ dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
53068 dtp->jif = jiffies;
53069 #endif
53070 return;
53071@@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
53072 !phba || !phba->slow_ring_trc)
53073 return;
53074
53075- index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
53076+ index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
53077 (lpfc_debugfs_max_slow_ring_trc - 1);
53078 dtp = phba->slow_ring_trc + index;
53079 dtp->fmt = fmt;
53080 dtp->data1 = data1;
53081 dtp->data2 = data2;
53082 dtp->data3 = data3;
53083- dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
53084+ dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
53085 dtp->jif = jiffies;
53086 #endif
53087 return;
53088@@ -4268,7 +4268,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
53089 "slow_ring buffer\n");
53090 goto debug_failed;
53091 }
53092- atomic_set(&phba->slow_ring_trc_cnt, 0);
53093+ atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
53094 memset(phba->slow_ring_trc, 0,
53095 (sizeof(struct lpfc_debugfs_trc) *
53096 lpfc_debugfs_max_slow_ring_trc));
53097@@ -4314,7 +4314,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
53098 "buffer\n");
53099 goto debug_failed;
53100 }
53101- atomic_set(&vport->disc_trc_cnt, 0);
53102+ atomic_set_unchecked(&vport->disc_trc_cnt, 0);
53103
53104 snprintf(name, sizeof(name), "discovery_trace");
53105 vport->debug_disc_trc =
53106diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
53107index e8c8c1e..5f2e11c 100644
53108--- a/drivers/scsi/lpfc/lpfc_init.c
53109+++ b/drivers/scsi/lpfc/lpfc_init.c
53110@@ -11406,8 +11406,10 @@ lpfc_init(void)
53111 "misc_register returned with status %d", error);
53112
53113 if (lpfc_enable_npiv) {
53114- lpfc_transport_functions.vport_create = lpfc_vport_create;
53115- lpfc_transport_functions.vport_delete = lpfc_vport_delete;
53116+ pax_open_kernel();
53117+ *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
53118+ *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
53119+ pax_close_kernel();
53120 }
53121 lpfc_transport_template =
53122 fc_attach_transport(&lpfc_transport_functions);
53123diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
53124index c140f99..11b2505 100644
53125--- a/drivers/scsi/lpfc/lpfc_scsi.c
53126+++ b/drivers/scsi/lpfc/lpfc_scsi.c
53127@@ -261,7 +261,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
53128 unsigned long expires;
53129
53130 spin_lock_irqsave(&phba->hbalock, flags);
53131- atomic_inc(&phba->num_rsrc_err);
53132+ atomic_inc_unchecked(&phba->num_rsrc_err);
53133 phba->last_rsrc_error_time = jiffies;
53134
53135 expires = phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL;
53136@@ -303,8 +303,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
53137 unsigned long num_rsrc_err, num_cmd_success;
53138 int i;
53139
53140- num_rsrc_err = atomic_read(&phba->num_rsrc_err);
53141- num_cmd_success = atomic_read(&phba->num_cmd_success);
53142+ num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
53143+ num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
53144
53145 /*
53146 * The error and success command counters are global per
53147@@ -331,8 +331,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
53148 }
53149 }
53150 lpfc_destroy_vport_work_array(phba, vports);
53151- atomic_set(&phba->num_rsrc_err, 0);
53152- atomic_set(&phba->num_cmd_success, 0);
53153+ atomic_set_unchecked(&phba->num_rsrc_err, 0);
53154+ atomic_set_unchecked(&phba->num_cmd_success, 0);
53155 }
53156
53157 /**
53158diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
53159index 3f26147..ee8efd1 100644
53160--- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
53161+++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
53162@@ -1509,7 +1509,7 @@ _scsih_get_resync(struct device *dev)
53163 {
53164 struct scsi_device *sdev = to_scsi_device(dev);
53165 struct MPT2SAS_ADAPTER *ioc = shost_priv(sdev->host);
53166- static struct _raid_device *raid_device;
53167+ struct _raid_device *raid_device;
53168 unsigned long flags;
53169 Mpi2RaidVolPage0_t vol_pg0;
53170 Mpi2ConfigReply_t mpi_reply;
53171@@ -1561,7 +1561,7 @@ _scsih_get_state(struct device *dev)
53172 {
53173 struct scsi_device *sdev = to_scsi_device(dev);
53174 struct MPT2SAS_ADAPTER *ioc = shost_priv(sdev->host);
53175- static struct _raid_device *raid_device;
53176+ struct _raid_device *raid_device;
53177 unsigned long flags;
53178 Mpi2RaidVolPage0_t vol_pg0;
53179 Mpi2ConfigReply_t mpi_reply;
53180@@ -6641,7 +6641,7 @@ _scsih_sas_ir_operation_status_event(struct MPT2SAS_ADAPTER *ioc,
53181 Mpi2EventDataIrOperationStatus_t *event_data =
53182 (Mpi2EventDataIrOperationStatus_t *)
53183 fw_event->event_data;
53184- static struct _raid_device *raid_device;
53185+ struct _raid_device *raid_device;
53186 unsigned long flags;
53187 u16 handle;
53188
53189@@ -7112,7 +7112,7 @@ _scsih_scan_for_devices_after_reset(struct MPT2SAS_ADAPTER *ioc)
53190 u64 sas_address;
53191 struct _sas_device *sas_device;
53192 struct _sas_node *expander_device;
53193- static struct _raid_device *raid_device;
53194+ struct _raid_device *raid_device;
53195 u8 retry_count;
53196 unsigned long flags;
53197
53198diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
53199index ed31d8c..ab856b3 100644
53200--- a/drivers/scsi/pmcraid.c
53201+++ b/drivers/scsi/pmcraid.c
53202@@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
53203 res->scsi_dev = scsi_dev;
53204 scsi_dev->hostdata = res;
53205 res->change_detected = 0;
53206- atomic_set(&res->read_failures, 0);
53207- atomic_set(&res->write_failures, 0);
53208+ atomic_set_unchecked(&res->read_failures, 0);
53209+ atomic_set_unchecked(&res->write_failures, 0);
53210 rc = 0;
53211 }
53212 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
53213@@ -2640,9 +2640,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
53214
53215 /* If this was a SCSI read/write command keep count of errors */
53216 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
53217- atomic_inc(&res->read_failures);
53218+ atomic_inc_unchecked(&res->read_failures);
53219 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
53220- atomic_inc(&res->write_failures);
53221+ atomic_inc_unchecked(&res->write_failures);
53222
53223 if (!RES_IS_GSCSI(res->cfg_entry) &&
53224 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
53225@@ -3468,7 +3468,7 @@ static int pmcraid_queuecommand_lck(
53226 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
53227 * hrrq_id assigned here in queuecommand
53228 */
53229- ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
53230+ ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
53231 pinstance->num_hrrq;
53232 cmd->cmd_done = pmcraid_io_done;
53233
53234@@ -3782,7 +3782,7 @@ static long pmcraid_ioctl_passthrough(
53235 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
53236 * hrrq_id assigned here in queuecommand
53237 */
53238- ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
53239+ ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
53240 pinstance->num_hrrq;
53241
53242 if (request_size) {
53243@@ -4420,7 +4420,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
53244
53245 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
53246 /* add resources only after host is added into system */
53247- if (!atomic_read(&pinstance->expose_resources))
53248+ if (!atomic_read_unchecked(&pinstance->expose_resources))
53249 return;
53250
53251 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
53252@@ -5237,8 +5237,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
53253 init_waitqueue_head(&pinstance->reset_wait_q);
53254
53255 atomic_set(&pinstance->outstanding_cmds, 0);
53256- atomic_set(&pinstance->last_message_id, 0);
53257- atomic_set(&pinstance->expose_resources, 0);
53258+ atomic_set_unchecked(&pinstance->last_message_id, 0);
53259+ atomic_set_unchecked(&pinstance->expose_resources, 0);
53260
53261 INIT_LIST_HEAD(&pinstance->free_res_q);
53262 INIT_LIST_HEAD(&pinstance->used_res_q);
53263@@ -5951,7 +5951,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
53264 /* Schedule worker thread to handle CCN and take care of adding and
53265 * removing devices to OS
53266 */
53267- atomic_set(&pinstance->expose_resources, 1);
53268+ atomic_set_unchecked(&pinstance->expose_resources, 1);
53269 schedule_work(&pinstance->worker_q);
53270 return rc;
53271
53272diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
53273index e1d150f..6c6df44 100644
53274--- a/drivers/scsi/pmcraid.h
53275+++ b/drivers/scsi/pmcraid.h
53276@@ -748,7 +748,7 @@ struct pmcraid_instance {
53277 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
53278
53279 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
53280- atomic_t last_message_id;
53281+ atomic_unchecked_t last_message_id;
53282
53283 /* configuration table */
53284 struct pmcraid_config_table *cfg_table;
53285@@ -777,7 +777,7 @@ struct pmcraid_instance {
53286 atomic_t outstanding_cmds;
53287
53288 /* should add/delete resources to mid-layer now ?*/
53289- atomic_t expose_resources;
53290+ atomic_unchecked_t expose_resources;
53291
53292
53293
53294@@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
53295 struct pmcraid_config_table_entry_ext cfg_entry_ext;
53296 };
53297 struct scsi_device *scsi_dev; /* Link scsi_device structure */
53298- atomic_t read_failures; /* count of failed READ commands */
53299- atomic_t write_failures; /* count of failed WRITE commands */
53300+ atomic_unchecked_t read_failures; /* count of failed READ commands */
53301+ atomic_unchecked_t write_failures; /* count of failed WRITE commands */
53302
53303 /* To indicate add/delete/modify during CCN */
53304 u8 change_detected;
53305diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
53306index 82b92c4..3178171 100644
53307--- a/drivers/scsi/qla2xxx/qla_attr.c
53308+++ b/drivers/scsi/qla2xxx/qla_attr.c
53309@@ -2192,7 +2192,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
53310 return 0;
53311 }
53312
53313-struct fc_function_template qla2xxx_transport_functions = {
53314+fc_function_template_no_const qla2xxx_transport_functions = {
53315
53316 .show_host_node_name = 1,
53317 .show_host_port_name = 1,
53318@@ -2240,7 +2240,7 @@ struct fc_function_template qla2xxx_transport_functions = {
53319 .bsg_timeout = qla24xx_bsg_timeout,
53320 };
53321
53322-struct fc_function_template qla2xxx_transport_vport_functions = {
53323+fc_function_template_no_const qla2xxx_transport_vport_functions = {
53324
53325 .show_host_node_name = 1,
53326 .show_host_port_name = 1,
53327diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
53328index 7686bfe..4710893 100644
53329--- a/drivers/scsi/qla2xxx/qla_gbl.h
53330+++ b/drivers/scsi/qla2xxx/qla_gbl.h
53331@@ -571,8 +571,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *, size_t);
53332 struct device_attribute;
53333 extern struct device_attribute *qla2x00_host_attrs[];
53334 struct fc_function_template;
53335-extern struct fc_function_template qla2xxx_transport_functions;
53336-extern struct fc_function_template qla2xxx_transport_vport_functions;
53337+extern fc_function_template_no_const qla2xxx_transport_functions;
53338+extern fc_function_template_no_const qla2xxx_transport_vport_functions;
53339 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
53340 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *, bool);
53341 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
53342diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
53343index 7462dd7..5b64c24 100644
53344--- a/drivers/scsi/qla2xxx/qla_os.c
53345+++ b/drivers/scsi/qla2xxx/qla_os.c
53346@@ -1435,8 +1435,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
53347 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
53348 /* Ok, a 64bit DMA mask is applicable. */
53349 ha->flags.enable_64bit_addressing = 1;
53350- ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
53351- ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
53352+ pax_open_kernel();
53353+ *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
53354+ *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
53355+ pax_close_kernel();
53356 return;
53357 }
53358 }
53359diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
53360index 8f6d0fb..1b21097 100644
53361--- a/drivers/scsi/qla4xxx/ql4_def.h
53362+++ b/drivers/scsi/qla4xxx/ql4_def.h
53363@@ -305,7 +305,7 @@ struct ddb_entry {
53364 * (4000 only) */
53365 atomic_t relogin_timer; /* Max Time to wait for
53366 * relogin to complete */
53367- atomic_t relogin_retry_count; /* Num of times relogin has been
53368+ atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
53369 * retried */
53370 uint32_t default_time2wait; /* Default Min time between
53371 * relogins (+aens) */
53372diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
53373index 6d25879..3031a9f 100644
53374--- a/drivers/scsi/qla4xxx/ql4_os.c
53375+++ b/drivers/scsi/qla4xxx/ql4_os.c
53376@@ -4491,12 +4491,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
53377 */
53378 if (!iscsi_is_session_online(cls_sess)) {
53379 /* Reset retry relogin timer */
53380- atomic_inc(&ddb_entry->relogin_retry_count);
53381+ atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
53382 DEBUG2(ql4_printk(KERN_INFO, ha,
53383 "%s: index[%d] relogin timed out-retrying"
53384 " relogin (%d), retry (%d)\n", __func__,
53385 ddb_entry->fw_ddb_index,
53386- atomic_read(&ddb_entry->relogin_retry_count),
53387+ atomic_read_unchecked(&ddb_entry->relogin_retry_count),
53388 ddb_entry->default_time2wait + 4));
53389 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
53390 atomic_set(&ddb_entry->retry_relogin_timer,
53391@@ -6604,7 +6604,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
53392
53393 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
53394 atomic_set(&ddb_entry->relogin_timer, 0);
53395- atomic_set(&ddb_entry->relogin_retry_count, 0);
53396+ atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
53397 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
53398 ddb_entry->default_relogin_timeout =
53399 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
53400diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
53401index 3833bf5..95feaf1 100644
53402--- a/drivers/scsi/scsi.c
53403+++ b/drivers/scsi/scsi.c
53404@@ -637,7 +637,7 @@ void scsi_finish_command(struct scsi_cmnd *cmd)
53405
53406 good_bytes = scsi_bufflen(cmd);
53407 if (cmd->request->cmd_type != REQ_TYPE_BLOCK_PC) {
53408- int old_good_bytes = good_bytes;
53409+ unsigned int old_good_bytes = good_bytes;
53410 drv = scsi_cmd_to_driver(cmd);
53411 if (drv->done)
53412 good_bytes = drv->done(cmd);
53413diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
53414index b1a2631..5bcd9c8 100644
53415--- a/drivers/scsi/scsi_lib.c
53416+++ b/drivers/scsi/scsi_lib.c
53417@@ -1597,7 +1597,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
53418 shost = sdev->host;
53419 scsi_init_cmd_errh(cmd);
53420 cmd->result = DID_NO_CONNECT << 16;
53421- atomic_inc(&cmd->device->iorequest_cnt);
53422+ atomic_inc_unchecked(&cmd->device->iorequest_cnt);
53423
53424 /*
53425 * SCSI request completion path will do scsi_device_unbusy(),
53426@@ -1620,9 +1620,9 @@ static void scsi_softirq_done(struct request *rq)
53427
53428 INIT_LIST_HEAD(&cmd->eh_entry);
53429
53430- atomic_inc(&cmd->device->iodone_cnt);
53431+ atomic_inc_unchecked(&cmd->device->iodone_cnt);
53432 if (cmd->result)
53433- atomic_inc(&cmd->device->ioerr_cnt);
53434+ atomic_inc_unchecked(&cmd->device->ioerr_cnt);
53435
53436 disposition = scsi_decide_disposition(cmd);
53437 if (disposition != SUCCESS &&
53438@@ -1663,7 +1663,7 @@ static int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
53439 struct Scsi_Host *host = cmd->device->host;
53440 int rtn = 0;
53441
53442- atomic_inc(&cmd->device->iorequest_cnt);
53443+ atomic_inc_unchecked(&cmd->device->iorequest_cnt);
53444
53445 /* check if the device is still usable */
53446 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
53447diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
53448index 1ac38e7..6acc656 100644
53449--- a/drivers/scsi/scsi_sysfs.c
53450+++ b/drivers/scsi/scsi_sysfs.c
53451@@ -788,7 +788,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
53452 char *buf) \
53453 { \
53454 struct scsi_device *sdev = to_scsi_device(dev); \
53455- unsigned long long count = atomic_read(&sdev->field); \
53456+ unsigned long long count = atomic_read_unchecked(&sdev->field); \
53457 return snprintf(buf, 20, "0x%llx\n", count); \
53458 } \
53459 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
53460diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
53461index 24eaaf6..de30ec9 100644
53462--- a/drivers/scsi/scsi_transport_fc.c
53463+++ b/drivers/scsi/scsi_transport_fc.c
53464@@ -502,7 +502,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
53465 * Netlink Infrastructure
53466 */
53467
53468-static atomic_t fc_event_seq;
53469+static atomic_unchecked_t fc_event_seq;
53470
53471 /**
53472 * fc_get_event_number - Obtain the next sequential FC event number
53473@@ -515,7 +515,7 @@ static atomic_t fc_event_seq;
53474 u32
53475 fc_get_event_number(void)
53476 {
53477- return atomic_add_return(1, &fc_event_seq);
53478+ return atomic_add_return_unchecked(1, &fc_event_seq);
53479 }
53480 EXPORT_SYMBOL(fc_get_event_number);
53481
53482@@ -659,7 +659,7 @@ static __init int fc_transport_init(void)
53483 {
53484 int error;
53485
53486- atomic_set(&fc_event_seq, 0);
53487+ atomic_set_unchecked(&fc_event_seq, 0);
53488
53489 error = transport_class_register(&fc_host_class);
53490 if (error)
53491@@ -849,7 +849,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
53492 char *cp;
53493
53494 *val = simple_strtoul(buf, &cp, 0);
53495- if ((*cp && (*cp != '\n')) || (*val < 0))
53496+ if (*cp && (*cp != '\n'))
53497 return -EINVAL;
53498 /*
53499 * Check for overflow; dev_loss_tmo is u32
53500diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
53501index 67d43e3..8cee73c 100644
53502--- a/drivers/scsi/scsi_transport_iscsi.c
53503+++ b/drivers/scsi/scsi_transport_iscsi.c
53504@@ -79,7 +79,7 @@ struct iscsi_internal {
53505 struct transport_container session_cont;
53506 };
53507
53508-static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
53509+static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
53510 static struct workqueue_struct *iscsi_eh_timer_workq;
53511
53512 static DEFINE_IDA(iscsi_sess_ida);
53513@@ -2071,7 +2071,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
53514 int err;
53515
53516 ihost = shost->shost_data;
53517- session->sid = atomic_add_return(1, &iscsi_session_nr);
53518+ session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
53519
53520 if (target_id == ISCSI_MAX_TARGET) {
53521 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
53522@@ -4515,7 +4515,7 @@ static __init int iscsi_transport_init(void)
53523 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
53524 ISCSI_TRANSPORT_VERSION);
53525
53526- atomic_set(&iscsi_session_nr, 0);
53527+ atomic_set_unchecked(&iscsi_session_nr, 0);
53528
53529 err = class_register(&iscsi_transport_class);
53530 if (err)
53531diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
53532index f115f67..b80b2c1 100644
53533--- a/drivers/scsi/scsi_transport_srp.c
53534+++ b/drivers/scsi/scsi_transport_srp.c
53535@@ -35,7 +35,7 @@
53536 #include "scsi_priv.h"
53537
53538 struct srp_host_attrs {
53539- atomic_t next_port_id;
53540+ atomic_unchecked_t next_port_id;
53541 };
53542 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
53543
53544@@ -100,7 +100,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
53545 struct Scsi_Host *shost = dev_to_shost(dev);
53546 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
53547
53548- atomic_set(&srp_host->next_port_id, 0);
53549+ atomic_set_unchecked(&srp_host->next_port_id, 0);
53550 return 0;
53551 }
53552
53553@@ -744,7 +744,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
53554 rport_fast_io_fail_timedout);
53555 INIT_DELAYED_WORK(&rport->dev_loss_work, rport_dev_loss_timedout);
53556
53557- id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
53558+ id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
53559 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
53560
53561 transport_setup_device(&rport->dev);
53562diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
53563index 7f9d65f..e856438 100644
53564--- a/drivers/scsi/sd.c
53565+++ b/drivers/scsi/sd.c
53566@@ -111,7 +111,7 @@ static int sd_resume(struct device *);
53567 static void sd_rescan(struct device *);
53568 static int sd_init_command(struct scsi_cmnd *SCpnt);
53569 static void sd_uninit_command(struct scsi_cmnd *SCpnt);
53570-static int sd_done(struct scsi_cmnd *);
53571+static unsigned int sd_done(struct scsi_cmnd *);
53572 static int sd_eh_action(struct scsi_cmnd *, int);
53573 static void sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer);
53574 static void scsi_disk_release(struct device *cdev);
53575@@ -1646,7 +1646,7 @@ static unsigned int sd_completed_bytes(struct scsi_cmnd *scmd)
53576 *
53577 * Note: potentially run from within an ISR. Must not block.
53578 **/
53579-static int sd_done(struct scsi_cmnd *SCpnt)
53580+static unsigned int sd_done(struct scsi_cmnd *SCpnt)
53581 {
53582 int result = SCpnt->result;
53583 unsigned int good_bytes = result ? 0 : scsi_bufflen(SCpnt);
53584@@ -2973,7 +2973,7 @@ static int sd_probe(struct device *dev)
53585 sdkp->disk = gd;
53586 sdkp->index = index;
53587 atomic_set(&sdkp->openers, 0);
53588- atomic_set(&sdkp->device->ioerr_cnt, 0);
53589+ atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
53590
53591 if (!sdp->request_queue->rq_timeout) {
53592 if (sdp->type != TYPE_MOD)
53593diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
53594index 9d7b7db..33ecc51 100644
53595--- a/drivers/scsi/sg.c
53596+++ b/drivers/scsi/sg.c
53597@@ -1083,7 +1083,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
53598 sdp->disk->disk_name,
53599 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
53600 NULL,
53601- (char *)arg);
53602+ (char __user *)arg);
53603 case BLKTRACESTART:
53604 return blk_trace_startstop(sdp->device->request_queue, 1);
53605 case BLKTRACESTOP:
53606diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
53607index 8bd54a6..dd037a5 100644
53608--- a/drivers/scsi/sr.c
53609+++ b/drivers/scsi/sr.c
53610@@ -80,7 +80,7 @@ static DEFINE_MUTEX(sr_mutex);
53611 static int sr_probe(struct device *);
53612 static int sr_remove(struct device *);
53613 static int sr_init_command(struct scsi_cmnd *SCpnt);
53614-static int sr_done(struct scsi_cmnd *);
53615+static unsigned int sr_done(struct scsi_cmnd *);
53616 static int sr_runtime_suspend(struct device *dev);
53617
53618 static struct dev_pm_ops sr_pm_ops = {
53619@@ -312,11 +312,11 @@ do_tur:
53620 * It will be notified on the end of a SCSI read / write, and will take one
53621 * of several actions based on success or failure.
53622 */
53623-static int sr_done(struct scsi_cmnd *SCpnt)
53624+static unsigned int sr_done(struct scsi_cmnd *SCpnt)
53625 {
53626 int result = SCpnt->result;
53627- int this_count = scsi_bufflen(SCpnt);
53628- int good_bytes = (result == 0 ? this_count : 0);
53629+ unsigned int this_count = scsi_bufflen(SCpnt);
53630+ unsigned int good_bytes = (result == 0 ? this_count : 0);
53631 int block_sectors = 0;
53632 long error_sector;
53633 struct scsi_cd *cd = scsi_cd(SCpnt->request->rq_disk);
53634diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
53635index 9a1c342..525ab4c 100644
53636--- a/drivers/scsi/st.c
53637+++ b/drivers/scsi/st.c
53638@@ -1274,9 +1274,9 @@ static int st_open(struct inode *inode, struct file *filp)
53639 spin_lock(&st_use_lock);
53640 STp->in_use = 0;
53641 spin_unlock(&st_use_lock);
53642- scsi_tape_put(STp);
53643 if (resumed)
53644 scsi_autopm_put_device(STp->device);
53645+ scsi_tape_put(STp);
53646 return retval;
53647
53648 }
53649diff --git a/drivers/soc/tegra/fuse/fuse-tegra.c b/drivers/soc/tegra/fuse/fuse-tegra.c
53650index c0d660f..24a5854 100644
53651--- a/drivers/soc/tegra/fuse/fuse-tegra.c
53652+++ b/drivers/soc/tegra/fuse/fuse-tegra.c
53653@@ -71,7 +71,7 @@ static ssize_t fuse_read(struct file *fd, struct kobject *kobj,
53654 return i;
53655 }
53656
53657-static struct bin_attribute fuse_bin_attr = {
53658+static bin_attribute_no_const fuse_bin_attr = {
53659 .attr = { .name = "fuse", .mode = S_IRUGO, },
53660 .read = fuse_read,
53661 };
53662diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
53663index d35c1a1..eda08dc 100644
53664--- a/drivers/spi/spi.c
53665+++ b/drivers/spi/spi.c
53666@@ -2206,7 +2206,7 @@ int spi_bus_unlock(struct spi_master *master)
53667 EXPORT_SYMBOL_GPL(spi_bus_unlock);
53668
53669 /* portable code must never pass more than 32 bytes */
53670-#define SPI_BUFSIZ max(32, SMP_CACHE_BYTES)
53671+#define SPI_BUFSIZ max(32UL, SMP_CACHE_BYTES)
53672
53673 static u8 *buf;
53674
53675diff --git a/drivers/staging/android/timed_output.c b/drivers/staging/android/timed_output.c
53676index b41429f..2de5373 100644
53677--- a/drivers/staging/android/timed_output.c
53678+++ b/drivers/staging/android/timed_output.c
53679@@ -25,7 +25,7 @@
53680 #include "timed_output.h"
53681
53682 static struct class *timed_output_class;
53683-static atomic_t device_count;
53684+static atomic_unchecked_t device_count;
53685
53686 static ssize_t enable_show(struct device *dev, struct device_attribute *attr,
53687 char *buf)
53688@@ -65,7 +65,7 @@ static int create_timed_output_class(void)
53689 timed_output_class = class_create(THIS_MODULE, "timed_output");
53690 if (IS_ERR(timed_output_class))
53691 return PTR_ERR(timed_output_class);
53692- atomic_set(&device_count, 0);
53693+ atomic_set_unchecked(&device_count, 0);
53694 timed_output_class->dev_groups = timed_output_groups;
53695 }
53696
53697@@ -83,7 +83,7 @@ int timed_output_dev_register(struct timed_output_dev *tdev)
53698 if (ret < 0)
53699 return ret;
53700
53701- tdev->index = atomic_inc_return(&device_count);
53702+ tdev->index = atomic_inc_return_unchecked(&device_count);
53703 tdev->dev = device_create(timed_output_class, NULL,
53704 MKDEV(0, tdev->index), NULL, "%s", tdev->name);
53705 if (IS_ERR(tdev->dev))
53706diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
53707index e78ddbe..ac437c0 100644
53708--- a/drivers/staging/comedi/comedi_fops.c
53709+++ b/drivers/staging/comedi/comedi_fops.c
53710@@ -297,8 +297,8 @@ static void comedi_file_reset(struct file *file)
53711 }
53712 cfp->last_attached = dev->attached;
53713 cfp->last_detach_count = dev->detach_count;
53714- ACCESS_ONCE(cfp->read_subdev) = read_s;
53715- ACCESS_ONCE(cfp->write_subdev) = write_s;
53716+ ACCESS_ONCE_RW(cfp->read_subdev) = read_s;
53717+ ACCESS_ONCE_RW(cfp->write_subdev) = write_s;
53718 }
53719
53720 static void comedi_file_check(struct file *file)
53721@@ -1951,7 +1951,7 @@ static int do_setrsubd_ioctl(struct comedi_device *dev, unsigned long arg,
53722 !(s_old->async->cmd.flags & CMDF_WRITE))
53723 return -EBUSY;
53724
53725- ACCESS_ONCE(cfp->read_subdev) = s_new;
53726+ ACCESS_ONCE_RW(cfp->read_subdev) = s_new;
53727 return 0;
53728 }
53729
53730@@ -1993,7 +1993,7 @@ static int do_setwsubd_ioctl(struct comedi_device *dev, unsigned long arg,
53731 (s_old->async->cmd.flags & CMDF_WRITE))
53732 return -EBUSY;
53733
53734- ACCESS_ONCE(cfp->write_subdev) = s_new;
53735+ ACCESS_ONCE_RW(cfp->write_subdev) = s_new;
53736 return 0;
53737 }
53738
53739diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c
53740index 53b748b..a5ae0b3 100644
53741--- a/drivers/staging/fbtft/fbtft-core.c
53742+++ b/drivers/staging/fbtft/fbtft-core.c
53743@@ -680,7 +680,7 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
53744 {
53745 struct fb_info *info;
53746 struct fbtft_par *par;
53747- struct fb_ops *fbops = NULL;
53748+ fb_ops_no_const *fbops = NULL;
53749 struct fb_deferred_io *fbdefio = NULL;
53750 struct fbtft_platform_data *pdata = dev->platform_data;
53751 u8 *vmem = NULL;
53752diff --git a/drivers/staging/fbtft/fbtft.h b/drivers/staging/fbtft/fbtft.h
53753index 9fd98cb..a9cf912 100644
53754--- a/drivers/staging/fbtft/fbtft.h
53755+++ b/drivers/staging/fbtft/fbtft.h
53756@@ -106,7 +106,7 @@ struct fbtft_ops {
53757
53758 int (*set_var)(struct fbtft_par *par);
53759 int (*set_gamma)(struct fbtft_par *par, unsigned long *curves);
53760-};
53761+} __no_const;
53762
53763 /**
53764 * struct fbtft_display - Describes the display properties
53765diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c
53766index 001348c..cfaac8a 100644
53767--- a/drivers/staging/gdm724x/gdm_tty.c
53768+++ b/drivers/staging/gdm724x/gdm_tty.c
53769@@ -44,7 +44,7 @@
53770 #define gdm_tty_send_control(n, r, v, d, l) (\
53771 n->tty_dev->send_control(n->tty_dev->priv_dev, r, v, d, l))
53772
53773-#define GDM_TTY_READY(gdm) (gdm && gdm->tty_dev && gdm->port.count)
53774+#define GDM_TTY_READY(gdm) (gdm && gdm->tty_dev && atomic_read(&gdm->port.count))
53775
53776 static struct tty_driver *gdm_driver[TTY_MAX_COUNT];
53777 static struct gdm *gdm_table[TTY_MAX_COUNT][GDM_TTY_MINOR];
53778diff --git a/drivers/staging/i2o/i2o.h b/drivers/staging/i2o/i2o.h
53779index d23c3c2..eb63c81 100644
53780--- a/drivers/staging/i2o/i2o.h
53781+++ b/drivers/staging/i2o/i2o.h
53782@@ -565,7 +565,7 @@ struct i2o_controller {
53783 struct i2o_device *exec; /* Executive */
53784 #if BITS_PER_LONG == 64
53785 spinlock_t context_list_lock; /* lock for context_list */
53786- atomic_t context_list_counter; /* needed for unique contexts */
53787+ atomic_unchecked_t context_list_counter; /* needed for unique contexts */
53788 struct list_head context_list; /* list of context id's
53789 and pointers */
53790 #endif
53791diff --git a/drivers/staging/i2o/i2o_proc.c b/drivers/staging/i2o/i2o_proc.c
53792index 780fee3..ca9dcae 100644
53793--- a/drivers/staging/i2o/i2o_proc.c
53794+++ b/drivers/staging/i2o/i2o_proc.c
53795@@ -253,12 +253,6 @@ static char *scsi_devices[] = {
53796 "Array Controller Device"
53797 };
53798
53799-static char *chtostr(char *tmp, u8 *chars, int n)
53800-{
53801- tmp[0] = 0;
53802- return strncat(tmp, (char *)chars, n);
53803-}
53804-
53805 static int i2o_report_query_status(struct seq_file *seq, int block_status,
53806 char *group)
53807 {
53808@@ -711,9 +705,9 @@ static int i2o_seq_show_status(struct seq_file *seq, void *v)
53809 static int i2o_seq_show_hw(struct seq_file *seq, void *v)
53810 {
53811 struct i2o_controller *c = (struct i2o_controller *)seq->private;
53812- static u32 work32[5];
53813- static u8 *work8 = (u8 *) work32;
53814- static u16 *work16 = (u16 *) work32;
53815+ u32 work32[5];
53816+ u8 *work8 = (u8 *) work32;
53817+ u16 *work16 = (u16 *) work32;
53818 int token;
53819 u32 hwcap;
53820
53821@@ -794,7 +788,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
53822 } *result;
53823
53824 i2o_exec_execute_ddm_table ddm_table;
53825- char tmp[28 + 1];
53826
53827 result = kmalloc(sizeof(*result), GFP_KERNEL);
53828 if (!result)
53829@@ -829,8 +822,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
53830
53831 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
53832 seq_printf(seq, "%-#8x", ddm_table.module_id);
53833- seq_printf(seq, "%-29s",
53834- chtostr(tmp, ddm_table.module_name_version, 28));
53835+ seq_printf(seq, "%-.28s", ddm_table.module_name_version);
53836 seq_printf(seq, "%9d ", ddm_table.data_size);
53837 seq_printf(seq, "%8d", ddm_table.code_size);
53838
53839@@ -897,7 +889,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
53840
53841 i2o_driver_result_table *result;
53842 i2o_driver_store_table *dst;
53843- char tmp[28 + 1];
53844
53845 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
53846 if (result == NULL)
53847@@ -932,9 +923,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
53848
53849 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
53850 seq_printf(seq, "%-#8x", dst->module_id);
53851- seq_printf(seq, "%-29s",
53852- chtostr(tmp, dst->module_name_version, 28));
53853- seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
53854+ seq_printf(seq, "%-.28s", dst->module_name_version);
53855+ seq_printf(seq, "%-.8s", dst->date);
53856 seq_printf(seq, "%8d ", dst->module_size);
53857 seq_printf(seq, "%8d ", dst->mpb_size);
53858 seq_printf(seq, "0x%04x", dst->module_flags);
53859@@ -1250,11 +1240,10 @@ static int i2o_seq_show_authorized_users(struct seq_file *seq, void *v)
53860 static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
53861 {
53862 struct i2o_device *d = (struct i2o_device *)seq->private;
53863- static u32 work32[128]; // allow for "stuff" + up to 256 byte (max) serial number
53864+ u32 work32[128]; // allow for "stuff" + up to 256 byte (max) serial number
53865 // == (allow) 512d bytes (max)
53866- static u16 *work16 = (u16 *) work32;
53867+ u16 *work16 = (u16 *) work32;
53868 int token;
53869- char tmp[16 + 1];
53870
53871 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
53872
53873@@ -1266,14 +1255,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
53874 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
53875 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
53876 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
53877- seq_printf(seq, "Vendor info : %s\n",
53878- chtostr(tmp, (u8 *) (work32 + 2), 16));
53879- seq_printf(seq, "Product info : %s\n",
53880- chtostr(tmp, (u8 *) (work32 + 6), 16));
53881- seq_printf(seq, "Description : %s\n",
53882- chtostr(tmp, (u8 *) (work32 + 10), 16));
53883- seq_printf(seq, "Product rev. : %s\n",
53884- chtostr(tmp, (u8 *) (work32 + 14), 8));
53885+ seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
53886+ seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
53887+ seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
53888+ seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
53889
53890 seq_printf(seq, "Serial number : ");
53891 print_serial_number(seq, (u8 *) (work32 + 16),
53892@@ -1310,8 +1295,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
53893 u8 pad[256]; // allow up to 256 byte (max) serial number
53894 } result;
53895
53896- char tmp[24 + 1];
53897-
53898 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
53899
53900 if (token < 0) {
53901@@ -1320,10 +1303,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
53902 }
53903
53904 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
53905- seq_printf(seq, "Module name : %s\n",
53906- chtostr(tmp, result.module_name, 24));
53907- seq_printf(seq, "Module revision : %s\n",
53908- chtostr(tmp, result.module_rev, 8));
53909+ seq_printf(seq, "Module name : %.24s\n", result.module_name);
53910+ seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
53911
53912 seq_printf(seq, "Serial number : ");
53913 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
53914@@ -1347,8 +1328,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
53915 u8 instance_number[4];
53916 } result;
53917
53918- char tmp[64 + 1];
53919-
53920 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
53921
53922 if (token < 0) {
53923@@ -1356,14 +1335,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
53924 return 0;
53925 }
53926
53927- seq_printf(seq, "Device name : %s\n",
53928- chtostr(tmp, result.device_name, 64));
53929- seq_printf(seq, "Service name : %s\n",
53930- chtostr(tmp, result.service_name, 64));
53931- seq_printf(seq, "Physical name : %s\n",
53932- chtostr(tmp, result.physical_location, 64));
53933- seq_printf(seq, "Instance number : %s\n",
53934- chtostr(tmp, result.instance_number, 4));
53935+ seq_printf(seq, "Device name : %.64s\n", result.device_name);
53936+ seq_printf(seq, "Service name : %.64s\n", result.service_name);
53937+ seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
53938+ seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
53939
53940 return 0;
53941 }
53942@@ -1372,9 +1347,9 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
53943 static int i2o_seq_show_sgl_limits(struct seq_file *seq, void *v)
53944 {
53945 struct i2o_device *d = (struct i2o_device *)seq->private;
53946- static u32 work32[12];
53947- static u16 *work16 = (u16 *) work32;
53948- static u8 *work8 = (u8 *) work32;
53949+ u32 work32[12];
53950+ u16 *work16 = (u16 *) work32;
53951+ u8 *work8 = (u8 *) work32;
53952 int token;
53953
53954 token = i2o_parm_field_get(d, 0xF103, -1, &work32, sizeof(work32));
53955diff --git a/drivers/staging/i2o/iop.c b/drivers/staging/i2o/iop.c
53956index 23bdbe4..4e1f340 100644
53957--- a/drivers/staging/i2o/iop.c
53958+++ b/drivers/staging/i2o/iop.c
53959@@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
53960
53961 spin_lock_irqsave(&c->context_list_lock, flags);
53962
53963- if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
53964- atomic_inc(&c->context_list_counter);
53965+ if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
53966+ atomic_inc_unchecked(&c->context_list_counter);
53967
53968- entry->context = atomic_read(&c->context_list_counter);
53969+ entry->context = atomic_read_unchecked(&c->context_list_counter);
53970
53971 list_add(&entry->list, &c->context_list);
53972
53973@@ -1076,7 +1076,7 @@ struct i2o_controller *i2o_iop_alloc(void)
53974
53975 #if BITS_PER_LONG == 64
53976 spin_lock_init(&c->context_list_lock);
53977- atomic_set(&c->context_list_counter, 0);
53978+ atomic_set_unchecked(&c->context_list_counter, 0);
53979 INIT_LIST_HEAD(&c->context_list);
53980 #endif
53981
53982diff --git a/drivers/staging/iio/accel/lis3l02dq_ring.c b/drivers/staging/iio/accel/lis3l02dq_ring.c
53983index b892f2c..9b4898a 100644
53984--- a/drivers/staging/iio/accel/lis3l02dq_ring.c
53985+++ b/drivers/staging/iio/accel/lis3l02dq_ring.c
53986@@ -118,7 +118,7 @@ static int lis3l02dq_get_buffer_element(struct iio_dev *indio_dev,
53987 int scan_count = bitmap_weight(indio_dev->active_scan_mask,
53988 indio_dev->masklength);
53989
53990- rx_array = kcalloc(4, scan_count, GFP_KERNEL);
53991+ rx_array = kcalloc(scan_count, 4, GFP_KERNEL);
53992 if (!rx_array)
53993 return -ENOMEM;
53994 ret = lis3l02dq_read_all(indio_dev, rx_array);
53995diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
53996index d98e229..9c59bc2 100644
53997--- a/drivers/staging/iio/adc/ad7280a.c
53998+++ b/drivers/staging/iio/adc/ad7280a.c
53999@@ -547,8 +547,8 @@ static int ad7280_attr_init(struct ad7280_state *st)
54000 {
54001 int dev, ch, cnt;
54002
54003- st->iio_attr = kcalloc(2, sizeof(*st->iio_attr) *
54004- (st->slave_num + 1) * AD7280A_CELLS_PER_DEV,
54005+ st->iio_attr = kcalloc(sizeof(*st->iio_attr) *
54006+ (st->slave_num + 1) * AD7280A_CELLS_PER_DEV, 2,
54007 GFP_KERNEL);
54008 if (st->iio_attr == NULL)
54009 return -ENOMEM;
54010diff --git a/drivers/staging/lustre/lnet/selftest/brw_test.c b/drivers/staging/lustre/lnet/selftest/brw_test.c
54011index 658f458..0564216 100644
54012--- a/drivers/staging/lustre/lnet/selftest/brw_test.c
54013+++ b/drivers/staging/lustre/lnet/selftest/brw_test.c
54014@@ -487,13 +487,11 @@ brw_server_handle(struct srpc_server_rpc *rpc)
54015 return 0;
54016 }
54017
54018-sfw_test_client_ops_t brw_test_client;
54019-void brw_init_test_client(void)
54020-{
54021- brw_test_client.tso_init = brw_client_init;
54022- brw_test_client.tso_fini = brw_client_fini;
54023- brw_test_client.tso_prep_rpc = brw_client_prep_rpc;
54024- brw_test_client.tso_done_rpc = brw_client_done_rpc;
54025+sfw_test_client_ops_t brw_test_client = {
54026+ .tso_init = brw_client_init,
54027+ .tso_fini = brw_client_fini,
54028+ .tso_prep_rpc = brw_client_prep_rpc,
54029+ .tso_done_rpc = brw_client_done_rpc,
54030 };
54031
54032 srpc_service_t brw_test_service;
54033diff --git a/drivers/staging/lustre/lnet/selftest/framework.c b/drivers/staging/lustre/lnet/selftest/framework.c
54034index a93a90d..c51dde6 100644
54035--- a/drivers/staging/lustre/lnet/selftest/framework.c
54036+++ b/drivers/staging/lustre/lnet/selftest/framework.c
54037@@ -1628,12 +1628,10 @@ static srpc_service_t sfw_services[] = {
54038
54039 extern sfw_test_client_ops_t ping_test_client;
54040 extern srpc_service_t ping_test_service;
54041-extern void ping_init_test_client(void);
54042 extern void ping_init_test_service(void);
54043
54044 extern sfw_test_client_ops_t brw_test_client;
54045 extern srpc_service_t brw_test_service;
54046-extern void brw_init_test_client(void);
54047 extern void brw_init_test_service(void);
54048
54049
54050@@ -1675,12 +1673,10 @@ sfw_startup(void)
54051 INIT_LIST_HEAD(&sfw_data.fw_zombie_rpcs);
54052 INIT_LIST_HEAD(&sfw_data.fw_zombie_sessions);
54053
54054- brw_init_test_client();
54055 brw_init_test_service();
54056 rc = sfw_register_test(&brw_test_service, &brw_test_client);
54057 LASSERT(rc == 0);
54058
54059- ping_init_test_client();
54060 ping_init_test_service();
54061 rc = sfw_register_test(&ping_test_service, &ping_test_client);
54062 LASSERT(rc == 0);
54063diff --git a/drivers/staging/lustre/lnet/selftest/ping_test.c b/drivers/staging/lustre/lnet/selftest/ping_test.c
54064index 644069a..83cbd26 100644
54065--- a/drivers/staging/lustre/lnet/selftest/ping_test.c
54066+++ b/drivers/staging/lustre/lnet/selftest/ping_test.c
54067@@ -211,14 +211,12 @@ ping_server_handle(struct srpc_server_rpc *rpc)
54068 return 0;
54069 }
54070
54071-sfw_test_client_ops_t ping_test_client;
54072-void ping_init_test_client(void)
54073-{
54074- ping_test_client.tso_init = ping_client_init;
54075- ping_test_client.tso_fini = ping_client_fini;
54076- ping_test_client.tso_prep_rpc = ping_client_prep_rpc;
54077- ping_test_client.tso_done_rpc = ping_client_done_rpc;
54078-}
54079+sfw_test_client_ops_t ping_test_client = {
54080+ .tso_init = ping_client_init,
54081+ .tso_fini = ping_client_fini,
54082+ .tso_prep_rpc = ping_client_prep_rpc,
54083+ .tso_done_rpc = ping_client_done_rpc,
54084+};
54085
54086 srpc_service_t ping_test_service;
54087 void ping_init_test_service(void)
54088diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h
54089index bac9902..0225fe1 100644
54090--- a/drivers/staging/lustre/lustre/include/lustre_dlm.h
54091+++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h
54092@@ -1139,7 +1139,7 @@ struct ldlm_callback_suite {
54093 ldlm_completion_callback lcs_completion;
54094 ldlm_blocking_callback lcs_blocking;
54095 ldlm_glimpse_callback lcs_glimpse;
54096-};
54097+} __no_const;
54098
54099 /* ldlm_lockd.c */
54100 int ldlm_del_waiting_lock(struct ldlm_lock *lock);
54101diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h
54102index 2a88b80..62e7e5f 100644
54103--- a/drivers/staging/lustre/lustre/include/obd.h
54104+++ b/drivers/staging/lustre/lustre/include/obd.h
54105@@ -1362,7 +1362,7 @@ struct md_ops {
54106 * lprocfs_alloc_md_stats() in obdclass/lprocfs_status.c. Also, add a
54107 * wrapper function in include/linux/obd_class.h.
54108 */
54109-};
54110+} __no_const;
54111
54112 struct lsm_operations {
54113 void (*lsm_free)(struct lov_stripe_md *);
54114diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
54115index a4c252f..b21acac 100644
54116--- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
54117+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
54118@@ -258,7 +258,7 @@ ldlm_process_flock_lock(struct ldlm_lock *req, __u64 *flags, int first_enq,
54119 int added = (mode == LCK_NL);
54120 int overlaps = 0;
54121 int splitted = 0;
54122- const struct ldlm_callback_suite null_cbs = { NULL };
54123+ const struct ldlm_callback_suite null_cbs = { };
54124
54125 CDEBUG(D_DLMTRACE,
54126 "flags %#llx owner %llu pid %u mode %u start %llu end %llu\n",
54127diff --git a/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c
54128index f0ee76a..1d01af9 100644
54129--- a/drivers/staging/lustre/lustre/libcfs/module.c
54130+++ b/drivers/staging/lustre/lustre/libcfs/module.c
54131@@ -380,11 +380,11 @@ out:
54132
54133
54134 struct cfs_psdev_ops libcfs_psdev_ops = {
54135- libcfs_psdev_open,
54136- libcfs_psdev_release,
54137- NULL,
54138- NULL,
54139- libcfs_ioctl
54140+ .p_open = libcfs_psdev_open,
54141+ .p_close = libcfs_psdev_release,
54142+ .p_read = NULL,
54143+ .p_write = NULL,
54144+ .p_ioctl = libcfs_ioctl
54145 };
54146
54147 static int init_libcfs_module(void)
54148@@ -631,7 +631,7 @@ static int proc_console_max_delay_cs(struct ctl_table *table, int write,
54149 loff_t *ppos)
54150 {
54151 int rc, max_delay_cs;
54152- struct ctl_table dummy = *table;
54153+ ctl_table_no_const dummy = *table;
54154 long d;
54155
54156 dummy.data = &max_delay_cs;
54157@@ -664,7 +664,7 @@ static int proc_console_min_delay_cs(struct ctl_table *table, int write,
54158 loff_t *ppos)
54159 {
54160 int rc, min_delay_cs;
54161- struct ctl_table dummy = *table;
54162+ ctl_table_no_const dummy = *table;
54163 long d;
54164
54165 dummy.data = &min_delay_cs;
54166@@ -696,7 +696,7 @@ static int proc_console_backoff(struct ctl_table *table, int write,
54167 void __user *buffer, size_t *lenp, loff_t *ppos)
54168 {
54169 int rc, backoff;
54170- struct ctl_table dummy = *table;
54171+ ctl_table_no_const dummy = *table;
54172
54173 dummy.data = &backoff;
54174 dummy.proc_handler = &proc_dointvec;
54175diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
54176index 22667db..8b703b6 100644
54177--- a/drivers/staging/octeon/ethernet-rx.c
54178+++ b/drivers/staging/octeon/ethernet-rx.c
54179@@ -354,14 +354,14 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
54180 /* Increment RX stats for virtual ports */
54181 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
54182 #ifdef CONFIG_64BIT
54183- atomic64_add(1,
54184+ atomic64_add_unchecked(1,
54185 (atomic64_t *)&priv->stats.rx_packets);
54186- atomic64_add(skb->len,
54187+ atomic64_add_unchecked(skb->len,
54188 (atomic64_t *)&priv->stats.rx_bytes);
54189 #else
54190- atomic_add(1,
54191+ atomic_add_unchecked(1,
54192 (atomic_t *)&priv->stats.rx_packets);
54193- atomic_add(skb->len,
54194+ atomic_add_unchecked(skb->len,
54195 (atomic_t *)&priv->stats.rx_bytes);
54196 #endif
54197 }
54198@@ -373,10 +373,10 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
54199 dev->name);
54200 */
54201 #ifdef CONFIG_64BIT
54202- atomic64_add(1,
54203+ atomic64_add_unchecked(1,
54204 (atomic64_t *)&priv->stats.rx_dropped);
54205 #else
54206- atomic_add(1,
54207+ atomic_add_unchecked(1,
54208 (atomic_t *)&priv->stats.rx_dropped);
54209 #endif
54210 dev_kfree_skb_irq(skb);
54211diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
54212index fbbe866..2943243 100644
54213--- a/drivers/staging/octeon/ethernet.c
54214+++ b/drivers/staging/octeon/ethernet.c
54215@@ -251,11 +251,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
54216 * since the RX tasklet also increments it.
54217 */
54218 #ifdef CONFIG_64BIT
54219- atomic64_add(rx_status.dropped_packets,
54220- (atomic64_t *)&priv->stats.rx_dropped);
54221+ atomic64_add_unchecked(rx_status.dropped_packets,
54222+ (atomic64_unchecked_t *)&priv->stats.rx_dropped);
54223 #else
54224- atomic_add(rx_status.dropped_packets,
54225- (atomic_t *)&priv->stats.rx_dropped);
54226+ atomic_add_unchecked(rx_status.dropped_packets,
54227+ (atomic_unchecked_t *)&priv->stats.rx_dropped);
54228 #endif
54229 }
54230
54231diff --git a/drivers/staging/rtl8188eu/include/hal_intf.h b/drivers/staging/rtl8188eu/include/hal_intf.h
54232index 3b476d8..f522d68 100644
54233--- a/drivers/staging/rtl8188eu/include/hal_intf.h
54234+++ b/drivers/staging/rtl8188eu/include/hal_intf.h
54235@@ -225,7 +225,7 @@ struct hal_ops {
54236
54237 void (*hal_notch_filter)(struct adapter *adapter, bool enable);
54238 void (*hal_reset_security_engine)(struct adapter *adapter);
54239-};
54240+} __no_const;
54241
54242 enum rt_eeprom_type {
54243 EEPROM_93C46,
54244diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
54245index 070cc03..6806e37 100644
54246--- a/drivers/staging/rtl8712/rtl871x_io.h
54247+++ b/drivers/staging/rtl8712/rtl871x_io.h
54248@@ -108,7 +108,7 @@ struct _io_ops {
54249 u8 *pmem);
54250 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
54251 u8 *pmem);
54252-};
54253+} __no_const;
54254
54255 struct io_req {
54256 struct list_head list;
54257diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
54258index dbbb2f8..5232114 100644
54259--- a/drivers/staging/sm750fb/sm750.c
54260+++ b/drivers/staging/sm750fb/sm750.c
54261@@ -780,6 +780,7 @@ static struct fb_ops lynxfb_ops = {
54262 .fb_set_par = lynxfb_ops_set_par,
54263 .fb_setcolreg = lynxfb_ops_setcolreg,
54264 .fb_blank = lynxfb_ops_blank,
54265+ .fb_pan_display = lynxfb_ops_pan_display,
54266 .fb_fillrect = cfb_fillrect,
54267 .fb_imageblit = cfb_imageblit,
54268 .fb_copyarea = cfb_copyarea,
54269@@ -827,8 +828,10 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)
54270 par->index = index;
54271 output->channel = &crtc->channel;
54272 sm750fb_set_drv(par);
54273- lynxfb_ops.fb_pan_display = lynxfb_ops_pan_display;
54274
54275+ pax_open_kernel();
54276+ *(void **)&lynxfb_ops.fb_pan_display = lynxfb_ops_pan_display;
54277+ pax_close_kernel();
54278
54279 /* set current cursor variable and proc pointer,
54280 * must be set after crtc member initialized */
54281@@ -850,7 +853,9 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)
54282 crtc->cursor.share = share;
54283 memset_io(crtc->cursor.vstart, 0, crtc->cursor.size);
54284 if (!g_hwcursor) {
54285- lynxfb_ops.fb_cursor = NULL;
54286+ pax_open_kernel();
54287+ *(void **)&lynxfb_ops.fb_cursor = NULL;
54288+ pax_close_kernel();
54289 crtc->cursor.disable(&crtc->cursor);
54290 }
54291
54292@@ -858,9 +863,11 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)
54293 /* set info->fbops, must be set before fb_find_mode */
54294 if (!share->accel_off) {
54295 /* use 2d acceleration */
54296- lynxfb_ops.fb_fillrect = lynxfb_ops_fillrect;
54297- lynxfb_ops.fb_copyarea = lynxfb_ops_copyarea;
54298- lynxfb_ops.fb_imageblit = lynxfb_ops_imageblit;
54299+ pax_open_kernel();
54300+ *(void **)&lynxfb_ops.fb_fillrect = lynxfb_ops_fillrect;
54301+ *(void **)&lynxfb_ops.fb_copyarea = lynxfb_ops_copyarea;
54302+ *(void **)&lynxfb_ops.fb_imageblit = lynxfb_ops_imageblit;
54303+ pax_close_kernel();
54304 }
54305 info->fbops = &lynxfb_ops;
54306
54307diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h
54308index bd46df9..a0a5274 100644
54309--- a/drivers/staging/unisys/visorchipset/visorchipset.h
54310+++ b/drivers/staging/unisys/visorchipset/visorchipset.h
54311@@ -170,7 +170,7 @@ struct visorchipset_busdev_notifiers {
54312 void (*device_resume)(ulong bus_no, ulong dev_no);
54313 int (*get_channel_info)(uuid_le type_uuid, ulong *min_size,
54314 ulong *max_size);
54315-};
54316+} __no_const;
54317
54318 /* These functions live inside visorchipset, and will be called to indicate
54319 * responses to specific events (by code outside of visorchipset).
54320@@ -185,7 +185,7 @@ struct visorchipset_busdev_responders {
54321 void (*device_destroy)(ulong bus_no, ulong dev_no, int response);
54322 void (*device_pause)(ulong bus_no, ulong dev_no, int response);
54323 void (*device_resume)(ulong bus_no, ulong dev_no, int response);
54324-};
54325+} __no_const;
54326
54327 /** Register functions (in the bus driver) to get called by visorchipset
54328 * whenever a bus or device appears for which this service partition is
54329diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c
54330index 18b0f97..9c7716e 100644
54331--- a/drivers/target/sbp/sbp_target.c
54332+++ b/drivers/target/sbp/sbp_target.c
54333@@ -61,7 +61,7 @@ static const u32 sbp_unit_directory_template[] = {
54334
54335 #define SESSION_MAINTENANCE_INTERVAL HZ
54336
54337-static atomic_t login_id = ATOMIC_INIT(0);
54338+static atomic_unchecked_t login_id = ATOMIC_INIT(0);
54339
54340 static void session_maintenance_work(struct work_struct *);
54341 static int sbp_run_transaction(struct fw_card *, int, int, int, int,
54342@@ -443,7 +443,7 @@ static void sbp_management_request_login(
54343 login->lun = se_lun;
54344 login->status_fifo_addr = sbp2_pointer_to_addr(&req->orb.status_fifo);
54345 login->exclusive = LOGIN_ORB_EXCLUSIVE(be32_to_cpu(req->orb.misc));
54346- login->login_id = atomic_inc_return(&login_id);
54347+ login->login_id = atomic_inc_return_unchecked(&login_id);
54348
54349 login->tgt_agt = sbp_target_agent_register(login);
54350 if (IS_ERR(login->tgt_agt)) {
54351diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
54352index ce5f768..a4f884a 100644
54353--- a/drivers/target/target_core_device.c
54354+++ b/drivers/target/target_core_device.c
54355@@ -1496,7 +1496,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
54356 spin_lock_init(&dev->se_tmr_lock);
54357 spin_lock_init(&dev->qf_cmd_lock);
54358 sema_init(&dev->caw_sem, 1);
54359- atomic_set(&dev->dev_ordered_id, 0);
54360+ atomic_set_unchecked(&dev->dev_ordered_id, 0);
54361 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
54362 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
54363 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
54364diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
54365index 675f2d9..1389429 100644
54366--- a/drivers/target/target_core_transport.c
54367+++ b/drivers/target/target_core_transport.c
54368@@ -1208,7 +1208,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
54369 * Used to determine when ORDERED commands should go from
54370 * Dormant to Active status.
54371 */
54372- cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
54373+ cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
54374 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
54375 cmd->se_ordered_id, cmd->sam_task_attr,
54376 dev->transport->name);
54377diff --git a/drivers/thermal/int340x_thermal/int3400_thermal.c b/drivers/thermal/int340x_thermal/int3400_thermal.c
54378index 031018e..90981a1 100644
54379--- a/drivers/thermal/int340x_thermal/int3400_thermal.c
54380+++ b/drivers/thermal/int340x_thermal/int3400_thermal.c
54381@@ -272,8 +272,10 @@ static int int3400_thermal_probe(struct platform_device *pdev)
54382 platform_set_drvdata(pdev, priv);
54383
54384 if (priv->uuid_bitmap & 1 << INT3400_THERMAL_PASSIVE_1) {
54385- int3400_thermal_ops.get_mode = int3400_thermal_get_mode;
54386- int3400_thermal_ops.set_mode = int3400_thermal_set_mode;
54387+ pax_open_kernel();
54388+ *(void **)&int3400_thermal_ops.get_mode = int3400_thermal_get_mode;
54389+ *(void **)&int3400_thermal_ops.set_mode = int3400_thermal_set_mode;
54390+ pax_close_kernel();
54391 }
54392 priv->thermal = thermal_zone_device_register("INT3400 Thermal", 0, 0,
54393 priv, &int3400_thermal_ops,
54394diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
54395index 668fb1b..2737bbe 100644
54396--- a/drivers/thermal/of-thermal.c
54397+++ b/drivers/thermal/of-thermal.c
54398@@ -31,6 +31,7 @@
54399 #include <linux/export.h>
54400 #include <linux/string.h>
54401 #include <linux/thermal.h>
54402+#include <linux/mm.h>
54403
54404 #include "thermal_core.h"
54405
54406@@ -412,9 +413,11 @@ thermal_zone_of_add_sensor(struct device_node *zone,
54407 tz->ops = ops;
54408 tz->sensor_data = data;
54409
54410- tzd->ops->get_temp = of_thermal_get_temp;
54411- tzd->ops->get_trend = of_thermal_get_trend;
54412- tzd->ops->set_emul_temp = of_thermal_set_emul_temp;
54413+ pax_open_kernel();
54414+ *(void **)&tzd->ops->get_temp = of_thermal_get_temp;
54415+ *(void **)&tzd->ops->get_trend = of_thermal_get_trend;
54416+ *(void **)&tzd->ops->set_emul_temp = of_thermal_set_emul_temp;
54417+ pax_close_kernel();
54418 mutex_unlock(&tzd->lock);
54419
54420 return tzd;
54421@@ -544,9 +547,11 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
54422 return;
54423
54424 mutex_lock(&tzd->lock);
54425- tzd->ops->get_temp = NULL;
54426- tzd->ops->get_trend = NULL;
54427- tzd->ops->set_emul_temp = NULL;
54428+ pax_open_kernel();
54429+ *(void **)&tzd->ops->get_temp = NULL;
54430+ *(void **)&tzd->ops->get_trend = NULL;
54431+ *(void **)&tzd->ops->set_emul_temp = NULL;
54432+ pax_close_kernel();
54433
54434 tz->ops = NULL;
54435 tz->sensor_data = NULL;
54436diff --git a/drivers/thermal/x86_pkg_temp_thermal.c b/drivers/thermal/x86_pkg_temp_thermal.c
54437index 9ea3d9d..53e8792 100644
54438--- a/drivers/thermal/x86_pkg_temp_thermal.c
54439+++ b/drivers/thermal/x86_pkg_temp_thermal.c
54440@@ -567,7 +567,7 @@ static int pkg_temp_thermal_cpu_callback(struct notifier_block *nfb,
54441 return NOTIFY_OK;
54442 }
54443
54444-static struct notifier_block pkg_temp_thermal_notifier __refdata = {
54445+static struct notifier_block pkg_temp_thermal_notifier __refconst = {
54446 .notifier_call = pkg_temp_thermal_cpu_callback,
54447 };
54448
54449diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
54450index fd66f57..48e6376 100644
54451--- a/drivers/tty/cyclades.c
54452+++ b/drivers/tty/cyclades.c
54453@@ -1570,10 +1570,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
54454 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
54455 info->port.count);
54456 #endif
54457- info->port.count++;
54458+ atomic_inc(&info->port.count);
54459 #ifdef CY_DEBUG_COUNT
54460 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
54461- current->pid, info->port.count);
54462+ current->pid, atomic_read(&info->port.count));
54463 #endif
54464
54465 /*
54466@@ -3974,7 +3974,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
54467 for (j = 0; j < cy_card[i].nports; j++) {
54468 info = &cy_card[i].ports[j];
54469
54470- if (info->port.count) {
54471+ if (atomic_read(&info->port.count)) {
54472 /* XXX is the ldisc num worth this? */
54473 struct tty_struct *tty;
54474 struct tty_ldisc *ld;
54475diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
54476index 4fcec1d..5a036f7 100644
54477--- a/drivers/tty/hvc/hvc_console.c
54478+++ b/drivers/tty/hvc/hvc_console.c
54479@@ -342,7 +342,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
54480
54481 spin_lock_irqsave(&hp->port.lock, flags);
54482 /* Check and then increment for fast path open. */
54483- if (hp->port.count++ > 0) {
54484+ if (atomic_inc_return(&hp->port.count) > 1) {
54485 spin_unlock_irqrestore(&hp->port.lock, flags);
54486 hvc_kick();
54487 return 0;
54488@@ -397,7 +397,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
54489
54490 spin_lock_irqsave(&hp->port.lock, flags);
54491
54492- if (--hp->port.count == 0) {
54493+ if (atomic_dec_return(&hp->port.count) == 0) {
54494 spin_unlock_irqrestore(&hp->port.lock, flags);
54495 /* We are done with the tty pointer now. */
54496 tty_port_tty_set(&hp->port, NULL);
54497@@ -419,9 +419,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
54498 */
54499 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
54500 } else {
54501- if (hp->port.count < 0)
54502+ if (atomic_read(&hp->port.count) < 0)
54503 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
54504- hp->vtermno, hp->port.count);
54505+ hp->vtermno, atomic_read(&hp->port.count));
54506 spin_unlock_irqrestore(&hp->port.lock, flags);
54507 }
54508 }
54509@@ -451,12 +451,12 @@ static void hvc_hangup(struct tty_struct *tty)
54510 * open->hangup case this can be called after the final close so prevent
54511 * that from happening for now.
54512 */
54513- if (hp->port.count <= 0) {
54514+ if (atomic_read(&hp->port.count) <= 0) {
54515 spin_unlock_irqrestore(&hp->port.lock, flags);
54516 return;
54517 }
54518
54519- hp->port.count = 0;
54520+ atomic_set(&hp->port.count, 0);
54521 spin_unlock_irqrestore(&hp->port.lock, flags);
54522 tty_port_tty_set(&hp->port, NULL);
54523
54524@@ -504,7 +504,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
54525 return -EPIPE;
54526
54527 /* FIXME what's this (unprotected) check for? */
54528- if (hp->port.count <= 0)
54529+ if (atomic_read(&hp->port.count) <= 0)
54530 return -EIO;
54531
54532 spin_lock_irqsave(&hp->lock, flags);
54533diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
54534index 81ff7e1..dfb7b71 100644
54535--- a/drivers/tty/hvc/hvcs.c
54536+++ b/drivers/tty/hvc/hvcs.c
54537@@ -83,6 +83,7 @@
54538 #include <asm/hvcserver.h>
54539 #include <asm/uaccess.h>
54540 #include <asm/vio.h>
54541+#include <asm/local.h>
54542
54543 /*
54544 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
54545@@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
54546
54547 spin_lock_irqsave(&hvcsd->lock, flags);
54548
54549- if (hvcsd->port.count > 0) {
54550+ if (atomic_read(&hvcsd->port.count) > 0) {
54551 spin_unlock_irqrestore(&hvcsd->lock, flags);
54552 printk(KERN_INFO "HVCS: vterm state unchanged. "
54553 "The hvcs device node is still in use.\n");
54554@@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
54555 }
54556 }
54557
54558- hvcsd->port.count = 0;
54559+ atomic_set(&hvcsd->port.count, 0);
54560 hvcsd->port.tty = tty;
54561 tty->driver_data = hvcsd;
54562
54563@@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
54564 unsigned long flags;
54565
54566 spin_lock_irqsave(&hvcsd->lock, flags);
54567- hvcsd->port.count++;
54568+ atomic_inc(&hvcsd->port.count);
54569 hvcsd->todo_mask |= HVCS_SCHED_READ;
54570 spin_unlock_irqrestore(&hvcsd->lock, flags);
54571
54572@@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
54573 hvcsd = tty->driver_data;
54574
54575 spin_lock_irqsave(&hvcsd->lock, flags);
54576- if (--hvcsd->port.count == 0) {
54577+ if (atomic_dec_and_test(&hvcsd->port.count)) {
54578
54579 vio_disable_interrupts(hvcsd->vdev);
54580
54581@@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
54582
54583 free_irq(irq, hvcsd);
54584 return;
54585- } else if (hvcsd->port.count < 0) {
54586+ } else if (atomic_read(&hvcsd->port.count) < 0) {
54587 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
54588 " is missmanaged.\n",
54589- hvcsd->vdev->unit_address, hvcsd->port.count);
54590+ hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
54591 }
54592
54593 spin_unlock_irqrestore(&hvcsd->lock, flags);
54594@@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
54595
54596 spin_lock_irqsave(&hvcsd->lock, flags);
54597 /* Preserve this so that we know how many kref refs to put */
54598- temp_open_count = hvcsd->port.count;
54599+ temp_open_count = atomic_read(&hvcsd->port.count);
54600
54601 /*
54602 * Don't kref put inside the spinlock because the destruction
54603@@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
54604 tty->driver_data = NULL;
54605 hvcsd->port.tty = NULL;
54606
54607- hvcsd->port.count = 0;
54608+ atomic_set(&hvcsd->port.count, 0);
54609
54610 /* This will drop any buffered data on the floor which is OK in a hangup
54611 * scenario. */
54612@@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
54613 * the middle of a write operation? This is a crummy place to do this
54614 * but we want to keep it all in the spinlock.
54615 */
54616- if (hvcsd->port.count <= 0) {
54617+ if (atomic_read(&hvcsd->port.count) <= 0) {
54618 spin_unlock_irqrestore(&hvcsd->lock, flags);
54619 return -ENODEV;
54620 }
54621@@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
54622 {
54623 struct hvcs_struct *hvcsd = tty->driver_data;
54624
54625- if (!hvcsd || hvcsd->port.count <= 0)
54626+ if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
54627 return 0;
54628
54629 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
54630diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
54631index 4190199..06d5bfa 100644
54632--- a/drivers/tty/hvc/hvsi.c
54633+++ b/drivers/tty/hvc/hvsi.c
54634@@ -85,7 +85,7 @@ struct hvsi_struct {
54635 int n_outbuf;
54636 uint32_t vtermno;
54637 uint32_t virq;
54638- atomic_t seqno; /* HVSI packet sequence number */
54639+ atomic_unchecked_t seqno; /* HVSI packet sequence number */
54640 uint16_t mctrl;
54641 uint8_t state; /* HVSI protocol state */
54642 uint8_t flags;
54643@@ -295,7 +295,7 @@ static int hvsi_version_respond(struct hvsi_struct *hp, uint16_t query_seqno)
54644
54645 packet.hdr.type = VS_QUERY_RESPONSE_PACKET_HEADER;
54646 packet.hdr.len = sizeof(struct hvsi_query_response);
54647- packet.hdr.seqno = atomic_inc_return(&hp->seqno);
54648+ packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
54649 packet.verb = VSV_SEND_VERSION_NUMBER;
54650 packet.u.version = HVSI_VERSION;
54651 packet.query_seqno = query_seqno+1;
54652@@ -555,7 +555,7 @@ static int hvsi_query(struct hvsi_struct *hp, uint16_t verb)
54653
54654 packet.hdr.type = VS_QUERY_PACKET_HEADER;
54655 packet.hdr.len = sizeof(struct hvsi_query);
54656- packet.hdr.seqno = atomic_inc_return(&hp->seqno);
54657+ packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
54658 packet.verb = verb;
54659
54660 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len);
54661@@ -597,7 +597,7 @@ static int hvsi_set_mctrl(struct hvsi_struct *hp, uint16_t mctrl)
54662 int wrote;
54663
54664 packet.hdr.type = VS_CONTROL_PACKET_HEADER,
54665- packet.hdr.seqno = atomic_inc_return(&hp->seqno);
54666+ packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
54667 packet.hdr.len = sizeof(struct hvsi_control);
54668 packet.verb = VSV_SET_MODEM_CTL;
54669 packet.mask = HVSI_TSDTR;
54670@@ -680,7 +680,7 @@ static int hvsi_put_chars(struct hvsi_struct *hp, const char *buf, int count)
54671 BUG_ON(count > HVSI_MAX_OUTGOING_DATA);
54672
54673 packet.hdr.type = VS_DATA_PACKET_HEADER;
54674- packet.hdr.seqno = atomic_inc_return(&hp->seqno);
54675+ packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
54676 packet.hdr.len = count + sizeof(struct hvsi_header);
54677 memcpy(&packet.data, buf, count);
54678
54679@@ -697,7 +697,7 @@ static void hvsi_close_protocol(struct hvsi_struct *hp)
54680 struct hvsi_control packet __ALIGNED__;
54681
54682 packet.hdr.type = VS_CONTROL_PACKET_HEADER;
54683- packet.hdr.seqno = atomic_inc_return(&hp->seqno);
54684+ packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
54685 packet.hdr.len = 6;
54686 packet.verb = VSV_CLOSE_PROTOCOL;
54687
54688@@ -725,7 +725,7 @@ static int hvsi_open(struct tty_struct *tty, struct file *filp)
54689
54690 tty_port_tty_set(&hp->port, tty);
54691 spin_lock_irqsave(&hp->lock, flags);
54692- hp->port.count++;
54693+ atomic_inc(&hp->port.count);
54694 atomic_set(&hp->seqno, 0);
54695 h_vio_signal(hp->vtermno, VIO_IRQ_ENABLE);
54696 spin_unlock_irqrestore(&hp->lock, flags);
54697@@ -782,7 +782,7 @@ static void hvsi_close(struct tty_struct *tty, struct file *filp)
54698
54699 spin_lock_irqsave(&hp->lock, flags);
54700
54701- if (--hp->port.count == 0) {
54702+ if (atomic_dec_return(&hp->port.count) == 0) {
54703 tty_port_tty_set(&hp->port, NULL);
54704 hp->inbuf_end = hp->inbuf; /* discard remaining partial packets */
54705
54706@@ -815,9 +815,9 @@ static void hvsi_close(struct tty_struct *tty, struct file *filp)
54707
54708 spin_lock_irqsave(&hp->lock, flags);
54709 }
54710- } else if (hp->port.count < 0)
54711+ } else if (atomic_read(&hp->port.count) < 0)
54712 printk(KERN_ERR "hvsi_close %lu: oops, count is %d\n",
54713- hp - hvsi_ports, hp->port.count);
54714+ hp - hvsi_ports, atomic_read(&hp->port.count));
54715
54716 spin_unlock_irqrestore(&hp->lock, flags);
54717 }
54718@@ -832,7 +832,7 @@ static void hvsi_hangup(struct tty_struct *tty)
54719 tty_port_tty_set(&hp->port, NULL);
54720
54721 spin_lock_irqsave(&hp->lock, flags);
54722- hp->port.count = 0;
54723+ atomic_set(&hp->port.count, 0);
54724 hp->n_outbuf = 0;
54725 spin_unlock_irqrestore(&hp->lock, flags);
54726 }
54727diff --git a/drivers/tty/hvc/hvsi_lib.c b/drivers/tty/hvc/hvsi_lib.c
54728index a270f04..7c77b5d 100644
54729--- a/drivers/tty/hvc/hvsi_lib.c
54730+++ b/drivers/tty/hvc/hvsi_lib.c
54731@@ -8,7 +8,7 @@
54732
54733 static int hvsi_send_packet(struct hvsi_priv *pv, struct hvsi_header *packet)
54734 {
54735- packet->seqno = cpu_to_be16(atomic_inc_return(&pv->seqno));
54736+ packet->seqno = cpu_to_be16(atomic_inc_return_unchecked(&pv->seqno));
54737
54738 /* Assumes that always succeeds, works in practice */
54739 return pv->put_chars(pv->termno, (char *)packet, packet->len);
54740@@ -20,7 +20,7 @@ static void hvsi_start_handshake(struct hvsi_priv *pv)
54741
54742 /* Reset state */
54743 pv->established = 0;
54744- atomic_set(&pv->seqno, 0);
54745+ atomic_set_unchecked(&pv->seqno, 0);
54746
54747 pr_devel("HVSI@%x: Handshaking started\n", pv->termno);
54748
54749diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
54750index 345cebb..d5a1e9e 100644
54751--- a/drivers/tty/ipwireless/tty.c
54752+++ b/drivers/tty/ipwireless/tty.c
54753@@ -28,6 +28,7 @@
54754 #include <linux/tty_driver.h>
54755 #include <linux/tty_flip.h>
54756 #include <linux/uaccess.h>
54757+#include <asm/local.h>
54758
54759 #include "tty.h"
54760 #include "network.h"
54761@@ -93,10 +94,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
54762 return -ENODEV;
54763
54764 mutex_lock(&tty->ipw_tty_mutex);
54765- if (tty->port.count == 0)
54766+ if (atomic_read(&tty->port.count) == 0)
54767 tty->tx_bytes_queued = 0;
54768
54769- tty->port.count++;
54770+ atomic_inc(&tty->port.count);
54771
54772 tty->port.tty = linux_tty;
54773 linux_tty->driver_data = tty;
54774@@ -112,9 +113,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
54775
54776 static void do_ipw_close(struct ipw_tty *tty)
54777 {
54778- tty->port.count--;
54779-
54780- if (tty->port.count == 0) {
54781+ if (atomic_dec_return(&tty->port.count) == 0) {
54782 struct tty_struct *linux_tty = tty->port.tty;
54783
54784 if (linux_tty != NULL) {
54785@@ -135,7 +134,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
54786 return;
54787
54788 mutex_lock(&tty->ipw_tty_mutex);
54789- if (tty->port.count == 0) {
54790+ if (atomic_read(&tty->port.count) == 0) {
54791 mutex_unlock(&tty->ipw_tty_mutex);
54792 return;
54793 }
54794@@ -158,7 +157,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
54795
54796 mutex_lock(&tty->ipw_tty_mutex);
54797
54798- if (!tty->port.count) {
54799+ if (!atomic_read(&tty->port.count)) {
54800 mutex_unlock(&tty->ipw_tty_mutex);
54801 return;
54802 }
54803@@ -197,7 +196,7 @@ static int ipw_write(struct tty_struct *linux_tty,
54804 return -ENODEV;
54805
54806 mutex_lock(&tty->ipw_tty_mutex);
54807- if (!tty->port.count) {
54808+ if (!atomic_read(&tty->port.count)) {
54809 mutex_unlock(&tty->ipw_tty_mutex);
54810 return -EINVAL;
54811 }
54812@@ -237,7 +236,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
54813 if (!tty)
54814 return -ENODEV;
54815
54816- if (!tty->port.count)
54817+ if (!atomic_read(&tty->port.count))
54818 return -EINVAL;
54819
54820 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
54821@@ -279,7 +278,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
54822 if (!tty)
54823 return 0;
54824
54825- if (!tty->port.count)
54826+ if (!atomic_read(&tty->port.count))
54827 return 0;
54828
54829 return tty->tx_bytes_queued;
54830@@ -360,7 +359,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
54831 if (!tty)
54832 return -ENODEV;
54833
54834- if (!tty->port.count)
54835+ if (!atomic_read(&tty->port.count))
54836 return -EINVAL;
54837
54838 return get_control_lines(tty);
54839@@ -376,7 +375,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
54840 if (!tty)
54841 return -ENODEV;
54842
54843- if (!tty->port.count)
54844+ if (!atomic_read(&tty->port.count))
54845 return -EINVAL;
54846
54847 return set_control_lines(tty, set, clear);
54848@@ -390,7 +389,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
54849 if (!tty)
54850 return -ENODEV;
54851
54852- if (!tty->port.count)
54853+ if (!atomic_read(&tty->port.count))
54854 return -EINVAL;
54855
54856 /* FIXME: Exactly how is the tty object locked here .. */
54857@@ -546,7 +545,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
54858 * are gone */
54859 mutex_lock(&ttyj->ipw_tty_mutex);
54860 }
54861- while (ttyj->port.count)
54862+ while (atomic_read(&ttyj->port.count))
54863 do_ipw_close(ttyj);
54864 ipwireless_disassociate_network_ttys(network,
54865 ttyj->channel_idx);
54866diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
54867index 14c54e0..1efd4f2 100644
54868--- a/drivers/tty/moxa.c
54869+++ b/drivers/tty/moxa.c
54870@@ -1189,7 +1189,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
54871 }
54872
54873 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
54874- ch->port.count++;
54875+ atomic_inc(&ch->port.count);
54876 tty->driver_data = ch;
54877 tty_port_tty_set(&ch->port, tty);
54878 mutex_lock(&ch->port.mutex);
54879diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
54880index 2c34c32..81d10e1 100644
54881--- a/drivers/tty/n_gsm.c
54882+++ b/drivers/tty/n_gsm.c
54883@@ -1644,7 +1644,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
54884 spin_lock_init(&dlci->lock);
54885 mutex_init(&dlci->mutex);
54886 dlci->fifo = &dlci->_fifo;
54887- if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
54888+ if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
54889 kfree(dlci);
54890 return NULL;
54891 }
54892@@ -2958,7 +2958,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
54893 struct gsm_dlci *dlci = tty->driver_data;
54894 struct tty_port *port = &dlci->port;
54895
54896- port->count++;
54897+ atomic_inc(&port->count);
54898 tty_port_tty_set(port, tty);
54899
54900 dlci->modem_rx = 0;
54901diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
54902index 396344c..875c1d6 100644
54903--- a/drivers/tty/n_tty.c
54904+++ b/drivers/tty/n_tty.c
54905@@ -116,7 +116,7 @@ struct n_tty_data {
54906 int minimum_to_wake;
54907
54908 /* consumer-published */
54909- size_t read_tail;
54910+ size_t read_tail __intentional_overflow(-1);
54911 size_t line_start;
54912
54913 /* protected by output lock */
54914@@ -2572,6 +2572,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
54915 {
54916 *ops = tty_ldisc_N_TTY;
54917 ops->owner = NULL;
54918- ops->refcount = ops->flags = 0;
54919+ atomic_set(&ops->refcount, 0);
54920+ ops->flags = 0;
54921 }
54922 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
54923diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
54924index 4d5e840..a2340a6 100644
54925--- a/drivers/tty/pty.c
54926+++ b/drivers/tty/pty.c
54927@@ -849,8 +849,10 @@ static void __init unix98_pty_init(void)
54928 panic("Couldn't register Unix98 pts driver");
54929
54930 /* Now create the /dev/ptmx special device */
54931+ pax_open_kernel();
54932 tty_default_fops(&ptmx_fops);
54933- ptmx_fops.open = ptmx_open;
54934+ *(void **)&ptmx_fops.open = ptmx_open;
54935+ pax_close_kernel();
54936
54937 cdev_init(&ptmx_cdev, &ptmx_fops);
54938 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
54939diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
54940index c8dd8dc..dca6cfd 100644
54941--- a/drivers/tty/rocket.c
54942+++ b/drivers/tty/rocket.c
54943@@ -914,7 +914,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
54944 tty->driver_data = info;
54945 tty_port_tty_set(port, tty);
54946
54947- if (port->count++ == 0) {
54948+ if (atomic_inc_return(&port->count) == 1) {
54949 atomic_inc(&rp_num_ports_open);
54950
54951 #ifdef ROCKET_DEBUG_OPEN
54952@@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
54953 #endif
54954 }
54955 #ifdef ROCKET_DEBUG_OPEN
54956- printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
54957+ printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
54958 #endif
54959
54960 /*
54961@@ -1515,7 +1515,7 @@ static void rp_hangup(struct tty_struct *tty)
54962 spin_unlock_irqrestore(&info->port.lock, flags);
54963 return;
54964 }
54965- if (info->port.count)
54966+ if (atomic_read(&info->port.count))
54967 atomic_dec(&rp_num_ports_open);
54968 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
54969 spin_unlock_irqrestore(&info->port.lock, flags);
54970diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
54971index 4506e40..ac0b470 100644
54972--- a/drivers/tty/serial/8250/8250_core.c
54973+++ b/drivers/tty/serial/8250/8250_core.c
54974@@ -3241,9 +3241,9 @@ static void univ8250_release_port(struct uart_port *port)
54975
54976 static void univ8250_rsa_support(struct uart_ops *ops)
54977 {
54978- ops->config_port = univ8250_config_port;
54979- ops->request_port = univ8250_request_port;
54980- ops->release_port = univ8250_release_port;
54981+ *(void **)&ops->config_port = univ8250_config_port;
54982+ *(void **)&ops->request_port = univ8250_request_port;
54983+ *(void **)&ops->release_port = univ8250_release_port;
54984 }
54985
54986 #else
54987@@ -3286,8 +3286,10 @@ static void __init serial8250_isa_init_ports(void)
54988 }
54989
54990 /* chain base port ops to support Remote Supervisor Adapter */
54991- univ8250_port_ops = *base_ops;
54992+ pax_open_kernel();
54993+ memcpy((void *)&univ8250_port_ops, base_ops, sizeof univ8250_port_ops);
54994 univ8250_rsa_support(&univ8250_port_ops);
54995+ pax_close_kernel();
54996
54997 if (share_irqs)
54998 irqflag = IRQF_SHARED;
54999diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
55000index aa28209..e08fb85 100644
55001--- a/drivers/tty/serial/ioc4_serial.c
55002+++ b/drivers/tty/serial/ioc4_serial.c
55003@@ -437,7 +437,7 @@ struct ioc4_soft {
55004 } is_intr_info[MAX_IOC4_INTR_ENTS];
55005
55006 /* Number of entries active in the above array */
55007- atomic_t is_num_intrs;
55008+ atomic_unchecked_t is_num_intrs;
55009 } is_intr_type[IOC4_NUM_INTR_TYPES];
55010
55011 /* is_ir_lock must be held while
55012@@ -974,7 +974,7 @@ intr_connect(struct ioc4_soft *soft, int type,
55013 BUG_ON(!((type == IOC4_SIO_INTR_TYPE)
55014 || (type == IOC4_OTHER_INTR_TYPE)));
55015
55016- i = atomic_inc_return(&soft-> is_intr_type[type].is_num_intrs) - 1;
55017+ i = atomic_inc_return_unchecked(&soft-> is_intr_type[type].is_num_intrs) - 1;
55018 BUG_ON(!(i < MAX_IOC4_INTR_ENTS || (printk("i %d\n", i), 0)));
55019
55020 /* Save off the lower level interrupt handler */
55021@@ -1001,7 +1001,7 @@ static irqreturn_t ioc4_intr(int irq, void *arg)
55022
55023 soft = arg;
55024 for (intr_type = 0; intr_type < IOC4_NUM_INTR_TYPES; intr_type++) {
55025- num_intrs = (int)atomic_read(
55026+ num_intrs = (int)atomic_read_unchecked(
55027 &soft->is_intr_type[intr_type].is_num_intrs);
55028
55029 this_mir = this_ir = pending_intrs(soft, intr_type);
55030diff --git a/drivers/tty/serial/kgdb_nmi.c b/drivers/tty/serial/kgdb_nmi.c
55031index 129dc5b..1da5bb8 100644
55032--- a/drivers/tty/serial/kgdb_nmi.c
55033+++ b/drivers/tty/serial/kgdb_nmi.c
55034@@ -53,7 +53,9 @@ static int kgdb_nmi_console_setup(struct console *co, char *options)
55035 * I/O utilities that messages sent to the console will automatically
55036 * be displayed on the dbg_io.
55037 */
55038- dbg_io_ops->is_console = true;
55039+ pax_open_kernel();
55040+ *(int *)&dbg_io_ops->is_console = true;
55041+ pax_close_kernel();
55042
55043 return 0;
55044 }
55045diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
55046index a260cde..6b2b5ce 100644
55047--- a/drivers/tty/serial/kgdboc.c
55048+++ b/drivers/tty/serial/kgdboc.c
55049@@ -24,8 +24,9 @@
55050 #define MAX_CONFIG_LEN 40
55051
55052 static struct kgdb_io kgdboc_io_ops;
55053+static struct kgdb_io kgdboc_io_ops_console;
55054
55055-/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
55056+/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
55057 static int configured = -1;
55058
55059 static char config[MAX_CONFIG_LEN];
55060@@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
55061 kgdboc_unregister_kbd();
55062 if (configured == 1)
55063 kgdb_unregister_io_module(&kgdboc_io_ops);
55064+ else if (configured == 2)
55065+ kgdb_unregister_io_module(&kgdboc_io_ops_console);
55066 }
55067
55068 static int configure_kgdboc(void)
55069@@ -160,13 +163,13 @@ static int configure_kgdboc(void)
55070 int err;
55071 char *cptr = config;
55072 struct console *cons;
55073+ int is_console = 0;
55074
55075 err = kgdboc_option_setup(config);
55076 if (err || !strlen(config) || isspace(config[0]))
55077 goto noconfig;
55078
55079 err = -ENODEV;
55080- kgdboc_io_ops.is_console = 0;
55081 kgdb_tty_driver = NULL;
55082
55083 kgdboc_use_kms = 0;
55084@@ -187,7 +190,7 @@ static int configure_kgdboc(void)
55085 int idx;
55086 if (cons->device && cons->device(cons, &idx) == p &&
55087 idx == tty_line) {
55088- kgdboc_io_ops.is_console = 1;
55089+ is_console = 1;
55090 break;
55091 }
55092 cons = cons->next;
55093@@ -197,7 +200,13 @@ static int configure_kgdboc(void)
55094 kgdb_tty_line = tty_line;
55095
55096 do_register:
55097- err = kgdb_register_io_module(&kgdboc_io_ops);
55098+ if (is_console) {
55099+ err = kgdb_register_io_module(&kgdboc_io_ops_console);
55100+ configured = 2;
55101+ } else {
55102+ err = kgdb_register_io_module(&kgdboc_io_ops);
55103+ configured = 1;
55104+ }
55105 if (err)
55106 goto noconfig;
55107
55108@@ -205,8 +214,6 @@ do_register:
55109 if (err)
55110 goto nmi_con_failed;
55111
55112- configured = 1;
55113-
55114 return 0;
55115
55116 nmi_con_failed:
55117@@ -223,7 +230,7 @@ noconfig:
55118 static int __init init_kgdboc(void)
55119 {
55120 /* Already configured? */
55121- if (configured == 1)
55122+ if (configured >= 1)
55123 return 0;
55124
55125 return configure_kgdboc();
55126@@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
55127 if (config[len - 1] == '\n')
55128 config[len - 1] = '\0';
55129
55130- if (configured == 1)
55131+ if (configured >= 1)
55132 cleanup_kgdboc();
55133
55134 /* Go and configure with the new params. */
55135@@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
55136 .post_exception = kgdboc_post_exp_handler,
55137 };
55138
55139+static struct kgdb_io kgdboc_io_ops_console = {
55140+ .name = "kgdboc",
55141+ .read_char = kgdboc_get_char,
55142+ .write_char = kgdboc_put_char,
55143+ .pre_exception = kgdboc_pre_exp_handler,
55144+ .post_exception = kgdboc_post_exp_handler,
55145+ .is_console = 1
55146+};
55147+
55148 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
55149 /* This is only available if kgdboc is a built in for early debugging */
55150 static int __init kgdboc_early_init(char *opt)
55151diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
55152index b73889c..9f74f0a 100644
55153--- a/drivers/tty/serial/msm_serial.c
55154+++ b/drivers/tty/serial/msm_serial.c
55155@@ -1012,7 +1012,7 @@ static struct uart_driver msm_uart_driver = {
55156 .cons = MSM_CONSOLE,
55157 };
55158
55159-static atomic_t msm_uart_next_id = ATOMIC_INIT(0);
55160+static atomic_unchecked_t msm_uart_next_id = ATOMIC_INIT(0);
55161
55162 static const struct of_device_id msm_uartdm_table[] = {
55163 { .compatible = "qcom,msm-uartdm-v1.1", .data = (void *)UARTDM_1P1 },
55164@@ -1036,7 +1036,7 @@ static int msm_serial_probe(struct platform_device *pdev)
55165 line = pdev->id;
55166
55167 if (line < 0)
55168- line = atomic_inc_return(&msm_uart_next_id) - 1;
55169+ line = atomic_inc_return_unchecked(&msm_uart_next_id) - 1;
55170
55171 if (unlikely(line < 0 || line >= UART_NR))
55172 return -ENXIO;
55173diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
55174index a0ae942..befa48d 100644
55175--- a/drivers/tty/serial/samsung.c
55176+++ b/drivers/tty/serial/samsung.c
55177@@ -987,11 +987,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
55178 ourport->tx_in_progress = 0;
55179 }
55180
55181+static int s3c64xx_serial_startup(struct uart_port *port);
55182 static int s3c24xx_serial_startup(struct uart_port *port)
55183 {
55184 struct s3c24xx_uart_port *ourport = to_ourport(port);
55185 int ret;
55186
55187+ /* Startup sequence is different for s3c64xx and higher SoC's */
55188+ if (s3c24xx_serial_has_interrupt_mask(port))
55189+ return s3c64xx_serial_startup(port);
55190+
55191 dbg("s3c24xx_serial_startup: port=%p (%08llx,%p)\n",
55192 port, (unsigned long long)port->mapbase, port->membase);
55193
55194@@ -1698,10 +1703,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
55195 /* setup info for port */
55196 port->dev = &platdev->dev;
55197
55198- /* Startup sequence is different for s3c64xx and higher SoC's */
55199- if (s3c24xx_serial_has_interrupt_mask(port))
55200- s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
55201-
55202 port->uartclk = 1;
55203
55204 if (cfg->uart_flags & UPF_CONS_FLOW) {
55205diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
55206index 0b7bb12..ebe191a 100644
55207--- a/drivers/tty/serial/serial_core.c
55208+++ b/drivers/tty/serial/serial_core.c
55209@@ -1376,7 +1376,7 @@ static void uart_close(struct tty_struct *tty, struct file *filp)
55210 state = drv->state + tty->index;
55211 port = &state->port;
55212 spin_lock_irq(&port->lock);
55213- --port->count;
55214+ atomic_dec(&port->count);
55215 spin_unlock_irq(&port->lock);
55216 return;
55217 }
55218@@ -1386,7 +1386,7 @@ static void uart_close(struct tty_struct *tty, struct file *filp)
55219
55220 pr_debug("uart_close(%d) called\n", uport ? uport->line : -1);
55221
55222- if (!port->count || tty_port_close_start(port, tty, filp) == 0)
55223+ if (!atomic_read(&port->count) || tty_port_close_start(port, tty, filp) == 0)
55224 return;
55225
55226 /*
55227@@ -1510,7 +1510,7 @@ static void uart_hangup(struct tty_struct *tty)
55228 uart_flush_buffer(tty);
55229 uart_shutdown(tty, state);
55230 spin_lock_irqsave(&port->lock, flags);
55231- port->count = 0;
55232+ atomic_set(&port->count, 0);
55233 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
55234 spin_unlock_irqrestore(&port->lock, flags);
55235 tty_port_tty_set(port, NULL);
55236@@ -1597,7 +1597,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
55237 pr_debug("uart_open(%d) called\n", line);
55238
55239 spin_lock_irq(&port->lock);
55240- ++port->count;
55241+ atomic_inc(&port->count);
55242 spin_unlock_irq(&port->lock);
55243
55244 /*
55245diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c
55246index b1c6bd3..5f038e2 100644
55247--- a/drivers/tty/serial/uartlite.c
55248+++ b/drivers/tty/serial/uartlite.c
55249@@ -341,13 +341,13 @@ static int ulite_request_port(struct uart_port *port)
55250 return -EBUSY;
55251 }
55252
55253- port->private_data = &uartlite_be;
55254+ port->private_data = (void *)&uartlite_be;
55255 ret = uart_in32(ULITE_CONTROL, port);
55256 uart_out32(ULITE_CONTROL_RST_TX, ULITE_CONTROL, port);
55257 ret = uart_in32(ULITE_STATUS, port);
55258 /* Endianess detection */
55259 if ((ret & ULITE_STATUS_TXEMPTY) != ULITE_STATUS_TXEMPTY)
55260- port->private_data = &uartlite_le;
55261+ port->private_data = (void *)&uartlite_le;
55262
55263 return 0;
55264 }
55265diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
55266index b799170..87dafd5 100644
55267--- a/drivers/tty/synclink.c
55268+++ b/drivers/tty/synclink.c
55269@@ -3090,7 +3090,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
55270
55271 if (debug_level >= DEBUG_LEVEL_INFO)
55272 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
55273- __FILE__,__LINE__, info->device_name, info->port.count);
55274+ __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
55275
55276 if (tty_port_close_start(&info->port, tty, filp) == 0)
55277 goto cleanup;
55278@@ -3108,7 +3108,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
55279 cleanup:
55280 if (debug_level >= DEBUG_LEVEL_INFO)
55281 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
55282- tty->driver->name, info->port.count);
55283+ tty->driver->name, atomic_read(&info->port.count));
55284
55285 } /* end of mgsl_close() */
55286
55287@@ -3207,8 +3207,8 @@ static void mgsl_hangup(struct tty_struct *tty)
55288
55289 mgsl_flush_buffer(tty);
55290 shutdown(info);
55291-
55292- info->port.count = 0;
55293+
55294+ atomic_set(&info->port.count, 0);
55295 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
55296 info->port.tty = NULL;
55297
55298@@ -3296,10 +3296,10 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
55299
55300 if (debug_level >= DEBUG_LEVEL_INFO)
55301 printk("%s(%d):block_til_ready before block on %s count=%d\n",
55302- __FILE__,__LINE__, tty->driver->name, port->count );
55303+ __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
55304
55305 spin_lock_irqsave(&info->irq_spinlock, flags);
55306- port->count--;
55307+ atomic_dec(&port->count);
55308 spin_unlock_irqrestore(&info->irq_spinlock, flags);
55309 port->blocked_open++;
55310
55311@@ -3327,7 +3327,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
55312
55313 if (debug_level >= DEBUG_LEVEL_INFO)
55314 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
55315- __FILE__,__LINE__, tty->driver->name, port->count );
55316+ __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
55317
55318 tty_unlock(tty);
55319 schedule();
55320@@ -3339,12 +3339,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
55321
55322 /* FIXME: Racy on hangup during close wait */
55323 if (!tty_hung_up_p(filp))
55324- port->count++;
55325+ atomic_inc(&port->count);
55326 port->blocked_open--;
55327
55328 if (debug_level >= DEBUG_LEVEL_INFO)
55329 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
55330- __FILE__,__LINE__, tty->driver->name, port->count );
55331+ __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
55332
55333 if (!retval)
55334 port->flags |= ASYNC_NORMAL_ACTIVE;
55335@@ -3396,7 +3396,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
55336
55337 if (debug_level >= DEBUG_LEVEL_INFO)
55338 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
55339- __FILE__,__LINE__,tty->driver->name, info->port.count);
55340+ __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
55341
55342 /* If port is closing, signal caller to try again */
55343 if (info->port.flags & ASYNC_CLOSING){
55344@@ -3415,10 +3415,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
55345 spin_unlock_irqrestore(&info->netlock, flags);
55346 goto cleanup;
55347 }
55348- info->port.count++;
55349+ atomic_inc(&info->port.count);
55350 spin_unlock_irqrestore(&info->netlock, flags);
55351
55352- if (info->port.count == 1) {
55353+ if (atomic_read(&info->port.count) == 1) {
55354 /* 1st open on this device, init hardware */
55355 retval = startup(info);
55356 if (retval < 0)
55357@@ -3442,8 +3442,8 @@ cleanup:
55358 if (retval) {
55359 if (tty->count == 1)
55360 info->port.tty = NULL; /* tty layer will release tty struct */
55361- if(info->port.count)
55362- info->port.count--;
55363+ if (atomic_read(&info->port.count))
55364+ atomic_dec(&info->port.count);
55365 }
55366
55367 return retval;
55368@@ -7661,7 +7661,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
55369 unsigned short new_crctype;
55370
55371 /* return error if TTY interface open */
55372- if (info->port.count)
55373+ if (atomic_read(&info->port.count))
55374 return -EBUSY;
55375
55376 switch (encoding)
55377@@ -7756,7 +7756,7 @@ static int hdlcdev_open(struct net_device *dev)
55378
55379 /* arbitrate between network and tty opens */
55380 spin_lock_irqsave(&info->netlock, flags);
55381- if (info->port.count != 0 || info->netcount != 0) {
55382+ if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
55383 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
55384 spin_unlock_irqrestore(&info->netlock, flags);
55385 return -EBUSY;
55386@@ -7842,7 +7842,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
55387 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
55388
55389 /* return error if TTY interface open */
55390- if (info->port.count)
55391+ if (atomic_read(&info->port.count))
55392 return -EBUSY;
55393
55394 if (cmd != SIOCWANDEV)
55395diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
55396index 0e8c39b..e0cb171 100644
55397--- a/drivers/tty/synclink_gt.c
55398+++ b/drivers/tty/synclink_gt.c
55399@@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
55400 tty->driver_data = info;
55401 info->port.tty = tty;
55402
55403- DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
55404+ DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
55405
55406 /* If port is closing, signal caller to try again */
55407 if (info->port.flags & ASYNC_CLOSING){
55408@@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
55409 mutex_unlock(&info->port.mutex);
55410 goto cleanup;
55411 }
55412- info->port.count++;
55413+ atomic_inc(&info->port.count);
55414 spin_unlock_irqrestore(&info->netlock, flags);
55415
55416- if (info->port.count == 1) {
55417+ if (atomic_read(&info->port.count) == 1) {
55418 /* 1st open on this device, init hardware */
55419 retval = startup(info);
55420 if (retval < 0) {
55421@@ -715,8 +715,8 @@ cleanup:
55422 if (retval) {
55423 if (tty->count == 1)
55424 info->port.tty = NULL; /* tty layer will release tty struct */
55425- if(info->port.count)
55426- info->port.count--;
55427+ if(atomic_read(&info->port.count))
55428+ atomic_dec(&info->port.count);
55429 }
55430
55431 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
55432@@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
55433
55434 if (sanity_check(info, tty->name, "close"))
55435 return;
55436- DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
55437+ DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
55438
55439 if (tty_port_close_start(&info->port, tty, filp) == 0)
55440 goto cleanup;
55441@@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
55442 tty_port_close_end(&info->port, tty);
55443 info->port.tty = NULL;
55444 cleanup:
55445- DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
55446+ DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
55447 }
55448
55449 static void hangup(struct tty_struct *tty)
55450@@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
55451 shutdown(info);
55452
55453 spin_lock_irqsave(&info->port.lock, flags);
55454- info->port.count = 0;
55455+ atomic_set(&info->port.count, 0);
55456 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
55457 info->port.tty = NULL;
55458 spin_unlock_irqrestore(&info->port.lock, flags);
55459@@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
55460 unsigned short new_crctype;
55461
55462 /* return error if TTY interface open */
55463- if (info->port.count)
55464+ if (atomic_read(&info->port.count))
55465 return -EBUSY;
55466
55467 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
55468@@ -1544,7 +1544,7 @@ static int hdlcdev_open(struct net_device *dev)
55469
55470 /* arbitrate between network and tty opens */
55471 spin_lock_irqsave(&info->netlock, flags);
55472- if (info->port.count != 0 || info->netcount != 0) {
55473+ if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
55474 DBGINFO(("%s hdlc_open busy\n", dev->name));
55475 spin_unlock_irqrestore(&info->netlock, flags);
55476 return -EBUSY;
55477@@ -1629,7 +1629,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
55478 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
55479
55480 /* return error if TTY interface open */
55481- if (info->port.count)
55482+ if (atomic_read(&info->port.count))
55483 return -EBUSY;
55484
55485 if (cmd != SIOCWANDEV)
55486@@ -2413,7 +2413,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
55487 if (port == NULL)
55488 continue;
55489 spin_lock(&port->lock);
55490- if ((port->port.count || port->netcount) &&
55491+ if ((atomic_read(&port->port.count) || port->netcount) &&
55492 port->pending_bh && !port->bh_running &&
55493 !port->bh_requested) {
55494 DBGISR(("%s bh queued\n", port->device_name));
55495@@ -3299,7 +3299,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
55496 add_wait_queue(&port->open_wait, &wait);
55497
55498 spin_lock_irqsave(&info->lock, flags);
55499- port->count--;
55500+ atomic_dec(&port->count);
55501 spin_unlock_irqrestore(&info->lock, flags);
55502 port->blocked_open++;
55503
55504@@ -3335,7 +3335,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
55505 remove_wait_queue(&port->open_wait, &wait);
55506
55507 if (!tty_hung_up_p(filp))
55508- port->count++;
55509+ atomic_inc(&port->count);
55510 port->blocked_open--;
55511
55512 if (!retval)
55513diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
55514index c3f9091..abe4601 100644
55515--- a/drivers/tty/synclinkmp.c
55516+++ b/drivers/tty/synclinkmp.c
55517@@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
55518
55519 if (debug_level >= DEBUG_LEVEL_INFO)
55520 printk("%s(%d):%s open(), old ref count = %d\n",
55521- __FILE__,__LINE__,tty->driver->name, info->port.count);
55522+ __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
55523
55524 /* If port is closing, signal caller to try again */
55525 if (info->port.flags & ASYNC_CLOSING){
55526@@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
55527 spin_unlock_irqrestore(&info->netlock, flags);
55528 goto cleanup;
55529 }
55530- info->port.count++;
55531+ atomic_inc(&info->port.count);
55532 spin_unlock_irqrestore(&info->netlock, flags);
55533
55534- if (info->port.count == 1) {
55535+ if (atomic_read(&info->port.count) == 1) {
55536 /* 1st open on this device, init hardware */
55537 retval = startup(info);
55538 if (retval < 0)
55539@@ -796,8 +796,8 @@ cleanup:
55540 if (retval) {
55541 if (tty->count == 1)
55542 info->port.tty = NULL; /* tty layer will release tty struct */
55543- if(info->port.count)
55544- info->port.count--;
55545+ if(atomic_read(&info->port.count))
55546+ atomic_dec(&info->port.count);
55547 }
55548
55549 return retval;
55550@@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
55551
55552 if (debug_level >= DEBUG_LEVEL_INFO)
55553 printk("%s(%d):%s close() entry, count=%d\n",
55554- __FILE__,__LINE__, info->device_name, info->port.count);
55555+ __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
55556
55557 if (tty_port_close_start(&info->port, tty, filp) == 0)
55558 goto cleanup;
55559@@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
55560 cleanup:
55561 if (debug_level >= DEBUG_LEVEL_INFO)
55562 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
55563- tty->driver->name, info->port.count);
55564+ tty->driver->name, atomic_read(&info->port.count));
55565 }
55566
55567 /* Called by tty_hangup() when a hangup is signaled.
55568@@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
55569 shutdown(info);
55570
55571 spin_lock_irqsave(&info->port.lock, flags);
55572- info->port.count = 0;
55573+ atomic_set(&info->port.count, 0);
55574 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
55575 info->port.tty = NULL;
55576 spin_unlock_irqrestore(&info->port.lock, flags);
55577@@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
55578 unsigned short new_crctype;
55579
55580 /* return error if TTY interface open */
55581- if (info->port.count)
55582+ if (atomic_read(&info->port.count))
55583 return -EBUSY;
55584
55585 switch (encoding)
55586@@ -1660,7 +1660,7 @@ static int hdlcdev_open(struct net_device *dev)
55587
55588 /* arbitrate between network and tty opens */
55589 spin_lock_irqsave(&info->netlock, flags);
55590- if (info->port.count != 0 || info->netcount != 0) {
55591+ if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
55592 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
55593 spin_unlock_irqrestore(&info->netlock, flags);
55594 return -EBUSY;
55595@@ -1746,7 +1746,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
55596 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
55597
55598 /* return error if TTY interface open */
55599- if (info->port.count)
55600+ if (atomic_read(&info->port.count))
55601 return -EBUSY;
55602
55603 if (cmd != SIOCWANDEV)
55604@@ -2621,7 +2621,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
55605 * do not request bottom half processing if the
55606 * device is not open in a normal mode.
55607 */
55608- if ( port && (port->port.count || port->netcount) &&
55609+ if ( port && (atomic_read(&port->port.count) || port->netcount) &&
55610 port->pending_bh && !port->bh_running &&
55611 !port->bh_requested ) {
55612 if ( debug_level >= DEBUG_LEVEL_ISR )
55613@@ -3318,10 +3318,10 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
55614
55615 if (debug_level >= DEBUG_LEVEL_INFO)
55616 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
55617- __FILE__,__LINE__, tty->driver->name, port->count );
55618+ __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
55619
55620 spin_lock_irqsave(&info->lock, flags);
55621- port->count--;
55622+ atomic_dec(&port->count);
55623 spin_unlock_irqrestore(&info->lock, flags);
55624 port->blocked_open++;
55625
55626@@ -3349,7 +3349,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
55627
55628 if (debug_level >= DEBUG_LEVEL_INFO)
55629 printk("%s(%d):%s block_til_ready() count=%d\n",
55630- __FILE__,__LINE__, tty->driver->name, port->count );
55631+ __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
55632
55633 tty_unlock(tty);
55634 schedule();
55635@@ -3359,12 +3359,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
55636 set_current_state(TASK_RUNNING);
55637 remove_wait_queue(&port->open_wait, &wait);
55638 if (!tty_hung_up_p(filp))
55639- port->count++;
55640+ atomic_inc(&port->count);
55641 port->blocked_open--;
55642
55643 if (debug_level >= DEBUG_LEVEL_INFO)
55644 printk("%s(%d):%s block_til_ready() after, count=%d\n",
55645- __FILE__,__LINE__, tty->driver->name, port->count );
55646+ __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
55647
55648 if (!retval)
55649 port->flags |= ASYNC_NORMAL_ACTIVE;
55650diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
55651index 843f2cd..7d530a6 100644
55652--- a/drivers/tty/sysrq.c
55653+++ b/drivers/tty/sysrq.c
55654@@ -1086,7 +1086,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
55655 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
55656 size_t count, loff_t *ppos)
55657 {
55658- if (count) {
55659+ if (count && capable(CAP_SYS_ADMIN)) {
55660 char c;
55661
55662 if (get_user(c, buf))
55663diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
55664index e569546..fbce20c 100644
55665--- a/drivers/tty/tty_io.c
55666+++ b/drivers/tty/tty_io.c
55667@@ -3509,7 +3509,7 @@ EXPORT_SYMBOL(tty_devnum);
55668
55669 void tty_default_fops(struct file_operations *fops)
55670 {
55671- *fops = tty_fops;
55672+ memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
55673 }
55674
55675 /*
55676diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
55677index 3737f55..7cef448 100644
55678--- a/drivers/tty/tty_ldisc.c
55679+++ b/drivers/tty/tty_ldisc.c
55680@@ -71,7 +71,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
55681 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
55682 tty_ldiscs[disc] = new_ldisc;
55683 new_ldisc->num = disc;
55684- new_ldisc->refcount = 0;
55685+ atomic_set(&new_ldisc->refcount, 0);
55686 raw_spin_unlock_irqrestore(&tty_ldiscs_lock, flags);
55687
55688 return ret;
55689@@ -99,7 +99,7 @@ int tty_unregister_ldisc(int disc)
55690 return -EINVAL;
55691
55692 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
55693- if (tty_ldiscs[disc]->refcount)
55694+ if (atomic_read(&tty_ldiscs[disc]->refcount))
55695 ret = -EBUSY;
55696 else
55697 tty_ldiscs[disc] = NULL;
55698@@ -120,7 +120,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
55699 if (ldops) {
55700 ret = ERR_PTR(-EAGAIN);
55701 if (try_module_get(ldops->owner)) {
55702- ldops->refcount++;
55703+ atomic_inc(&ldops->refcount);
55704 ret = ldops;
55705 }
55706 }
55707@@ -133,7 +133,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
55708 unsigned long flags;
55709
55710 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
55711- ldops->refcount--;
55712+ atomic_dec(&ldops->refcount);
55713 module_put(ldops->owner);
55714 raw_spin_unlock_irqrestore(&tty_ldiscs_lock, flags);
55715 }
55716diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
55717index 40b31835..94d92ae 100644
55718--- a/drivers/tty/tty_port.c
55719+++ b/drivers/tty/tty_port.c
55720@@ -236,7 +236,7 @@ void tty_port_hangup(struct tty_port *port)
55721 unsigned long flags;
55722
55723 spin_lock_irqsave(&port->lock, flags);
55724- port->count = 0;
55725+ atomic_set(&port->count, 0);
55726 port->flags &= ~ASYNC_NORMAL_ACTIVE;
55727 tty = port->tty;
55728 if (tty)
55729@@ -398,7 +398,7 @@ int tty_port_block_til_ready(struct tty_port *port,
55730
55731 /* The port lock protects the port counts */
55732 spin_lock_irqsave(&port->lock, flags);
55733- port->count--;
55734+ atomic_dec(&port->count);
55735 port->blocked_open++;
55736 spin_unlock_irqrestore(&port->lock, flags);
55737
55738@@ -440,7 +440,7 @@ int tty_port_block_til_ready(struct tty_port *port,
55739 we must not mess that up further */
55740 spin_lock_irqsave(&port->lock, flags);
55741 if (!tty_hung_up_p(filp))
55742- port->count++;
55743+ atomic_inc(&port->count);
55744 port->blocked_open--;
55745 if (retval == 0)
55746 port->flags |= ASYNC_NORMAL_ACTIVE;
55747@@ -476,19 +476,19 @@ int tty_port_close_start(struct tty_port *port,
55748 return 0;
55749
55750 spin_lock_irqsave(&port->lock, flags);
55751- if (tty->count == 1 && port->count != 1) {
55752+ if (tty->count == 1 && atomic_read(&port->count) != 1) {
55753 printk(KERN_WARNING
55754 "tty_port_close_start: tty->count = 1 port count = %d.\n",
55755- port->count);
55756- port->count = 1;
55757+ atomic_read(&port->count));
55758+ atomic_set(&port->count, 1);
55759 }
55760- if (--port->count < 0) {
55761+ if (atomic_dec_return(&port->count) < 0) {
55762 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
55763- port->count);
55764- port->count = 0;
55765+ atomic_read(&port->count));
55766+ atomic_set(&port->count, 0);
55767 }
55768
55769- if (port->count) {
55770+ if (atomic_read(&port->count)) {
55771 spin_unlock_irqrestore(&port->lock, flags);
55772 return 0;
55773 }
55774@@ -590,7 +590,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
55775 struct file *filp)
55776 {
55777 spin_lock_irq(&port->lock);
55778- ++port->count;
55779+ atomic_inc(&port->count);
55780 spin_unlock_irq(&port->lock);
55781 tty_port_tty_set(port, tty);
55782
55783diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
55784index 8a89f6e..50b32af 100644
55785--- a/drivers/tty/vt/keyboard.c
55786+++ b/drivers/tty/vt/keyboard.c
55787@@ -641,6 +641,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
55788 kbd->kbdmode == VC_OFF) &&
55789 value != KVAL(K_SAK))
55790 return; /* SAK is allowed even in raw mode */
55791+
55792+#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55793+ {
55794+ void *func = fn_handler[value];
55795+ if (func == fn_show_state || func == fn_show_ptregs ||
55796+ func == fn_show_mem)
55797+ return;
55798+ }
55799+#endif
55800+
55801 fn_handler[value](vc);
55802 }
55803
55804@@ -1776,9 +1786,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
55805 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
55806 return -EFAULT;
55807
55808- if (!capable(CAP_SYS_TTY_CONFIG))
55809- perm = 0;
55810-
55811 switch (cmd) {
55812 case KDGKBENT:
55813 /* Ensure another thread doesn't free it under us */
55814@@ -1793,6 +1800,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
55815 spin_unlock_irqrestore(&kbd_event_lock, flags);
55816 return put_user(val, &user_kbe->kb_value);
55817 case KDSKBENT:
55818+ if (!capable(CAP_SYS_TTY_CONFIG))
55819+ perm = 0;
55820+
55821 if (!perm)
55822 return -EPERM;
55823 if (!i && v == K_NOSUCHMAP) {
55824@@ -1883,9 +1893,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
55825 int i, j, k;
55826 int ret;
55827
55828- if (!capable(CAP_SYS_TTY_CONFIG))
55829- perm = 0;
55830-
55831 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
55832 if (!kbs) {
55833 ret = -ENOMEM;
55834@@ -1919,6 +1926,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
55835 kfree(kbs);
55836 return ((p && *p) ? -EOVERFLOW : 0);
55837 case KDSKBSENT:
55838+ if (!capable(CAP_SYS_TTY_CONFIG))
55839+ perm = 0;
55840+
55841 if (!perm) {
55842 ret = -EPERM;
55843 goto reterr;
55844diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
55845index 65bf067..b3b2e13 100644
55846--- a/drivers/uio/uio.c
55847+++ b/drivers/uio/uio.c
55848@@ -25,6 +25,7 @@
55849 #include <linux/kobject.h>
55850 #include <linux/cdev.h>
55851 #include <linux/uio_driver.h>
55852+#include <asm/local.h>
55853
55854 #define UIO_MAX_DEVICES (1U << MINORBITS)
55855
55856@@ -231,7 +232,7 @@ static ssize_t event_show(struct device *dev,
55857 struct device_attribute *attr, char *buf)
55858 {
55859 struct uio_device *idev = dev_get_drvdata(dev);
55860- return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
55861+ return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
55862 }
55863 static DEVICE_ATTR_RO(event);
55864
55865@@ -393,7 +394,7 @@ void uio_event_notify(struct uio_info *info)
55866 {
55867 struct uio_device *idev = info->uio_dev;
55868
55869- atomic_inc(&idev->event);
55870+ atomic_inc_unchecked(&idev->event);
55871 wake_up_interruptible(&idev->wait);
55872 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
55873 }
55874@@ -446,7 +447,7 @@ static int uio_open(struct inode *inode, struct file *filep)
55875 }
55876
55877 listener->dev = idev;
55878- listener->event_count = atomic_read(&idev->event);
55879+ listener->event_count = atomic_read_unchecked(&idev->event);
55880 filep->private_data = listener;
55881
55882 if (idev->info->open) {
55883@@ -497,7 +498,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
55884 return -EIO;
55885
55886 poll_wait(filep, &idev->wait, wait);
55887- if (listener->event_count != atomic_read(&idev->event))
55888+ if (listener->event_count != atomic_read_unchecked(&idev->event))
55889 return POLLIN | POLLRDNORM;
55890 return 0;
55891 }
55892@@ -522,7 +523,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
55893 do {
55894 set_current_state(TASK_INTERRUPTIBLE);
55895
55896- event_count = atomic_read(&idev->event);
55897+ event_count = atomic_read_unchecked(&idev->event);
55898 if (event_count != listener->event_count) {
55899 if (copy_to_user(buf, &event_count, count))
55900 retval = -EFAULT;
55901@@ -579,9 +580,13 @@ static ssize_t uio_write(struct file *filep, const char __user *buf,
55902 static int uio_find_mem_index(struct vm_area_struct *vma)
55903 {
55904 struct uio_device *idev = vma->vm_private_data;
55905+ unsigned long size;
55906
55907 if (vma->vm_pgoff < MAX_UIO_MAPS) {
55908- if (idev->info->mem[vma->vm_pgoff].size == 0)
55909+ size = idev->info->mem[vma->vm_pgoff].size;
55910+ if (size == 0)
55911+ return -1;
55912+ if (vma->vm_end - vma->vm_start > size)
55913 return -1;
55914 return (int)vma->vm_pgoff;
55915 }
55916@@ -813,7 +818,7 @@ int __uio_register_device(struct module *owner,
55917 idev->owner = owner;
55918 idev->info = info;
55919 init_waitqueue_head(&idev->wait);
55920- atomic_set(&idev->event, 0);
55921+ atomic_set_unchecked(&idev->event, 0);
55922
55923 ret = uio_get_minor(idev);
55924 if (ret)
55925diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
55926index 813d4d3..a71934f 100644
55927--- a/drivers/usb/atm/cxacru.c
55928+++ b/drivers/usb/atm/cxacru.c
55929@@ -472,7 +472,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
55930 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
55931 if (ret < 2)
55932 return -EINVAL;
55933- if (index < 0 || index > 0x7f)
55934+ if (index > 0x7f)
55935 return -EINVAL;
55936 pos += tmp;
55937
55938diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
55939index dada014..1d0d517 100644
55940--- a/drivers/usb/atm/usbatm.c
55941+++ b/drivers/usb/atm/usbatm.c
55942@@ -331,7 +331,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
55943 if (printk_ratelimit())
55944 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
55945 __func__, vpi, vci);
55946- atomic_inc(&vcc->stats->rx_err);
55947+ atomic_inc_unchecked(&vcc->stats->rx_err);
55948 return;
55949 }
55950
55951@@ -358,7 +358,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
55952 if (length > ATM_MAX_AAL5_PDU) {
55953 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
55954 __func__, length, vcc);
55955- atomic_inc(&vcc->stats->rx_err);
55956+ atomic_inc_unchecked(&vcc->stats->rx_err);
55957 goto out;
55958 }
55959
55960@@ -367,14 +367,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
55961 if (sarb->len < pdu_length) {
55962 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
55963 __func__, pdu_length, sarb->len, vcc);
55964- atomic_inc(&vcc->stats->rx_err);
55965+ atomic_inc_unchecked(&vcc->stats->rx_err);
55966 goto out;
55967 }
55968
55969 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
55970 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
55971 __func__, vcc);
55972- atomic_inc(&vcc->stats->rx_err);
55973+ atomic_inc_unchecked(&vcc->stats->rx_err);
55974 goto out;
55975 }
55976
55977@@ -386,7 +386,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
55978 if (printk_ratelimit())
55979 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
55980 __func__, length);
55981- atomic_inc(&vcc->stats->rx_drop);
55982+ atomic_inc_unchecked(&vcc->stats->rx_drop);
55983 goto out;
55984 }
55985
55986@@ -414,7 +414,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
55987
55988 vcc->push(vcc, skb);
55989
55990- atomic_inc(&vcc->stats->rx);
55991+ atomic_inc_unchecked(&vcc->stats->rx);
55992 out:
55993 skb_trim(sarb, 0);
55994 }
55995@@ -612,7 +612,7 @@ static void usbatm_tx_process(unsigned long data)
55996 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
55997
55998 usbatm_pop(vcc, skb);
55999- atomic_inc(&vcc->stats->tx);
56000+ atomic_inc_unchecked(&vcc->stats->tx);
56001
56002 skb = skb_dequeue(&instance->sndqueue);
56003 }
56004@@ -756,11 +756,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t *pos, char *page
56005 if (!left--)
56006 return sprintf(page,
56007 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
56008- atomic_read(&atm_dev->stats.aal5.tx),
56009- atomic_read(&atm_dev->stats.aal5.tx_err),
56010- atomic_read(&atm_dev->stats.aal5.rx),
56011- atomic_read(&atm_dev->stats.aal5.rx_err),
56012- atomic_read(&atm_dev->stats.aal5.rx_drop));
56013+ atomic_read_unchecked(&atm_dev->stats.aal5.tx),
56014+ atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
56015+ atomic_read_unchecked(&atm_dev->stats.aal5.rx),
56016+ atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
56017+ atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
56018
56019 if (!left--) {
56020 if (instance->disconnected)
56021diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
56022index 2a3bbdf..91d72cf 100644
56023--- a/drivers/usb/core/devices.c
56024+++ b/drivers/usb/core/devices.c
56025@@ -126,7 +126,7 @@ static const char format_endpt[] =
56026 * time it gets called.
56027 */
56028 static struct device_connect_event {
56029- atomic_t count;
56030+ atomic_unchecked_t count;
56031 wait_queue_head_t wait;
56032 } device_event = {
56033 .count = ATOMIC_INIT(1),
56034@@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
56035
56036 void usbfs_conn_disc_event(void)
56037 {
56038- atomic_add(2, &device_event.count);
56039+ atomic_add_unchecked(2, &device_event.count);
56040 wake_up(&device_event.wait);
56041 }
56042
56043@@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
56044
56045 poll_wait(file, &device_event.wait, wait);
56046
56047- event_count = atomic_read(&device_event.count);
56048+ event_count = atomic_read_unchecked(&device_event.count);
56049 if (file->f_version != event_count) {
56050 file->f_version = event_count;
56051 return POLLIN | POLLRDNORM;
56052diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
56053index 4b0448c..fc84bec 100644
56054--- a/drivers/usb/core/devio.c
56055+++ b/drivers/usb/core/devio.c
56056@@ -187,7 +187,7 @@ static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes,
56057 struct usb_dev_state *ps = file->private_data;
56058 struct usb_device *dev = ps->dev;
56059 ssize_t ret = 0;
56060- unsigned len;
56061+ size_t len;
56062 loff_t pos;
56063 int i;
56064
56065@@ -229,22 +229,22 @@ static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes,
56066 for (i = 0; nbytes && i < dev->descriptor.bNumConfigurations; i++) {
56067 struct usb_config_descriptor *config =
56068 (struct usb_config_descriptor *)dev->rawdescriptors[i];
56069- unsigned int length = le16_to_cpu(config->wTotalLength);
56070+ size_t length = le16_to_cpu(config->wTotalLength);
56071
56072 if (*ppos < pos + length) {
56073
56074 /* The descriptor may claim to be longer than it
56075 * really is. Here is the actual allocated length. */
56076- unsigned alloclen =
56077+ size_t alloclen =
56078 le16_to_cpu(dev->config[i].desc.wTotalLength);
56079
56080- len = length - (*ppos - pos);
56081+ len = length + pos - *ppos;
56082 if (len > nbytes)
56083 len = nbytes;
56084
56085 /* Simply don't write (skip over) unallocated parts */
56086 if (alloclen > (*ppos - pos)) {
56087- alloclen -= (*ppos - pos);
56088+ alloclen = alloclen + pos - *ppos;
56089 if (copy_to_user(buf,
56090 dev->rawdescriptors[i] + (*ppos - pos),
56091 min(len, alloclen))) {
56092diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
56093index 45a915c..09f9735 100644
56094--- a/drivers/usb/core/hcd.c
56095+++ b/drivers/usb/core/hcd.c
56096@@ -1551,7 +1551,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
56097 */
56098 usb_get_urb(urb);
56099 atomic_inc(&urb->use_count);
56100- atomic_inc(&urb->dev->urbnum);
56101+ atomic_inc_unchecked(&urb->dev->urbnum);
56102 usbmon_urb_submit(&hcd->self, urb);
56103
56104 /* NOTE requirements on root-hub callers (usbfs and the hub
56105@@ -1578,7 +1578,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
56106 urb->hcpriv = NULL;
56107 INIT_LIST_HEAD(&urb->urb_list);
56108 atomic_dec(&urb->use_count);
56109- atomic_dec(&urb->dev->urbnum);
56110+ atomic_dec_unchecked(&urb->dev->urbnum);
56111 if (atomic_read(&urb->reject))
56112 wake_up(&usb_kill_urb_queue);
56113 usb_put_urb(urb);
56114diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
56115index 3b71516..1f26579 100644
56116--- a/drivers/usb/core/hub.c
56117+++ b/drivers/usb/core/hub.c
56118@@ -26,6 +26,7 @@
56119 #include <linux/mutex.h>
56120 #include <linux/random.h>
56121 #include <linux/pm_qos.h>
56122+#include <linux/grsecurity.h>
56123
56124 #include <asm/uaccess.h>
56125 #include <asm/byteorder.h>
56126@@ -4665,6 +4666,10 @@ static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus,
56127 goto done;
56128 return;
56129 }
56130+
56131+ if (gr_handle_new_usb())
56132+ goto done;
56133+
56134 if (hub_is_superspeed(hub->hdev))
56135 unit_load = 150;
56136 else
56137diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
56138index f368d20..0c30ac5 100644
56139--- a/drivers/usb/core/message.c
56140+++ b/drivers/usb/core/message.c
56141@@ -128,7 +128,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
56142 * Return: If successful, the number of bytes transferred. Otherwise, a negative
56143 * error number.
56144 */
56145-int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
56146+int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
56147 __u8 requesttype, __u16 value, __u16 index, void *data,
56148 __u16 size, int timeout)
56149 {
56150@@ -180,7 +180,7 @@ EXPORT_SYMBOL_GPL(usb_control_msg);
56151 * If successful, 0. Otherwise a negative error number. The number of actual
56152 * bytes transferred will be stored in the @actual_length parameter.
56153 */
56154-int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
56155+int __intentional_overflow(-1) usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
56156 void *data, int len, int *actual_length, int timeout)
56157 {
56158 return usb_bulk_msg(usb_dev, pipe, data, len, actual_length, timeout);
56159@@ -220,7 +220,7 @@ EXPORT_SYMBOL_GPL(usb_interrupt_msg);
56160 * bytes transferred will be stored in the @actual_length parameter.
56161 *
56162 */
56163-int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
56164+int __intentional_overflow(-1) usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
56165 void *data, int len, int *actual_length, int timeout)
56166 {
56167 struct urb *urb;
56168diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
56169index d269738..7340cd7 100644
56170--- a/drivers/usb/core/sysfs.c
56171+++ b/drivers/usb/core/sysfs.c
56172@@ -244,7 +244,7 @@ static ssize_t urbnum_show(struct device *dev, struct device_attribute *attr,
56173 struct usb_device *udev;
56174
56175 udev = to_usb_device(dev);
56176- return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
56177+ return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
56178 }
56179 static DEVICE_ATTR_RO(urbnum);
56180
56181diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
56182index 8d5b2f4..3896940 100644
56183--- a/drivers/usb/core/usb.c
56184+++ b/drivers/usb/core/usb.c
56185@@ -447,7 +447,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
56186 set_dev_node(&dev->dev, dev_to_node(bus->controller));
56187 dev->state = USB_STATE_ATTACHED;
56188 dev->lpm_disable_count = 1;
56189- atomic_set(&dev->urbnum, 0);
56190+ atomic_set_unchecked(&dev->urbnum, 0);
56191
56192 INIT_LIST_HEAD(&dev->ep0.urb_list);
56193 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
56194diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
56195index 8cfc319..4868255 100644
56196--- a/drivers/usb/early/ehci-dbgp.c
56197+++ b/drivers/usb/early/ehci-dbgp.c
56198@@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
56199
56200 #ifdef CONFIG_KGDB
56201 static struct kgdb_io kgdbdbgp_io_ops;
56202-#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
56203+static struct kgdb_io kgdbdbgp_io_ops_console;
56204+#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
56205 #else
56206 #define dbgp_kgdb_mode (0)
56207 #endif
56208@@ -1043,6 +1044,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
56209 .write_char = kgdbdbgp_write_char,
56210 };
56211
56212+static struct kgdb_io kgdbdbgp_io_ops_console = {
56213+ .name = "kgdbdbgp",
56214+ .read_char = kgdbdbgp_read_char,
56215+ .write_char = kgdbdbgp_write_char,
56216+ .is_console = 1
56217+};
56218+
56219 static int kgdbdbgp_wait_time;
56220
56221 static int __init kgdbdbgp_parse_config(char *str)
56222@@ -1058,8 +1066,10 @@ static int __init kgdbdbgp_parse_config(char *str)
56223 ptr++;
56224 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
56225 }
56226- kgdb_register_io_module(&kgdbdbgp_io_ops);
56227- kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
56228+ if (early_dbgp_console.index != -1)
56229+ kgdb_register_io_module(&kgdbdbgp_io_ops_console);
56230+ else
56231+ kgdb_register_io_module(&kgdbdbgp_io_ops);
56232
56233 return 0;
56234 }
56235diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
56236index 0495c94..289e201 100644
56237--- a/drivers/usb/gadget/configfs.c
56238+++ b/drivers/usb/gadget/configfs.c
56239@@ -571,7 +571,7 @@ static struct config_group *function_make(
56240 if (IS_ERR(fi))
56241 return ERR_CAST(fi);
56242
56243- ret = config_item_set_name(&fi->group.cg_item, name);
56244+ ret = config_item_set_name(&fi->group.cg_item, "%s", name);
56245 if (ret) {
56246 usb_put_function_instance(fi);
56247 return ERR_PTR(ret);
56248diff --git a/drivers/usb/gadget/function/f_uac1.c b/drivers/usb/gadget/function/f_uac1.c
56249index 7856b33..8b7fe09 100644
56250--- a/drivers/usb/gadget/function/f_uac1.c
56251+++ b/drivers/usb/gadget/function/f_uac1.c
56252@@ -14,6 +14,7 @@
56253 #include <linux/module.h>
56254 #include <linux/device.h>
56255 #include <linux/atomic.h>
56256+#include <linux/module.h>
56257
56258 #include "u_uac1.h"
56259
56260diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c
56261index 7ee05793..2e31e99 100644
56262--- a/drivers/usb/gadget/function/u_serial.c
56263+++ b/drivers/usb/gadget/function/u_serial.c
56264@@ -732,9 +732,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
56265 spin_lock_irq(&port->port_lock);
56266
56267 /* already open? Great. */
56268- if (port->port.count) {
56269+ if (atomic_read(&port->port.count)) {
56270 status = 0;
56271- port->port.count++;
56272+ atomic_inc(&port->port.count);
56273
56274 /* currently opening/closing? wait ... */
56275 } else if (port->openclose) {
56276@@ -793,7 +793,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
56277 tty->driver_data = port;
56278 port->port.tty = tty;
56279
56280- port->port.count = 1;
56281+ atomic_set(&port->port.count, 1);
56282 port->openclose = false;
56283
56284 /* if connected, start the I/O stream */
56285@@ -835,11 +835,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
56286
56287 spin_lock_irq(&port->port_lock);
56288
56289- if (port->port.count != 1) {
56290- if (port->port.count == 0)
56291+ if (atomic_read(&port->port.count) != 1) {
56292+ if (atomic_read(&port->port.count) == 0)
56293 WARN_ON(1);
56294 else
56295- --port->port.count;
56296+ atomic_dec(&port->port.count);
56297 goto exit;
56298 }
56299
56300@@ -849,7 +849,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
56301 * and sleep if necessary
56302 */
56303 port->openclose = true;
56304- port->port.count = 0;
56305+ atomic_set(&port->port.count, 0);
56306
56307 gser = port->port_usb;
56308 if (gser && gser->disconnect)
56309@@ -1065,7 +1065,7 @@ static int gs_closed(struct gs_port *port)
56310 int cond;
56311
56312 spin_lock_irq(&port->port_lock);
56313- cond = (port->port.count == 0) && !port->openclose;
56314+ cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
56315 spin_unlock_irq(&port->port_lock);
56316 return cond;
56317 }
56318@@ -1208,7 +1208,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
56319 /* if it's already open, start I/O ... and notify the serial
56320 * protocol about open/close status (connect/disconnect).
56321 */
56322- if (port->port.count) {
56323+ if (atomic_read(&port->port.count)) {
56324 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
56325 gs_start_io(port);
56326 if (gser->connect)
56327@@ -1255,7 +1255,7 @@ void gserial_disconnect(struct gserial *gser)
56328
56329 port->port_usb = NULL;
56330 gser->ioport = NULL;
56331- if (port->port.count > 0 || port->openclose) {
56332+ if (atomic_read(&port->port.count) > 0 || port->openclose) {
56333 wake_up_interruptible(&port->drain_wait);
56334 if (port->port.tty)
56335 tty_hangup(port->port.tty);
56336@@ -1271,7 +1271,7 @@ void gserial_disconnect(struct gserial *gser)
56337
56338 /* finally, free any unused/unusable I/O buffers */
56339 spin_lock_irqsave(&port->port_lock, flags);
56340- if (port->port.count == 0 && !port->openclose)
56341+ if (atomic_read(&port->port.count) == 0 && !port->openclose)
56342 gs_buf_free(&port->port_write_buf);
56343 gs_free_requests(gser->out, &port->read_pool, NULL);
56344 gs_free_requests(gser->out, &port->read_queue, NULL);
56345diff --git a/drivers/usb/gadget/function/u_uac1.c b/drivers/usb/gadget/function/u_uac1.c
56346index c78c841..48fd281 100644
56347--- a/drivers/usb/gadget/function/u_uac1.c
56348+++ b/drivers/usb/gadget/function/u_uac1.c
56349@@ -17,6 +17,7 @@
56350 #include <linux/ctype.h>
56351 #include <linux/random.h>
56352 #include <linux/syscalls.h>
56353+#include <linux/module.h>
56354
56355 #include "u_uac1.h"
56356
56357diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
56358index 6920844..480bb7e 100644
56359--- a/drivers/usb/host/ehci-hub.c
56360+++ b/drivers/usb/host/ehci-hub.c
56361@@ -772,7 +772,7 @@ static struct urb *request_single_step_set_feature_urb(
56362 urb->transfer_flags = URB_DIR_IN;
56363 usb_get_urb(urb);
56364 atomic_inc(&urb->use_count);
56365- atomic_inc(&urb->dev->urbnum);
56366+ atomic_inc_unchecked(&urb->dev->urbnum);
56367 urb->setup_dma = dma_map_single(
56368 hcd->self.controller,
56369 urb->setup_packet,
56370@@ -839,7 +839,7 @@ static int ehset_single_step_set_feature(struct usb_hcd *hcd, int port)
56371 urb->status = -EINPROGRESS;
56372 usb_get_urb(urb);
56373 atomic_inc(&urb->use_count);
56374- atomic_inc(&urb->dev->urbnum);
56375+ atomic_inc_unchecked(&urb->dev->urbnum);
56376 retval = submit_single_step_set_feature(hcd, urb, 0);
56377 if (!retval && !wait_for_completion_timeout(&done,
56378 msecs_to_jiffies(2000))) {
56379diff --git a/drivers/usb/host/hwa-hc.c b/drivers/usb/host/hwa-hc.c
56380index 1db0626..4948782 100644
56381--- a/drivers/usb/host/hwa-hc.c
56382+++ b/drivers/usb/host/hwa-hc.c
56383@@ -337,7 +337,10 @@ static int __hwahc_op_bwa_set(struct wusbhc *wusbhc, s8 stream_index,
56384 struct hwahc *hwahc = container_of(wusbhc, struct hwahc, wusbhc);
56385 struct wahc *wa = &hwahc->wa;
56386 struct device *dev = &wa->usb_iface->dev;
56387- u8 mas_le[UWB_NUM_MAS/8];
56388+ u8 *mas_le = kmalloc(UWB_NUM_MAS/8, GFP_KERNEL);
56389+
56390+ if (mas_le == NULL)
56391+ return -ENOMEM;
56392
56393 /* Set the stream index */
56394 result = usb_control_msg(wa->usb_dev, usb_sndctrlpipe(wa->usb_dev, 0),
56395@@ -356,10 +359,12 @@ static int __hwahc_op_bwa_set(struct wusbhc *wusbhc, s8 stream_index,
56396 WUSB_REQ_SET_WUSB_MAS,
56397 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
56398 0, wa->usb_iface->cur_altsetting->desc.bInterfaceNumber,
56399- mas_le, 32, USB_CTRL_SET_TIMEOUT);
56400+ mas_le, UWB_NUM_MAS/8, USB_CTRL_SET_TIMEOUT);
56401 if (result < 0)
56402 dev_err(dev, "Cannot set WUSB MAS allocation: %d\n", result);
56403 out:
56404+ kfree(mas_le);
56405+
56406 return result;
56407 }
56408
56409diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
56410index a0a3827..d7ec10b 100644
56411--- a/drivers/usb/misc/appledisplay.c
56412+++ b/drivers/usb/misc/appledisplay.c
56413@@ -84,7 +84,7 @@ struct appledisplay {
56414 struct mutex sysfslock; /* concurrent read and write */
56415 };
56416
56417-static atomic_t count_displays = ATOMIC_INIT(0);
56418+static atomic_unchecked_t count_displays = ATOMIC_INIT(0);
56419 static struct workqueue_struct *wq;
56420
56421 static void appledisplay_complete(struct urb *urb)
56422@@ -288,7 +288,7 @@ static int appledisplay_probe(struct usb_interface *iface,
56423
56424 /* Register backlight device */
56425 snprintf(bl_name, sizeof(bl_name), "appledisplay%d",
56426- atomic_inc_return(&count_displays) - 1);
56427+ atomic_inc_return_unchecked(&count_displays) - 1);
56428 memset(&props, 0, sizeof(struct backlight_properties));
56429 props.type = BACKLIGHT_RAW;
56430 props.max_brightness = 0xff;
56431diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
56432index 3806e70..55c508b 100644
56433--- a/drivers/usb/serial/console.c
56434+++ b/drivers/usb/serial/console.c
56435@@ -126,7 +126,7 @@ static int usb_console_setup(struct console *co, char *options)
56436
56437 info->port = port;
56438
56439- ++port->port.count;
56440+ atomic_inc(&port->port.count);
56441 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
56442 if (serial->type->set_termios) {
56443 /*
56444@@ -175,7 +175,7 @@ static int usb_console_setup(struct console *co, char *options)
56445 }
56446 /* Now that any required fake tty operations are completed restore
56447 * the tty port count */
56448- --port->port.count;
56449+ atomic_dec(&port->port.count);
56450 /* The console is special in terms of closing the device so
56451 * indicate this port is now acting as a system console. */
56452 port->port.console = 1;
56453@@ -188,7 +188,7 @@ static int usb_console_setup(struct console *co, char *options)
56454 put_tty:
56455 tty_kref_put(tty);
56456 reset_open_count:
56457- port->port.count = 0;
56458+ atomic_set(&port->port.count, 0);
56459 usb_autopm_put_interface(serial->interface);
56460 error_get_interface:
56461 usb_serial_put(serial);
56462@@ -199,7 +199,7 @@ static int usb_console_setup(struct console *co, char *options)
56463 static void usb_console_write(struct console *co,
56464 const char *buf, unsigned count)
56465 {
56466- static struct usbcons_info *info = &usbcons_info;
56467+ struct usbcons_info *info = &usbcons_info;
56468 struct usb_serial_port *port = info->port;
56469 struct usb_serial *serial;
56470 int retval = -ENODEV;
56471diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
56472index 307e339..6aa97cb 100644
56473--- a/drivers/usb/storage/usb.h
56474+++ b/drivers/usb/storage/usb.h
56475@@ -63,7 +63,7 @@ struct us_unusual_dev {
56476 __u8 useProtocol;
56477 __u8 useTransport;
56478 int (*initFunction)(struct us_data *);
56479-};
56480+} __do_const;
56481
56482
56483 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
56484diff --git a/drivers/usb/usbip/vhci.h b/drivers/usb/usbip/vhci.h
56485index a863a98..d272795 100644
56486--- a/drivers/usb/usbip/vhci.h
56487+++ b/drivers/usb/usbip/vhci.h
56488@@ -83,7 +83,7 @@ struct vhci_hcd {
56489 unsigned resuming:1;
56490 unsigned long re_timeout;
56491
56492- atomic_t seqnum;
56493+ atomic_unchecked_t seqnum;
56494
56495 /*
56496 * NOTE:
56497diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
56498index e9ef1ec..c3a0b04 100644
56499--- a/drivers/usb/usbip/vhci_hcd.c
56500+++ b/drivers/usb/usbip/vhci_hcd.c
56501@@ -440,7 +440,7 @@ static void vhci_tx_urb(struct urb *urb)
56502
56503 spin_lock(&vdev->priv_lock);
56504
56505- priv->seqnum = atomic_inc_return(&the_controller->seqnum);
56506+ priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
56507 if (priv->seqnum == 0xffff)
56508 dev_info(&urb->dev->dev, "seqnum max\n");
56509
56510@@ -685,7 +685,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
56511 return -ENOMEM;
56512 }
56513
56514- unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
56515+ unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
56516 if (unlink->seqnum == 0xffff)
56517 pr_info("seqnum max\n");
56518
56519@@ -889,7 +889,7 @@ static int vhci_start(struct usb_hcd *hcd)
56520 vdev->rhport = rhport;
56521 }
56522
56523- atomic_set(&vhci->seqnum, 0);
56524+ atomic_set_unchecked(&vhci->seqnum, 0);
56525 spin_lock_init(&vhci->lock);
56526
56527 hcd->power_budget = 0; /* no limit */
56528diff --git a/drivers/usb/usbip/vhci_rx.c b/drivers/usb/usbip/vhci_rx.c
56529index 00e4a54..d676f85 100644
56530--- a/drivers/usb/usbip/vhci_rx.c
56531+++ b/drivers/usb/usbip/vhci_rx.c
56532@@ -80,7 +80,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
56533 if (!urb) {
56534 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
56535 pr_info("max seqnum %d\n",
56536- atomic_read(&the_controller->seqnum));
56537+ atomic_read_unchecked(&the_controller->seqnum));
56538 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
56539 return;
56540 }
56541diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
56542index edc7267..9f65ce2 100644
56543--- a/drivers/usb/wusbcore/wa-hc.h
56544+++ b/drivers/usb/wusbcore/wa-hc.h
56545@@ -240,7 +240,7 @@ struct wahc {
56546 spinlock_t xfer_list_lock;
56547 struct work_struct xfer_enqueue_work;
56548 struct work_struct xfer_error_work;
56549- atomic_t xfer_id_count;
56550+ atomic_unchecked_t xfer_id_count;
56551
56552 kernel_ulong_t quirks;
56553 };
56554@@ -305,7 +305,7 @@ static inline void wa_init(struct wahc *wa)
56555 INIT_WORK(&wa->xfer_enqueue_work, wa_urb_enqueue_run);
56556 INIT_WORK(&wa->xfer_error_work, wa_process_errored_transfers_run);
56557 wa->dto_in_use = 0;
56558- atomic_set(&wa->xfer_id_count, 1);
56559+ atomic_set_unchecked(&wa->xfer_id_count, 1);
56560 /* init the buf in URBs */
56561 for (index = 0; index < WA_MAX_BUF_IN_URBS; ++index)
56562 usb_init_urb(&(wa->buf_in_urbs[index]));
56563diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
56564index 69af4fd..da390d7 100644
56565--- a/drivers/usb/wusbcore/wa-xfer.c
56566+++ b/drivers/usb/wusbcore/wa-xfer.c
56567@@ -314,7 +314,7 @@ static void wa_xfer_completion(struct wa_xfer *xfer)
56568 */
56569 static void wa_xfer_id_init(struct wa_xfer *xfer)
56570 {
56571- xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
56572+ xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
56573 }
56574
56575 /* Return the xfer's ID. */
56576diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
56577index e1278fe..7fdeac4 100644
56578--- a/drivers/vfio/vfio.c
56579+++ b/drivers/vfio/vfio.c
56580@@ -517,7 +517,7 @@ static int vfio_group_nb_add_dev(struct vfio_group *group, struct device *dev)
56581 return 0;
56582
56583 /* TODO Prevent device auto probing */
56584- WARN("Device %s added to live group %d!\n", dev_name(dev),
56585+ WARN(1, "Device %s added to live group %d!\n", dev_name(dev),
56586 iommu_group_id(group->iommu_group));
56587
56588 return 0;
56589diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
56590index 3bb02c6..a01ff38 100644
56591--- a/drivers/vhost/vringh.c
56592+++ b/drivers/vhost/vringh.c
56593@@ -551,7 +551,7 @@ static inline void __vringh_notify_disable(struct vringh *vrh,
56594 static inline int getu16_user(const struct vringh *vrh, u16 *val, const __virtio16 *p)
56595 {
56596 __virtio16 v = 0;
56597- int rc = get_user(v, (__force __virtio16 __user *)p);
56598+ int rc = get_user(v, (__force_user __virtio16 *)p);
56599 *val = vringh16_to_cpu(vrh, v);
56600 return rc;
56601 }
56602@@ -559,12 +559,12 @@ static inline int getu16_user(const struct vringh *vrh, u16 *val, const __virtio
56603 static inline int putu16_user(const struct vringh *vrh, __virtio16 *p, u16 val)
56604 {
56605 __virtio16 v = cpu_to_vringh16(vrh, val);
56606- return put_user(v, (__force __virtio16 __user *)p);
56607+ return put_user(v, (__force_user __virtio16 *)p);
56608 }
56609
56610 static inline int copydesc_user(void *dst, const void *src, size_t len)
56611 {
56612- return copy_from_user(dst, (__force void __user *)src, len) ?
56613+ return copy_from_user(dst, (void __force_user *)src, len) ?
56614 -EFAULT : 0;
56615 }
56616
56617@@ -572,19 +572,19 @@ static inline int putused_user(struct vring_used_elem *dst,
56618 const struct vring_used_elem *src,
56619 unsigned int num)
56620 {
56621- return copy_to_user((__force void __user *)dst, src,
56622+ return copy_to_user((void __force_user *)dst, src,
56623 sizeof(*dst) * num) ? -EFAULT : 0;
56624 }
56625
56626 static inline int xfer_from_user(void *src, void *dst, size_t len)
56627 {
56628- return copy_from_user(dst, (__force void __user *)src, len) ?
56629+ return copy_from_user(dst, (void __force_user *)src, len) ?
56630 -EFAULT : 0;
56631 }
56632
56633 static inline int xfer_to_user(void *dst, void *src, size_t len)
56634 {
56635- return copy_to_user((__force void __user *)dst, src, len) ?
56636+ return copy_to_user((void __force_user *)dst, src, len) ?
56637 -EFAULT : 0;
56638 }
56639
56640@@ -621,9 +621,9 @@ int vringh_init_user(struct vringh *vrh, u64 features,
56641 vrh->last_used_idx = 0;
56642 vrh->vring.num = num;
56643 /* vring expects kernel addresses, but only used via accessors. */
56644- vrh->vring.desc = (__force struct vring_desc *)desc;
56645- vrh->vring.avail = (__force struct vring_avail *)avail;
56646- vrh->vring.used = (__force struct vring_used *)used;
56647+ vrh->vring.desc = (__force_kernel struct vring_desc *)desc;
56648+ vrh->vring.avail = (__force_kernel struct vring_avail *)avail;
56649+ vrh->vring.used = (__force_kernel struct vring_used *)used;
56650 return 0;
56651 }
56652 EXPORT_SYMBOL(vringh_init_user);
56653@@ -826,7 +826,7 @@ static inline int getu16_kern(const struct vringh *vrh,
56654
56655 static inline int putu16_kern(const struct vringh *vrh, __virtio16 *p, u16 val)
56656 {
56657- ACCESS_ONCE(*p) = cpu_to_vringh16(vrh, val);
56658+ ACCESS_ONCE_RW(*p) = cpu_to_vringh16(vrh, val);
56659 return 0;
56660 }
56661
56662diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
56663index 84a110a..96312c3 100644
56664--- a/drivers/video/backlight/kb3886_bl.c
56665+++ b/drivers/video/backlight/kb3886_bl.c
56666@@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
56667 static unsigned long kb3886bl_flags;
56668 #define KB3886BL_SUSPENDED 0x01
56669
56670-static struct dmi_system_id kb3886bl_device_table[] __initdata = {
56671+static const struct dmi_system_id kb3886bl_device_table[] __initconst = {
56672 {
56673 .ident = "Sahara Touch-iT",
56674 .matches = {
56675diff --git a/drivers/video/fbdev/arcfb.c b/drivers/video/fbdev/arcfb.c
56676index 1b0b233..6f34c2c 100644
56677--- a/drivers/video/fbdev/arcfb.c
56678+++ b/drivers/video/fbdev/arcfb.c
56679@@ -458,7 +458,7 @@ static ssize_t arcfb_write(struct fb_info *info, const char __user *buf,
56680 return -ENOSPC;
56681
56682 err = 0;
56683- if ((count + p) > fbmemlength) {
56684+ if (count > (fbmemlength - p)) {
56685 count = fbmemlength - p;
56686 err = -ENOSPC;
56687 }
56688diff --git a/drivers/video/fbdev/aty/aty128fb.c b/drivers/video/fbdev/aty/aty128fb.c
56689index 0156954..c07d4e0 100644
56690--- a/drivers/video/fbdev/aty/aty128fb.c
56691+++ b/drivers/video/fbdev/aty/aty128fb.c
56692@@ -149,7 +149,7 @@ enum {
56693 };
56694
56695 /* Must match above enum */
56696-static char * const r128_family[] = {
56697+static const char * const r128_family[] = {
56698 "AGP",
56699 "PCI",
56700 "PRO AGP",
56701diff --git a/drivers/video/fbdev/aty/atyfb_base.c b/drivers/video/fbdev/aty/atyfb_base.c
56702index 8789e48..698fe4c 100644
56703--- a/drivers/video/fbdev/aty/atyfb_base.c
56704+++ b/drivers/video/fbdev/aty/atyfb_base.c
56705@@ -1326,10 +1326,14 @@ static int atyfb_set_par(struct fb_info *info)
56706 par->accel_flags = var->accel_flags; /* hack */
56707
56708 if (var->accel_flags) {
56709- info->fbops->fb_sync = atyfb_sync;
56710+ pax_open_kernel();
56711+ *(void **)&info->fbops->fb_sync = atyfb_sync;
56712+ pax_close_kernel();
56713 info->flags &= ~FBINFO_HWACCEL_DISABLED;
56714 } else {
56715- info->fbops->fb_sync = NULL;
56716+ pax_open_kernel();
56717+ *(void **)&info->fbops->fb_sync = NULL;
56718+ pax_close_kernel();
56719 info->flags |= FBINFO_HWACCEL_DISABLED;
56720 }
56721
56722diff --git a/drivers/video/fbdev/aty/mach64_cursor.c b/drivers/video/fbdev/aty/mach64_cursor.c
56723index 2fa0317..4983f2a 100644
56724--- a/drivers/video/fbdev/aty/mach64_cursor.c
56725+++ b/drivers/video/fbdev/aty/mach64_cursor.c
56726@@ -8,6 +8,7 @@
56727 #include "../core/fb_draw.h"
56728
56729 #include <asm/io.h>
56730+#include <asm/pgtable.h>
56731
56732 #ifdef __sparc__
56733 #include <asm/fbio.h>
56734@@ -218,7 +219,9 @@ int aty_init_cursor(struct fb_info *info)
56735 info->sprite.buf_align = 16; /* and 64 lines tall. */
56736 info->sprite.flags = FB_PIXMAP_IO;
56737
56738- info->fbops->fb_cursor = atyfb_cursor;
56739+ pax_open_kernel();
56740+ *(void **)&info->fbops->fb_cursor = atyfb_cursor;
56741+ pax_close_kernel();
56742
56743 return 0;
56744 }
56745diff --git a/drivers/video/fbdev/core/fb_defio.c b/drivers/video/fbdev/core/fb_defio.c
56746index d6cab1f..112f680 100644
56747--- a/drivers/video/fbdev/core/fb_defio.c
56748+++ b/drivers/video/fbdev/core/fb_defio.c
56749@@ -207,7 +207,9 @@ void fb_deferred_io_init(struct fb_info *info)
56750
56751 BUG_ON(!fbdefio);
56752 mutex_init(&fbdefio->lock);
56753- info->fbops->fb_mmap = fb_deferred_io_mmap;
56754+ pax_open_kernel();
56755+ *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
56756+ pax_close_kernel();
56757 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
56758 INIT_LIST_HEAD(&fbdefio->pagelist);
56759 if (fbdefio->delay == 0) /* set a default of 1 s */
56760@@ -238,7 +240,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
56761 page->mapping = NULL;
56762 }
56763
56764- info->fbops->fb_mmap = NULL;
56765+ *(void **)&info->fbops->fb_mmap = NULL;
56766 mutex_destroy(&fbdefio->lock);
56767 }
56768 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
56769diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
56770index 0705d88..d9429bf 100644
56771--- a/drivers/video/fbdev/core/fbmem.c
56772+++ b/drivers/video/fbdev/core/fbmem.c
56773@@ -1301,7 +1301,7 @@ static int do_fscreeninfo_to_user(struct fb_fix_screeninfo *fix,
56774 __u32 data;
56775 int err;
56776
56777- err = copy_to_user(&fix32->id, &fix->id, sizeof(fix32->id));
56778+ err = copy_to_user(fix32->id, &fix->id, sizeof(fix32->id));
56779
56780 data = (__u32) (unsigned long) fix->smem_start;
56781 err |= put_user(data, &fix32->smem_start);
56782diff --git a/drivers/video/fbdev/hyperv_fb.c b/drivers/video/fbdev/hyperv_fb.c
56783index 807ee22..7814cd6 100644
56784--- a/drivers/video/fbdev/hyperv_fb.c
56785+++ b/drivers/video/fbdev/hyperv_fb.c
56786@@ -240,7 +240,7 @@ static uint screen_fb_size;
56787 static inline int synthvid_send(struct hv_device *hdev,
56788 struct synthvid_msg *msg)
56789 {
56790- static atomic64_t request_id = ATOMIC64_INIT(0);
56791+ static atomic64_unchecked_t request_id = ATOMIC64_INIT(0);
56792 int ret;
56793
56794 msg->pipe_hdr.type = PIPE_MSG_DATA;
56795@@ -248,7 +248,7 @@ static inline int synthvid_send(struct hv_device *hdev,
56796
56797 ret = vmbus_sendpacket(hdev->channel, msg,
56798 msg->vid_hdr.size + sizeof(struct pipe_msg_hdr),
56799- atomic64_inc_return(&request_id),
56800+ atomic64_inc_return_unchecked(&request_id),
56801 VM_PKT_DATA_INBAND, 0);
56802
56803 if (ret)
56804diff --git a/drivers/video/fbdev/i810/i810_accel.c b/drivers/video/fbdev/i810/i810_accel.c
56805index 7672d2e..b56437f 100644
56806--- a/drivers/video/fbdev/i810/i810_accel.c
56807+++ b/drivers/video/fbdev/i810/i810_accel.c
56808@@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
56809 }
56810 }
56811 printk("ringbuffer lockup!!!\n");
56812+ printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
56813 i810_report_error(mmio);
56814 par->dev_flags |= LOCKUP;
56815 info->pixmap.scan_align = 1;
56816diff --git a/drivers/video/fbdev/matrox/matroxfb_DAC1064.c b/drivers/video/fbdev/matrox/matroxfb_DAC1064.c
56817index a01147f..5d896f8 100644
56818--- a/drivers/video/fbdev/matrox/matroxfb_DAC1064.c
56819+++ b/drivers/video/fbdev/matrox/matroxfb_DAC1064.c
56820@@ -1088,14 +1088,20 @@ static void MGAG100_restore(struct matrox_fb_info *minfo)
56821
56822 #ifdef CONFIG_FB_MATROX_MYSTIQUE
56823 struct matrox_switch matrox_mystique = {
56824- MGA1064_preinit, MGA1064_reset, MGA1064_init, MGA1064_restore,
56825+ .preinit = MGA1064_preinit,
56826+ .reset = MGA1064_reset,
56827+ .init = MGA1064_init,
56828+ .restore = MGA1064_restore,
56829 };
56830 EXPORT_SYMBOL(matrox_mystique);
56831 #endif
56832
56833 #ifdef CONFIG_FB_MATROX_G
56834 struct matrox_switch matrox_G100 = {
56835- MGAG100_preinit, MGAG100_reset, MGAG100_init, MGAG100_restore,
56836+ .preinit = MGAG100_preinit,
56837+ .reset = MGAG100_reset,
56838+ .init = MGAG100_init,
56839+ .restore = MGAG100_restore,
56840 };
56841 EXPORT_SYMBOL(matrox_G100);
56842 #endif
56843diff --git a/drivers/video/fbdev/matrox/matroxfb_Ti3026.c b/drivers/video/fbdev/matrox/matroxfb_Ti3026.c
56844index 195ad7c..09743fc 100644
56845--- a/drivers/video/fbdev/matrox/matroxfb_Ti3026.c
56846+++ b/drivers/video/fbdev/matrox/matroxfb_Ti3026.c
56847@@ -738,7 +738,10 @@ static int Ti3026_preinit(struct matrox_fb_info *minfo)
56848 }
56849
56850 struct matrox_switch matrox_millennium = {
56851- Ti3026_preinit, Ti3026_reset, Ti3026_init, Ti3026_restore
56852+ .preinit = Ti3026_preinit,
56853+ .reset = Ti3026_reset,
56854+ .init = Ti3026_init,
56855+ .restore = Ti3026_restore
56856 };
56857 EXPORT_SYMBOL(matrox_millennium);
56858 #endif
56859diff --git a/drivers/video/fbdev/mb862xx/mb862xxfb_accel.c b/drivers/video/fbdev/mb862xx/mb862xxfb_accel.c
56860index fe92eed..106e085 100644
56861--- a/drivers/video/fbdev/mb862xx/mb862xxfb_accel.c
56862+++ b/drivers/video/fbdev/mb862xx/mb862xxfb_accel.c
56863@@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
56864 struct mb862xxfb_par *par = info->par;
56865
56866 if (info->var.bits_per_pixel == 32) {
56867- info->fbops->fb_fillrect = cfb_fillrect;
56868- info->fbops->fb_copyarea = cfb_copyarea;
56869- info->fbops->fb_imageblit = cfb_imageblit;
56870+ pax_open_kernel();
56871+ *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
56872+ *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
56873+ *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
56874+ pax_close_kernel();
56875 } else {
56876 outreg(disp, GC_L0EM, 3);
56877- info->fbops->fb_fillrect = mb86290fb_fillrect;
56878- info->fbops->fb_copyarea = mb86290fb_copyarea;
56879- info->fbops->fb_imageblit = mb86290fb_imageblit;
56880+ pax_open_kernel();
56881+ *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
56882+ *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
56883+ *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
56884+ pax_close_kernel();
56885 }
56886 outreg(draw, GDC_REG_DRAW_BASE, 0);
56887 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
56888diff --git a/drivers/video/fbdev/nvidia/nvidia.c b/drivers/video/fbdev/nvidia/nvidia.c
56889index 4273c6e..b413013 100644
56890--- a/drivers/video/fbdev/nvidia/nvidia.c
56891+++ b/drivers/video/fbdev/nvidia/nvidia.c
56892@@ -665,19 +665,23 @@ static int nvidiafb_set_par(struct fb_info *info)
56893 info->fix.line_length = (info->var.xres_virtual *
56894 info->var.bits_per_pixel) >> 3;
56895 if (info->var.accel_flags) {
56896- info->fbops->fb_imageblit = nvidiafb_imageblit;
56897- info->fbops->fb_fillrect = nvidiafb_fillrect;
56898- info->fbops->fb_copyarea = nvidiafb_copyarea;
56899- info->fbops->fb_sync = nvidiafb_sync;
56900+ pax_open_kernel();
56901+ *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
56902+ *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
56903+ *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
56904+ *(void **)&info->fbops->fb_sync = nvidiafb_sync;
56905+ pax_close_kernel();
56906 info->pixmap.scan_align = 4;
56907 info->flags &= ~FBINFO_HWACCEL_DISABLED;
56908 info->flags |= FBINFO_READS_FAST;
56909 NVResetGraphics(info);
56910 } else {
56911- info->fbops->fb_imageblit = cfb_imageblit;
56912- info->fbops->fb_fillrect = cfb_fillrect;
56913- info->fbops->fb_copyarea = cfb_copyarea;
56914- info->fbops->fb_sync = NULL;
56915+ pax_open_kernel();
56916+ *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
56917+ *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
56918+ *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
56919+ *(void **)&info->fbops->fb_sync = NULL;
56920+ pax_close_kernel();
56921 info->pixmap.scan_align = 1;
56922 info->flags |= FBINFO_HWACCEL_DISABLED;
56923 info->flags &= ~FBINFO_READS_FAST;
56924@@ -1169,8 +1173,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
56925 info->pixmap.size = 8 * 1024;
56926 info->pixmap.flags = FB_PIXMAP_SYSTEM;
56927
56928- if (!hwcur)
56929- info->fbops->fb_cursor = NULL;
56930+ if (!hwcur) {
56931+ pax_open_kernel();
56932+ *(void **)&info->fbops->fb_cursor = NULL;
56933+ pax_close_kernel();
56934+ }
56935
56936 info->var.accel_flags = (!noaccel);
56937
56938diff --git a/drivers/video/fbdev/omap2/dss/display.c b/drivers/video/fbdev/omap2/dss/display.c
56939index ef5b902..47cf7f5 100644
56940--- a/drivers/video/fbdev/omap2/dss/display.c
56941+++ b/drivers/video/fbdev/omap2/dss/display.c
56942@@ -161,12 +161,14 @@ int omapdss_register_display(struct omap_dss_device *dssdev)
56943 if (dssdev->name == NULL)
56944 dssdev->name = dssdev->alias;
56945
56946+ pax_open_kernel();
56947 if (drv && drv->get_resolution == NULL)
56948- drv->get_resolution = omapdss_default_get_resolution;
56949+ *(void **)&drv->get_resolution = omapdss_default_get_resolution;
56950 if (drv && drv->get_recommended_bpp == NULL)
56951- drv->get_recommended_bpp = omapdss_default_get_recommended_bpp;
56952+ *(void **)&drv->get_recommended_bpp = omapdss_default_get_recommended_bpp;
56953 if (drv && drv->get_timings == NULL)
56954- drv->get_timings = omapdss_default_get_timings;
56955+ *(void **)&drv->get_timings = omapdss_default_get_timings;
56956+ pax_close_kernel();
56957
56958 mutex_lock(&panel_list_mutex);
56959 list_add_tail(&dssdev->panel_list, &panel_list);
56960diff --git a/drivers/video/fbdev/s1d13xxxfb.c b/drivers/video/fbdev/s1d13xxxfb.c
56961index 83433cb..71e9b98 100644
56962--- a/drivers/video/fbdev/s1d13xxxfb.c
56963+++ b/drivers/video/fbdev/s1d13xxxfb.c
56964@@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
56965
56966 switch(prod_id) {
56967 case S1D13506_PROD_ID: /* activate acceleration */
56968- s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
56969- s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
56970+ pax_open_kernel();
56971+ *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
56972+ *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
56973+ pax_close_kernel();
56974 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
56975 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
56976 break;
56977diff --git a/drivers/video/fbdev/sh_mobile_lcdcfb.c b/drivers/video/fbdev/sh_mobile_lcdcfb.c
56978index 82c0a8c..42499a1 100644
56979--- a/drivers/video/fbdev/sh_mobile_lcdcfb.c
56980+++ b/drivers/video/fbdev/sh_mobile_lcdcfb.c
56981@@ -439,9 +439,9 @@ static unsigned long lcdc_sys_read_data(void *handle)
56982 }
56983
56984 static struct sh_mobile_lcdc_sys_bus_ops sh_mobile_lcdc_sys_bus_ops = {
56985- lcdc_sys_write_index,
56986- lcdc_sys_write_data,
56987- lcdc_sys_read_data,
56988+ .write_index = lcdc_sys_write_index,
56989+ .write_data = lcdc_sys_write_data,
56990+ .read_data = lcdc_sys_read_data,
56991 };
56992
56993 static int sh_mobile_lcdc_sginit(struct fb_info *info,
56994diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c
56995index 9279e5f..d5f5276 100644
56996--- a/drivers/video/fbdev/smscufx.c
56997+++ b/drivers/video/fbdev/smscufx.c
56998@@ -1174,7 +1174,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
56999 fb_deferred_io_cleanup(info);
57000 kfree(info->fbdefio);
57001 info->fbdefio = NULL;
57002- info->fbops->fb_mmap = ufx_ops_mmap;
57003+ pax_open_kernel();
57004+ *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
57005+ pax_close_kernel();
57006 }
57007
57008 pr_debug("released /dev/fb%d user=%d count=%d",
57009diff --git a/drivers/video/fbdev/udlfb.c b/drivers/video/fbdev/udlfb.c
57010index ff2b873..626a8d5 100644
57011--- a/drivers/video/fbdev/udlfb.c
57012+++ b/drivers/video/fbdev/udlfb.c
57013@@ -623,11 +623,11 @@ static int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
57014 dlfb_urb_completion(urb);
57015
57016 error:
57017- atomic_add(bytes_sent, &dev->bytes_sent);
57018- atomic_add(bytes_identical, &dev->bytes_identical);
57019- atomic_add(width*height*2, &dev->bytes_rendered);
57020+ atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
57021+ atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
57022+ atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
57023 end_cycles = get_cycles();
57024- atomic_add(((unsigned int) ((end_cycles - start_cycles)
57025+ atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
57026 >> 10)), /* Kcycles */
57027 &dev->cpu_kcycles_used);
57028
57029@@ -748,11 +748,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
57030 dlfb_urb_completion(urb);
57031
57032 error:
57033- atomic_add(bytes_sent, &dev->bytes_sent);
57034- atomic_add(bytes_identical, &dev->bytes_identical);
57035- atomic_add(bytes_rendered, &dev->bytes_rendered);
57036+ atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
57037+ atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
57038+ atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
57039 end_cycles = get_cycles();
57040- atomic_add(((unsigned int) ((end_cycles - start_cycles)
57041+ atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
57042 >> 10)), /* Kcycles */
57043 &dev->cpu_kcycles_used);
57044 }
57045@@ -991,7 +991,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
57046 fb_deferred_io_cleanup(info);
57047 kfree(info->fbdefio);
57048 info->fbdefio = NULL;
57049- info->fbops->fb_mmap = dlfb_ops_mmap;
57050+ pax_open_kernel();
57051+ *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
57052+ pax_close_kernel();
57053 }
57054
57055 pr_warn("released /dev/fb%d user=%d count=%d\n",
57056@@ -1373,7 +1375,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
57057 struct fb_info *fb_info = dev_get_drvdata(fbdev);
57058 struct dlfb_data *dev = fb_info->par;
57059 return snprintf(buf, PAGE_SIZE, "%u\n",
57060- atomic_read(&dev->bytes_rendered));
57061+ atomic_read_unchecked(&dev->bytes_rendered));
57062 }
57063
57064 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
57065@@ -1381,7 +1383,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
57066 struct fb_info *fb_info = dev_get_drvdata(fbdev);
57067 struct dlfb_data *dev = fb_info->par;
57068 return snprintf(buf, PAGE_SIZE, "%u\n",
57069- atomic_read(&dev->bytes_identical));
57070+ atomic_read_unchecked(&dev->bytes_identical));
57071 }
57072
57073 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
57074@@ -1389,7 +1391,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
57075 struct fb_info *fb_info = dev_get_drvdata(fbdev);
57076 struct dlfb_data *dev = fb_info->par;
57077 return snprintf(buf, PAGE_SIZE, "%u\n",
57078- atomic_read(&dev->bytes_sent));
57079+ atomic_read_unchecked(&dev->bytes_sent));
57080 }
57081
57082 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
57083@@ -1397,7 +1399,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
57084 struct fb_info *fb_info = dev_get_drvdata(fbdev);
57085 struct dlfb_data *dev = fb_info->par;
57086 return snprintf(buf, PAGE_SIZE, "%u\n",
57087- atomic_read(&dev->cpu_kcycles_used));
57088+ atomic_read_unchecked(&dev->cpu_kcycles_used));
57089 }
57090
57091 static ssize_t edid_show(
57092@@ -1457,10 +1459,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
57093 struct fb_info *fb_info = dev_get_drvdata(fbdev);
57094 struct dlfb_data *dev = fb_info->par;
57095
57096- atomic_set(&dev->bytes_rendered, 0);
57097- atomic_set(&dev->bytes_identical, 0);
57098- atomic_set(&dev->bytes_sent, 0);
57099- atomic_set(&dev->cpu_kcycles_used, 0);
57100+ atomic_set_unchecked(&dev->bytes_rendered, 0);
57101+ atomic_set_unchecked(&dev->bytes_identical, 0);
57102+ atomic_set_unchecked(&dev->bytes_sent, 0);
57103+ atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
57104
57105 return count;
57106 }
57107diff --git a/drivers/video/fbdev/uvesafb.c b/drivers/video/fbdev/uvesafb.c
57108index d32d1c4..46722e6 100644
57109--- a/drivers/video/fbdev/uvesafb.c
57110+++ b/drivers/video/fbdev/uvesafb.c
57111@@ -19,6 +19,7 @@
57112 #include <linux/io.h>
57113 #include <linux/mutex.h>
57114 #include <linux/slab.h>
57115+#include <linux/moduleloader.h>
57116 #include <video/edid.h>
57117 #include <video/uvesafb.h>
57118 #ifdef CONFIG_X86
57119@@ -565,10 +566,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
57120 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
57121 par->pmi_setpal = par->ypan = 0;
57122 } else {
57123+
57124+#ifdef CONFIG_PAX_KERNEXEC
57125+#ifdef CONFIG_MODULES
57126+ par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
57127+#endif
57128+ if (!par->pmi_code) {
57129+ par->pmi_setpal = par->ypan = 0;
57130+ return 0;
57131+ }
57132+#endif
57133+
57134 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
57135 + task->t.regs.edi);
57136+
57137+#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
57138+ pax_open_kernel();
57139+ memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
57140+ pax_close_kernel();
57141+
57142+ par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
57143+ par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
57144+#else
57145 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
57146 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
57147+#endif
57148+
57149 printk(KERN_INFO "uvesafb: protected mode interface info at "
57150 "%04x:%04x\n",
57151 (u16)task->t.regs.es, (u16)task->t.regs.edi);
57152@@ -813,13 +836,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
57153 par->ypan = ypan;
57154
57155 if (par->pmi_setpal || par->ypan) {
57156+#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
57157 if (__supported_pte_mask & _PAGE_NX) {
57158 par->pmi_setpal = par->ypan = 0;
57159 printk(KERN_WARNING "uvesafb: NX protection is active, "
57160 "better not use the PMI.\n");
57161- } else {
57162+ } else
57163+#endif
57164 uvesafb_vbe_getpmi(task, par);
57165- }
57166 }
57167 #else
57168 /* The protected mode interface is not available on non-x86. */
57169@@ -1452,8 +1476,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
57170 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
57171
57172 /* Disable blanking if the user requested so. */
57173- if (!blank)
57174- info->fbops->fb_blank = NULL;
57175+ if (!blank) {
57176+ pax_open_kernel();
57177+ *(void **)&info->fbops->fb_blank = NULL;
57178+ pax_close_kernel();
57179+ }
57180
57181 /*
57182 * Find out how much IO memory is required for the mode with
57183@@ -1524,8 +1551,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
57184 info->flags = FBINFO_FLAG_DEFAULT |
57185 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
57186
57187- if (!par->ypan)
57188- info->fbops->fb_pan_display = NULL;
57189+ if (!par->ypan) {
57190+ pax_open_kernel();
57191+ *(void **)&info->fbops->fb_pan_display = NULL;
57192+ pax_close_kernel();
57193+ }
57194 }
57195
57196 static void uvesafb_init_mtrr(struct fb_info *info)
57197@@ -1786,6 +1816,11 @@ out_mode:
57198 out:
57199 kfree(par->vbe_modes);
57200
57201+#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
57202+ if (par->pmi_code)
57203+ module_memfree_exec(par->pmi_code);
57204+#endif
57205+
57206 framebuffer_release(info);
57207 return err;
57208 }
57209@@ -1810,6 +1845,11 @@ static int uvesafb_remove(struct platform_device *dev)
57210 kfree(par->vbe_state_orig);
57211 kfree(par->vbe_state_saved);
57212
57213+#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
57214+ if (par->pmi_code)
57215+ module_memfree_exec(par->pmi_code);
57216+#endif
57217+
57218 framebuffer_release(info);
57219 }
57220 return 0;
57221diff --git a/drivers/video/fbdev/vesafb.c b/drivers/video/fbdev/vesafb.c
57222index d79a0ac..2d0c3d4 100644
57223--- a/drivers/video/fbdev/vesafb.c
57224+++ b/drivers/video/fbdev/vesafb.c
57225@@ -9,6 +9,7 @@
57226 */
57227
57228 #include <linux/module.h>
57229+#include <linux/moduleloader.h>
57230 #include <linux/kernel.h>
57231 #include <linux/errno.h>
57232 #include <linux/string.h>
57233@@ -52,8 +53,8 @@ static int vram_remap; /* Set amount of memory to be used */
57234 static int vram_total; /* Set total amount of memory */
57235 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
57236 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
57237-static void (*pmi_start)(void) __read_mostly;
57238-static void (*pmi_pal) (void) __read_mostly;
57239+static void (*pmi_start)(void) __read_only;
57240+static void (*pmi_pal) (void) __read_only;
57241 static int depth __read_mostly;
57242 static int vga_compat __read_mostly;
57243 /* --------------------------------------------------------------------- */
57244@@ -233,6 +234,7 @@ static int vesafb_probe(struct platform_device *dev)
57245 unsigned int size_remap;
57246 unsigned int size_total;
57247 char *option = NULL;
57248+ void *pmi_code = NULL;
57249
57250 /* ignore error return of fb_get_options */
57251 fb_get_options("vesafb", &option);
57252@@ -279,10 +281,6 @@ static int vesafb_probe(struct platform_device *dev)
57253 size_remap = size_total;
57254 vesafb_fix.smem_len = size_remap;
57255
57256-#ifndef __i386__
57257- screen_info.vesapm_seg = 0;
57258-#endif
57259-
57260 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
57261 printk(KERN_WARNING
57262 "vesafb: cannot reserve video memory at 0x%lx\n",
57263@@ -312,9 +310,21 @@ static int vesafb_probe(struct platform_device *dev)
57264 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
57265 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
57266
57267+#ifdef __i386__
57268+
57269+#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
57270+ pmi_code = module_alloc_exec(screen_info.vesapm_size);
57271+ if (!pmi_code)
57272+#elif !defined(CONFIG_PAX_KERNEXEC)
57273+ if (0)
57274+#endif
57275+
57276+#endif
57277+ screen_info.vesapm_seg = 0;
57278+
57279 if (screen_info.vesapm_seg) {
57280- printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
57281- screen_info.vesapm_seg,screen_info.vesapm_off);
57282+ printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
57283+ screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
57284 }
57285
57286 if (screen_info.vesapm_seg < 0xc000)
57287@@ -322,9 +332,25 @@ static int vesafb_probe(struct platform_device *dev)
57288
57289 if (ypan || pmi_setpal) {
57290 unsigned short *pmi_base;
57291+
57292 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
57293- pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
57294- pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
57295+
57296+#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
57297+ pax_open_kernel();
57298+ memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
57299+#else
57300+ pmi_code = pmi_base;
57301+#endif
57302+
57303+ pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
57304+ pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
57305+
57306+#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
57307+ pmi_start = ktva_ktla(pmi_start);
57308+ pmi_pal = ktva_ktla(pmi_pal);
57309+ pax_close_kernel();
57310+#endif
57311+
57312 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
57313 if (pmi_base[3]) {
57314 printk(KERN_INFO "vesafb: pmi: ports = ");
57315@@ -477,8 +503,11 @@ static int vesafb_probe(struct platform_device *dev)
57316 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
57317 (ypan ? FBINFO_HWACCEL_YPAN : 0);
57318
57319- if (!ypan)
57320- info->fbops->fb_pan_display = NULL;
57321+ if (!ypan) {
57322+ pax_open_kernel();
57323+ *(void **)&info->fbops->fb_pan_display = NULL;
57324+ pax_close_kernel();
57325+ }
57326
57327 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
57328 err = -ENOMEM;
57329@@ -492,6 +521,11 @@ static int vesafb_probe(struct platform_device *dev)
57330 fb_info(info, "%s frame buffer device\n", info->fix.id);
57331 return 0;
57332 err:
57333+
57334+#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
57335+ module_memfree_exec(pmi_code);
57336+#endif
57337+
57338 if (info->screen_base)
57339 iounmap(info->screen_base);
57340 framebuffer_release(info);
57341diff --git a/drivers/video/fbdev/via/via_clock.h b/drivers/video/fbdev/via/via_clock.h
57342index 88714ae..16c2e11 100644
57343--- a/drivers/video/fbdev/via/via_clock.h
57344+++ b/drivers/video/fbdev/via/via_clock.h
57345@@ -56,7 +56,7 @@ struct via_clock {
57346
57347 void (*set_engine_pll_state)(u8 state);
57348 void (*set_engine_pll)(struct via_pll_config config);
57349-};
57350+} __no_const;
57351
57352
57353 static inline u32 get_pll_internal_frequency(u32 ref_freq,
57354diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
57355index 3c14e43..2630570 100644
57356--- a/drivers/video/logo/logo_linux_clut224.ppm
57357+++ b/drivers/video/logo/logo_linux_clut224.ppm
57358@@ -2,1603 +2,1123 @@ P3
57359 # Standard 224-color Linux logo
57360 80 80
57361 255
57362- 0 0 0 0 0 0 0 0 0 0 0 0
57363- 0 0 0 0 0 0 0 0 0 0 0 0
57364- 0 0 0 0 0 0 0 0 0 0 0 0
57365- 0 0 0 0 0 0 0 0 0 0 0 0
57366- 0 0 0 0 0 0 0 0 0 0 0 0
57367- 0 0 0 0 0 0 0 0 0 0 0 0
57368- 0 0 0 0 0 0 0 0 0 0 0 0
57369- 0 0 0 0 0 0 0 0 0 0 0 0
57370- 0 0 0 0 0 0 0 0 0 0 0 0
57371- 6 6 6 6 6 6 10 10 10 10 10 10
57372- 10 10 10 6 6 6 6 6 6 6 6 6
57373- 0 0 0 0 0 0 0 0 0 0 0 0
57374- 0 0 0 0 0 0 0 0 0 0 0 0
57375- 0 0 0 0 0 0 0 0 0 0 0 0
57376- 0 0 0 0 0 0 0 0 0 0 0 0
57377- 0 0 0 0 0 0 0 0 0 0 0 0
57378- 0 0 0 0 0 0 0 0 0 0 0 0
57379- 0 0 0 0 0 0 0 0 0 0 0 0
57380- 0 0 0 0 0 0 0 0 0 0 0 0
57381- 0 0 0 0 0 0 0 0 0 0 0 0
57382- 0 0 0 0 0 0 0 0 0 0 0 0
57383- 0 0 0 0 0 0 0 0 0 0 0 0
57384- 0 0 0 0 0 0 0 0 0 0 0 0
57385- 0 0 0 0 0 0 0 0 0 0 0 0
57386- 0 0 0 0 0 0 0 0 0 0 0 0
57387- 0 0 0 0 0 0 0 0 0 0 0 0
57388- 0 0 0 0 0 0 0 0 0 0 0 0
57389- 0 0 0 0 0 0 0 0 0 0 0 0
57390- 0 0 0 6 6 6 10 10 10 14 14 14
57391- 22 22 22 26 26 26 30 30 30 34 34 34
57392- 30 30 30 30 30 30 26 26 26 18 18 18
57393- 14 14 14 10 10 10 6 6 6 0 0 0
57394- 0 0 0 0 0 0 0 0 0 0 0 0
57395- 0 0 0 0 0 0 0 0 0 0 0 0
57396- 0 0 0 0 0 0 0 0 0 0 0 0
57397- 0 0 0 0 0 0 0 0 0 0 0 0
57398- 0 0 0 0 0 0 0 0 0 0 0 0
57399- 0 0 0 0 0 0 0 0 0 0 0 0
57400- 0 0 0 0 0 0 0 0 0 0 0 0
57401- 0 0 0 0 0 0 0 0 0 0 0 0
57402- 0 0 0 0 0 0 0 0 0 0 0 0
57403- 0 0 0 0 0 1 0 0 1 0 0 0
57404- 0 0 0 0 0 0 0 0 0 0 0 0
57405- 0 0 0 0 0 0 0 0 0 0 0 0
57406- 0 0 0 0 0 0 0 0 0 0 0 0
57407- 0 0 0 0 0 0 0 0 0 0 0 0
57408- 0 0 0 0 0 0 0 0 0 0 0 0
57409- 0 0 0 0 0 0 0 0 0 0 0 0
57410- 6 6 6 14 14 14 26 26 26 42 42 42
57411- 54 54 54 66 66 66 78 78 78 78 78 78
57412- 78 78 78 74 74 74 66 66 66 54 54 54
57413- 42 42 42 26 26 26 18 18 18 10 10 10
57414- 6 6 6 0 0 0 0 0 0 0 0 0
57415- 0 0 0 0 0 0 0 0 0 0 0 0
57416- 0 0 0 0 0 0 0 0 0 0 0 0
57417- 0 0 0 0 0 0 0 0 0 0 0 0
57418- 0 0 0 0 0 0 0 0 0 0 0 0
57419- 0 0 0 0 0 0 0 0 0 0 0 0
57420- 0 0 0 0 0 0 0 0 0 0 0 0
57421- 0 0 0 0 0 0 0 0 0 0 0 0
57422- 0 0 0 0 0 0 0 0 0 0 0 0
57423- 0 0 1 0 0 0 0 0 0 0 0 0
57424- 0 0 0 0 0 0 0 0 0 0 0 0
57425- 0 0 0 0 0 0 0 0 0 0 0 0
57426- 0 0 0 0 0 0 0 0 0 0 0 0
57427- 0 0 0 0 0 0 0 0 0 0 0 0
57428- 0 0 0 0 0 0 0 0 0 0 0 0
57429- 0 0 0 0 0 0 0 0 0 10 10 10
57430- 22 22 22 42 42 42 66 66 66 86 86 86
57431- 66 66 66 38 38 38 38 38 38 22 22 22
57432- 26 26 26 34 34 34 54 54 54 66 66 66
57433- 86 86 86 70 70 70 46 46 46 26 26 26
57434- 14 14 14 6 6 6 0 0 0 0 0 0
57435- 0 0 0 0 0 0 0 0 0 0 0 0
57436- 0 0 0 0 0 0 0 0 0 0 0 0
57437- 0 0 0 0 0 0 0 0 0 0 0 0
57438- 0 0 0 0 0 0 0 0 0 0 0 0
57439- 0 0 0 0 0 0 0 0 0 0 0 0
57440- 0 0 0 0 0 0 0 0 0 0 0 0
57441- 0 0 0 0 0 0 0 0 0 0 0 0
57442- 0 0 0 0 0 0 0 0 0 0 0 0
57443- 0 0 1 0 0 1 0 0 1 0 0 0
57444- 0 0 0 0 0 0 0 0 0 0 0 0
57445- 0 0 0 0 0 0 0 0 0 0 0 0
57446- 0 0 0 0 0 0 0 0 0 0 0 0
57447- 0 0 0 0 0 0 0 0 0 0 0 0
57448- 0 0 0 0 0 0 0 0 0 0 0 0
57449- 0 0 0 0 0 0 10 10 10 26 26 26
57450- 50 50 50 82 82 82 58 58 58 6 6 6
57451- 2 2 6 2 2 6 2 2 6 2 2 6
57452- 2 2 6 2 2 6 2 2 6 2 2 6
57453- 6 6 6 54 54 54 86 86 86 66 66 66
57454- 38 38 38 18 18 18 6 6 6 0 0 0
57455- 0 0 0 0 0 0 0 0 0 0 0 0
57456- 0 0 0 0 0 0 0 0 0 0 0 0
57457- 0 0 0 0 0 0 0 0 0 0 0 0
57458- 0 0 0 0 0 0 0 0 0 0 0 0
57459- 0 0 0 0 0 0 0 0 0 0 0 0
57460- 0 0 0 0 0 0 0 0 0 0 0 0
57461- 0 0 0 0 0 0 0 0 0 0 0 0
57462- 0 0 0 0 0 0 0 0 0 0 0 0
57463- 0 0 0 0 0 0 0 0 0 0 0 0
57464- 0 0 0 0 0 0 0 0 0 0 0 0
57465- 0 0 0 0 0 0 0 0 0 0 0 0
57466- 0 0 0 0 0 0 0 0 0 0 0 0
57467- 0 0 0 0 0 0 0 0 0 0 0 0
57468- 0 0 0 0 0 0 0 0 0 0 0 0
57469- 0 0 0 6 6 6 22 22 22 50 50 50
57470- 78 78 78 34 34 34 2 2 6 2 2 6
57471- 2 2 6 2 2 6 2 2 6 2 2 6
57472- 2 2 6 2 2 6 2 2 6 2 2 6
57473- 2 2 6 2 2 6 6 6 6 70 70 70
57474- 78 78 78 46 46 46 22 22 22 6 6 6
57475- 0 0 0 0 0 0 0 0 0 0 0 0
57476- 0 0 0 0 0 0 0 0 0 0 0 0
57477- 0 0 0 0 0 0 0 0 0 0 0 0
57478- 0 0 0 0 0 0 0 0 0 0 0 0
57479- 0 0 0 0 0 0 0 0 0 0 0 0
57480- 0 0 0 0 0 0 0 0 0 0 0 0
57481- 0 0 0 0 0 0 0 0 0 0 0 0
57482- 0 0 0 0 0 0 0 0 0 0 0 0
57483- 0 0 1 0 0 1 0 0 1 0 0 0
57484- 0 0 0 0 0 0 0 0 0 0 0 0
57485- 0 0 0 0 0 0 0 0 0 0 0 0
57486- 0 0 0 0 0 0 0 0 0 0 0 0
57487- 0 0 0 0 0 0 0 0 0 0 0 0
57488- 0 0 0 0 0 0 0 0 0 0 0 0
57489- 6 6 6 18 18 18 42 42 42 82 82 82
57490- 26 26 26 2 2 6 2 2 6 2 2 6
57491- 2 2 6 2 2 6 2 2 6 2 2 6
57492- 2 2 6 2 2 6 2 2 6 14 14 14
57493- 46 46 46 34 34 34 6 6 6 2 2 6
57494- 42 42 42 78 78 78 42 42 42 18 18 18
57495- 6 6 6 0 0 0 0 0 0 0 0 0
57496- 0 0 0 0 0 0 0 0 0 0 0 0
57497- 0 0 0 0 0 0 0 0 0 0 0 0
57498- 0 0 0 0 0 0 0 0 0 0 0 0
57499- 0 0 0 0 0 0 0 0 0 0 0 0
57500- 0 0 0 0 0 0 0 0 0 0 0 0
57501- 0 0 0 0 0 0 0 0 0 0 0 0
57502- 0 0 0 0 0 0 0 0 0 0 0 0
57503- 0 0 1 0 0 0 0 0 1 0 0 0
57504- 0 0 0 0 0 0 0 0 0 0 0 0
57505- 0 0 0 0 0 0 0 0 0 0 0 0
57506- 0 0 0 0 0 0 0 0 0 0 0 0
57507- 0 0 0 0 0 0 0 0 0 0 0 0
57508- 0 0 0 0 0 0 0 0 0 0 0 0
57509- 10 10 10 30 30 30 66 66 66 58 58 58
57510- 2 2 6 2 2 6 2 2 6 2 2 6
57511- 2 2 6 2 2 6 2 2 6 2 2 6
57512- 2 2 6 2 2 6 2 2 6 26 26 26
57513- 86 86 86 101 101 101 46 46 46 10 10 10
57514- 2 2 6 58 58 58 70 70 70 34 34 34
57515- 10 10 10 0 0 0 0 0 0 0 0 0
57516- 0 0 0 0 0 0 0 0 0 0 0 0
57517- 0 0 0 0 0 0 0 0 0 0 0 0
57518- 0 0 0 0 0 0 0 0 0 0 0 0
57519- 0 0 0 0 0 0 0 0 0 0 0 0
57520- 0 0 0 0 0 0 0 0 0 0 0 0
57521- 0 0 0 0 0 0 0 0 0 0 0 0
57522- 0 0 0 0 0 0 0 0 0 0 0 0
57523- 0 0 1 0 0 1 0 0 1 0 0 0
57524- 0 0 0 0 0 0 0 0 0 0 0 0
57525- 0 0 0 0 0 0 0 0 0 0 0 0
57526- 0 0 0 0 0 0 0 0 0 0 0 0
57527- 0 0 0 0 0 0 0 0 0 0 0 0
57528- 0 0 0 0 0 0 0 0 0 0 0 0
57529- 14 14 14 42 42 42 86 86 86 10 10 10
57530- 2 2 6 2 2 6 2 2 6 2 2 6
57531- 2 2 6 2 2 6 2 2 6 2 2 6
57532- 2 2 6 2 2 6 2 2 6 30 30 30
57533- 94 94 94 94 94 94 58 58 58 26 26 26
57534- 2 2 6 6 6 6 78 78 78 54 54 54
57535- 22 22 22 6 6 6 0 0 0 0 0 0
57536- 0 0 0 0 0 0 0 0 0 0 0 0
57537- 0 0 0 0 0 0 0 0 0 0 0 0
57538- 0 0 0 0 0 0 0 0 0 0 0 0
57539- 0 0 0 0 0 0 0 0 0 0 0 0
57540- 0 0 0 0 0 0 0 0 0 0 0 0
57541- 0 0 0 0 0 0 0 0 0 0 0 0
57542- 0 0 0 0 0 0 0 0 0 0 0 0
57543- 0 0 0 0 0 0 0 0 0 0 0 0
57544- 0 0 0 0 0 0 0 0 0 0 0 0
57545- 0 0 0 0 0 0 0 0 0 0 0 0
57546- 0 0 0 0 0 0 0 0 0 0 0 0
57547- 0 0 0 0 0 0 0 0 0 0 0 0
57548- 0 0 0 0 0 0 0 0 0 6 6 6
57549- 22 22 22 62 62 62 62 62 62 2 2 6
57550- 2 2 6 2 2 6 2 2 6 2 2 6
57551- 2 2 6 2 2 6 2 2 6 2 2 6
57552- 2 2 6 2 2 6 2 2 6 26 26 26
57553- 54 54 54 38 38 38 18 18 18 10 10 10
57554- 2 2 6 2 2 6 34 34 34 82 82 82
57555- 38 38 38 14 14 14 0 0 0 0 0 0
57556- 0 0 0 0 0 0 0 0 0 0 0 0
57557- 0 0 0 0 0 0 0 0 0 0 0 0
57558- 0 0 0 0 0 0 0 0 0 0 0 0
57559- 0 0 0 0 0 0 0 0 0 0 0 0
57560- 0 0 0 0 0 0 0 0 0 0 0 0
57561- 0 0 0 0 0 0 0 0 0 0 0 0
57562- 0 0 0 0 0 0 0 0 0 0 0 0
57563- 0 0 0 0 0 1 0 0 1 0 0 0
57564- 0 0 0 0 0 0 0 0 0 0 0 0
57565- 0 0 0 0 0 0 0 0 0 0 0 0
57566- 0 0 0 0 0 0 0 0 0 0 0 0
57567- 0 0 0 0 0 0 0 0 0 0 0 0
57568- 0 0 0 0 0 0 0 0 0 6 6 6
57569- 30 30 30 78 78 78 30 30 30 2 2 6
57570- 2 2 6 2 2 6 2 2 6 2 2 6
57571- 2 2 6 2 2 6 2 2 6 2 2 6
57572- 2 2 6 2 2 6 2 2 6 10 10 10
57573- 10 10 10 2 2 6 2 2 6 2 2 6
57574- 2 2 6 2 2 6 2 2 6 78 78 78
57575- 50 50 50 18 18 18 6 6 6 0 0 0
57576- 0 0 0 0 0 0 0 0 0 0 0 0
57577- 0 0 0 0 0 0 0 0 0 0 0 0
57578- 0 0 0 0 0 0 0 0 0 0 0 0
57579- 0 0 0 0 0 0 0 0 0 0 0 0
57580- 0 0 0 0 0 0 0 0 0 0 0 0
57581- 0 0 0 0 0 0 0 0 0 0 0 0
57582- 0 0 0 0 0 0 0 0 0 0 0 0
57583- 0 0 1 0 0 0 0 0 0 0 0 0
57584- 0 0 0 0 0 0 0 0 0 0 0 0
57585- 0 0 0 0 0 0 0 0 0 0 0 0
57586- 0 0 0 0 0 0 0 0 0 0 0 0
57587- 0 0 0 0 0 0 0 0 0 0 0 0
57588- 0 0 0 0 0 0 0 0 0 10 10 10
57589- 38 38 38 86 86 86 14 14 14 2 2 6
57590- 2 2 6 2 2 6 2 2 6 2 2 6
57591- 2 2 6 2 2 6 2 2 6 2 2 6
57592- 2 2 6 2 2 6 2 2 6 2 2 6
57593- 2 2 6 2 2 6 2 2 6 2 2 6
57594- 2 2 6 2 2 6 2 2 6 54 54 54
57595- 66 66 66 26 26 26 6 6 6 0 0 0
57596- 0 0 0 0 0 0 0 0 0 0 0 0
57597- 0 0 0 0 0 0 0 0 0 0 0 0
57598- 0 0 0 0 0 0 0 0 0 0 0 0
57599- 0 0 0 0 0 0 0 0 0 0 0 0
57600- 0 0 0 0 0 0 0 0 0 0 0 0
57601- 0 0 0 0 0 0 0 0 0 0 0 0
57602- 0 0 0 0 0 0 0 0 0 0 0 0
57603- 0 0 0 0 0 1 0 0 1 0 0 0
57604- 0 0 0 0 0 0 0 0 0 0 0 0
57605- 0 0 0 0 0 0 0 0 0 0 0 0
57606- 0 0 0 0 0 0 0 0 0 0 0 0
57607- 0 0 0 0 0 0 0 0 0 0 0 0
57608- 0 0 0 0 0 0 0 0 0 14 14 14
57609- 42 42 42 82 82 82 2 2 6 2 2 6
57610- 2 2 6 6 6 6 10 10 10 2 2 6
57611- 2 2 6 2 2 6 2 2 6 2 2 6
57612- 2 2 6 2 2 6 2 2 6 6 6 6
57613- 14 14 14 10 10 10 2 2 6 2 2 6
57614- 2 2 6 2 2 6 2 2 6 18 18 18
57615- 82 82 82 34 34 34 10 10 10 0 0 0
57616- 0 0 0 0 0 0 0 0 0 0 0 0
57617- 0 0 0 0 0 0 0 0 0 0 0 0
57618- 0 0 0 0 0 0 0 0 0 0 0 0
57619- 0 0 0 0 0 0 0 0 0 0 0 0
57620- 0 0 0 0 0 0 0 0 0 0 0 0
57621- 0 0 0 0 0 0 0 0 0 0 0 0
57622- 0 0 0 0 0 0 0 0 0 0 0 0
57623- 0 0 1 0 0 0 0 0 0 0 0 0
57624- 0 0 0 0 0 0 0 0 0 0 0 0
57625- 0 0 0 0 0 0 0 0 0 0 0 0
57626- 0 0 0 0 0 0 0 0 0 0 0 0
57627- 0 0 0 0 0 0 0 0 0 0 0 0
57628- 0 0 0 0 0 0 0 0 0 14 14 14
57629- 46 46 46 86 86 86 2 2 6 2 2 6
57630- 6 6 6 6 6 6 22 22 22 34 34 34
57631- 6 6 6 2 2 6 2 2 6 2 2 6
57632- 2 2 6 2 2 6 18 18 18 34 34 34
57633- 10 10 10 50 50 50 22 22 22 2 2 6
57634- 2 2 6 2 2 6 2 2 6 10 10 10
57635- 86 86 86 42 42 42 14 14 14 0 0 0
57636- 0 0 0 0 0 0 0 0 0 0 0 0
57637- 0 0 0 0 0 0 0 0 0 0 0 0
57638- 0 0 0 0 0 0 0 0 0 0 0 0
57639- 0 0 0 0 0 0 0 0 0 0 0 0
57640- 0 0 0 0 0 0 0 0 0 0 0 0
57641- 0 0 0 0 0 0 0 0 0 0 0 0
57642- 0 0 0 0 0 0 0 0 0 0 0 0
57643- 0 0 1 0 0 1 0 0 1 0 0 0
57644- 0 0 0 0 0 0 0 0 0 0 0 0
57645- 0 0 0 0 0 0 0 0 0 0 0 0
57646- 0 0 0 0 0 0 0 0 0 0 0 0
57647- 0 0 0 0 0 0 0 0 0 0 0 0
57648- 0 0 0 0 0 0 0 0 0 14 14 14
57649- 46 46 46 86 86 86 2 2 6 2 2 6
57650- 38 38 38 116 116 116 94 94 94 22 22 22
57651- 22 22 22 2 2 6 2 2 6 2 2 6
57652- 14 14 14 86 86 86 138 138 138 162 162 162
57653-154 154 154 38 38 38 26 26 26 6 6 6
57654- 2 2 6 2 2 6 2 2 6 2 2 6
57655- 86 86 86 46 46 46 14 14 14 0 0 0
57656- 0 0 0 0 0 0 0 0 0 0 0 0
57657- 0 0 0 0 0 0 0 0 0 0 0 0
57658- 0 0 0 0 0 0 0 0 0 0 0 0
57659- 0 0 0 0 0 0 0 0 0 0 0 0
57660- 0 0 0 0 0 0 0 0 0 0 0 0
57661- 0 0 0 0 0 0 0 0 0 0 0 0
57662- 0 0 0 0 0 0 0 0 0 0 0 0
57663- 0 0 0 0 0 0 0 0 0 0 0 0
57664- 0 0 0 0 0 0 0 0 0 0 0 0
57665- 0 0 0 0 0 0 0 0 0 0 0 0
57666- 0 0 0 0 0 0 0 0 0 0 0 0
57667- 0 0 0 0 0 0 0 0 0 0 0 0
57668- 0 0 0 0 0 0 0 0 0 14 14 14
57669- 46 46 46 86 86 86 2 2 6 14 14 14
57670-134 134 134 198 198 198 195 195 195 116 116 116
57671- 10 10 10 2 2 6 2 2 6 6 6 6
57672-101 98 89 187 187 187 210 210 210 218 218 218
57673-214 214 214 134 134 134 14 14 14 6 6 6
57674- 2 2 6 2 2 6 2 2 6 2 2 6
57675- 86 86 86 50 50 50 18 18 18 6 6 6
57676- 0 0 0 0 0 0 0 0 0 0 0 0
57677- 0 0 0 0 0 0 0 0 0 0 0 0
57678- 0 0 0 0 0 0 0 0 0 0 0 0
57679- 0 0 0 0 0 0 0 0 0 0 0 0
57680- 0 0 0 0 0 0 0 0 0 0 0 0
57681- 0 0 0 0 0 0 0 0 0 0 0 0
57682- 0 0 0 0 0 0 0 0 1 0 0 0
57683- 0 0 1 0 0 1 0 0 1 0 0 0
57684- 0 0 0 0 0 0 0 0 0 0 0 0
57685- 0 0 0 0 0 0 0 0 0 0 0 0
57686- 0 0 0 0 0 0 0 0 0 0 0 0
57687- 0 0 0 0 0 0 0 0 0 0 0 0
57688- 0 0 0 0 0 0 0 0 0 14 14 14
57689- 46 46 46 86 86 86 2 2 6 54 54 54
57690-218 218 218 195 195 195 226 226 226 246 246 246
57691- 58 58 58 2 2 6 2 2 6 30 30 30
57692-210 210 210 253 253 253 174 174 174 123 123 123
57693-221 221 221 234 234 234 74 74 74 2 2 6
57694- 2 2 6 2 2 6 2 2 6 2 2 6
57695- 70 70 70 58 58 58 22 22 22 6 6 6
57696- 0 0 0 0 0 0 0 0 0 0 0 0
57697- 0 0 0 0 0 0 0 0 0 0 0 0
57698- 0 0 0 0 0 0 0 0 0 0 0 0
57699- 0 0 0 0 0 0 0 0 0 0 0 0
57700- 0 0 0 0 0 0 0 0 0 0 0 0
57701- 0 0 0 0 0 0 0 0 0 0 0 0
57702- 0 0 0 0 0 0 0 0 0 0 0 0
57703- 0 0 0 0 0 0 0 0 0 0 0 0
57704- 0 0 0 0 0 0 0 0 0 0 0 0
57705- 0 0 0 0 0 0 0 0 0 0 0 0
57706- 0 0 0 0 0 0 0 0 0 0 0 0
57707- 0 0 0 0 0 0 0 0 0 0 0 0
57708- 0 0 0 0 0 0 0 0 0 14 14 14
57709- 46 46 46 82 82 82 2 2 6 106 106 106
57710-170 170 170 26 26 26 86 86 86 226 226 226
57711-123 123 123 10 10 10 14 14 14 46 46 46
57712-231 231 231 190 190 190 6 6 6 70 70 70
57713- 90 90 90 238 238 238 158 158 158 2 2 6
57714- 2 2 6 2 2 6 2 2 6 2 2 6
57715- 70 70 70 58 58 58 22 22 22 6 6 6
57716- 0 0 0 0 0 0 0 0 0 0 0 0
57717- 0 0 0 0 0 0 0 0 0 0 0 0
57718- 0 0 0 0 0 0 0 0 0 0 0 0
57719- 0 0 0 0 0 0 0 0 0 0 0 0
57720- 0 0 0 0 0 0 0 0 0 0 0 0
57721- 0 0 0 0 0 0 0 0 0 0 0 0
57722- 0 0 0 0 0 0 0 0 1 0 0 0
57723- 0 0 1 0 0 1 0 0 1 0 0 0
57724- 0 0 0 0 0 0 0 0 0 0 0 0
57725- 0 0 0 0 0 0 0 0 0 0 0 0
57726- 0 0 0 0 0 0 0 0 0 0 0 0
57727- 0 0 0 0 0 0 0 0 0 0 0 0
57728- 0 0 0 0 0 0 0 0 0 14 14 14
57729- 42 42 42 86 86 86 6 6 6 116 116 116
57730-106 106 106 6 6 6 70 70 70 149 149 149
57731-128 128 128 18 18 18 38 38 38 54 54 54
57732-221 221 221 106 106 106 2 2 6 14 14 14
57733- 46 46 46 190 190 190 198 198 198 2 2 6
57734- 2 2 6 2 2 6 2 2 6 2 2 6
57735- 74 74 74 62 62 62 22 22 22 6 6 6
57736- 0 0 0 0 0 0 0 0 0 0 0 0
57737- 0 0 0 0 0 0 0 0 0 0 0 0
57738- 0 0 0 0 0 0 0 0 0 0 0 0
57739- 0 0 0 0 0 0 0 0 0 0 0 0
57740- 0 0 0 0 0 0 0 0 0 0 0 0
57741- 0 0 0 0 0 0 0 0 0 0 0 0
57742- 0 0 0 0 0 0 0 0 1 0 0 0
57743- 0 0 1 0 0 0 0 0 1 0 0 0
57744- 0 0 0 0 0 0 0 0 0 0 0 0
57745- 0 0 0 0 0 0 0 0 0 0 0 0
57746- 0 0 0 0 0 0 0 0 0 0 0 0
57747- 0 0 0 0 0 0 0 0 0 0 0 0
57748- 0 0 0 0 0 0 0 0 0 14 14 14
57749- 42 42 42 94 94 94 14 14 14 101 101 101
57750-128 128 128 2 2 6 18 18 18 116 116 116
57751-118 98 46 121 92 8 121 92 8 98 78 10
57752-162 162 162 106 106 106 2 2 6 2 2 6
57753- 2 2 6 195 195 195 195 195 195 6 6 6
57754- 2 2 6 2 2 6 2 2 6 2 2 6
57755- 74 74 74 62 62 62 22 22 22 6 6 6
57756- 0 0 0 0 0 0 0 0 0 0 0 0
57757- 0 0 0 0 0 0 0 0 0 0 0 0
57758- 0 0 0 0 0 0 0 0 0 0 0 0
57759- 0 0 0 0 0 0 0 0 0 0 0 0
57760- 0 0 0 0 0 0 0 0 0 0 0 0
57761- 0 0 0 0 0 0 0 0 0 0 0 0
57762- 0 0 0 0 0 0 0 0 1 0 0 1
57763- 0 0 1 0 0 0 0 0 1 0 0 0
57764- 0 0 0 0 0 0 0 0 0 0 0 0
57765- 0 0 0 0 0 0 0 0 0 0 0 0
57766- 0 0 0 0 0 0 0 0 0 0 0 0
57767- 0 0 0 0 0 0 0 0 0 0 0 0
57768- 0 0 0 0 0 0 0 0 0 10 10 10
57769- 38 38 38 90 90 90 14 14 14 58 58 58
57770-210 210 210 26 26 26 54 38 6 154 114 10
57771-226 170 11 236 186 11 225 175 15 184 144 12
57772-215 174 15 175 146 61 37 26 9 2 2 6
57773- 70 70 70 246 246 246 138 138 138 2 2 6
57774- 2 2 6 2 2 6 2 2 6 2 2 6
57775- 70 70 70 66 66 66 26 26 26 6 6 6
57776- 0 0 0 0 0 0 0 0 0 0 0 0
57777- 0 0 0 0 0 0 0 0 0 0 0 0
57778- 0 0 0 0 0 0 0 0 0 0 0 0
57779- 0 0 0 0 0 0 0 0 0 0 0 0
57780- 0 0 0 0 0 0 0 0 0 0 0 0
57781- 0 0 0 0 0 0 0 0 0 0 0 0
57782- 0 0 0 0 0 0 0 0 0 0 0 0
57783- 0 0 0 0 0 0 0 0 0 0 0 0
57784- 0 0 0 0 0 0 0 0 0 0 0 0
57785- 0 0 0 0 0 0 0 0 0 0 0 0
57786- 0 0 0 0 0 0 0 0 0 0 0 0
57787- 0 0 0 0 0 0 0 0 0 0 0 0
57788- 0 0 0 0 0 0 0 0 0 10 10 10
57789- 38 38 38 86 86 86 14 14 14 10 10 10
57790-195 195 195 188 164 115 192 133 9 225 175 15
57791-239 182 13 234 190 10 232 195 16 232 200 30
57792-245 207 45 241 208 19 232 195 16 184 144 12
57793-218 194 134 211 206 186 42 42 42 2 2 6
57794- 2 2 6 2 2 6 2 2 6 2 2 6
57795- 50 50 50 74 74 74 30 30 30 6 6 6
57796- 0 0 0 0 0 0 0 0 0 0 0 0
57797- 0 0 0 0 0 0 0 0 0 0 0 0
57798- 0 0 0 0 0 0 0 0 0 0 0 0
57799- 0 0 0 0 0 0 0 0 0 0 0 0
57800- 0 0 0 0 0 0 0 0 0 0 0 0
57801- 0 0 0 0 0 0 0 0 0 0 0 0
57802- 0 0 0 0 0 0 0 0 0 0 0 0
57803- 0 0 0 0 0 0 0 0 0 0 0 0
57804- 0 0 0 0 0 0 0 0 0 0 0 0
57805- 0 0 0 0 0 0 0 0 0 0 0 0
57806- 0 0 0 0 0 0 0 0 0 0 0 0
57807- 0 0 0 0 0 0 0 0 0 0 0 0
57808- 0 0 0 0 0 0 0 0 0 10 10 10
57809- 34 34 34 86 86 86 14 14 14 2 2 6
57810-121 87 25 192 133 9 219 162 10 239 182 13
57811-236 186 11 232 195 16 241 208 19 244 214 54
57812-246 218 60 246 218 38 246 215 20 241 208 19
57813-241 208 19 226 184 13 121 87 25 2 2 6
57814- 2 2 6 2 2 6 2 2 6 2 2 6
57815- 50 50 50 82 82 82 34 34 34 10 10 10
57816- 0 0 0 0 0 0 0 0 0 0 0 0
57817- 0 0 0 0 0 0 0 0 0 0 0 0
57818- 0 0 0 0 0 0 0 0 0 0 0 0
57819- 0 0 0 0 0 0 0 0 0 0 0 0
57820- 0 0 0 0 0 0 0 0 0 0 0 0
57821- 0 0 0 0 0 0 0 0 0 0 0 0
57822- 0 0 0 0 0 0 0 0 0 0 0 0
57823- 0 0 0 0 0 0 0 0 0 0 0 0
57824- 0 0 0 0 0 0 0 0 0 0 0 0
57825- 0 0 0 0 0 0 0 0 0 0 0 0
57826- 0 0 0 0 0 0 0 0 0 0 0 0
57827- 0 0 0 0 0 0 0 0 0 0 0 0
57828- 0 0 0 0 0 0 0 0 0 10 10 10
57829- 34 34 34 82 82 82 30 30 30 61 42 6
57830-180 123 7 206 145 10 230 174 11 239 182 13
57831-234 190 10 238 202 15 241 208 19 246 218 74
57832-246 218 38 246 215 20 246 215 20 246 215 20
57833-226 184 13 215 174 15 184 144 12 6 6 6
57834- 2 2 6 2 2 6 2 2 6 2 2 6
57835- 26 26 26 94 94 94 42 42 42 14 14 14
57836- 0 0 0 0 0 0 0 0 0 0 0 0
57837- 0 0 0 0 0 0 0 0 0 0 0 0
57838- 0 0 0 0 0 0 0 0 0 0 0 0
57839- 0 0 0 0 0 0 0 0 0 0 0 0
57840- 0 0 0 0 0 0 0 0 0 0 0 0
57841- 0 0 0 0 0 0 0 0 0 0 0 0
57842- 0 0 0 0 0 0 0 0 0 0 0 0
57843- 0 0 0 0 0 0 0 0 0 0 0 0
57844- 0 0 0 0 0 0 0 0 0 0 0 0
57845- 0 0 0 0 0 0 0 0 0 0 0 0
57846- 0 0 0 0 0 0 0 0 0 0 0 0
57847- 0 0 0 0 0 0 0 0 0 0 0 0
57848- 0 0 0 0 0 0 0 0 0 10 10 10
57849- 30 30 30 78 78 78 50 50 50 104 69 6
57850-192 133 9 216 158 10 236 178 12 236 186 11
57851-232 195 16 241 208 19 244 214 54 245 215 43
57852-246 215 20 246 215 20 241 208 19 198 155 10
57853-200 144 11 216 158 10 156 118 10 2 2 6
57854- 2 2 6 2 2 6 2 2 6 2 2 6
57855- 6 6 6 90 90 90 54 54 54 18 18 18
57856- 6 6 6 0 0 0 0 0 0 0 0 0
57857- 0 0 0 0 0 0 0 0 0 0 0 0
57858- 0 0 0 0 0 0 0 0 0 0 0 0
57859- 0 0 0 0 0 0 0 0 0 0 0 0
57860- 0 0 0 0 0 0 0 0 0 0 0 0
57861- 0 0 0 0 0 0 0 0 0 0 0 0
57862- 0 0 0 0 0 0 0 0 0 0 0 0
57863- 0 0 0 0 0 0 0 0 0 0 0 0
57864- 0 0 0 0 0 0 0 0 0 0 0 0
57865- 0 0 0 0 0 0 0 0 0 0 0 0
57866- 0 0 0 0 0 0 0 0 0 0 0 0
57867- 0 0 0 0 0 0 0 0 0 0 0 0
57868- 0 0 0 0 0 0 0 0 0 10 10 10
57869- 30 30 30 78 78 78 46 46 46 22 22 22
57870-137 92 6 210 162 10 239 182 13 238 190 10
57871-238 202 15 241 208 19 246 215 20 246 215 20
57872-241 208 19 203 166 17 185 133 11 210 150 10
57873-216 158 10 210 150 10 102 78 10 2 2 6
57874- 6 6 6 54 54 54 14 14 14 2 2 6
57875- 2 2 6 62 62 62 74 74 74 30 30 30
57876- 10 10 10 0 0 0 0 0 0 0 0 0
57877- 0 0 0 0 0 0 0 0 0 0 0 0
57878- 0 0 0 0 0 0 0 0 0 0 0 0
57879- 0 0 0 0 0 0 0 0 0 0 0 0
57880- 0 0 0 0 0 0 0 0 0 0 0 0
57881- 0 0 0 0 0 0 0 0 0 0 0 0
57882- 0 0 0 0 0 0 0 0 0 0 0 0
57883- 0 0 0 0 0 0 0 0 0 0 0 0
57884- 0 0 0 0 0 0 0 0 0 0 0 0
57885- 0 0 0 0 0 0 0 0 0 0 0 0
57886- 0 0 0 0 0 0 0 0 0 0 0 0
57887- 0 0 0 0 0 0 0 0 0 0 0 0
57888- 0 0 0 0 0 0 0 0 0 10 10 10
57889- 34 34 34 78 78 78 50 50 50 6 6 6
57890- 94 70 30 139 102 15 190 146 13 226 184 13
57891-232 200 30 232 195 16 215 174 15 190 146 13
57892-168 122 10 192 133 9 210 150 10 213 154 11
57893-202 150 34 182 157 106 101 98 89 2 2 6
57894- 2 2 6 78 78 78 116 116 116 58 58 58
57895- 2 2 6 22 22 22 90 90 90 46 46 46
57896- 18 18 18 6 6 6 0 0 0 0 0 0
57897- 0 0 0 0 0 0 0 0 0 0 0 0
57898- 0 0 0 0 0 0 0 0 0 0 0 0
57899- 0 0 0 0 0 0 0 0 0 0 0 0
57900- 0 0 0 0 0 0 0 0 0 0 0 0
57901- 0 0 0 0 0 0 0 0 0 0 0 0
57902- 0 0 0 0 0 0 0 0 0 0 0 0
57903- 0 0 0 0 0 0 0 0 0 0 0 0
57904- 0 0 0 0 0 0 0 0 0 0 0 0
57905- 0 0 0 0 0 0 0 0 0 0 0 0
57906- 0 0 0 0 0 0 0 0 0 0 0 0
57907- 0 0 0 0 0 0 0 0 0 0 0 0
57908- 0 0 0 0 0 0 0 0 0 10 10 10
57909- 38 38 38 86 86 86 50 50 50 6 6 6
57910-128 128 128 174 154 114 156 107 11 168 122 10
57911-198 155 10 184 144 12 197 138 11 200 144 11
57912-206 145 10 206 145 10 197 138 11 188 164 115
57913-195 195 195 198 198 198 174 174 174 14 14 14
57914- 2 2 6 22 22 22 116 116 116 116 116 116
57915- 22 22 22 2 2 6 74 74 74 70 70 70
57916- 30 30 30 10 10 10 0 0 0 0 0 0
57917- 0 0 0 0 0 0 0 0 0 0 0 0
57918- 0 0 0 0 0 0 0 0 0 0 0 0
57919- 0 0 0 0 0 0 0 0 0 0 0 0
57920- 0 0 0 0 0 0 0 0 0 0 0 0
57921- 0 0 0 0 0 0 0 0 0 0 0 0
57922- 0 0 0 0 0 0 0 0 0 0 0 0
57923- 0 0 0 0 0 0 0 0 0 0 0 0
57924- 0 0 0 0 0 0 0 0 0 0 0 0
57925- 0 0 0 0 0 0 0 0 0 0 0 0
57926- 0 0 0 0 0 0 0 0 0 0 0 0
57927- 0 0 0 0 0 0 0 0 0 0 0 0
57928- 0 0 0 0 0 0 6 6 6 18 18 18
57929- 50 50 50 101 101 101 26 26 26 10 10 10
57930-138 138 138 190 190 190 174 154 114 156 107 11
57931-197 138 11 200 144 11 197 138 11 192 133 9
57932-180 123 7 190 142 34 190 178 144 187 187 187
57933-202 202 202 221 221 221 214 214 214 66 66 66
57934- 2 2 6 2 2 6 50 50 50 62 62 62
57935- 6 6 6 2 2 6 10 10 10 90 90 90
57936- 50 50 50 18 18 18 6 6 6 0 0 0
57937- 0 0 0 0 0 0 0 0 0 0 0 0
57938- 0 0 0 0 0 0 0 0 0 0 0 0
57939- 0 0 0 0 0 0 0 0 0 0 0 0
57940- 0 0 0 0 0 0 0 0 0 0 0 0
57941- 0 0 0 0 0 0 0 0 0 0 0 0
57942- 0 0 0 0 0 0 0 0 0 0 0 0
57943- 0 0 0 0 0 0 0 0 0 0 0 0
57944- 0 0 0 0 0 0 0 0 0 0 0 0
57945- 0 0 0 0 0 0 0 0 0 0 0 0
57946- 0 0 0 0 0 0 0 0 0 0 0 0
57947- 0 0 0 0 0 0 0 0 0 0 0 0
57948- 0 0 0 0 0 0 10 10 10 34 34 34
57949- 74 74 74 74 74 74 2 2 6 6 6 6
57950-144 144 144 198 198 198 190 190 190 178 166 146
57951-154 121 60 156 107 11 156 107 11 168 124 44
57952-174 154 114 187 187 187 190 190 190 210 210 210
57953-246 246 246 253 253 253 253 253 253 182 182 182
57954- 6 6 6 2 2 6 2 2 6 2 2 6
57955- 2 2 6 2 2 6 2 2 6 62 62 62
57956- 74 74 74 34 34 34 14 14 14 0 0 0
57957- 0 0 0 0 0 0 0 0 0 0 0 0
57958- 0 0 0 0 0 0 0 0 0 0 0 0
57959- 0 0 0 0 0 0 0 0 0 0 0 0
57960- 0 0 0 0 0 0 0 0 0 0 0 0
57961- 0 0 0 0 0 0 0 0 0 0 0 0
57962- 0 0 0 0 0 0 0 0 0 0 0 0
57963- 0 0 0 0 0 0 0 0 0 0 0 0
57964- 0 0 0 0 0 0 0 0 0 0 0 0
57965- 0 0 0 0 0 0 0 0 0 0 0 0
57966- 0 0 0 0 0 0 0 0 0 0 0 0
57967- 0 0 0 0 0 0 0 0 0 0 0 0
57968- 0 0 0 10 10 10 22 22 22 54 54 54
57969- 94 94 94 18 18 18 2 2 6 46 46 46
57970-234 234 234 221 221 221 190 190 190 190 190 190
57971-190 190 190 187 187 187 187 187 187 190 190 190
57972-190 190 190 195 195 195 214 214 214 242 242 242
57973-253 253 253 253 253 253 253 253 253 253 253 253
57974- 82 82 82 2 2 6 2 2 6 2 2 6
57975- 2 2 6 2 2 6 2 2 6 14 14 14
57976- 86 86 86 54 54 54 22 22 22 6 6 6
57977- 0 0 0 0 0 0 0 0 0 0 0 0
57978- 0 0 0 0 0 0 0 0 0 0 0 0
57979- 0 0 0 0 0 0 0 0 0 0 0 0
57980- 0 0 0 0 0 0 0 0 0 0 0 0
57981- 0 0 0 0 0 0 0 0 0 0 0 0
57982- 0 0 0 0 0 0 0 0 0 0 0 0
57983- 0 0 0 0 0 0 0 0 0 0 0 0
57984- 0 0 0 0 0 0 0 0 0 0 0 0
57985- 0 0 0 0 0 0 0 0 0 0 0 0
57986- 0 0 0 0 0 0 0 0 0 0 0 0
57987- 0 0 0 0 0 0 0 0 0 0 0 0
57988- 6 6 6 18 18 18 46 46 46 90 90 90
57989- 46 46 46 18 18 18 6 6 6 182 182 182
57990-253 253 253 246 246 246 206 206 206 190 190 190
57991-190 190 190 190 190 190 190 190 190 190 190 190
57992-206 206 206 231 231 231 250 250 250 253 253 253
57993-253 253 253 253 253 253 253 253 253 253 253 253
57994-202 202 202 14 14 14 2 2 6 2 2 6
57995- 2 2 6 2 2 6 2 2 6 2 2 6
57996- 42 42 42 86 86 86 42 42 42 18 18 18
57997- 6 6 6 0 0 0 0 0 0 0 0 0
57998- 0 0 0 0 0 0 0 0 0 0 0 0
57999- 0 0 0 0 0 0 0 0 0 0 0 0
58000- 0 0 0 0 0 0 0 0 0 0 0 0
58001- 0 0 0 0 0 0 0 0 0 0 0 0
58002- 0 0 0 0 0 0 0 0 0 0 0 0
58003- 0 0 0 0 0 0 0 0 0 0 0 0
58004- 0 0 0 0 0 0 0 0 0 0 0 0
58005- 0 0 0 0 0 0 0 0 0 0 0 0
58006- 0 0 0 0 0 0 0 0 0 0 0 0
58007- 0 0 0 0 0 0 0 0 0 6 6 6
58008- 14 14 14 38 38 38 74 74 74 66 66 66
58009- 2 2 6 6 6 6 90 90 90 250 250 250
58010-253 253 253 253 253 253 238 238 238 198 198 198
58011-190 190 190 190 190 190 195 195 195 221 221 221
58012-246 246 246 253 253 253 253 253 253 253 253 253
58013-253 253 253 253 253 253 253 253 253 253 253 253
58014-253 253 253 82 82 82 2 2 6 2 2 6
58015- 2 2 6 2 2 6 2 2 6 2 2 6
58016- 2 2 6 78 78 78 70 70 70 34 34 34
58017- 14 14 14 6 6 6 0 0 0 0 0 0
58018- 0 0 0 0 0 0 0 0 0 0 0 0
58019- 0 0 0 0 0 0 0 0 0 0 0 0
58020- 0 0 0 0 0 0 0 0 0 0 0 0
58021- 0 0 0 0 0 0 0 0 0 0 0 0
58022- 0 0 0 0 0 0 0 0 0 0 0 0
58023- 0 0 0 0 0 0 0 0 0 0 0 0
58024- 0 0 0 0 0 0 0 0 0 0 0 0
58025- 0 0 0 0 0 0 0 0 0 0 0 0
58026- 0 0 0 0 0 0 0 0 0 0 0 0
58027- 0 0 0 0 0 0 0 0 0 14 14 14
58028- 34 34 34 66 66 66 78 78 78 6 6 6
58029- 2 2 6 18 18 18 218 218 218 253 253 253
58030-253 253 253 253 253 253 253 253 253 246 246 246
58031-226 226 226 231 231 231 246 246 246 253 253 253
58032-253 253 253 253 253 253 253 253 253 253 253 253
58033-253 253 253 253 253 253 253 253 253 253 253 253
58034-253 253 253 178 178 178 2 2 6 2 2 6
58035- 2 2 6 2 2 6 2 2 6 2 2 6
58036- 2 2 6 18 18 18 90 90 90 62 62 62
58037- 30 30 30 10 10 10 0 0 0 0 0 0
58038- 0 0 0 0 0 0 0 0 0 0 0 0
58039- 0 0 0 0 0 0 0 0 0 0 0 0
58040- 0 0 0 0 0 0 0 0 0 0 0 0
58041- 0 0 0 0 0 0 0 0 0 0 0 0
58042- 0 0 0 0 0 0 0 0 0 0 0 0
58043- 0 0 0 0 0 0 0 0 0 0 0 0
58044- 0 0 0 0 0 0 0 0 0 0 0 0
58045- 0 0 0 0 0 0 0 0 0 0 0 0
58046- 0 0 0 0 0 0 0 0 0 0 0 0
58047- 0 0 0 0 0 0 10 10 10 26 26 26
58048- 58 58 58 90 90 90 18 18 18 2 2 6
58049- 2 2 6 110 110 110 253 253 253 253 253 253
58050-253 253 253 253 253 253 253 253 253 253 253 253
58051-250 250 250 253 253 253 253 253 253 253 253 253
58052-253 253 253 253 253 253 253 253 253 253 253 253
58053-253 253 253 253 253 253 253 253 253 253 253 253
58054-253 253 253 231 231 231 18 18 18 2 2 6
58055- 2 2 6 2 2 6 2 2 6 2 2 6
58056- 2 2 6 2 2 6 18 18 18 94 94 94
58057- 54 54 54 26 26 26 10 10 10 0 0 0
58058- 0 0 0 0 0 0 0 0 0 0 0 0
58059- 0 0 0 0 0 0 0 0 0 0 0 0
58060- 0 0 0 0 0 0 0 0 0 0 0 0
58061- 0 0 0 0 0 0 0 0 0 0 0 0
58062- 0 0 0 0 0 0 0 0 0 0 0 0
58063- 0 0 0 0 0 0 0 0 0 0 0 0
58064- 0 0 0 0 0 0 0 0 0 0 0 0
58065- 0 0 0 0 0 0 0 0 0 0 0 0
58066- 0 0 0 0 0 0 0 0 0 0 0 0
58067- 0 0 0 6 6 6 22 22 22 50 50 50
58068- 90 90 90 26 26 26 2 2 6 2 2 6
58069- 14 14 14 195 195 195 250 250 250 253 253 253
58070-253 253 253 253 253 253 253 253 253 253 253 253
58071-253 253 253 253 253 253 253 253 253 253 253 253
58072-253 253 253 253 253 253 253 253 253 253 253 253
58073-253 253 253 253 253 253 253 253 253 253 253 253
58074-250 250 250 242 242 242 54 54 54 2 2 6
58075- 2 2 6 2 2 6 2 2 6 2 2 6
58076- 2 2 6 2 2 6 2 2 6 38 38 38
58077- 86 86 86 50 50 50 22 22 22 6 6 6
58078- 0 0 0 0 0 0 0 0 0 0 0 0
58079- 0 0 0 0 0 0 0 0 0 0 0 0
58080- 0 0 0 0 0 0 0 0 0 0 0 0
58081- 0 0 0 0 0 0 0 0 0 0 0 0
58082- 0 0 0 0 0 0 0 0 0 0 0 0
58083- 0 0 0 0 0 0 0 0 0 0 0 0
58084- 0 0 0 0 0 0 0 0 0 0 0 0
58085- 0 0 0 0 0 0 0 0 0 0 0 0
58086- 0 0 0 0 0 0 0 0 0 0 0 0
58087- 6 6 6 14 14 14 38 38 38 82 82 82
58088- 34 34 34 2 2 6 2 2 6 2 2 6
58089- 42 42 42 195 195 195 246 246 246 253 253 253
58090-253 253 253 253 253 253 253 253 253 250 250 250
58091-242 242 242 242 242 242 250 250 250 253 253 253
58092-253 253 253 253 253 253 253 253 253 253 253 253
58093-253 253 253 250 250 250 246 246 246 238 238 238
58094-226 226 226 231 231 231 101 101 101 6 6 6
58095- 2 2 6 2 2 6 2 2 6 2 2 6
58096- 2 2 6 2 2 6 2 2 6 2 2 6
58097- 38 38 38 82 82 82 42 42 42 14 14 14
58098- 6 6 6 0 0 0 0 0 0 0 0 0
58099- 0 0 0 0 0 0 0 0 0 0 0 0
58100- 0 0 0 0 0 0 0 0 0 0 0 0
58101- 0 0 0 0 0 0 0 0 0 0 0 0
58102- 0 0 0 0 0 0 0 0 0 0 0 0
58103- 0 0 0 0 0 0 0 0 0 0 0 0
58104- 0 0 0 0 0 0 0 0 0 0 0 0
58105- 0 0 0 0 0 0 0 0 0 0 0 0
58106- 0 0 0 0 0 0 0 0 0 0 0 0
58107- 10 10 10 26 26 26 62 62 62 66 66 66
58108- 2 2 6 2 2 6 2 2 6 6 6 6
58109- 70 70 70 170 170 170 206 206 206 234 234 234
58110-246 246 246 250 250 250 250 250 250 238 238 238
58111-226 226 226 231 231 231 238 238 238 250 250 250
58112-250 250 250 250 250 250 246 246 246 231 231 231
58113-214 214 214 206 206 206 202 202 202 202 202 202
58114-198 198 198 202 202 202 182 182 182 18 18 18
58115- 2 2 6 2 2 6 2 2 6 2 2 6
58116- 2 2 6 2 2 6 2 2 6 2 2 6
58117- 2 2 6 62 62 62 66 66 66 30 30 30
58118- 10 10 10 0 0 0 0 0 0 0 0 0
58119- 0 0 0 0 0 0 0 0 0 0 0 0
58120- 0 0 0 0 0 0 0 0 0 0 0 0
58121- 0 0 0 0 0 0 0 0 0 0 0 0
58122- 0 0 0 0 0 0 0 0 0 0 0 0
58123- 0 0 0 0 0 0 0 0 0 0 0 0
58124- 0 0 0 0 0 0 0 0 0 0 0 0
58125- 0 0 0 0 0 0 0 0 0 0 0 0
58126- 0 0 0 0 0 0 0 0 0 0 0 0
58127- 14 14 14 42 42 42 82 82 82 18 18 18
58128- 2 2 6 2 2 6 2 2 6 10 10 10
58129- 94 94 94 182 182 182 218 218 218 242 242 242
58130-250 250 250 253 253 253 253 253 253 250 250 250
58131-234 234 234 253 253 253 253 253 253 253 253 253
58132-253 253 253 253 253 253 253 253 253 246 246 246
58133-238 238 238 226 226 226 210 210 210 202 202 202
58134-195 195 195 195 195 195 210 210 210 158 158 158
58135- 6 6 6 14 14 14 50 50 50 14 14 14
58136- 2 2 6 2 2 6 2 2 6 2 2 6
58137- 2 2 6 6 6 6 86 86 86 46 46 46
58138- 18 18 18 6 6 6 0 0 0 0 0 0
58139- 0 0 0 0 0 0 0 0 0 0 0 0
58140- 0 0 0 0 0 0 0 0 0 0 0 0
58141- 0 0 0 0 0 0 0 0 0 0 0 0
58142- 0 0 0 0 0 0 0 0 0 0 0 0
58143- 0 0 0 0 0 0 0 0 0 0 0 0
58144- 0 0 0 0 0 0 0 0 0 0 0 0
58145- 0 0 0 0 0 0 0 0 0 0 0 0
58146- 0 0 0 0 0 0 0 0 0 6 6 6
58147- 22 22 22 54 54 54 70 70 70 2 2 6
58148- 2 2 6 10 10 10 2 2 6 22 22 22
58149-166 166 166 231 231 231 250 250 250 253 253 253
58150-253 253 253 253 253 253 253 253 253 250 250 250
58151-242 242 242 253 253 253 253 253 253 253 253 253
58152-253 253 253 253 253 253 253 253 253 253 253 253
58153-253 253 253 253 253 253 253 253 253 246 246 246
58154-231 231 231 206 206 206 198 198 198 226 226 226
58155- 94 94 94 2 2 6 6 6 6 38 38 38
58156- 30 30 30 2 2 6 2 2 6 2 2 6
58157- 2 2 6 2 2 6 62 62 62 66 66 66
58158- 26 26 26 10 10 10 0 0 0 0 0 0
58159- 0 0 0 0 0 0 0 0 0 0 0 0
58160- 0 0 0 0 0 0 0 0 0 0 0 0
58161- 0 0 0 0 0 0 0 0 0 0 0 0
58162- 0 0 0 0 0 0 0 0 0 0 0 0
58163- 0 0 0 0 0 0 0 0 0 0 0 0
58164- 0 0 0 0 0 0 0 0 0 0 0 0
58165- 0 0 0 0 0 0 0 0 0 0 0 0
58166- 0 0 0 0 0 0 0 0 0 10 10 10
58167- 30 30 30 74 74 74 50 50 50 2 2 6
58168- 26 26 26 26 26 26 2 2 6 106 106 106
58169-238 238 238 253 253 253 253 253 253 253 253 253
58170-253 253 253 253 253 253 253 253 253 253 253 253
58171-253 253 253 253 253 253 253 253 253 253 253 253
58172-253 253 253 253 253 253 253 253 253 253 253 253
58173-253 253 253 253 253 253 253 253 253 253 253 253
58174-253 253 253 246 246 246 218 218 218 202 202 202
58175-210 210 210 14 14 14 2 2 6 2 2 6
58176- 30 30 30 22 22 22 2 2 6 2 2 6
58177- 2 2 6 2 2 6 18 18 18 86 86 86
58178- 42 42 42 14 14 14 0 0 0 0 0 0
58179- 0 0 0 0 0 0 0 0 0 0 0 0
58180- 0 0 0 0 0 0 0 0 0 0 0 0
58181- 0 0 0 0 0 0 0 0 0 0 0 0
58182- 0 0 0 0 0 0 0 0 0 0 0 0
58183- 0 0 0 0 0 0 0 0 0 0 0 0
58184- 0 0 0 0 0 0 0 0 0 0 0 0
58185- 0 0 0 0 0 0 0 0 0 0 0 0
58186- 0 0 0 0 0 0 0 0 0 14 14 14
58187- 42 42 42 90 90 90 22 22 22 2 2 6
58188- 42 42 42 2 2 6 18 18 18 218 218 218
58189-253 253 253 253 253 253 253 253 253 253 253 253
58190-253 253 253 253 253 253 253 253 253 253 253 253
58191-253 253 253 253 253 253 253 253 253 253 253 253
58192-253 253 253 253 253 253 253 253 253 253 253 253
58193-253 253 253 253 253 253 253 253 253 253 253 253
58194-253 253 253 253 253 253 250 250 250 221 221 221
58195-218 218 218 101 101 101 2 2 6 14 14 14
58196- 18 18 18 38 38 38 10 10 10 2 2 6
58197- 2 2 6 2 2 6 2 2 6 78 78 78
58198- 58 58 58 22 22 22 6 6 6 0 0 0
58199- 0 0 0 0 0 0 0 0 0 0 0 0
58200- 0 0 0 0 0 0 0 0 0 0 0 0
58201- 0 0 0 0 0 0 0 0 0 0 0 0
58202- 0 0 0 0 0 0 0 0 0 0 0 0
58203- 0 0 0 0 0 0 0 0 0 0 0 0
58204- 0 0 0 0 0 0 0 0 0 0 0 0
58205- 0 0 0 0 0 0 0 0 0 0 0 0
58206- 0 0 0 0 0 0 6 6 6 18 18 18
58207- 54 54 54 82 82 82 2 2 6 26 26 26
58208- 22 22 22 2 2 6 123 123 123 253 253 253
58209-253 253 253 253 253 253 253 253 253 253 253 253
58210-253 253 253 253 253 253 253 253 253 253 253 253
58211-253 253 253 253 253 253 253 253 253 253 253 253
58212-253 253 253 253 253 253 253 253 253 253 253 253
58213-253 253 253 253 253 253 253 253 253 253 253 253
58214-253 253 253 253 253 253 253 253 253 250 250 250
58215-238 238 238 198 198 198 6 6 6 38 38 38
58216- 58 58 58 26 26 26 38 38 38 2 2 6
58217- 2 2 6 2 2 6 2 2 6 46 46 46
58218- 78 78 78 30 30 30 10 10 10 0 0 0
58219- 0 0 0 0 0 0 0 0 0 0 0 0
58220- 0 0 0 0 0 0 0 0 0 0 0 0
58221- 0 0 0 0 0 0 0 0 0 0 0 0
58222- 0 0 0 0 0 0 0 0 0 0 0 0
58223- 0 0 0 0 0 0 0 0 0 0 0 0
58224- 0 0 0 0 0 0 0 0 0 0 0 0
58225- 0 0 0 0 0 0 0 0 0 0 0 0
58226- 0 0 0 0 0 0 10 10 10 30 30 30
58227- 74 74 74 58 58 58 2 2 6 42 42 42
58228- 2 2 6 22 22 22 231 231 231 253 253 253
58229-253 253 253 253 253 253 253 253 253 253 253 253
58230-253 253 253 253 253 253 253 253 253 250 250 250
58231-253 253 253 253 253 253 253 253 253 253 253 253
58232-253 253 253 253 253 253 253 253 253 253 253 253
58233-253 253 253 253 253 253 253 253 253 253 253 253
58234-253 253 253 253 253 253 253 253 253 253 253 253
58235-253 253 253 246 246 246 46 46 46 38 38 38
58236- 42 42 42 14 14 14 38 38 38 14 14 14
58237- 2 2 6 2 2 6 2 2 6 6 6 6
58238- 86 86 86 46 46 46 14 14 14 0 0 0
58239- 0 0 0 0 0 0 0 0 0 0 0 0
58240- 0 0 0 0 0 0 0 0 0 0 0 0
58241- 0 0 0 0 0 0 0 0 0 0 0 0
58242- 0 0 0 0 0 0 0 0 0 0 0 0
58243- 0 0 0 0 0 0 0 0 0 0 0 0
58244- 0 0 0 0 0 0 0 0 0 0 0 0
58245- 0 0 0 0 0 0 0 0 0 0 0 0
58246- 0 0 0 6 6 6 14 14 14 42 42 42
58247- 90 90 90 18 18 18 18 18 18 26 26 26
58248- 2 2 6 116 116 116 253 253 253 253 253 253
58249-253 253 253 253 253 253 253 253 253 253 253 253
58250-253 253 253 253 253 253 250 250 250 238 238 238
58251-253 253 253 253 253 253 253 253 253 253 253 253
58252-253 253 253 253 253 253 253 253 253 253 253 253
58253-253 253 253 253 253 253 253 253 253 253 253 253
58254-253 253 253 253 253 253 253 253 253 253 253 253
58255-253 253 253 253 253 253 94 94 94 6 6 6
58256- 2 2 6 2 2 6 10 10 10 34 34 34
58257- 2 2 6 2 2 6 2 2 6 2 2 6
58258- 74 74 74 58 58 58 22 22 22 6 6 6
58259- 0 0 0 0 0 0 0 0 0 0 0 0
58260- 0 0 0 0 0 0 0 0 0 0 0 0
58261- 0 0 0 0 0 0 0 0 0 0 0 0
58262- 0 0 0 0 0 0 0 0 0 0 0 0
58263- 0 0 0 0 0 0 0 0 0 0 0 0
58264- 0 0 0 0 0 0 0 0 0 0 0 0
58265- 0 0 0 0 0 0 0 0 0 0 0 0
58266- 0 0 0 10 10 10 26 26 26 66 66 66
58267- 82 82 82 2 2 6 38 38 38 6 6 6
58268- 14 14 14 210 210 210 253 253 253 253 253 253
58269-253 253 253 253 253 253 253 253 253 253 253 253
58270-253 253 253 253 253 253 246 246 246 242 242 242
58271-253 253 253 253 253 253 253 253 253 253 253 253
58272-253 253 253 253 253 253 253 253 253 253 253 253
58273-253 253 253 253 253 253 253 253 253 253 253 253
58274-253 253 253 253 253 253 253 253 253 253 253 253
58275-253 253 253 253 253 253 144 144 144 2 2 6
58276- 2 2 6 2 2 6 2 2 6 46 46 46
58277- 2 2 6 2 2 6 2 2 6 2 2 6
58278- 42 42 42 74 74 74 30 30 30 10 10 10
58279- 0 0 0 0 0 0 0 0 0 0 0 0
58280- 0 0 0 0 0 0 0 0 0 0 0 0
58281- 0 0 0 0 0 0 0 0 0 0 0 0
58282- 0 0 0 0 0 0 0 0 0 0 0 0
58283- 0 0 0 0 0 0 0 0 0 0 0 0
58284- 0 0 0 0 0 0 0 0 0 0 0 0
58285- 0 0 0 0 0 0 0 0 0 0 0 0
58286- 6 6 6 14 14 14 42 42 42 90 90 90
58287- 26 26 26 6 6 6 42 42 42 2 2 6
58288- 74 74 74 250 250 250 253 253 253 253 253 253
58289-253 253 253 253 253 253 253 253 253 253 253 253
58290-253 253 253 253 253 253 242 242 242 242 242 242
58291-253 253 253 253 253 253 253 253 253 253 253 253
58292-253 253 253 253 253 253 253 253 253 253 253 253
58293-253 253 253 253 253 253 253 253 253 253 253 253
58294-253 253 253 253 253 253 253 253 253 253 253 253
58295-253 253 253 253 253 253 182 182 182 2 2 6
58296- 2 2 6 2 2 6 2 2 6 46 46 46
58297- 2 2 6 2 2 6 2 2 6 2 2 6
58298- 10 10 10 86 86 86 38 38 38 10 10 10
58299- 0 0 0 0 0 0 0 0 0 0 0 0
58300- 0 0 0 0 0 0 0 0 0 0 0 0
58301- 0 0 0 0 0 0 0 0 0 0 0 0
58302- 0 0 0 0 0 0 0 0 0 0 0 0
58303- 0 0 0 0 0 0 0 0 0 0 0 0
58304- 0 0 0 0 0 0 0 0 0 0 0 0
58305- 0 0 0 0 0 0 0 0 0 0 0 0
58306- 10 10 10 26 26 26 66 66 66 82 82 82
58307- 2 2 6 22 22 22 18 18 18 2 2 6
58308-149 149 149 253 253 253 253 253 253 253 253 253
58309-253 253 253 253 253 253 253 253 253 253 253 253
58310-253 253 253 253 253 253 234 234 234 242 242 242
58311-253 253 253 253 253 253 253 253 253 253 253 253
58312-253 253 253 253 253 253 253 253 253 253 253 253
58313-253 253 253 253 253 253 253 253 253 253 253 253
58314-253 253 253 253 253 253 253 253 253 253 253 253
58315-253 253 253 253 253 253 206 206 206 2 2 6
58316- 2 2 6 2 2 6 2 2 6 38 38 38
58317- 2 2 6 2 2 6 2 2 6 2 2 6
58318- 6 6 6 86 86 86 46 46 46 14 14 14
58319- 0 0 0 0 0 0 0 0 0 0 0 0
58320- 0 0 0 0 0 0 0 0 0 0 0 0
58321- 0 0 0 0 0 0 0 0 0 0 0 0
58322- 0 0 0 0 0 0 0 0 0 0 0 0
58323- 0 0 0 0 0 0 0 0 0 0 0 0
58324- 0 0 0 0 0 0 0 0 0 0 0 0
58325- 0 0 0 0 0 0 0 0 0 6 6 6
58326- 18 18 18 46 46 46 86 86 86 18 18 18
58327- 2 2 6 34 34 34 10 10 10 6 6 6
58328-210 210 210 253 253 253 253 253 253 253 253 253
58329-253 253 253 253 253 253 253 253 253 253 253 253
58330-253 253 253 253 253 253 234 234 234 242 242 242
58331-253 253 253 253 253 253 253 253 253 253 253 253
58332-253 253 253 253 253 253 253 253 253 253 253 253
58333-253 253 253 253 253 253 253 253 253 253 253 253
58334-253 253 253 253 253 253 253 253 253 253 253 253
58335-253 253 253 253 253 253 221 221 221 6 6 6
58336- 2 2 6 2 2 6 6 6 6 30 30 30
58337- 2 2 6 2 2 6 2 2 6 2 2 6
58338- 2 2 6 82 82 82 54 54 54 18 18 18
58339- 6 6 6 0 0 0 0 0 0 0 0 0
58340- 0 0 0 0 0 0 0 0 0 0 0 0
58341- 0 0 0 0 0 0 0 0 0 0 0 0
58342- 0 0 0 0 0 0 0 0 0 0 0 0
58343- 0 0 0 0 0 0 0 0 0 0 0 0
58344- 0 0 0 0 0 0 0 0 0 0 0 0
58345- 0 0 0 0 0 0 0 0 0 10 10 10
58346- 26 26 26 66 66 66 62 62 62 2 2 6
58347- 2 2 6 38 38 38 10 10 10 26 26 26
58348-238 238 238 253 253 253 253 253 253 253 253 253
58349-253 253 253 253 253 253 253 253 253 253 253 253
58350-253 253 253 253 253 253 231 231 231 238 238 238
58351-253 253 253 253 253 253 253 253 253 253 253 253
58352-253 253 253 253 253 253 253 253 253 253 253 253
58353-253 253 253 253 253 253 253 253 253 253 253 253
58354-253 253 253 253 253 253 253 253 253 253 253 253
58355-253 253 253 253 253 253 231 231 231 6 6 6
58356- 2 2 6 2 2 6 10 10 10 30 30 30
58357- 2 2 6 2 2 6 2 2 6 2 2 6
58358- 2 2 6 66 66 66 58 58 58 22 22 22
58359- 6 6 6 0 0 0 0 0 0 0 0 0
58360- 0 0 0 0 0 0 0 0 0 0 0 0
58361- 0 0 0 0 0 0 0 0 0 0 0 0
58362- 0 0 0 0 0 0 0 0 0 0 0 0
58363- 0 0 0 0 0 0 0 0 0 0 0 0
58364- 0 0 0 0 0 0 0 0 0 0 0 0
58365- 0 0 0 0 0 0 0 0 0 10 10 10
58366- 38 38 38 78 78 78 6 6 6 2 2 6
58367- 2 2 6 46 46 46 14 14 14 42 42 42
58368-246 246 246 253 253 253 253 253 253 253 253 253
58369-253 253 253 253 253 253 253 253 253 253 253 253
58370-253 253 253 253 253 253 231 231 231 242 242 242
58371-253 253 253 253 253 253 253 253 253 253 253 253
58372-253 253 253 253 253 253 253 253 253 253 253 253
58373-253 253 253 253 253 253 253 253 253 253 253 253
58374-253 253 253 253 253 253 253 253 253 253 253 253
58375-253 253 253 253 253 253 234 234 234 10 10 10
58376- 2 2 6 2 2 6 22 22 22 14 14 14
58377- 2 2 6 2 2 6 2 2 6 2 2 6
58378- 2 2 6 66 66 66 62 62 62 22 22 22
58379- 6 6 6 0 0 0 0 0 0 0 0 0
58380- 0 0 0 0 0 0 0 0 0 0 0 0
58381- 0 0 0 0 0 0 0 0 0 0 0 0
58382- 0 0 0 0 0 0 0 0 0 0 0 0
58383- 0 0 0 0 0 0 0 0 0 0 0 0
58384- 0 0 0 0 0 0 0 0 0 0 0 0
58385- 0 0 0 0 0 0 6 6 6 18 18 18
58386- 50 50 50 74 74 74 2 2 6 2 2 6
58387- 14 14 14 70 70 70 34 34 34 62 62 62
58388-250 250 250 253 253 253 253 253 253 253 253 253
58389-253 253 253 253 253 253 253 253 253 253 253 253
58390-253 253 253 253 253 253 231 231 231 246 246 246
58391-253 253 253 253 253 253 253 253 253 253 253 253
58392-253 253 253 253 253 253 253 253 253 253 253 253
58393-253 253 253 253 253 253 253 253 253 253 253 253
58394-253 253 253 253 253 253 253 253 253 253 253 253
58395-253 253 253 253 253 253 234 234 234 14 14 14
58396- 2 2 6 2 2 6 30 30 30 2 2 6
58397- 2 2 6 2 2 6 2 2 6 2 2 6
58398- 2 2 6 66 66 66 62 62 62 22 22 22
58399- 6 6 6 0 0 0 0 0 0 0 0 0
58400- 0 0 0 0 0 0 0 0 0 0 0 0
58401- 0 0 0 0 0 0 0 0 0 0 0 0
58402- 0 0 0 0 0 0 0 0 0 0 0 0
58403- 0 0 0 0 0 0 0 0 0 0 0 0
58404- 0 0 0 0 0 0 0 0 0 0 0 0
58405- 0 0 0 0 0 0 6 6 6 18 18 18
58406- 54 54 54 62 62 62 2 2 6 2 2 6
58407- 2 2 6 30 30 30 46 46 46 70 70 70
58408-250 250 250 253 253 253 253 253 253 253 253 253
58409-253 253 253 253 253 253 253 253 253 253 253 253
58410-253 253 253 253 253 253 231 231 231 246 246 246
58411-253 253 253 253 253 253 253 253 253 253 253 253
58412-253 253 253 253 253 253 253 253 253 253 253 253
58413-253 253 253 253 253 253 253 253 253 253 253 253
58414-253 253 253 253 253 253 253 253 253 253 253 253
58415-253 253 253 253 253 253 226 226 226 10 10 10
58416- 2 2 6 6 6 6 30 30 30 2 2 6
58417- 2 2 6 2 2 6 2 2 6 2 2 6
58418- 2 2 6 66 66 66 58 58 58 22 22 22
58419- 6 6 6 0 0 0 0 0 0 0 0 0
58420- 0 0 0 0 0 0 0 0 0 0 0 0
58421- 0 0 0 0 0 0 0 0 0 0 0 0
58422- 0 0 0 0 0 0 0 0 0 0 0 0
58423- 0 0 0 0 0 0 0 0 0 0 0 0
58424- 0 0 0 0 0 0 0 0 0 0 0 0
58425- 0 0 0 0 0 0 6 6 6 22 22 22
58426- 58 58 58 62 62 62 2 2 6 2 2 6
58427- 2 2 6 2 2 6 30 30 30 78 78 78
58428-250 250 250 253 253 253 253 253 253 253 253 253
58429-253 253 253 253 253 253 253 253 253 253 253 253
58430-253 253 253 253 253 253 231 231 231 246 246 246
58431-253 253 253 253 253 253 253 253 253 253 253 253
58432-253 253 253 253 253 253 253 253 253 253 253 253
58433-253 253 253 253 253 253 253 253 253 253 253 253
58434-253 253 253 253 253 253 253 253 253 253 253 253
58435-253 253 253 253 253 253 206 206 206 2 2 6
58436- 22 22 22 34 34 34 18 14 6 22 22 22
58437- 26 26 26 18 18 18 6 6 6 2 2 6
58438- 2 2 6 82 82 82 54 54 54 18 18 18
58439- 6 6 6 0 0 0 0 0 0 0 0 0
58440- 0 0 0 0 0 0 0 0 0 0 0 0
58441- 0 0 0 0 0 0 0 0 0 0 0 0
58442- 0 0 0 0 0 0 0 0 0 0 0 0
58443- 0 0 0 0 0 0 0 0 0 0 0 0
58444- 0 0 0 0 0 0 0 0 0 0 0 0
58445- 0 0 0 0 0 0 6 6 6 26 26 26
58446- 62 62 62 106 106 106 74 54 14 185 133 11
58447-210 162 10 121 92 8 6 6 6 62 62 62
58448-238 238 238 253 253 253 253 253 253 253 253 253
58449-253 253 253 253 253 253 253 253 253 253 253 253
58450-253 253 253 253 253 253 231 231 231 246 246 246
58451-253 253 253 253 253 253 253 253 253 253 253 253
58452-253 253 253 253 253 253 253 253 253 253 253 253
58453-253 253 253 253 253 253 253 253 253 253 253 253
58454-253 253 253 253 253 253 253 253 253 253 253 253
58455-253 253 253 253 253 253 158 158 158 18 18 18
58456- 14 14 14 2 2 6 2 2 6 2 2 6
58457- 6 6 6 18 18 18 66 66 66 38 38 38
58458- 6 6 6 94 94 94 50 50 50 18 18 18
58459- 6 6 6 0 0 0 0 0 0 0 0 0
58460- 0 0 0 0 0 0 0 0 0 0 0 0
58461- 0 0 0 0 0 0 0 0 0 0 0 0
58462- 0 0 0 0 0 0 0 0 0 0 0 0
58463- 0 0 0 0 0 0 0 0 0 0 0 0
58464- 0 0 0 0 0 0 0 0 0 6 6 6
58465- 10 10 10 10 10 10 18 18 18 38 38 38
58466- 78 78 78 142 134 106 216 158 10 242 186 14
58467-246 190 14 246 190 14 156 118 10 10 10 10
58468- 90 90 90 238 238 238 253 253 253 253 253 253
58469-253 253 253 253 253 253 253 253 253 253 253 253
58470-253 253 253 253 253 253 231 231 231 250 250 250
58471-253 253 253 253 253 253 253 253 253 253 253 253
58472-253 253 253 253 253 253 253 253 253 253 253 253
58473-253 253 253 253 253 253 253 253 253 253 253 253
58474-253 253 253 253 253 253 253 253 253 246 230 190
58475-238 204 91 238 204 91 181 142 44 37 26 9
58476- 2 2 6 2 2 6 2 2 6 2 2 6
58477- 2 2 6 2 2 6 38 38 38 46 46 46
58478- 26 26 26 106 106 106 54 54 54 18 18 18
58479- 6 6 6 0 0 0 0 0 0 0 0 0
58480- 0 0 0 0 0 0 0 0 0 0 0 0
58481- 0 0 0 0 0 0 0 0 0 0 0 0
58482- 0 0 0 0 0 0 0 0 0 0 0 0
58483- 0 0 0 0 0 0 0 0 0 0 0 0
58484- 0 0 0 6 6 6 14 14 14 22 22 22
58485- 30 30 30 38 38 38 50 50 50 70 70 70
58486-106 106 106 190 142 34 226 170 11 242 186 14
58487-246 190 14 246 190 14 246 190 14 154 114 10
58488- 6 6 6 74 74 74 226 226 226 253 253 253
58489-253 253 253 253 253 253 253 253 253 253 253 253
58490-253 253 253 253 253 253 231 231 231 250 250 250
58491-253 253 253 253 253 253 253 253 253 253 253 253
58492-253 253 253 253 253 253 253 253 253 253 253 253
58493-253 253 253 253 253 253 253 253 253 253 253 253
58494-253 253 253 253 253 253 253 253 253 228 184 62
58495-241 196 14 241 208 19 232 195 16 38 30 10
58496- 2 2 6 2 2 6 2 2 6 2 2 6
58497- 2 2 6 6 6 6 30 30 30 26 26 26
58498-203 166 17 154 142 90 66 66 66 26 26 26
58499- 6 6 6 0 0 0 0 0 0 0 0 0
58500- 0 0 0 0 0 0 0 0 0 0 0 0
58501- 0 0 0 0 0 0 0 0 0 0 0 0
58502- 0 0 0 0 0 0 0 0 0 0 0 0
58503- 0 0 0 0 0 0 0 0 0 0 0 0
58504- 6 6 6 18 18 18 38 38 38 58 58 58
58505- 78 78 78 86 86 86 101 101 101 123 123 123
58506-175 146 61 210 150 10 234 174 13 246 186 14
58507-246 190 14 246 190 14 246 190 14 238 190 10
58508-102 78 10 2 2 6 46 46 46 198 198 198
58509-253 253 253 253 253 253 253 253 253 253 253 253
58510-253 253 253 253 253 253 234 234 234 242 242 242
58511-253 253 253 253 253 253 253 253 253 253 253 253
58512-253 253 253 253 253 253 253 253 253 253 253 253
58513-253 253 253 253 253 253 253 253 253 253 253 253
58514-253 253 253 253 253 253 253 253 253 224 178 62
58515-242 186 14 241 196 14 210 166 10 22 18 6
58516- 2 2 6 2 2 6 2 2 6 2 2 6
58517- 2 2 6 2 2 6 6 6 6 121 92 8
58518-238 202 15 232 195 16 82 82 82 34 34 34
58519- 10 10 10 0 0 0 0 0 0 0 0 0
58520- 0 0 0 0 0 0 0 0 0 0 0 0
58521- 0 0 0 0 0 0 0 0 0 0 0 0
58522- 0 0 0 0 0 0 0 0 0 0 0 0
58523- 0 0 0 0 0 0 0 0 0 0 0 0
58524- 14 14 14 38 38 38 70 70 70 154 122 46
58525-190 142 34 200 144 11 197 138 11 197 138 11
58526-213 154 11 226 170 11 242 186 14 246 190 14
58527-246 190 14 246 190 14 246 190 14 246 190 14
58528-225 175 15 46 32 6 2 2 6 22 22 22
58529-158 158 158 250 250 250 253 253 253 253 253 253
58530-253 253 253 253 253 253 253 253 253 253 253 253
58531-253 253 253 253 253 253 253 253 253 253 253 253
58532-253 253 253 253 253 253 253 253 253 253 253 253
58533-253 253 253 253 253 253 253 253 253 253 253 253
58534-253 253 253 250 250 250 242 242 242 224 178 62
58535-239 182 13 236 186 11 213 154 11 46 32 6
58536- 2 2 6 2 2 6 2 2 6 2 2 6
58537- 2 2 6 2 2 6 61 42 6 225 175 15
58538-238 190 10 236 186 11 112 100 78 42 42 42
58539- 14 14 14 0 0 0 0 0 0 0 0 0
58540- 0 0 0 0 0 0 0 0 0 0 0 0
58541- 0 0 0 0 0 0 0 0 0 0 0 0
58542- 0 0 0 0 0 0 0 0 0 0 0 0
58543- 0 0 0 0 0 0 0 0 0 6 6 6
58544- 22 22 22 54 54 54 154 122 46 213 154 11
58545-226 170 11 230 174 11 226 170 11 226 170 11
58546-236 178 12 242 186 14 246 190 14 246 190 14
58547-246 190 14 246 190 14 246 190 14 246 190 14
58548-241 196 14 184 144 12 10 10 10 2 2 6
58549- 6 6 6 116 116 116 242 242 242 253 253 253
58550-253 253 253 253 253 253 253 253 253 253 253 253
58551-253 253 253 253 253 253 253 253 253 253 253 253
58552-253 253 253 253 253 253 253 253 253 253 253 253
58553-253 253 253 253 253 253 253 253 253 253 253 253
58554-253 253 253 231 231 231 198 198 198 214 170 54
58555-236 178 12 236 178 12 210 150 10 137 92 6
58556- 18 14 6 2 2 6 2 2 6 2 2 6
58557- 6 6 6 70 47 6 200 144 11 236 178 12
58558-239 182 13 239 182 13 124 112 88 58 58 58
58559- 22 22 22 6 6 6 0 0 0 0 0 0
58560- 0 0 0 0 0 0 0 0 0 0 0 0
58561- 0 0 0 0 0 0 0 0 0 0 0 0
58562- 0 0 0 0 0 0 0 0 0 0 0 0
58563- 0 0 0 0 0 0 0 0 0 10 10 10
58564- 30 30 30 70 70 70 180 133 36 226 170 11
58565-239 182 13 242 186 14 242 186 14 246 186 14
58566-246 190 14 246 190 14 246 190 14 246 190 14
58567-246 190 14 246 190 14 246 190 14 246 190 14
58568-246 190 14 232 195 16 98 70 6 2 2 6
58569- 2 2 6 2 2 6 66 66 66 221 221 221
58570-253 253 253 253 253 253 253 253 253 253 253 253
58571-253 253 253 253 253 253 253 253 253 253 253 253
58572-253 253 253 253 253 253 253 253 253 253 253 253
58573-253 253 253 253 253 253 253 253 253 253 253 253
58574-253 253 253 206 206 206 198 198 198 214 166 58
58575-230 174 11 230 174 11 216 158 10 192 133 9
58576-163 110 8 116 81 8 102 78 10 116 81 8
58577-167 114 7 197 138 11 226 170 11 239 182 13
58578-242 186 14 242 186 14 162 146 94 78 78 78
58579- 34 34 34 14 14 14 6 6 6 0 0 0
58580- 0 0 0 0 0 0 0 0 0 0 0 0
58581- 0 0 0 0 0 0 0 0 0 0 0 0
58582- 0 0 0 0 0 0 0 0 0 0 0 0
58583- 0 0 0 0 0 0 0 0 0 6 6 6
58584- 30 30 30 78 78 78 190 142 34 226 170 11
58585-239 182 13 246 190 14 246 190 14 246 190 14
58586-246 190 14 246 190 14 246 190 14 246 190 14
58587-246 190 14 246 190 14 246 190 14 246 190 14
58588-246 190 14 241 196 14 203 166 17 22 18 6
58589- 2 2 6 2 2 6 2 2 6 38 38 38
58590-218 218 218 253 253 253 253 253 253 253 253 253
58591-253 253 253 253 253 253 253 253 253 253 253 253
58592-253 253 253 253 253 253 253 253 253 253 253 253
58593-253 253 253 253 253 253 253 253 253 253 253 253
58594-250 250 250 206 206 206 198 198 198 202 162 69
58595-226 170 11 236 178 12 224 166 10 210 150 10
58596-200 144 11 197 138 11 192 133 9 197 138 11
58597-210 150 10 226 170 11 242 186 14 246 190 14
58598-246 190 14 246 186 14 225 175 15 124 112 88
58599- 62 62 62 30 30 30 14 14 14 6 6 6
58600- 0 0 0 0 0 0 0 0 0 0 0 0
58601- 0 0 0 0 0 0 0 0 0 0 0 0
58602- 0 0 0 0 0 0 0 0 0 0 0 0
58603- 0 0 0 0 0 0 0 0 0 10 10 10
58604- 30 30 30 78 78 78 174 135 50 224 166 10
58605-239 182 13 246 190 14 246 190 14 246 190 14
58606-246 190 14 246 190 14 246 190 14 246 190 14
58607-246 190 14 246 190 14 246 190 14 246 190 14
58608-246 190 14 246 190 14 241 196 14 139 102 15
58609- 2 2 6 2 2 6 2 2 6 2 2 6
58610- 78 78 78 250 250 250 253 253 253 253 253 253
58611-253 253 253 253 253 253 253 253 253 253 253 253
58612-253 253 253 253 253 253 253 253 253 253 253 253
58613-253 253 253 253 253 253 253 253 253 253 253 253
58614-250 250 250 214 214 214 198 198 198 190 150 46
58615-219 162 10 236 178 12 234 174 13 224 166 10
58616-216 158 10 213 154 11 213 154 11 216 158 10
58617-226 170 11 239 182 13 246 190 14 246 190 14
58618-246 190 14 246 190 14 242 186 14 206 162 42
58619-101 101 101 58 58 58 30 30 30 14 14 14
58620- 6 6 6 0 0 0 0 0 0 0 0 0
58621- 0 0 0 0 0 0 0 0 0 0 0 0
58622- 0 0 0 0 0 0 0 0 0 0 0 0
58623- 0 0 0 0 0 0 0 0 0 10 10 10
58624- 30 30 30 74 74 74 174 135 50 216 158 10
58625-236 178 12 246 190 14 246 190 14 246 190 14
58626-246 190 14 246 190 14 246 190 14 246 190 14
58627-246 190 14 246 190 14 246 190 14 246 190 14
58628-246 190 14 246 190 14 241 196 14 226 184 13
58629- 61 42 6 2 2 6 2 2 6 2 2 6
58630- 22 22 22 238 238 238 253 253 253 253 253 253
58631-253 253 253 253 253 253 253 253 253 253 253 253
58632-253 253 253 253 253 253 253 253 253 253 253 253
58633-253 253 253 253 253 253 253 253 253 253 253 253
58634-253 253 253 226 226 226 187 187 187 180 133 36
58635-216 158 10 236 178 12 239 182 13 236 178 12
58636-230 174 11 226 170 11 226 170 11 230 174 11
58637-236 178 12 242 186 14 246 190 14 246 190 14
58638-246 190 14 246 190 14 246 186 14 239 182 13
58639-206 162 42 106 106 106 66 66 66 34 34 34
58640- 14 14 14 6 6 6 0 0 0 0 0 0
58641- 0 0 0 0 0 0 0 0 0 0 0 0
58642- 0 0 0 0 0 0 0 0 0 0 0 0
58643- 0 0 0 0 0 0 0 0 0 6 6 6
58644- 26 26 26 70 70 70 163 133 67 213 154 11
58645-236 178 12 246 190 14 246 190 14 246 190 14
58646-246 190 14 246 190 14 246 190 14 246 190 14
58647-246 190 14 246 190 14 246 190 14 246 190 14
58648-246 190 14 246 190 14 246 190 14 241 196 14
58649-190 146 13 18 14 6 2 2 6 2 2 6
58650- 46 46 46 246 246 246 253 253 253 253 253 253
58651-253 253 253 253 253 253 253 253 253 253 253 253
58652-253 253 253 253 253 253 253 253 253 253 253 253
58653-253 253 253 253 253 253 253 253 253 253 253 253
58654-253 253 253 221 221 221 86 86 86 156 107 11
58655-216 158 10 236 178 12 242 186 14 246 186 14
58656-242 186 14 239 182 13 239 182 13 242 186 14
58657-242 186 14 246 186 14 246 190 14 246 190 14
58658-246 190 14 246 190 14 246 190 14 246 190 14
58659-242 186 14 225 175 15 142 122 72 66 66 66
58660- 30 30 30 10 10 10 0 0 0 0 0 0
58661- 0 0 0 0 0 0 0 0 0 0 0 0
58662- 0 0 0 0 0 0 0 0 0 0 0 0
58663- 0 0 0 0 0 0 0 0 0 6 6 6
58664- 26 26 26 70 70 70 163 133 67 210 150 10
58665-236 178 12 246 190 14 246 190 14 246 190 14
58666-246 190 14 246 190 14 246 190 14 246 190 14
58667-246 190 14 246 190 14 246 190 14 246 190 14
58668-246 190 14 246 190 14 246 190 14 246 190 14
58669-232 195 16 121 92 8 34 34 34 106 106 106
58670-221 221 221 253 253 253 253 253 253 253 253 253
58671-253 253 253 253 253 253 253 253 253 253 253 253
58672-253 253 253 253 253 253 253 253 253 253 253 253
58673-253 253 253 253 253 253 253 253 253 253 253 253
58674-242 242 242 82 82 82 18 14 6 163 110 8
58675-216 158 10 236 178 12 242 186 14 246 190 14
58676-246 190 14 246 190 14 246 190 14 246 190 14
58677-246 190 14 246 190 14 246 190 14 246 190 14
58678-246 190 14 246 190 14 246 190 14 246 190 14
58679-246 190 14 246 190 14 242 186 14 163 133 67
58680- 46 46 46 18 18 18 6 6 6 0 0 0
58681- 0 0 0 0 0 0 0 0 0 0 0 0
58682- 0 0 0 0 0 0 0 0 0 0 0 0
58683- 0 0 0 0 0 0 0 0 0 10 10 10
58684- 30 30 30 78 78 78 163 133 67 210 150 10
58685-236 178 12 246 186 14 246 190 14 246 190 14
58686-246 190 14 246 190 14 246 190 14 246 190 14
58687-246 190 14 246 190 14 246 190 14 246 190 14
58688-246 190 14 246 190 14 246 190 14 246 190 14
58689-241 196 14 215 174 15 190 178 144 253 253 253
58690-253 253 253 253 253 253 253 253 253 253 253 253
58691-253 253 253 253 253 253 253 253 253 253 253 253
58692-253 253 253 253 253 253 253 253 253 253 253 253
58693-253 253 253 253 253 253 253 253 253 218 218 218
58694- 58 58 58 2 2 6 22 18 6 167 114 7
58695-216 158 10 236 178 12 246 186 14 246 190 14
58696-246 190 14 246 190 14 246 190 14 246 190 14
58697-246 190 14 246 190 14 246 190 14 246 190 14
58698-246 190 14 246 190 14 246 190 14 246 190 14
58699-246 190 14 246 186 14 242 186 14 190 150 46
58700- 54 54 54 22 22 22 6 6 6 0 0 0
58701- 0 0 0 0 0 0 0 0 0 0 0 0
58702- 0 0 0 0 0 0 0 0 0 0 0 0
58703- 0 0 0 0 0 0 0 0 0 14 14 14
58704- 38 38 38 86 86 86 180 133 36 213 154 11
58705-236 178 12 246 186 14 246 190 14 246 190 14
58706-246 190 14 246 190 14 246 190 14 246 190 14
58707-246 190 14 246 190 14 246 190 14 246 190 14
58708-246 190 14 246 190 14 246 190 14 246 190 14
58709-246 190 14 232 195 16 190 146 13 214 214 214
58710-253 253 253 253 253 253 253 253 253 253 253 253
58711-253 253 253 253 253 253 253 253 253 253 253 253
58712-253 253 253 253 253 253 253 253 253 253 253 253
58713-253 253 253 250 250 250 170 170 170 26 26 26
58714- 2 2 6 2 2 6 37 26 9 163 110 8
58715-219 162 10 239 182 13 246 186 14 246 190 14
58716-246 190 14 246 190 14 246 190 14 246 190 14
58717-246 190 14 246 190 14 246 190 14 246 190 14
58718-246 190 14 246 190 14 246 190 14 246 190 14
58719-246 186 14 236 178 12 224 166 10 142 122 72
58720- 46 46 46 18 18 18 6 6 6 0 0 0
58721- 0 0 0 0 0 0 0 0 0 0 0 0
58722- 0 0 0 0 0 0 0 0 0 0 0 0
58723- 0 0 0 0 0 0 6 6 6 18 18 18
58724- 50 50 50 109 106 95 192 133 9 224 166 10
58725-242 186 14 246 190 14 246 190 14 246 190 14
58726-246 190 14 246 190 14 246 190 14 246 190 14
58727-246 190 14 246 190 14 246 190 14 246 190 14
58728-246 190 14 246 190 14 246 190 14 246 190 14
58729-242 186 14 226 184 13 210 162 10 142 110 46
58730-226 226 226 253 253 253 253 253 253 253 253 253
58731-253 253 253 253 253 253 253 253 253 253 253 253
58732-253 253 253 253 253 253 253 253 253 253 253 253
58733-198 198 198 66 66 66 2 2 6 2 2 6
58734- 2 2 6 2 2 6 50 34 6 156 107 11
58735-219 162 10 239 182 13 246 186 14 246 190 14
58736-246 190 14 246 190 14 246 190 14 246 190 14
58737-246 190 14 246 190 14 246 190 14 246 190 14
58738-246 190 14 246 190 14 246 190 14 242 186 14
58739-234 174 13 213 154 11 154 122 46 66 66 66
58740- 30 30 30 10 10 10 0 0 0 0 0 0
58741- 0 0 0 0 0 0 0 0 0 0 0 0
58742- 0 0 0 0 0 0 0 0 0 0 0 0
58743- 0 0 0 0 0 0 6 6 6 22 22 22
58744- 58 58 58 154 121 60 206 145 10 234 174 13
58745-242 186 14 246 186 14 246 190 14 246 190 14
58746-246 190 14 246 190 14 246 190 14 246 190 14
58747-246 190 14 246 190 14 246 190 14 246 190 14
58748-246 190 14 246 190 14 246 190 14 246 190 14
58749-246 186 14 236 178 12 210 162 10 163 110 8
58750- 61 42 6 138 138 138 218 218 218 250 250 250
58751-253 253 253 253 253 253 253 253 253 250 250 250
58752-242 242 242 210 210 210 144 144 144 66 66 66
58753- 6 6 6 2 2 6 2 2 6 2 2 6
58754- 2 2 6 2 2 6 61 42 6 163 110 8
58755-216 158 10 236 178 12 246 190 14 246 190 14
58756-246 190 14 246 190 14 246 190 14 246 190 14
58757-246 190 14 246 190 14 246 190 14 246 190 14
58758-246 190 14 239 182 13 230 174 11 216 158 10
58759-190 142 34 124 112 88 70 70 70 38 38 38
58760- 18 18 18 6 6 6 0 0 0 0 0 0
58761- 0 0 0 0 0 0 0 0 0 0 0 0
58762- 0 0 0 0 0 0 0 0 0 0 0 0
58763- 0 0 0 0 0 0 6 6 6 22 22 22
58764- 62 62 62 168 124 44 206 145 10 224 166 10
58765-236 178 12 239 182 13 242 186 14 242 186 14
58766-246 186 14 246 190 14 246 190 14 246 190 14
58767-246 190 14 246 190 14 246 190 14 246 190 14
58768-246 190 14 246 190 14 246 190 14 246 190 14
58769-246 190 14 236 178 12 216 158 10 175 118 6
58770- 80 54 7 2 2 6 6 6 6 30 30 30
58771- 54 54 54 62 62 62 50 50 50 38 38 38
58772- 14 14 14 2 2 6 2 2 6 2 2 6
58773- 2 2 6 2 2 6 2 2 6 2 2 6
58774- 2 2 6 6 6 6 80 54 7 167 114 7
58775-213 154 11 236 178 12 246 190 14 246 190 14
58776-246 190 14 246 190 14 246 190 14 246 190 14
58777-246 190 14 242 186 14 239 182 13 239 182 13
58778-230 174 11 210 150 10 174 135 50 124 112 88
58779- 82 82 82 54 54 54 34 34 34 18 18 18
58780- 6 6 6 0 0 0 0 0 0 0 0 0
58781- 0 0 0 0 0 0 0 0 0 0 0 0
58782- 0 0 0 0 0 0 0 0 0 0 0 0
58783- 0 0 0 0 0 0 6 6 6 18 18 18
58784- 50 50 50 158 118 36 192 133 9 200 144 11
58785-216 158 10 219 162 10 224 166 10 226 170 11
58786-230 174 11 236 178 12 239 182 13 239 182 13
58787-242 186 14 246 186 14 246 190 14 246 190 14
58788-246 190 14 246 190 14 246 190 14 246 190 14
58789-246 186 14 230 174 11 210 150 10 163 110 8
58790-104 69 6 10 10 10 2 2 6 2 2 6
58791- 2 2 6 2 2 6 2 2 6 2 2 6
58792- 2 2 6 2 2 6 2 2 6 2 2 6
58793- 2 2 6 2 2 6 2 2 6 2 2 6
58794- 2 2 6 6 6 6 91 60 6 167 114 7
58795-206 145 10 230 174 11 242 186 14 246 190 14
58796-246 190 14 246 190 14 246 186 14 242 186 14
58797-239 182 13 230 174 11 224 166 10 213 154 11
58798-180 133 36 124 112 88 86 86 86 58 58 58
58799- 38 38 38 22 22 22 10 10 10 6 6 6
58800- 0 0 0 0 0 0 0 0 0 0 0 0
58801- 0 0 0 0 0 0 0 0 0 0 0 0
58802- 0 0 0 0 0 0 0 0 0 0 0 0
58803- 0 0 0 0 0 0 0 0 0 14 14 14
58804- 34 34 34 70 70 70 138 110 50 158 118 36
58805-167 114 7 180 123 7 192 133 9 197 138 11
58806-200 144 11 206 145 10 213 154 11 219 162 10
58807-224 166 10 230 174 11 239 182 13 242 186 14
58808-246 186 14 246 186 14 246 186 14 246 186 14
58809-239 182 13 216 158 10 185 133 11 152 99 6
58810-104 69 6 18 14 6 2 2 6 2 2 6
58811- 2 2 6 2 2 6 2 2 6 2 2 6
58812- 2 2 6 2 2 6 2 2 6 2 2 6
58813- 2 2 6 2 2 6 2 2 6 2 2 6
58814- 2 2 6 6 6 6 80 54 7 152 99 6
58815-192 133 9 219 162 10 236 178 12 239 182 13
58816-246 186 14 242 186 14 239 182 13 236 178 12
58817-224 166 10 206 145 10 192 133 9 154 121 60
58818- 94 94 94 62 62 62 42 42 42 22 22 22
58819- 14 14 14 6 6 6 0 0 0 0 0 0
58820- 0 0 0 0 0 0 0 0 0 0 0 0
58821- 0 0 0 0 0 0 0 0 0 0 0 0
58822- 0 0 0 0 0 0 0 0 0 0 0 0
58823- 0 0 0 0 0 0 0 0 0 6 6 6
58824- 18 18 18 34 34 34 58 58 58 78 78 78
58825-101 98 89 124 112 88 142 110 46 156 107 11
58826-163 110 8 167 114 7 175 118 6 180 123 7
58827-185 133 11 197 138 11 210 150 10 219 162 10
58828-226 170 11 236 178 12 236 178 12 234 174 13
58829-219 162 10 197 138 11 163 110 8 130 83 6
58830- 91 60 6 10 10 10 2 2 6 2 2 6
58831- 18 18 18 38 38 38 38 38 38 38 38 38
58832- 38 38 38 38 38 38 38 38 38 38 38 38
58833- 38 38 38 38 38 38 26 26 26 2 2 6
58834- 2 2 6 6 6 6 70 47 6 137 92 6
58835-175 118 6 200 144 11 219 162 10 230 174 11
58836-234 174 13 230 174 11 219 162 10 210 150 10
58837-192 133 9 163 110 8 124 112 88 82 82 82
58838- 50 50 50 30 30 30 14 14 14 6 6 6
58839- 0 0 0 0 0 0 0 0 0 0 0 0
58840- 0 0 0 0 0 0 0 0 0 0 0 0
58841- 0 0 0 0 0 0 0 0 0 0 0 0
58842- 0 0 0 0 0 0 0 0 0 0 0 0
58843- 0 0 0 0 0 0 0 0 0 0 0 0
58844- 6 6 6 14 14 14 22 22 22 34 34 34
58845- 42 42 42 58 58 58 74 74 74 86 86 86
58846-101 98 89 122 102 70 130 98 46 121 87 25
58847-137 92 6 152 99 6 163 110 8 180 123 7
58848-185 133 11 197 138 11 206 145 10 200 144 11
58849-180 123 7 156 107 11 130 83 6 104 69 6
58850- 50 34 6 54 54 54 110 110 110 101 98 89
58851- 86 86 86 82 82 82 78 78 78 78 78 78
58852- 78 78 78 78 78 78 78 78 78 78 78 78
58853- 78 78 78 82 82 82 86 86 86 94 94 94
58854-106 106 106 101 101 101 86 66 34 124 80 6
58855-156 107 11 180 123 7 192 133 9 200 144 11
58856-206 145 10 200 144 11 192 133 9 175 118 6
58857-139 102 15 109 106 95 70 70 70 42 42 42
58858- 22 22 22 10 10 10 0 0 0 0 0 0
58859- 0 0 0 0 0 0 0 0 0 0 0 0
58860- 0 0 0 0 0 0 0 0 0 0 0 0
58861- 0 0 0 0 0 0 0 0 0 0 0 0
58862- 0 0 0 0 0 0 0 0 0 0 0 0
58863- 0 0 0 0 0 0 0 0 0 0 0 0
58864- 0 0 0 0 0 0 6 6 6 10 10 10
58865- 14 14 14 22 22 22 30 30 30 38 38 38
58866- 50 50 50 62 62 62 74 74 74 90 90 90
58867-101 98 89 112 100 78 121 87 25 124 80 6
58868-137 92 6 152 99 6 152 99 6 152 99 6
58869-138 86 6 124 80 6 98 70 6 86 66 30
58870-101 98 89 82 82 82 58 58 58 46 46 46
58871- 38 38 38 34 34 34 34 34 34 34 34 34
58872- 34 34 34 34 34 34 34 34 34 34 34 34
58873- 34 34 34 34 34 34 38 38 38 42 42 42
58874- 54 54 54 82 82 82 94 86 76 91 60 6
58875-134 86 6 156 107 11 167 114 7 175 118 6
58876-175 118 6 167 114 7 152 99 6 121 87 25
58877-101 98 89 62 62 62 34 34 34 18 18 18
58878- 6 6 6 0 0 0 0 0 0 0 0 0
58879- 0 0 0 0 0 0 0 0 0 0 0 0
58880- 0 0 0 0 0 0 0 0 0 0 0 0
58881- 0 0 0 0 0 0 0 0 0 0 0 0
58882- 0 0 0 0 0 0 0 0 0 0 0 0
58883- 0 0 0 0 0 0 0 0 0 0 0 0
58884- 0 0 0 0 0 0 0 0 0 0 0 0
58885- 0 0 0 6 6 6 6 6 6 10 10 10
58886- 18 18 18 22 22 22 30 30 30 42 42 42
58887- 50 50 50 66 66 66 86 86 86 101 98 89
58888-106 86 58 98 70 6 104 69 6 104 69 6
58889-104 69 6 91 60 6 82 62 34 90 90 90
58890- 62 62 62 38 38 38 22 22 22 14 14 14
58891- 10 10 10 10 10 10 10 10 10 10 10 10
58892- 10 10 10 10 10 10 6 6 6 10 10 10
58893- 10 10 10 10 10 10 10 10 10 14 14 14
58894- 22 22 22 42 42 42 70 70 70 89 81 66
58895- 80 54 7 104 69 6 124 80 6 137 92 6
58896-134 86 6 116 81 8 100 82 52 86 86 86
58897- 58 58 58 30 30 30 14 14 14 6 6 6
58898- 0 0 0 0 0 0 0 0 0 0 0 0
58899- 0 0 0 0 0 0 0 0 0 0 0 0
58900- 0 0 0 0 0 0 0 0 0 0 0 0
58901- 0 0 0 0 0 0 0 0 0 0 0 0
58902- 0 0 0 0 0 0 0 0 0 0 0 0
58903- 0 0 0 0 0 0 0 0 0 0 0 0
58904- 0 0 0 0 0 0 0 0 0 0 0 0
58905- 0 0 0 0 0 0 0 0 0 0 0 0
58906- 0 0 0 6 6 6 10 10 10 14 14 14
58907- 18 18 18 26 26 26 38 38 38 54 54 54
58908- 70 70 70 86 86 86 94 86 76 89 81 66
58909- 89 81 66 86 86 86 74 74 74 50 50 50
58910- 30 30 30 14 14 14 6 6 6 0 0 0
58911- 0 0 0 0 0 0 0 0 0 0 0 0
58912- 0 0 0 0 0 0 0 0 0 0 0 0
58913- 0 0 0 0 0 0 0 0 0 0 0 0
58914- 6 6 6 18 18 18 34 34 34 58 58 58
58915- 82 82 82 89 81 66 89 81 66 89 81 66
58916- 94 86 66 94 86 76 74 74 74 50 50 50
58917- 26 26 26 14 14 14 6 6 6 0 0 0
58918- 0 0 0 0 0 0 0 0 0 0 0 0
58919- 0 0 0 0 0 0 0 0 0 0 0 0
58920- 0 0 0 0 0 0 0 0 0 0 0 0
58921- 0 0 0 0 0 0 0 0 0 0 0 0
58922- 0 0 0 0 0 0 0 0 0 0 0 0
58923- 0 0 0 0 0 0 0 0 0 0 0 0
58924- 0 0 0 0 0 0 0 0 0 0 0 0
58925- 0 0 0 0 0 0 0 0 0 0 0 0
58926- 0 0 0 0 0 0 0 0 0 0 0 0
58927- 6 6 6 6 6 6 14 14 14 18 18 18
58928- 30 30 30 38 38 38 46 46 46 54 54 54
58929- 50 50 50 42 42 42 30 30 30 18 18 18
58930- 10 10 10 0 0 0 0 0 0 0 0 0
58931- 0 0 0 0 0 0 0 0 0 0 0 0
58932- 0 0 0 0 0 0 0 0 0 0 0 0
58933- 0 0 0 0 0 0 0 0 0 0 0 0
58934- 0 0 0 6 6 6 14 14 14 26 26 26
58935- 38 38 38 50 50 50 58 58 58 58 58 58
58936- 54 54 54 42 42 42 30 30 30 18 18 18
58937- 10 10 10 0 0 0 0 0 0 0 0 0
58938- 0 0 0 0 0 0 0 0 0 0 0 0
58939- 0 0 0 0 0 0 0 0 0 0 0 0
58940- 0 0 0 0 0 0 0 0 0 0 0 0
58941- 0 0 0 0 0 0 0 0 0 0 0 0
58942- 0 0 0 0 0 0 0 0 0 0 0 0
58943- 0 0 0 0 0 0 0 0 0 0 0 0
58944- 0 0 0 0 0 0 0 0 0 0 0 0
58945- 0 0 0 0 0 0 0 0 0 0 0 0
58946- 0 0 0 0 0 0 0 0 0 0 0 0
58947- 0 0 0 0 0 0 0 0 0 6 6 6
58948- 6 6 6 10 10 10 14 14 14 18 18 18
58949- 18 18 18 14 14 14 10 10 10 6 6 6
58950- 0 0 0 0 0 0 0 0 0 0 0 0
58951- 0 0 0 0 0 0 0 0 0 0 0 0
58952- 0 0 0 0 0 0 0 0 0 0 0 0
58953- 0 0 0 0 0 0 0 0 0 0 0 0
58954- 0 0 0 0 0 0 0 0 0 6 6 6
58955- 14 14 14 18 18 18 22 22 22 22 22 22
58956- 18 18 18 14 14 14 10 10 10 6 6 6
58957- 0 0 0 0 0 0 0 0 0 0 0 0
58958- 0 0 0 0 0 0 0 0 0 0 0 0
58959- 0 0 0 0 0 0 0 0 0 0 0 0
58960- 0 0 0 0 0 0 0 0 0 0 0 0
58961- 0 0 0 0 0 0 0 0 0 0 0 0
58962+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
58963+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
58964+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
58965+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
58966+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
58967+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
58968+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
58969+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
58970+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
58971+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
58972+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
58973+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
58974+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
58975+4 4 4 4 4 4
58976+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
58977+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
58978+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
58979+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
58980+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
58981+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
58982+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
58983+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
58984+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
58985+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
58986+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
58987+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
58988+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
58989+4 4 4 4 4 4
58990+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
58991+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
58992+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
58993+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
58994+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
58995+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
58996+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
58997+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
58998+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
58999+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59000+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59001+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59002+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59003+4 4 4 4 4 4
59004+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59005+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59006+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59007+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59008+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59009+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59010+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59011+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59012+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59013+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59014+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59015+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59016+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59017+4 4 4 4 4 4
59018+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59019+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59020+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59021+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59022+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59023+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59024+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59025+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59026+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59027+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59028+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59029+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59030+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59031+4 4 4 4 4 4
59032+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59033+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59034+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59035+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59036+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59037+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59038+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59039+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59040+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59041+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59042+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59043+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59044+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59045+4 4 4 4 4 4
59046+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59047+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59048+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59049+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59050+4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
59051+0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
59052+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59053+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59054+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59055+4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
59056+0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
59057+4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
59058+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59059+4 4 4 4 4 4
59060+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59061+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59062+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59063+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59064+4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
59065+37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
59066+5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59067+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59068+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59069+4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
59070+2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
59071+4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
59072+1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59073+4 4 4 4 4 4
59074+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59075+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59076+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59077+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59078+2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
59079+153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
59080+0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
59081+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59082+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59083+4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
59084+60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
59085+4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
59086+2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
59087+4 4 4 4 4 4
59088+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59089+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59090+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59091+4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
59092+4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
59093+165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
59094+1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
59095+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59096+4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
59097+3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
59098+163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
59099+0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
59100+37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
59101+4 4 4 4 4 4
59102+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59103+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59104+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59105+4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
59106+37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
59107+156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
59108+125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
59109+5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
59110+4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
59111+0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
59112+174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
59113+0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
59114+64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
59115+4 4 4 4 4 4
59116+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59117+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59118+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
59119+5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
59120+156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
59121+156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
59122+174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
59123+1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
59124+4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
59125+13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
59126+174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
59127+22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
59128+90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
59129+4 4 4 4 4 4
59130+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59131+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59132+4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
59133+0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
59134+174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
59135+156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
59136+163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
59137+4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
59138+5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
59139+131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
59140+190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
59141+90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
59142+31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
59143+4 4 4 4 4 4
59144+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59145+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59146+4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
59147+4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
59148+155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
59149+167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
59150+153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
59151+41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
59152+1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
59153+177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
59154+125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
59155+136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
59156+7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
59157+4 4 4 4 4 4
59158+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59159+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59160+4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
59161+125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
59162+156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
59163+137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
59164+156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
59165+167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
59166+0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
59167+166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
59168+6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
59169+90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
59170+1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
59171+4 4 4 4 4 4
59172+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59173+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59174+1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
59175+167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
59176+157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
59177+26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
59178+158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
59179+165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
59180+60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
59181+137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
59182+52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
59183+13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
59184+4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
59185+4 4 4 4 4 4
59186+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59187+4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
59188+0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
59189+158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
59190+167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
59191+4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
59192+174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
59193+155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
59194+137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
59195+16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
59196+136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
59197+2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
59198+4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
59199+4 4 4 4 4 4
59200+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59201+4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
59202+37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
59203+157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
59204+153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
59205+4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
59206+125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
59207+156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
59208+174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
59209+4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
59210+136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
59211+1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
59212+2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
59213+0 0 0 4 4 4
59214+4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
59215+4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
59216+158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
59217+153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
59218+37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
59219+4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
59220+4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
59221+154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
59222+174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
59223+32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
59224+28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
59225+50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
59226+0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
59227+2 0 0 0 0 0
59228+4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
59229+0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
59230+174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
59231+165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
59232+4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
59233+4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
59234+4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
59235+174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
59236+60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
59237+136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
59238+22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
59239+136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
59240+26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
59241+37 38 37 0 0 0
59242+4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
59243+13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
59244+153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
59245+177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
59246+4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
59247+5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
59248+6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
59249+166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
59250+4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
59251+146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
59252+71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
59253+90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
59254+125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
59255+85 115 134 4 0 0
59256+4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
59257+125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
59258+155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
59259+125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
59260+5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
59261+0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
59262+5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
59263+37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
59264+4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
59265+90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
59266+2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
59267+13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
59268+166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
59269+60 73 81 4 0 0
59270+4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
59271+174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
59272+156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
59273+4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
59274+4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
59275+10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
59276+4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
59277+4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
59278+80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
59279+28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
59280+50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
59281+1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
59282+167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
59283+16 19 21 4 0 0
59284+4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
59285+158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
59286+167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
59287+4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
59288+4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
59289+80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
59290+4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
59291+3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
59292+146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
59293+68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
59294+136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
59295+24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
59296+163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
59297+4 0 0 4 3 3
59298+3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
59299+156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
59300+155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
59301+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
59302+2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
59303+136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
59304+0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
59305+0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
59306+136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
59307+28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
59308+22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
59309+137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
59310+60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
59311+3 2 2 4 4 4
59312+3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
59313+157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
59314+37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
59315+4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
59316+0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
59317+101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
59318+14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
59319+22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
59320+136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
59321+17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
59322+2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
59323+166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
59324+13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
59325+4 4 4 4 4 4
59326+1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
59327+163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
59328+4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
59329+4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
59330+40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
59331+101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
59332+101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
59333+136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
59334+136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
59335+136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
59336+3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
59337+174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
59338+4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
59339+4 4 4 4 4 4
59340+4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
59341+155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
59342+4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
59343+4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
59344+101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
59345+101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
59346+136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
59347+136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
59348+136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
59349+90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
59350+85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
59351+167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
59352+6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
59353+5 5 5 5 5 5
59354+1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
59355+131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
59356+6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
59357+0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
59358+101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
59359+101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
59360+101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
59361+136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
59362+101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
59363+7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
59364+174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
59365+24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
59366+4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
59367+5 5 5 4 4 4
59368+4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
59369+131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
59370+6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
59371+13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
59372+90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
59373+101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
59374+101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
59375+136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
59376+136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
59377+2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
59378+174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
59379+4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
59380+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59381+4 4 4 4 4 4
59382+1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
59383+137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
59384+4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
59385+64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
59386+90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
59387+101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
59388+101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
59389+136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
59390+101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
59391+37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
59392+167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
59393+3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
59394+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59395+4 4 4 4 4 4
59396+4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
59397+153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
59398+4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
59399+90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
59400+90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
59401+90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
59402+101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
59403+101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
59404+35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
59405+154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
59406+60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
59407+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59408+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59409+4 4 4 4 4 4
59410+1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
59411+153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
59412+4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
59413+64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
59414+64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
59415+101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
59416+101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
59417+136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
59418+13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
59419+174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
59420+6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
59421+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59422+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59423+4 4 4 4 4 4
59424+4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
59425+156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
59426+4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
59427+90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
59428+90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
59429+90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
59430+101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
59431+101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
59432+2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
59433+174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
59434+4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
59435+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59436+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59437+4 4 4 4 4 4
59438+3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
59439+158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
59440+4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
59441+37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
59442+90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
59443+90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
59444+101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
59445+90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
59446+5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
59447+167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
59448+6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
59449+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59450+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59451+4 4 4 4 4 4
59452+4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
59453+163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
59454+4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
59455+18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
59456+64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
59457+90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
59458+101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
59459+13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
59460+3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
59461+174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
59462+4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
59463+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59464+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59465+4 4 4 4 4 4
59466+1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
59467+167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
59468+4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
59469+18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
59470+26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
59471+90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
59472+101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
59473+7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
59474+4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
59475+174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
59476+4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
59477+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59478+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59479+4 4 4 4 4 4
59480+4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
59481+174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
59482+5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
59483+18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
59484+26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
59485+90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
59486+101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
59487+2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
59488+3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
59489+153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
59490+4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
59491+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59492+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59493+4 4 4 4 4 4
59494+1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
59495+174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
59496+5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
59497+18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
59498+26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
59499+26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
59500+35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
59501+2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
59502+3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
59503+131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
59504+4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
59505+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59506+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59507+4 4 4 4 4 4
59508+3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
59509+174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
59510+5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
59511+18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
59512+26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
59513+26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
59514+7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
59515+4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
59516+4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
59517+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
59518+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
59519+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59520+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59521+4 4 4 4 4 4
59522+1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
59523+174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
59524+5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
59525+18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
59526+18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
59527+26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
59528+28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
59529+3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
59530+4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
59531+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
59532+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
59533+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59534+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59535+4 4 4 4 4 4
59536+4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
59537+174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
59538+5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
59539+10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
59540+26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
59541+18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
59542+90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
59543+3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
59544+4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
59545+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
59546+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
59547+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59548+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59549+4 4 4 4 4 4
59550+1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
59551+177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
59552+5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
59553+10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
59554+26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
59555+6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
59556+10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
59557+2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
59558+4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
59559+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
59560+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
59561+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59562+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59563+4 4 4 4 4 4
59564+4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
59565+177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
59566+5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
59567+10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
59568+26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
59569+7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
59570+3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
59571+21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
59572+4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
59573+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
59574+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
59575+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59576+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59577+4 4 4 4 4 4
59578+3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
59579+190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
59580+5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
59581+10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
59582+24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
59583+18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
59584+28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
59585+26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
59586+4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
59587+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
59588+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
59589+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59590+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59591+4 4 4 4 4 4
59592+4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
59593+190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
59594+5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
59595+10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
59596+0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
59597+26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
59598+37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
59599+90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
59600+4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
59601+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
59602+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
59603+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59604+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59605+4 4 4 4 4 4
59606+4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
59607+193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
59608+5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
59609+10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
59610+1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
59611+26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
59612+22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
59613+26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
59614+4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
59615+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
59616+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
59617+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59618+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59619+4 4 4 4 4 4
59620+4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
59621+190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
59622+5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
59623+10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
59624+2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
59625+26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
59626+10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
59627+26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
59628+4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
59629+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
59630+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
59631+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59632+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59633+4 4 4 4 4 4
59634+4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
59635+193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
59636+5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
59637+10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
59638+13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
59639+10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
59640+26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
59641+26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
59642+4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
59643+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
59644+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
59645+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59646+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59647+4 4 4 4 4 4
59648+4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
59649+190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
59650+5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
59651+28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
59652+10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
59653+28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
59654+26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
59655+26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
59656+4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
59657+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
59658+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
59659+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59660+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59661+4 4 4 4 4 4
59662+4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
59663+193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
59664+5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
59665+4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
59666+10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
59667+10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
59668+18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
59669+22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
59670+4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
59671+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
59672+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
59673+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59674+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59675+4 4 4 4 4 4
59676+4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
59677+190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
59678+6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
59679+1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
59680+18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
59681+10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
59682+26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
59683+1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
59684+5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
59685+137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
59686+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
59687+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59688+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59689+4 4 4 4 4 4
59690+4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
59691+193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
59692+2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
59693+4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
59694+10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
59695+10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
59696+26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
59697+2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
59698+3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
59699+131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
59700+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
59701+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59702+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59703+4 4 4 4 4 4
59704+4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
59705+193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
59706+0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
59707+4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
59708+13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
59709+10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
59710+28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
59711+4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
59712+0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
59713+125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
59714+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
59715+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59716+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59717+4 4 4 4 4 4
59718+4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
59719+193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
59720+120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
59721+4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
59722+4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
59723+10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
59724+4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
59725+4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
59726+24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
59727+125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
59728+0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
59729+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59730+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59731+4 4 4 4 4 4
59732+4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
59733+174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
59734+220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
59735+3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
59736+4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
59737+10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
59738+1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
59739+5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
59740+137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
59741+125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
59742+0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59743+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59744+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59745+4 4 4 4 4 4
59746+5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
59747+193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
59748+220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
59749+4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
59750+4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
59751+22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
59752+4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59753+1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
59754+166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
59755+125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
59756+4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
59757+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59758+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59759+4 4 4 4 4 4
59760+4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
59761+220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
59762+205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
59763+24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
59764+4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
59765+4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
59766+4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
59767+2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
59768+156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
59769+137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
59770+5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59771+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59772+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59773+4 4 4 4 4 4
59774+5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
59775+125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
59776+205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
59777+193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
59778+5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
59779+1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
59780+5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
59781+60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
59782+153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
59783+125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
59784+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59785+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59786+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59787+4 4 4 4 4 4
59788+4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
59789+6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
59790+193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
59791+244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
59792+0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
59793+4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
59794+3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
59795+220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
59796+153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
59797+13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
59798+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59799+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59800+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59801+4 4 4 4 4 4
59802+5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
59803+6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
59804+244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
59805+220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
59806+3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
59807+4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
59808+0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
59809+177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
59810+158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
59811+4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
59812+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59813+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59814+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59815+4 4 4 4 4 4
59816+5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
59817+6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
59818+177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
59819+220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
59820+125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
59821+4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
59822+37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
59823+174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
59824+158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
59825+4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
59826+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59827+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59828+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59829+4 4 4 4 4 4
59830+4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
59831+4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
59832+26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
59833+205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
59834+244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
59835+0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
59836+177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
59837+174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
59838+60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
59839+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59840+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59841+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59842+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59843+4 4 4 4 4 4
59844+5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
59845+6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
59846+6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
59847+220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
59848+220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
59849+0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
59850+220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
59851+174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
59852+4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
59853+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59854+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59855+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59856+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59857+4 4 4 4 4 4
59858+4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
59859+6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
59860+4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
59861+220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
59862+205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
59863+60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
59864+177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
59865+190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
59866+4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59867+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59868+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59869+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59870+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59871+4 4 4 4 4 4
59872+4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
59873+4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
59874+6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
59875+125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
59876+205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
59877+193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
59878+190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
59879+153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
59880+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59881+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59882+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59883+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59884+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59885+4 4 4 4 4 4
59886+4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
59887+6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
59888+4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
59889+4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
59890+205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
59891+220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
59892+174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
59893+6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
59894+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59895+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59896+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59897+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59898+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59899+4 4 4 4 4 4
59900+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
59901+5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
59902+6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
59903+4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
59904+220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
59905+190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
59906+193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
59907+4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
59908+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59909+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59910+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59911+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59912+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59913+4 4 4 4 4 4
59914+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59915+4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
59916+4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
59917+6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
59918+174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
59919+193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
59920+193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
59921+6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
59922+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59923+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59924+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59925+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59926+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59927+4 4 4 4 4 4
59928+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59929+4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
59930+5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
59931+5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
59932+6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
59933+193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
59934+60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
59935+5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
59936+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59937+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59938+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59939+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59940+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59941+4 4 4 4 4 4
59942+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59943+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59944+4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
59945+5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
59946+4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
59947+193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
59948+6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
59949+4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
59950+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59951+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59952+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59953+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59954+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59955+4 4 4 4 4 4
59956+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59957+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59958+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
59959+4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
59960+6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
59961+153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
59962+6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
59963+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59964+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59965+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59966+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59967+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59968+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59969+4 4 4 4 4 4
59970+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59971+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59972+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59973+4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
59974+6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
59975+24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
59976+6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
59977+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59978+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59979+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59980+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59981+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59982+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59983+4 4 4 4 4 4
59984+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59985+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59986+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59987+4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
59988+4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
59989+6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
59990+4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
59991+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59992+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59993+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59994+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59995+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59996+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59997+4 4 4 4 4 4
59998+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
59999+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60000+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60001+4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
60002+5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
60003+6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
60004+6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
60005+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60006+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60007+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60008+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60009+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60010+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60011+4 4 4 4 4 4
60012+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60013+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60014+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60015+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
60016+4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
60017+4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
60018+6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
60019+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60020+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60021+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60022+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60023+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60024+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60025+4 4 4 4 4 4
60026+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60027+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60028+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60029+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60030+4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
60031+6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
60032+4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
60033+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60034+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60035+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60036+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60037+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60038+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60039+4 4 4 4 4 4
60040+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60041+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60042+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60043+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60044+4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
60045+4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
60046+5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60047+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60048+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60049+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60050+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60051+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60052+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60053+4 4 4 4 4 4
60054+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60055+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60056+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60057+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60058+4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
60059+5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
60060+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60061+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60062+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60063+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60064+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60065+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60066+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60067+4 4 4 4 4 4
60068+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60069+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60070+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60071+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60072+4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
60073+5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
60074+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60075+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60076+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60077+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60078+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60079+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60080+4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
60081+4 4 4 4 4 4
60082diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
60083index 3838795..0d48d61 100644
60084--- a/drivers/xen/events/events_base.c
60085+++ b/drivers/xen/events/events_base.c
60086@@ -1568,7 +1568,7 @@ void xen_irq_resume(void)
60087 restore_pirqs();
60088 }
60089
60090-static struct irq_chip xen_dynamic_chip __read_mostly = {
60091+static struct irq_chip xen_dynamic_chip = {
60092 .name = "xen-dyn",
60093
60094 .irq_disable = disable_dynirq,
60095@@ -1582,7 +1582,7 @@ static struct irq_chip xen_dynamic_chip __read_mostly = {
60096 .irq_retrigger = retrigger_dynirq,
60097 };
60098
60099-static struct irq_chip xen_pirq_chip __read_mostly = {
60100+static struct irq_chip xen_pirq_chip = {
60101 .name = "xen-pirq",
60102
60103 .irq_startup = startup_pirq,
60104@@ -1602,7 +1602,7 @@ static struct irq_chip xen_pirq_chip __read_mostly = {
60105 .irq_retrigger = retrigger_dynirq,
60106 };
60107
60108-static struct irq_chip xen_percpu_chip __read_mostly = {
60109+static struct irq_chip xen_percpu_chip = {
60110 .name = "xen-percpu",
60111
60112 .irq_disable = disable_dynirq,
60113diff --git a/drivers/xen/evtchn.c b/drivers/xen/evtchn.c
60114index 00f40f0..e3c0b15 100644
60115--- a/drivers/xen/evtchn.c
60116+++ b/drivers/xen/evtchn.c
60117@@ -201,8 +201,8 @@ static ssize_t evtchn_read(struct file *file, char __user *buf,
60118
60119 /* Byte lengths of two chunks. Chunk split (if any) is at ring wrap. */
60120 if (((c ^ p) & EVTCHN_RING_SIZE) != 0) {
60121- bytes1 = (EVTCHN_RING_SIZE - EVTCHN_RING_MASK(c)) *
60122- sizeof(evtchn_port_t);
60123+ bytes1 = EVTCHN_RING_SIZE - EVTCHN_RING_MASK(c);
60124+ bytes1 *= sizeof(evtchn_port_t);
60125 bytes2 = EVTCHN_RING_MASK(p) * sizeof(evtchn_port_t);
60126 } else {
60127 bytes1 = (p - c) * sizeof(evtchn_port_t);
60128diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
60129index fef20db..d28b1ab 100644
60130--- a/drivers/xen/xenfs/xenstored.c
60131+++ b/drivers/xen/xenfs/xenstored.c
60132@@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
60133 static int xsd_kva_open(struct inode *inode, struct file *file)
60134 {
60135 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
60136+#ifdef CONFIG_GRKERNSEC_HIDESYM
60137+ NULL);
60138+#else
60139 xen_store_interface);
60140+#endif
60141+
60142 if (!file->private_data)
60143 return -ENOMEM;
60144 return 0;
60145diff --git a/firmware/Makefile b/firmware/Makefile
60146index e297e1b..aeb0982 100644
60147--- a/firmware/Makefile
60148+++ b/firmware/Makefile
60149@@ -35,9 +35,11 @@ fw-shipped-$(CONFIG_BNX2X) += bnx2x/bnx2x-e1-6.2.9.0.fw \
60150 bnx2x/bnx2x-e1h-6.2.9.0.fw \
60151 bnx2x/bnx2x-e2-6.2.9.0.fw
60152 fw-shipped-$(CONFIG_BNX2) += bnx2/bnx2-mips-09-6.2.1a.fw \
60153+ bnx2/bnx2-mips-09-6.2.1b.fw \
60154 bnx2/bnx2-rv2p-09-6.0.17.fw \
60155 bnx2/bnx2-rv2p-09ax-6.0.17.fw \
60156 bnx2/bnx2-mips-06-6.2.1.fw \
60157+ bnx2/bnx2-mips-06-6.2.3.fw \
60158 bnx2/bnx2-rv2p-06-6.0.15.fw
60159 fw-shipped-$(CONFIG_CASSINI) += sun/cassini.bin
60160 fw-shipped-$(CONFIG_CHELSIO_T3) += cxgb3/t3b_psram-1.1.0.bin \
60161diff --git a/firmware/WHENCE b/firmware/WHENCE
60162index 0c4d96d..b17700f 100644
60163--- a/firmware/WHENCE
60164+++ b/firmware/WHENCE
60165@@ -653,21 +653,23 @@ Found in hex form in kernel source.
60166 Driver: BNX2 - Broadcom NetXtremeII
60167
60168 File: bnx2/bnx2-mips-06-6.2.1.fw
60169+File: bnx2/bnx2-mips-06-6.2.3.fw
60170 File: bnx2/bnx2-rv2p-06-6.0.15.fw
60171 File: bnx2/bnx2-mips-09-6.2.1a.fw
60172+File: bnx2/bnx2-mips-09-6.2.1b.fw
60173 File: bnx2/bnx2-rv2p-09-6.0.17.fw
60174 File: bnx2/bnx2-rv2p-09ax-6.0.17.fw
60175
60176 Licence:
60177-
60178- This file contains firmware data derived from proprietary unpublished
60179- source code, Copyright (c) 2004 - 2010 Broadcom Corporation.
60180-
60181- Permission is hereby granted for the distribution of this firmware data
60182- in hexadecimal or equivalent format, provided this copyright notice is
60183- accompanying it.
60184-
60185-Found in hex form in kernel source.
60186+
60187+ This file contains firmware data derived from proprietary unpublished
60188+ source code, Copyright (c) 2004 - 2010 Broadcom Corporation.
60189+
60190+ Permission is hereby granted for the distribution of this firmware data
60191+ in hexadecimal or equivalent format, provided this copyright notice is
60192+ accompanying it.
60193+
60194+Found in hex form in kernel source.
60195
60196 --------------------------------------------------------------------------
60197
60198diff --git a/firmware/bnx2/bnx2-mips-06-6.2.3.fw.ihex b/firmware/bnx2/bnx2-mips-06-6.2.3.fw.ihex
60199new file mode 100644
60200index 0000000..da72bf1
60201--- /dev/null
60202+++ b/firmware/bnx2/bnx2-mips-06-6.2.3.fw.ihex
60203@@ -0,0 +1,5804 @@
60204+:10000000080001180800000000004A68000000C84D
60205+:1000100000000000000000000000000008004A6826
60206+:100020000000001400004B30080000A00800000091
60207+:100030000000569400004B44080058200000008443
60208+:100040000000A1D808005694000001580000A25CEE
60209+:100050000800321008000000000072F00000A3B495
60210+:10006000000000000000000000000000080072F026
60211+:1000700000000024000116A40800049008000400F9
60212+:10008000000017D4000116C80000000000000000A6
60213+:100090000000000000000000000000000000000060
60214+:1000A000080000A80800000000003BFC00012E9C96
60215+:1000B0000000000000000000000000000000000040
60216+:1000C00000000000000000000A00004600000000E0
60217+:1000D000000000000000000D636F6D362E322E33DD
60218+:1000E0000000000006020302000000000000000300
60219+:1000F000000000C800000032000000030000000003
60220+:1001000000000000000000000000000000000000EF
60221+:1001100000000010000001360000EA600000000549
60222+:1001200000000000000000000000000000000008C7
60223+:1001300000000000000000000000000000000000BF
60224+:1001400000000000000000000000000000000000AF
60225+:10015000000000000000000000000000000000009F
60226+:10016000000000020000000000000000000000008D
60227+:10017000000000000000000000000000000000007F
60228+:10018000000000000000000000000010000000005F
60229+:10019000000000000000000000000000000000005F
60230+:1001A000000000000000000000000000000000004F
60231+:1001B000000000000000000000000000000000003F
60232+:1001C000000000000000000000000000000000002F
60233+:1001D000000000000000000000000000000000001F
60234+:1001E0000000000010000003000000000000000DEF
60235+:1001F0000000000D3C02080024424AA03C03080015
60236+:1002000024634B9CAC4000000043202B1480FFFD76
60237+:10021000244200043C1D080037BD7FFC03A0F021F0
60238+:100220003C100800261001183C1C0800279C4AA01E
60239+:100230000E000168000000000000000D27470100CB
60240+:1002400090E3000B2402001A94E5000814620028D1
60241+:10025000000020218CE200003C0308008C63004475
60242+:1002600094E60014000211C20002104030A4000203
60243+:10027000005A10212463000130A50004A446008028
60244+:100280003C010800AC23004410A000190004202BFE
60245+:100290008F4202B804410008240400013C02080017
60246+:1002A0008C420060244200013C010800AC22006046
60247+:1002B00003E00008008010218CE2002094E3001687
60248+:1002C00000002021AF4202808CE20004A743028498
60249+:1002D000AF4202883C021000AF4202B83C02080064
60250+:1002E0008C42005C244200013C010800AC22005C0E
60251+:1002F00003E00008008010212747010090E3000B75
60252+:100300002402000394E50008146200280000202164
60253+:100310008CE200003C0308008C63004494E6001467
60254+:10032000000211C20002104030A40002005A102145
60255+:100330002463000130A50004A44600803C010800AD
60256+:10034000AC23004410A000190004202B8F4202B8F7
60257+:1003500004410008240400013C0208008C420060B3
60258+:10036000244200013C010800AC22006003E00008C8
60259+:10037000008010218CE2002094E300160000202170
60260+:10038000AF4202808CE20004A7430284AF4202889D
60261+:100390003C021000AF4202B83C0208008C42005CF4
60262+:1003A000244200013C010800AC22005C03E000088C
60263+:1003B000008010218F4301002402010050620003DD
60264+:1003C000000311C20000000D000311C20002104022
60265+:1003D000005A1021A440008003E000080000102112
60266+:1003E0009362000003E00008AF80000003E0000813
60267+:1003F0000000102103E00008000010212402010089
60268+:1004000014820008000000003C0208008C4200FC3E
60269+:10041000244200013C010800AC2200FC0A0000DD7F
60270+:1004200030A200203C0208008C42008424420001DB
60271+:100430003C010800AC22008430A2002010400008DB
60272+:1004400030A300103C0208008C4201082442000145
60273+:100450003C010800AC22010803E000080000000095
60274+:1004600010600008000000003C0208008C420104FB
60275+:10047000244200013C010800AC22010403E0000812
60276+:10048000000000003C0208008C42010024420001F0
60277+:100490003C010800AC22010003E00008000000005D
60278+:1004A00027BDFFE8AFBF0010274401009483000878
60279+:1004B000306200041040001B306600028F4202B818
60280+:1004C00004410008240500013C0208008C42006041
60281+:1004D000244200013C010800AC2200600A0001290E
60282+:1004E0008FBF00108C82002094830016000028210A
60283+:1004F000AF4202808C820004A7430284AF4202888C
60284+:100500003C021000AF4202B83C0208008C42005C82
60285+:10051000244200013C010800AC22005C0A000129D1
60286+:100520008FBF001010C00006006028218F4401001A
60287+:100530000E0000CD000000000A0001282405000183
60288+:100540008F8200088F4301045043000700002821D8
60289+:100550008F4401000E0000CD000000008F42010416
60290+:10056000AF820008000028218FBF001000A01021DA
60291+:1005700003E0000827BD001827BDFFE8AFBF001447
60292+:10058000AFB00010974201083043700024022000F1
60293+:100590001062000B286220011440002F000010217F
60294+:1005A00024024000106200250000000024026000C8
60295+:1005B00010620026000010210A0001658FBF0014A0
60296+:1005C00027500100920200091040001A2403000184
60297+:1005D0003C0208008C420020104000160000182148
60298+:1005E0000E00049300000000960300083C0608007B
60299+:1005F00094C64B5E8E0400188F8200209605000C76
60300+:1006000000031C0000661825AC440000AC45000443
60301+:1006100024040001AC400008AC40000CAC400010C9
60302+:10062000AC400014AC4000180E0004B8AC43001CF1
60303+:10063000000018210A000164006010210E0003254B
60304+:10064000000000000A000164000010210E000EE905
60305+:1006500000000000000010218FBF00148FB00010B8
60306+:1006600003E0000827BD001827BDFFE0AFB2001867
60307+:100670003C036010AFBF001CAFB10014AFB000105E
60308+:100680008C6450002402FF7F3C1A800000822024EA
60309+:100690003484380C24020037AC6450003C1208004B
60310+:1006A00026524AD8AF42000824020C80AF420024F0
60311+:1006B0003C1B80083C06080024C60324024010218D
60312+:1006C0002404001D2484FFFFAC4600000481FFFDCC
60313+:1006D000244200043C020800244204B03C0108000B
60314+:1006E000AC224AE03C020800244202303C010800EF
60315+:1006F000AC224AE43C020800244201743C03080096
60316+:100700002463032C3C040800248403D83C0508001F
60317+:1007100024A538F03C010800AC224B403C02080004
60318+:10072000244202EC3C010800AC264B243C010800AA
60319+:10073000AC254B343C010800AC234B3C3C01080089
60320+:10074000AC244B443C010800AC224B483C0108005F
60321+:10075000AC234ADC3C010800AC204AE83C0108001C
60322+:10076000AC204AEC3C010800AC204AF03C010800F7
60323+:10077000AC204AF43C010800AC204AF83C010800D7
60324+:10078000AC204AFC3C010800AC204B003C010800B6
60325+:10079000AC244B043C010800AC204B083C01080091
60326+:1007A000AC204B0C3C010800AC204B103C01080075
60327+:1007B000AC204B143C010800AC204B183C01080055
60328+:1007C000AC264B1C3C010800AC264B203C01080029
60329+:1007D000AC254B303C010800AC234B380E000623FF
60330+:1007E000000000003C028000344200708C42000097
60331+:1007F000AF8200143C0308008C6300208F82000449
60332+:10080000104300043C0280000E00045BAF83000430
60333+:100810003C028000344600703C0308008C6300A05A
60334+:100820003C0208008C4200A4104300048F84001492
60335+:100830003C010800AC2300A4A743009E8CCA000022
60336+:100840003C0308008C6300BC3C0208008C4200B8EA
60337+:100850000144202300641821000040210064202B63
60338+:1008600000481021004410213C010800AC2300BCCA
60339+:100870003C010800AC2200B88F5100003222000772
60340+:100880001040FFDCAF8A00148CC600003C05080055
60341+:100890008CA500BC3C0408008C8400B800CA30233E
60342+:1008A00000A628210000102100A6302B0082202164
60343+:1008B00000862021322700013C010800AC2500BC45
60344+:1008C0003C010800AC2400B810E0001F32220002F6
60345+:1008D0008F420100AF4200208F420104AF4200A8C6
60346+:1008E0009342010B0E0000C6305000FF2E02001E86
60347+:1008F00054400004001010800E0000C90A000213CA
60348+:1009000000000000005210218C4200000040F80955
60349+:1009100000000000104000053C0240008F4301042D
60350+:100920003C026020AC4300143C024000AF4201385E
60351+:100930003C0208008C420034244200013C010800C3
60352+:10094000AC220034322200021040000E3222000499
60353+:100950008F4201400E0000C6AF4200200E000295FB
60354+:10096000000000003C024000AF4201783C02080059
60355+:100970008C420038244200013C010800AC220038BF
60356+:10098000322200041040FF983C0280008F42018018
60357+:100990000E0000C6AF4200208F43018024020F00EA
60358+:1009A00014620005000000008F420188A742009CED
60359+:1009B0000A0002483C0240009362000024030050F9
60360+:1009C000304200FF144300083C0240000E00027B4E
60361+:1009D00000000000544000043C0240000E000D7571
60362+:1009E000000000003C024000AF4201B83C02080099
60363+:1009F0008C42003C244200013C010800AC22003C37
60364+:100A00000A0001C83C0280003C0290003442000110
60365+:100A100000822025AF4400208F4200200440FFFECA
60366+:100A20000000000003E00008000000003C0280001D
60367+:100A3000344200010082202503E00008AF4400207A
60368+:100A400027BDFFE0AFB10014AFB0001000808821D7
60369+:100A5000AFBF00180E00025030B000FF9362007D5F
60370+:100A60000220202102028025A370007D8F70007477
60371+:100A70003C0280000E000259020280241600000988
60372+:100A80008FBF00188F4201F80440FFFE24020002CD
60373+:100A9000AF5101C0A34201C43C021000AF4201F8B3
60374+:100AA0008FBF00188FB100148FB0001003E0000852
60375+:100AB00027BD002027BDFFE8AFBF0010974201848B
60376+:100AC0008F440188304202001040000500002821B8
60377+:100AD0000E000FAA000000000A00028D240500018C
60378+:100AE0003C02FF0004800005008218243C02040040
60379+:100AF000506200019362003E240500018FBF001088
60380+:100B000000A0102103E0000827BD0018A360002208
60381+:100B10008F4401400A00025E2405000127BDFFE862
60382+:100B2000AFBF0014AFB0001093620000304400FF6C
60383+:100B300038830020388200300003182B0002102B6D
60384+:100B40000062182410600003240200501482008008
60385+:100B50008FBF001493620005304200011040007CFA
60386+:100B60008FBF0014934201482443FFFF2C6200050D
60387+:100B7000104000788FB00010000310803C03080084
60388+:100B800024634A68004310218C42000000400008A2
60389+:100B9000000000000E0002508F4401408F70000CD6
60390+:100BA0008F4201441602000224020001AF62000CD1
60391+:100BB0000E0002598F4401408F420144145000043A
60392+:100BC0008FBF00148FB000100A000F2027BD00183F
60393+:100BD0008F62000C0A0003040000000097620010FE
60394+:100BE0008F4301443042FFFF1462001A00000000EE
60395+:100BF00024020001A76200108F4202380443001053
60396+:100C00008F4201403C02003F3446F0003C0560004A
60397+:100C10003C04FFC08CA22BBC0044182400461024C6
60398+:100C20000002130200031D82106200390000000060
60399+:100C30008F4202380440FFF7000000008F4201405D
60400+:100C4000AF4202003C021000AF4202380A00032209
60401+:100C50008FBF0014976200100A0003040000000018
60402+:100C60000E0002508F440140976200128F430144EE
60403+:100C70003050FFFF1603000224020001A762001299
60404+:100C80000E0002598F4401408F42014416020004B5
60405+:100C90008FBF00148FB000100A00029127BD00180A
60406+:100CA000976200120A00030400000000976200141B
60407+:100CB0008F4301443042FFFF14620006240200010A
60408+:100CC0008FBF00148FB00010A76200140A00124AF0
60409+:100CD00027BD0018976200141440001D8FBF001438
60410+:100CE0000A00031C00000000976200168F430144B5
60411+:100CF0003042FFFF1462000B240200018FBF00147A
60412+:100D00008FB00010A76200160A000B1227BD001852
60413+:100D10009742007824420004A76200100A000322D0
60414+:100D20008FBF001497620016240300013042FFFFBA
60415+:100D3000144300078FBF00143C0208008C4200706F
60416+:100D4000244200013C010800AC2200708FBF001457
60417+:100D50008FB0001003E0000827BD001827BDFFE892
60418+:100D6000AFBF0014AFB000108F50010093620000BD
60419+:100D700093430109304400FF2402001F106200A5C4
60420+:100D80002862002010400018240200382862000A5F
60421+:100D90001040000C2402000B286200081040002CB8
60422+:100DA00000000000046000E52862000214400028F2
60423+:100DB00024020006106200268FBF00140A00041FE0
60424+:100DC0008FB000101062005E2862000B144000DC3F
60425+:100DD0008FBF00142402000E106200738FB0001049
60426+:100DE0000A00041F00000000106200C028620039E1
60427+:100DF0001040000A2402008024020036106200CA5B
60428+:100E000028620037104000B424020035106200C18F
60429+:100E10008FBF00140A00041F8FB000101062002B57
60430+:100E20002862008110400006240200C82402003914
60431+:100E3000106200B48FBF00140A00041F8FB00010AE
60432+:100E4000106200998FBF00140A00041F8FB00010B9
60433+:100E50003C0208008C420020104000B98FBF0014F3
60434+:100E60000E000493000000008F4201008F830020D9
60435+:100E70009745010C97460108AC6200008F420104BF
60436+:100E80003C04080094844B5E00052C00AC62000416
60437+:100E90008F4201180006340000C43025AC620008FF
60438+:100EA0008F42011C24040001AC62000C9342010A31
60439+:100EB00000A22825AC650010AC600014AC600018DE
60440+:100EC000AC66001C0A0003F58FBF00143C0208004A
60441+:100ED0008C4200201040009A8FBF00140E00049333
60442+:100EE00000000000974401083C03080094634B5E37
60443+:100EF0009745010C000422029746010E8F820020C4
60444+:100F0000000426000083202500052C003C030080FF
60445+:100F100000A6282500832025AC400000AC4000043A
60446+:100F2000AC400008AC40000CAC450010AC400014D4
60447+:100F3000AC400018AC44001C0A0003F42404000177
60448+:100F40009742010C14400015000000009362000558
60449+:100F50003042001014400011000000000E0002504A
60450+:100F6000020020219362000502002021344200107B
60451+:100F70000E000259A36200059362000024030020C2
60452+:100F8000304200FF1043006D020020218FBF00148B
60453+:100F90008FB000100A000FC027BD00180000000D20
60454+:100FA0000A00041E8FBF00143C0208008C4200207F
60455+:100FB000104000638FBF00140E0004930000000077
60456+:100FC0008F4201048F8300209744010C3C050800E8
60457+:100FD00094A54B5EAC6200009762002C00042400D4
60458+:100FE0003042FFFF008220253C02400E00A228254F
60459+:100FF000AC640004AC600008AC60000CAC60001095
60460+:10100000AC600014AC600018AC65001C0A0003F46E
60461+:10101000240400010E00025002002021A7600008F5
60462+:101020000E00025902002021020020210E00025E63
60463+:10103000240500013C0208008C42002010400040C2
60464+:101040008FBF00140E000493000000009742010CB3
60465+:101050008F8300203C05080094A54B5E000214001D
60466+:10106000AC700000AC620004AC6000088F64004CFF
60467+:101070003C02401F00A22825AC64000C8F62005087
60468+:1010800024040001AC6200108F620054AC620014B2
60469+:10109000AC600018AC65001C8FBF00148FB000104E
60470+:1010A0000A0004B827BD0018240200205082002541
60471+:1010B0008FB000100E000F0A020020211040002007
60472+:1010C0008FBF0014020020218FB0001000002821E3
60473+:1010D0000A00025E27BD0018020020218FBF001405
60474+:1010E0008FB000100A00058027BD00189745010C3D
60475+:1010F000020020218FBF00148FB000100A0005A04D
60476+:1011000027BD0018020020218FB000100A0005C57D
60477+:1011100027BD00189345010D020020218FB000105B
60478+:101120000A00060F27BD0018020020218FBF0014FF
60479+:101130008FB000100A0005EB27BD00188FBF001408
60480+:101140008FB0001003E0000827BD00188F4202781E
60481+:101150000440FFFE2402000234840080AF440240B9
60482+:10116000A34202443C02100003E00008AF420278B0
60483+:101170003C04080094844B6A3C0208008C424B7487
60484+:101180003083FFFF000318C000431021AF42003C32
60485+:101190003C0208008C424B70AF4200383C020050C9
60486+:1011A00034420008AF4200300000000000000000A0
60487+:1011B000000000008F420000304200201040FFFD80
60488+:1011C000000000008F4204003C010800AC224B608C
60489+:1011D0008F4204043C010800AC224B643C02002016
60490+:1011E000AF420030000000003C02080094424B680F
60491+:1011F0003C03080094634B6C3C05080094A54B6EBF
60492+:1012000024840001004310213083FFFF3C010800CB
60493+:10121000A4224B683C010800A4244B6A1465000317
60494+:10122000000000003C010800A4204B6A03E0000815
60495+:10123000000000003C05000A27BDFFE80345282107
60496+:101240003C04080024844B50AFBF00100E00051D65
60497+:101250002406000A3C02080094424B523C0308005A
60498+:1012600094634B6E3042000F244200030043180485
60499+:1012700024027FFF0043102B10400002AF83001CAC
60500+:101280000000000D0E00042A000000003C020800CF
60501+:1012900094424B5A8FBF001027BD001803E000088E
60502+:1012A000A74200A23C02000A034210219443000618
60503+:1012B0003C02080094424B5A3C010800A4234B56C0
60504+:1012C000004310238F83001C00021400000214034B
60505+:1012D0000043102B03E000083842000127BDFFE85F
60506+:1012E000AFBF00103C02000A0342102194420006E6
60507+:1012F0003C010800A4224B560E00047700000000B9
60508+:101300005440FFF93C02000A8FBF001003E00008C0
60509+:1013100027BD001827BDFFE8AFBF00100E000477FF
60510+:101320000000000010400003000000000E000485D3
60511+:10133000000000003C0208008C424B608FBF001090
60512+:1013400027430400AF4200383C0208008C424B6443
60513+:1013500027BD0018AF830020AF42003C3C020005CF
60514+:10136000AF42003003E00008AF8000188F82001801
60515+:101370003C0300060002114000431025AF4200303C
60516+:101380000000000000000000000000008F4200008C
60517+:10139000304200101040FFFD27420400AF820020C1
60518+:1013A00003E00008AF8000183C0608008CC64B64C0
60519+:1013B0008F8500188F8300203C02080094424B5A0E
60520+:1013C00027BDFFE024A50001246300202442000182
60521+:1013D00024C70020AFB10014AFB00010AFBF001899
60522+:1013E000AF850018AF8300203C010800A4224B5AAF
60523+:1013F000309000FF3C010800AC274B6404C100089A
60524+:101400000000882104E00006000000003C02080003
60525+:101410008C424B60244200013C010800AC224B602E
60526+:101420003C02080094424B5A3C03080094634B680A
60527+:101430000010202B004310262C42000100441025F0
60528+:10144000144000048F830018240200101462000F5F
60529+:10145000000000000E0004A9241100013C03080054
60530+:1014600094634B5A3C02080094424B681462000398
60531+:10147000000000000E00042A000000001600000317
60532+:10148000000000000E000493000000003C03080070
60533+:1014900094634B5E3C02080094424B5C2463000161
60534+:1014A0003064FFFF3C010800A4234B5E148200035C
60535+:1014B000000000003C010800A4204B5E1200000662
60536+:1014C000000000003C02080094424B5AA74200A2D0
60537+:1014D0000A00050B022010210E0004770000000016
60538+:1014E00010400004022010210E00048500000000BE
60539+:1014F000022010218FBF00188FB100148FB0001090
60540+:1015000003E0000827BD00203084FFFF30A5FFFF67
60541+:101510000000182110800007000000003082000148
60542+:101520001040000200042042006518210A00051343
60543+:101530000005284003E000080060102110C00006EC
60544+:1015400024C6FFFF8CA2000024A50004AC8200008A
60545+:101550000A00051D2484000403E0000800000000C8
60546+:1015600010A0000824A3FFFFAC86000000000000CC
60547+:10157000000000002402FFFF2463FFFF1462FFFA53
60548+:101580002484000403E0000800000000240200019D
60549+:10159000AF62000CA7620010A7620012A7620014DD
60550+:1015A00003E00008A76200163082007F034210218A
60551+:1015B0003C08000E004818213C0208008C42002024
60552+:1015C00027BDFFD82407FF80AFB3001CAFB20018BF
60553+:1015D000AFB10014AFB00010AFBF00200080802179
60554+:1015E00030B100FF0087202430D200FF1040002FD0
60555+:1015F00000009821AF44002C9062000024030050AA
60556+:10160000304200FF1443000E000000003C020800BE
60557+:101610008C4200E00202102100471024AF42002C4F
60558+:101620003C0208008C4200E0020210213042007FA0
60559+:101630000342102100481021944200D43053FFFF90
60560+:101640000E000493000000003C02080094424B5E30
60561+:101650008F8300200011340000C2302500122C00BE
60562+:101660003C02400000C2302534A50001AC700000EF
60563+:101670008FBF0020AC6000048FB20018AC7300086C
60564+:101680008FB10014AC60000C8FB3001CAC6500106F
60565+:101690008FB00010AC60001424040001AC6000188E
60566+:1016A00027BD00280A0004B8AC66001C8FBF0020CC
60567+:1016B0008FB3001C8FB200188FB100148FB00010D0
60568+:1016C00003E0000827BD00289343010F2402001007
60569+:1016D0001062000E2865001110A0000724020012FD
60570+:1016E000240200082405003A1062000600003021A0
60571+:1016F00003E0000800000000240500351462FFFC30
60572+:10170000000030210A000538000000008F420074FC
60573+:1017100024420FA003E00008AF62000C27BDFFE8E1
60574+:10172000AFBF00100E00025E240500018FBF001045
60575+:1017300024020001A762001227BD00182402000144
60576+:1017400003E00008A360002227BDFFE0AFB1001452
60577+:10175000AFB00010AFBF001830B1FFFF0E00025055
60578+:10176000008080219362003F24030004304200FF88
60579+:101770001443000C02002021122000082402000A59
60580+:101780000E00053100000000936200052403FFFEF7
60581+:1017900000431024A362000524020012A362003F4C
60582+:1017A000020020210E000259A360008116200003D0
60583+:1017B000020020210E0005950000000002002021FB
60584+:1017C000322600FF8FBF00188FB100148FB00010B9
60585+:1017D000240500380A00053827BD002027BDFFE09A
60586+:1017E000AFBF001CAFB20018AFB10014AFB0001013
60587+:1017F0000E000250008080210E0005310000000024
60588+:101800009362003F24120018305100FF123200038F
60589+:101810000200202124020012A362003F936200050F
60590+:101820002403FFFE004310240E000259A3620005AA
60591+:10183000020020212405002016320007000030217C
60592+:101840008FBF001C8FB200188FB100148FB0001032
60593+:101850000A00025E27BD00208FBF001C8FB2001857
60594+:101860008FB100148FB00010240500390A0005382C
60595+:1018700027BD002027BDFFE8AFB00010AFBF0014A8
60596+:101880009742010C2405003600808021144000108E
60597+:10189000304600FF0E00025000000000240200123B
60598+:1018A000A362003F93620005344200100E00053130
60599+:1018B000A36200050E00025902002021020020212F
60600+:1018C0000E00025E240500200A000604000000004D
60601+:1018D0000E000538000000000E000250020020211A
60602+:1018E000936200232403FF9F020020210043102461
60603+:1018F0008FBF00148FB00010A36200230A000259AA
60604+:1019000027BD001827BDFFE0AFBF0018AFB100141E
60605+:10191000AFB0001030B100FF0E00025000808021F7
60606+:10192000240200120E000531A362003F0E0002598E
60607+:101930000200202102002021022030218FBF001848
60608+:101940008FB100148FB00010240500350A0005384F
60609+:1019500027BD0020A380002C03E00008A380002DF9
60610+:101960008F4202780440FFFE8F820034AF42024073
60611+:1019700024020002A34202443C02100003E00008DB
60612+:10198000AF4202783C0360008C6254003042000891
60613+:101990001440FFFD000000008C625408AF82000C70
60614+:1019A00024020052AC605408AC645430AC6254342D
60615+:1019B0002402000803E00008AC6254003C0260000E
60616+:1019C0008C42540030420008104000053C03600087
60617+:1019D0008C625400304200081440FFFD00000000FB
60618+:1019E0008F83000C3C02600003E00008AC43540805
60619+:1019F00090A3000024020005008040213063003FD6
60620+:101A000000004821146200050000502190A2001C33
60621+:101A100094A3001E304900FF306AFFFFAD00000CA8
60622+:101A2000AD000010AD000024950200148D05001CCF
60623+:101A30008D0400183042FFFF0049102300021100FE
60624+:101A4000000237C3004038210086202300A2102B5B
60625+:101A50000082202300A72823AD05001CAD04001838
60626+:101A6000A5090014A5090020A50A001603E0000836
60627+:101A7000A50A00228F4201F80440FFFE2402000262
60628+:101A8000AF4401C0A34201C43C02100003E00008BF
60629+:101A9000AF4201F83C0208008C4200B427BDFFE8C9
60630+:101AA000AFBF001424420001AFB000103C01080099
60631+:101AB000AC2200B48F4300243C02001F30AA00FF78
60632+:101AC0003442FF8030D800FF006280240080F8217B
60633+:101AD00030EF00FF1158003B01405821240CFF80DB
60634+:101AE0003C19000A3163007F000310C00003194055
60635+:101AF000006218213C0208008C4200DC25680001CD
60636+:101B0000310D007F03E21021004310213043007F9C
60637+:101B100003431821004C102400794821AF420024CF
60638+:101B20008D220024016C1824006C7026AD22000C5C
60639+:101B30008D220024310800FFAD22001095220014F0
60640+:101B4000952300208D27001C3042FFFF3063FFFFEC
60641+:101B50008D2600180043102300021100000227C345
60642+:101B60000040282100C4302300E2102B00C23023A3
60643+:101B700000E53823AD27001CAD2600189522002073
60644+:101B8000A522001495220022154B000AA52200165A
60645+:101B90008D2300248D220008254600013145008058
60646+:101BA0001462000430C4007F108F000238AA008045
60647+:101BB00000C0502151AF000131C800FF1518FFC906
60648+:101BC000010058218F8400343082007F03421821A5
60649+:101BD0003C02000A006218212402FF8000822024B7
60650+:101BE000AF440024A06A0079A06A00838C62005090
60651+:101BF0008F840034AC6200708C6500743C027FFFFF
60652+:101C00003442FFFF00A228240E00066BAC6500746E
60653+:101C1000AF5000248FBF00148FB0001003E0000805
60654+:101C200027BD001827BDFFC0AFBE0038AFB70034D6
60655+:101C3000AFB5002CAFB20020AFB1001CAFB00018A0
60656+:101C4000AFBF003CAFB60030AFB40028AFB3002444
60657+:101C50008F4500248F4600288F43002C3C02001F34
60658+:101C60003442FF800062182400C230240080A82182
60659+:101C7000AFA3001400A2F0240E00062FAFA60010A0
60660+:101C80003C0208008C4200E02410FF8003608821A1
60661+:101C900002A2102100501024AF4200243C02080090
60662+:101CA0008C4200E002A210213042007F0342182142
60663+:101CB0003C02000A00629021924200D293630084A9
60664+:101CC000305700FF306300FF24020001106200342F
60665+:101CD000036020212402000214620036000000008C
60666+:101CE0000E001216024028219223008392220083C4
60667+:101CF0003063007F3042007F000210C000031940B3
60668+:101D0000006218213C0208008C4200DC02A2102173
60669+:101D10000043382100F01024AF42002892250078BB
60670+:101D20009224008330E2007F034218213C02000C21
60671+:101D300014850007006280212402FFFFA24200F107
60672+:101D40002402FFFFA64200F20A0007272402FFFF39
60673+:101D500096020020A24200F196020022A64200F262
60674+:101D60008E020024AE4200F492220083A24200F0D0
60675+:101D70008E4200C8AE4200FC8E4200C4AE4200F863
60676+:101D80008E220050AE4201008E4200CCAE420104D1
60677+:101D9000922200853042003F0A0007823442004010
60678+:101DA0000E00123902402821922200850A00078283
60679+:101DB0003042003F936200852403FFDF3042003F42
60680+:101DC000A36200859362008500431024A36200850E
60681+:101DD0009363008393620078307400FF304200FF09
60682+:101DE00010540036240AFF803C0C000C3283007F24
60683+:101DF000000310C000031940006218213C020800D3
60684+:101E00008C4200DC268800013109007F02A21021EB
60685+:101E10000043382130E2007F0342182100EA1024F9
60686+:101E2000AF420028006C80218E020024028A182410
60687+:101E3000006A5826AE02000C8E020024310800FF12
60688+:101E4000AE02001096020014960300208E07001CBC
60689+:101E50003042FFFF3063FFFF8E060018004310235F
60690+:101E600000021100000227C30040282100C43023D3
60691+:101E700000E2102B00C2302300E53823AE07001C1F
60692+:101E8000AE06001896020020A60200149602002258
60693+:101E9000A602001692220079304200FF105400077B
60694+:101EA0000000000051370001316800FF92220078E5
60695+:101EB000304200FF1448FFCD0100A0219222008390
60696+:101EC000A22200798E2200500A0007E2AE220070A2
60697+:101ED000A22200858E22004C2405FF80AE42010C18
60698+:101EE0009222008534420020A2220085924200D135
60699+:101EF0003C0308008C6300DC305400FF3C02080007
60700+:101F00008C4200E400143140001420C002A31821C8
60701+:101F100000C4202102A210210064382100461021B3
60702+:101F20000045182400E52824AF450028AF43002CC5
60703+:101F30003042007F924400D030E3007F03422821EA
60704+:101F4000034318213C02000C006280213C02000E79
60705+:101F5000309600FF00A298211296002A000000008F
60706+:101F60008E02000C02002021026028211040002572
60707+:101F7000261000280E00064A000000009262000DA4
60708+:101F800026830001307400FF3042007FA262000D02
60709+:101F90002404FF801697FFF0267300203C020800FF
60710+:101FA0008C4200DC0000A02102A210210044102479
60711+:101FB000AF4200283C0208008C4200E43C030800C9
60712+:101FC0008C6300DC02A2102100441024AF42002CDC
60713+:101FD0003C0208008C4200E402A318213063007F19
60714+:101FE00002A210213042007F034220210343182126
60715+:101FF0003C02000C006280213C02000E0A0007A493
60716+:10200000008298218E4200D8AE2200508E4200D825
60717+:10201000AE22007092250083924600D19223008365
60718+:10202000924400D12402FF8000A228243063007F64
60719+:10203000308400FF00A628250064182A10600002E2
60720+:1020400030A500FF38A50080A2250083A2250079D5
60721+:102050000E00063D000000009222007E02A020211A
60722+:10206000A222007A8E2300743C027FFF3442FFFFDD
60723+:10207000006218240E00066BAE2300748FA20010BD
60724+:10208000AF5E00248FBF003CAF4200288FBE0038F7
60725+:102090008FA200148FB700348FB600308FB5002C9C
60726+:1020A0008FB400288FB300248FB200208FB1001CA2
60727+:1020B0008FB0001827BD004003E00008AF42002C9D
60728+:1020C00090A2000024420001A0A200003C030800EE
60729+:1020D0008C6300F4304200FF1443000F0080302175
60730+:1020E000A0A000003C0208008C4200E48F84003471
60731+:1020F000008220213082007F034218213C02000C24
60732+:10210000006218212402FF8000822024ACC300005A
60733+:1021100003E00008AF4400288C8200002442002025
60734+:1021200003E00008AC82000094C200003C080800F4
60735+:10213000950800CA30E7FFFF008048210102102106
60736+:10214000A4C2000094C200003042FFFF00E2102B46
60737+:1021500054400001A4C7000094A200003C03080002
60738+:102160008C6300CC24420001A4A2000094A20000D1
60739+:102170003042FFFF544300078F8600280107102BD1
60740+:10218000A4A000005440000101003821A4C70000B1
60741+:102190008F8600288CC4001CAF44003C94A2000031
60742+:1021A0008F43003C3042FFFF000210C00062182144
60743+:1021B000AF43003C8F42003C008220231880000483
60744+:1021C000000000008CC200180A00084324420001ED
60745+:1021D0008CC20018AF4200383C020050344200105C
60746+:1021E000AF420030000000000000000000000000CE
60747+:1021F0008F420000304200201040FFFD0000000030
60748+:102200008F420404AD2200048F420400AD2200007E
60749+:102210003C020020AF42003003E000080000000054
60750+:1022200027BDFFE0AFB20018AFB10014AFB000108F
60751+:10223000AFBF001C94C2000000C080213C12080007
60752+:10224000965200C624420001A60200009603000038
60753+:1022500094E2000000E03021144300058FB100300B
60754+:102260000E000818024038210A000875000000001E
60755+:102270008C8300048C820004244200400461000727
60756+:10228000AC8200048C8200040440000400000000C2
60757+:102290008C82000024420001AC8200009602000003
60758+:1022A0003042FFFF50520001A600000096220000BD
60759+:1022B00024420001A62200008F82002896230000FD
60760+:1022C00094420016144300048FBF001C2402000136
60761+:1022D000A62200008FBF001C8FB200188FB100141F
60762+:1022E0008FB0001003E0000827BD00208F89002870
60763+:1022F00027BDFFE0AFBF00188D220028274804004B
60764+:1023000030E700FFAF4200388D22002CAF8800304C
60765+:10231000AF42003C3C020005AF420030000000002C
60766+:1023200000000000000000000000000000000000AD
60767+:10233000000000008C82000C8C82000CAD020000BA
60768+:102340008C820010AD0200048C820018AD020008DF
60769+:102350008C82001CAD02000C8CA20014AD02001097
60770+:102360008C820020AD02001490820005304200FFF4
60771+:1023700000021200AD0200188CA20018AD02001C71
60772+:102380008CA2000CAD0200208CA20010AD02002433
60773+:102390008CA2001CAD0200288CA20020AD02002CF3
60774+:1023A000AD060030AD000034978300263402FFFFF5
60775+:1023B00014620002006020213404FFFF10E00011CD
60776+:1023C000AD04003895230036952400362402000120
60777+:1023D0003063FFFF000318C20069182190650040B8
60778+:1023E000308400070082100400451025A0620040E0
60779+:1023F0008F820028944200563042FFFF0A0008DC1A
60780+:10240000AD02003C952300369524003624020001DD
60781+:102410003063FFFF000318C2006918219065004077
60782+:1024200030840007008210040002102700451024A9
60783+:10243000A0620040AD00003C000000000000000071
60784+:10244000000000003C02000634420040AF42003071
60785+:102450000000000000000000000000008F420000AB
60786+:10246000304200101040FFFD8F860028AF880030FA
60787+:1024700024C2005624C7003C24C4002824C50032CE
60788+:1024800024C600360E000856AFA200108FBF0018F9
60789+:1024900003E0000827BD00208F8300243C060800CD
60790+:1024A0008CC600E88F82003430633FFF0003198040
60791+:1024B00000461021004310212403FF803046007F96
60792+:1024C00000431024AF420028034618213C02000CB0
60793+:1024D0000062302190C2000D30A500FF00003821BD
60794+:1024E00034420010A0C2000D8F8900288F8A00247A
60795+:1024F00095230036000A13823048000324020001AD
60796+:10250000A4C3000E1102000B2902000210400005B6
60797+:10251000240200021100000C240300010A0009201B
60798+:102520000000182111020006000000000A00092026
60799+:10253000000018218CC2002C0A000920244300014D
60800+:102540008CC20014244300018CC200180043102BDD
60801+:1025500050400009240700012402002714A20003B0
60802+:10256000000000000A00092C240700019522003E0B
60803+:1025700024420001A522003E000A138230430003DA
60804+:102580002C62000210400009008028211460000421
60805+:102590000000000094C200360A00093C3046FFFFEC
60806+:1025A0008CC600380A00093C008028210000302138
60807+:1025B0003C04080024844B780A00088900000000CD
60808+:1025C000274901008D22000C9523000601202021BF
60809+:1025D000000216023046003F3063FFFF240200274E
60810+:1025E00000C0282128C7002810C2000EAF83002495
60811+:1025F00010E00008240200312402002110C200096A
60812+:102600002402002510C200079382002D0A00095BF6
60813+:102610000000000010C200059382002D0A00095B33
60814+:10262000000000000A0008F4000000000A0006266E
60815+:102630000000000095230006912400058D25000C64
60816+:102640008D2600108D2700188D28001C8D29002054
60817+:10265000244200013C010800A4234B7E3C010800F9
60818+:10266000A0244B7D3C010800AC254B843C010800B4
60819+:10267000AC264B883C010800AC274B903C0108007D
60820+:10268000AC284B943C010800AC294B9803E00008AF
60821+:10269000A382002D8F87002827BDFFC0AFB3003471
60822+:1026A000AFB20030AFB1002CAFB00028AFBF0038E0
60823+:1026B0003C0208008C4200D094E3003030B0FFFFB1
60824+:1026C000005010073045FFFF3063FFFF00C0982126
60825+:1026D000A7A200103C110800963100C614A3000602
60826+:1026E0003092FFFF8CE2002424420030AF42003CD5
60827+:1026F0000A0009948CE2002094E200323042FFFF8D
60828+:1027000054A2000827A400188CE2002C24420030B8
60829+:10271000AF42003C8CE20028AF4200380A0009A218
60830+:102720008F84002827A5001027A60020022038212A
60831+:102730000E000818A7A000208FA200182442003025
60832+:10274000AF4200388FA2001CAF42003C8F840028AB
60833+:102750003C020005AF42003094820034274304005D
60834+:102760003042FFFF0202102B14400007AF830030FD
60835+:1027700094820054948300340202102100431023F9
60836+:102780000A0009B63043FFFF94830054948200345A
60837+:102790000223182100501023006218233063FFFF2A
60838+:1027A000948200163042FFFF144300030000000033
60839+:1027B0000A0009C424030001948200163042FFFF7E
60840+:1027C0000043102B104000058F82003094820016C9
60841+:1027D000006210233043FFFF8F820030AC530000B3
60842+:1027E000AC400004AC520008AC43000C3C020006B4
60843+:1027F00034420010AF420030000000000000000032
60844+:10280000000000008F420000304200101040FFFD29
60845+:10281000001018C2006418219065004032040007BF
60846+:10282000240200018FBF00388FB300348FB2003014
60847+:102830008FB1002C8FB000280082100400451025B5
60848+:1028400027BD004003E00008A062004027BDFFA8AC
60849+:10285000AFB60050AFB5004CAFB40048AFB30044C2
60850+:10286000AFB1003CAFBF0054AFB20040AFB00038D2
60851+:102870008C9000003C0208008C4200E88F860034F7
60852+:10288000960300022413FF8000C2302130633FFF13
60853+:102890000003198000C3382100F3102490B2000017
60854+:1028A000AF42002C9203000230E2007F034230214D
60855+:1028B0003C02000E00C28821306300C024020040A8
60856+:1028C0000080A82100A0B021146200260000A021F1
60857+:1028D0008E3400388E2200181440000224020001B9
60858+:1028E000AE2200189202000D304200201440001564
60859+:1028F0008F8200343C0308008C6300DC001238C077
60860+:10290000001231400043102100C730210046382119
60861+:1029100030E300073C02008030E6007800C230253A
60862+:102920000343182100F31024AF4208002463090078
60863+:10293000AF4608108E2200188C6300080043102157
60864+:10294000AE2200188E22002C8E2300182442000193
60865+:102950000062182B1060003D000000000A000A7899
60866+:1029600000000000920300022402FFC00043102474
60867+:10297000304200FF1440000524020001AE2200187E
60868+:10298000962200360A000A613054FFFF8E2200149E
60869+:1029900024420001AE22001892020000000216003C
60870+:1029A0000002160304410029000000009602000204
60871+:1029B00027A4001000802821A7A20016960200027A
60872+:1029C00024070001000030213042FFFFAF820024C5
60873+:1029D0000E000889AFA0001C960300023C0408000A
60874+:1029E0008C8400E88F82003430633FFF000319803D
60875+:1029F00000441021004310213043007F3C05000CAF
60876+:102A00000053102403431821AF4200280065182109
60877+:102A10009062000D001221403042007FA062000D44
60878+:102A20003C0308008C6300E48F82003400431021D3
60879+:102A30000044382130E2007F03421021004510217C
60880+:102A400000F31824AF430028AEA200009222000D2C
60881+:102A5000304200101040001302A020218F83002874
60882+:102A60008EA40000028030219462003E2442FFFFC9
60883+:102A7000A462003E948400029625000E3084FFFF7D
60884+:102A80000E00097330A5FFFF8F82002894430034A5
60885+:102A90009622000E1443000302A02021240200010C
60886+:102AA000A382002C02C028210E0007FE00000000B7
60887+:102AB0008FBF00548FB600508FB5004C8FB40048C4
60888+:102AC0008FB300448FB200408FB1003C8FB000380C
60889+:102AD00003E0000827BD00588F82002827BDFFD0E3
60890+:102AE000AFB40028AFB20020AFBF002CAFB30024BA
60891+:102AF000AFB1001CAFB00018904400D0904300D19B
60892+:102B00000000A021309200FFA3A30010306300FF5B
60893+:102B10008C5100D88C5300DC1072002B2402000171
60894+:102B20003C0308008C6300E493A400108F820034FF
60895+:102B30002406FF800004214000431021004410219E
60896+:102B40003043007F00461024AF4200280343182181
60897+:102B50003C02000C006218218C62000427A40014BF
60898+:102B600027A50010022280210270102304400015C6
60899+:102B7000AFA300149062000D00C21024304200FF89
60900+:102B800014400007020088219062000D344200408A
60901+:102B90000E0007FEA062000D0A000ABD93A20010FD
60902+:102BA0000E0009E1241400018F830028AC7000D8C6
60903+:102BB00093A20010A06200D193A200101452FFD87B
60904+:102BC0000000000024020001168200048FBF002CC8
60905+:102BD0000E000626000000008FBF002C8FB40028D6
60906+:102BE0008FB300248FB200208FB1001C8FB000186B
60907+:102BF00003E0000827BD003027BDFFD8AFB3001C9D
60908+:102C0000AFB20018AFB10014AFB00010AFBF0020DA
60909+:102C10000080982100E0802130B1FFFF0E00049376
60910+:102C200030D200FF000000000000000000000000A3
60911+:102C30008F820020AC510000AC520004AC5300085D
60912+:102C4000AC40000CAC400010AC400014AC4000188C
60913+:102C50003C03080094634B5E02038025AC50001CCB
60914+:102C6000000000000000000000000000240400013B
60915+:102C70008FBF00208FB3001C8FB200188FB10014DB
60916+:102C80008FB000100A0004B827BD002827BDFFE858
60917+:102C9000AFB00010AFBF001430A5FFFF30C600FF7B
60918+:102CA0000080802124020C80AF420024000000003C
60919+:102CB0000000000000000000000000000000000014
60920+:102CC0000E000ACC000000003C040800248400E050
60921+:102CD0008C8200002403FF808FBF001402021021A9
60922+:102CE00000431024AF4200248C8200003C03000A01
60923+:102CF000020280213210007F035010218FB000109B
60924+:102D00000043102127BD001803E00008AF8200280F
60925+:102D100027BDFFE8AFBF00108F4401403C0308000F
60926+:102D20008C6300E02402FF80AF840034008318210C
60927+:102D300000621024AF4200243C02000803424021FC
60928+:102D4000950500023063007F3C02000A034318210E
60929+:102D50000062182130A5FFFF3402FFFF0000302180
60930+:102D60003C07602010A20006AF8300282402FFFF6A
60931+:102D7000A5020002946500D40E000AF130A5FFFF01
60932+:102D80008FBF001024020C8027BD001803E000084C
60933+:102D9000AF4200243C020008034240219502000299
60934+:102DA0003C0A0800954A00C63046FFFF14C00007E1
60935+:102DB0003402FFFF8F8200288F8400343C0760209C
60936+:102DC000944500D40A000B5A30A5FFFF10C200241E
60937+:102DD0008F87002894E2005494E400163045FFFFEA
60938+:102DE00000A6102300A6182B3089FFFF10600004F6
60939+:102DF0003044FFFF00C51023012210233044FFFFA1
60940+:102E0000008A102B1040000C012A1023240200011C
60941+:102E1000A50200162402FFFFA502000294E500D4DB
60942+:102E20008F8400340000302130A5FFFF3C07602074
60943+:102E30000A000AF1000000000044102A10400008B7
60944+:102E4000000000009502001630420001104000040E
60945+:102E5000000000009742007E24420014A5020016E4
60946+:102E600003E00008000000008F84002827BDFFE079
60947+:102E7000AFBF0018948200349483003E1060001AA3
60948+:102E80003048FFFF9383002C2402000114620027C6
60949+:102E90008FBF00188F820028000818C23108000771
60950+:102EA000006218212447003A244900542444002099
60951+:102EB000244500302446003490620040304200FF38
60952+:102EC0000102100730420001104000168FBF0018A9
60953+:102ED0000E000856AFA900108F82002894420034DB
60954+:102EE0000A000B733048FFFF94830036948200344D
60955+:102EF0001043000E8FBF001894820036A482003465
60956+:102F000094820056A48200548C82002CAC8200244F
60957+:102F100094820032A48200309482003CA482003A61
60958+:102F20008FBF00180A000B3327BD002003E0000804
60959+:102F300027BD002027BDFFE8AFBF00108F4A01006A
60960+:102F40003C0508008CA500E03C02080090424B8440
60961+:102F50003C0C0800958C4B7E01452821304B003FEE
60962+:102F600030A2007F03424021396900323C02000A4E
60963+:102F70003963003F2C630001010240212D2900012B
60964+:102F80002402FF8000A2282401234825AF8A0034B0
60965+:102F900000801821AF450024000030210080282146
60966+:102FA00024070001AF8800283C04080024844B78E3
60967+:102FB000AF8C002415200007A380002D24020020E0
60968+:102FC0005562000F006020213402FFFF5582000C83
60969+:102FD000006020212402002015620005000000008E
60970+:102FE0008C6300142402FFFF106200070000000041
60971+:102FF0000E000889000000000A000BD0000000004D
60972+:103000000E0008F4016028210E000B68000000008B
60973+:103010008FBF001024020C8027BD001803E00008B9
60974+:10302000AF4200243C0208008C4200E027BDFFA014
60975+:10303000AFB1003C008210212411FF80AFBE0058C8
60976+:10304000AFB70054AFB20040AFB00038AFBF005CC4
60977+:10305000AFB60050AFB5004CAFB40048AFB30044BA
60978+:10306000005110248F4800248F4900288F470028E2
60979+:10307000AF4200243C0208008C4200E00080902116
60980+:1030800024060006008210213042007F03421821EE
60981+:103090003C02000A006280213C02001F3442FF8093
60982+:1030A00000E2382427A40010260500F00122F024B5
60983+:1030B0000102B8240E00051DAFA700308FA2001832
60984+:1030C000AE0200C48FA2001CAE0200C88FA2002472
60985+:1030D000AE0200CC93A40010920300D12402FF8022
60986+:1030E0000082102400431025304900FF3083007F08
60987+:1030F0003122007F0062102A10400004000310C03B
60988+:1031000001311026304900FF000310C000031940B0
60989+:10311000006218213C0208008C4200DC920400D2BC
60990+:10312000024210210043102100511024AF42002818
60991+:1031300093A300103063007F000310C00003194008
60992+:10314000006218213C0208008C4200DC024210217F
60993+:10315000004310213042007F034218213C02000C42
60994+:10316000006240218FA300142402FFFF1062003090
60995+:10317000309500FF93A2001195030014304400FF26
60996+:103180003063FFFF0064182B1060000D000000008A
60997+:10319000950400148D07001C8D0600183084FFFF75
60998+:1031A00000442023000421000000102100E4382105
60999+:1031B00000E4202B00C230210A000C4A00C4302158
61000+:1031C000950400148D07001C8D0600183084FFFF45
61001+:1031D000008220230004210000001021008018211B
61002+:1031E00000C2302300E4202B00C4302300E3382346
61003+:1031F000AD07001CAD06001893A20011A502001433
61004+:1032000097A20012A50200168FA20014AD020010B2
61005+:103210008FA20014AD02000C93A20011A5020020A1
61006+:1032200097A20012A50200228FA20014AD02002472
61007+:103230002406FF80024610243256007FAF4200244D
61008+:10324000035618213C02000A006280218E02004CC5
61009+:103250008FA200203124007F000428C0AE0200505D
61010+:103260008FA200200004214000852821AE020070BA
61011+:1032700093A2001001208821A202008393A20010D3
61012+:10328000A2020079920200853042003FA20200852E
61013+:103290003C0208008C4200DC024210210045102153
61014+:1032A00000461024AF42002C3C0208008C4200E48F
61015+:1032B0003C0308008C6300DC024210210044102112
61016+:1032C00000461024AF4200283C0208008C4200E473
61017+:1032D00002431821006518210242102100441021E8
61018+:1032E0003042007F3063007F93A50010034220210D
61019+:1032F000034318213C02000E006240213C02000CF6
61020+:1033000010B1008C008248213233007F1660001912
61021+:103310002404FF803C0208008C4200DC02421021A1
61022+:1033200000441024AF42002C3C0208008C4200E410
61023+:103330003C0308008C6300DC02421021004410248E
61024+:10334000AF4200283C0208008C4200E402431821EE
61025+:103350003063007F024210213042007F034220216F
61026+:10336000034318213C02000E006240213C02000C85
61027+:10337000008248219124000D2414FF8000001021B8
61028+:1033800000942025A124000D950400029505001449
61029+:103390008D07001C3084FFFF30A5FFFF8D0600184D
61030+:1033A000008520230004210000E4382100C23021E0
61031+:1033B00000E4202B00C43021AD07001CAD0600182E
61032+:1033C00095020002A5020014A50000168D02000857
61033+:1033D000AD0200108D020008AD02000C9502000243
61034+:1033E000A5020020A50000228D020008AD020024E5
61035+:1033F0009122000D30420040104000422622000180
61036+:103400003C0208008C4200E0A3B300283C10000AF4
61037+:103410000242102100541024AF4200243C02080054
61038+:103420008C4200E0A380002C27A4002C0242102133
61039+:103430003042007F03421821007018218C6200D8AE
61040+:103440008D26000427A50028AFA9002C00461021D6
61041+:10345000AC6200D80E0009E1AF83002893A30028D6
61042+:103460008F8200280E000626A04300D10E000B68B4
61043+:103470000000000002541024AF4200243C02080067
61044+:103480008C4200DC00132940001320C000A420213E
61045+:10349000024210210044102100541024AF42002C9D
61046+:1034A0003C0208008C4200E43C0308008C6300DC12
61047+:1034B00003563021024210210045102100541024EF
61048+:1034C000AF4200283C0208008C4200E4024318216D
61049+:1034D0000064182102421021004510213042007F73
61050+:1034E0003063007F03422021034318213C02000E79
61051+:1034F000006240213C02000C00D080210082482163
61052+:10350000262200013043007F14750005304400FF7F
61053+:103510002403FF800223102400431026304400FFC0
61054+:1035200093A2001000808821250800281444FF760B
61055+:103530002529002093A400108FA300142402FFFF6C
61056+:103540001062000A308900FF2482000124830001F8
61057+:103550003042007F14550005306900FF2403FF80CE
61058+:103560000083102400431026304900FF92020078A7
61059+:10357000305300FF11330032012088213C02080043
61060+:103580008C4200DC3225007F000520C00005294068
61061+:1035900000A42021024210212406FF8000441021B3
61062+:1035A00000461024AF42002C3C0308008C6300DC72
61063+:1035B0003C0208008C4200E4024318210242102120
61064+:1035C0000045102100641821004610243063007F5C
61065+:1035D000AF420028034318213C02000E0062402144
61066+:1035E0003C0208008C4200E48D06000C0100202102
61067+:1035F00002421021004510213042007F0342182171
61068+:103600003C02000C0062482110C0000D012028215E
61069+:103610000E00064A000000002402FF800222182447
61070+:1036200026240001006228263082007F1455000203
61071+:10363000308300FF30A300FF1473FFD000608821A7
61072+:103640008E0300743C027FFF3442FFFF00621824A7
61073+:10365000AE0300740E00066B02402021AF57002419
61074+:103660008FA20030AF5E00288FBF005C8FBE005875
61075+:103670008FB700548FB600508FB5004C8FB4004800
61076+:103680008FB300448FB200408FB1003C8FB0003840
61077+:1036900027BD006003E00008AF42002C27BDFFD823
61078+:1036A000AFB1001CAFBF0020AFB000182751018898
61079+:1036B000922200032408FF803C03000A3047007F69
61080+:1036C000A3A700108F4601803C0208008C4200E056
61081+:1036D000AF86003400C2282100A81024AF42002485
61082+:1036E0009224000030A2007F0342102100431021E9
61083+:1036F000AF8200283084007F24020002148200255B
61084+:10370000000719403C0208008C4200E400C210216E
61085+:103710000043282130A2007F0342182100A8102472
61086+:10372000AF4200283C02000C006218219062000D9C
61087+:10373000AFA3001400481025A062000D8FA3001451
61088+:103740009062000D304200405040006A8FBF002060
61089+:103750008F860028A380002C27A400148CC200D8D8
61090+:103760008C63000427A50010004310210E0009E11E
61091+:10377000ACC200D893A300108F8200280E0006264A
61092+:10378000A04300D10E000B68000000000A000E0BE1
61093+:103790008FBF00200E00062F00C020210E00063D26
61094+:1037A000000000003C020008034280219223000137
61095+:1037B0009202007B1443004F8FBF00209222000032
61096+:1037C0003044007F24020004108200172882000584
61097+:1037D00010400006240200052402000310820007A6
61098+:1037E0008FB1001C0A000E0C0000000010820012B5
61099+:1037F0008FBF00200A000E0C8FB1001C92050083C1
61100+:10380000920600788E0700748F84003430A500FF84
61101+:1038100000073E0230C600FF0E00067330E7007F4F
61102+:103820000A000E0B8FBF00200E000BD78F840034D0
61103+:103830000A000E0B8FBF002024020C80AF42002430
61104+:103840009202003E30420040104000200000000084
61105+:103850009202003E00021600000216030441000618
61106+:10386000000000008F8400340E0005A024050093A2
61107+:103870000A000E0B8FBF00209202003F24030018A5
61108+:10388000304200FF1443000C8F84003424050039BB
61109+:103890000E000538000030210E0002508F840034E5
61110+:1038A00024020012A202003F0E0002598F8400344D
61111+:1038B0000A000E0B8FBF0020240500360E000538CD
61112+:1038C000000030210A000E0B8FBF00200E000250B6
61113+:1038D0008F8400349202000534420020A2020005C9
61114+:1038E0000E0002598F8400340E000FC08F84003404
61115+:1038F0008FBF00208FB1001C8FB0001824020C80F5
61116+:1039000027BD002803E00008AF42002427BDFFE8E0
61117+:10391000AFB00010AFBF001427430100946200084D
61118+:103920000002140000021403044100020000802180
61119+:103930002410000194620008304200801040001AF8
61120+:10394000020010219462000830422000104000164E
61121+:10395000020010218C6300183C021C2D344219ED2A
61122+:10396000240600061062000F3C0760213C0208009C
61123+:103970008C4200D4104000078F8200288F830028DB
61124+:10398000906200623042000F34420040A062006248
61125+:103990008F8200288F840034944500D40E000AF1F1
61126+:1039A00030A5FFFF020010218FBF00148FB0001060
61127+:1039B00003E0000827BD001827BDFFE0AFB10014E9
61128+:1039C000AFB00010A380002CAFBF00188F450100DE
61129+:1039D0003C0308008C6300E02402FF80AF850034C4
61130+:1039E00000A318213064007F0344202100621824C2
61131+:1039F0003C02000A00822021AF430024275001002E
61132+:103A00008E0200148C8300DCAF8400280043102356
61133+:103A100018400004000088218E0200140E000A8461
61134+:103A2000AC8200DC9202000B24030002304200FF53
61135+:103A30001443002F0000000096020008304300FFEE
61136+:103A40002402008214620005240200840E00093E54
61137+:103A5000000000000A000E97000000001462000938
61138+:103A6000240200818F8200288F8400343C0760216B
61139+:103A7000944500D49206000530A5FFFF0A000E868B
61140+:103A800030C600FF14620027000000009202000A06
61141+:103A9000304300FF306200201040000430620040DC
61142+:103AA0008F8400340A000E82240600401040000477
61143+:103AB000000316008F8400340A000E8224060041A1
61144+:103AC00000021603044100178F84003424060042CC
61145+:103AD0008F8200283C076019944500D430A5FFFF71
61146+:103AE0000E000AF1000000000A000E97000000001E
61147+:103AF0009202000B24030016304200FF1043000620
61148+:103B0000000000009202000B24030017304200FF67
61149+:103B100014430004000000000E000E11000000001D
61150+:103B2000004088210E000B68000000009202000A8D
61151+:103B3000304200081040000624020C808F850028C7
61152+:103B40003C0400080E0011EE0344202124020C80E6
61153+:103B5000AF4200248FBF0018022010218FB0001048
61154+:103B60008FB1001403E0000827BD002027BDFFE847
61155+:103B7000AFBF0014AFB000108F5000243C0308000A
61156+:103B80008C6300E08F4501002402FF8000A3182110
61157+:103B90003064007F03442021006218243C02000AA4
61158+:103BA00000822021AF850034AF4300249082006260
61159+:103BB000AF8400283042000F34420050A0820062DF
61160+:103BC0003C02001F3442FF800E00062602028024C1
61161+:103BD000AF5000248FBF00148FB0001003E0000826
61162+:103BE00027BD00183C0208008C4200201040001D38
61163+:103BF0002745010090A300093C0200080342202150
61164+:103C000024020018546200033C0200080A000ED887
61165+:103C10002402000803422021240200161462000539
61166+:103C20002402001724020012A082003F0A000EE2C4
61167+:103C300094A700085462000694A700089362000548
61168+:103C40002403FFFE00431024A362000594A700088C
61169+:103C500090A6001B8CA4000094A500060A000ACCC4
61170+:103C600000073C0003E000080000000027440100BA
61171+:103C700094820008304500FF38A3008238A20084F7
61172+:103C80002C6300012C420001006218251060000620
61173+:103C9000240200839382002D1040000D00000000DC
61174+:103CA0000A000B9B0000000014A2000524A2FF8064
61175+:103CB0008F4301043C02602003E00008AC43001481
61176+:103CC000304200FF2C420002104000032402002278
61177+:103CD0000A000E3C0000000014A2000300000000D7
61178+:103CE0000A000EA9000000000A000EC70000000034
61179+:103CF0009363007E9362007A144300090000202140
61180+:103D00009362000024030050304200FF144300047B
61181+:103D1000240400019362007E24420001A362007E1D
61182+:103D200003E00008008010218F4201F80440FFFEEC
61183+:103D300024020002AF4401C0A34201C43C021000AF
61184+:103D400003E00008AF4201F827BDFFE8AFBF001055
61185+:103D50009362003F2403000A304200FF14430046F0
61186+:103D6000000000008F6300548F62004C1062007DE1
61187+:103D7000036030219362000024030050304200FFB2
61188+:103D80001443002F000000008F4401403C02080053
61189+:103D90008C4200E02403FF800082102100431024A5
61190+:103DA000AF4200243C0208008C4200E08F650054C2
61191+:103DB0003C03000A008220213084007F034410214C
61192+:103DC00000431021AC4501089762003C8F63004C12
61193+:103DD0003042FFFF0002104000621821AF63005C18
61194+:103DE0008F6300548F64004C9762003C006418237A
61195+:103DF0003042FFFF00031843000210400043102A26
61196+:103E000010400006000000008F6200548F63004CD9
61197+:103E1000004310230A000F58000210439762003C31
61198+:103E20003042FFFF00021040ACC2006424020001D7
61199+:103E3000A0C0007CA0C2008424020C80AF420024F9
61200+:103E40000E000F0A8F440140104000478FBF001042
61201+:103E50008F4301408F4201F80440FFFE240200021C
61202+:103E6000AF4301C0A34201C43C021000AF4201F8BD
61203+:103E70000A000FA88FBF00109362003F24030010B8
61204+:103E8000304200FF14430004000000008F44014052
61205+:103E90000A000F94000028219362003F24030016BB
61206+:103EA000304200FF1443000424020014A362003FC8
61207+:103EB0000A000FA2000000008F62004C8F630050C8
61208+:103EC00000431023044100288FBF0010936200813B
61209+:103ED00024420001A3620081936200812C4200040D
61210+:103EE00014400010000000009362003F240300040F
61211+:103EF000304200FF14430006000000008F440140E0
61212+:103F00008FBF0010240500930A0005A027BD0018EC
61213+:103F10008F440140240500938FBF00100A00060F54
61214+:103F200027BD00188F4401400E0002500000000021
61215+:103F30008F6200542442FFFFAF6200548F62005032
61216+:103F40002442FFFFAF6200500E0002598F4401402F
61217+:103F50008F4401408FBF0010240500040A00025E58
61218+:103F600027BD00188FBF001003E0000827BD001810
61219+:103F70008F4201889363007E00021402304400FFE8
61220+:103F8000306300FF1464000D0000000093620080A5
61221+:103F9000304200FF1044000900000000A3640080CC
61222+:103FA0009362000024030050304200FF14430004D9
61223+:103FB000000000000A0006D78F440180A36400803F
61224+:103FC00003E000080000000027BDFFE8AFB00010CC
61225+:103FD000AFBF00149362000524030030304200306C
61226+:103FE00014430089008080213C0208008C4200209C
61227+:103FF00010400080020020210E0004930000000009
61228+:104000008F850020ACB000009362003E9363003FB8
61229+:10401000304200FF00021200306300FF0043102511
61230+:10402000ACA2000493620082000216000002160394
61231+:1040300004410005000000003C0308008C630048B8
61232+:104040000A000FE6000000009362003E304200408C
61233+:10405000144000030000182193620081304300FFE8
61234+:104060009362008200031E00304200FF0002140031
61235+:1040700000621825ACA300088F620040ACA2000CBF
61236+:104080008F620048ACA200108F62004CACA20014FA
61237+:104090008F6200508F63004C0043102304410003E3
61238+:1040A000000000000A000FFA8F62004C8F6200507F
61239+:1040B000ACA200183C02080094424B5E3C03C00BCB
61240+:1040C00000002021004310250E0004B8ACA2001C03
61241+:1040D0008F6200548F840020AC8200008F620058F1
61242+:1040E000AC8200048F62005CAC8200088F620060CA
61243+:1040F0008F43007400431021AC82000C8F62006477
61244+:10410000AC820010976300689762006A00031C008D
61245+:104110003042FFFF00621825AC83001493620082D6
61246+:1041200024030080304200FF14430003000000001D
61247+:104130000A00102EAC8000188F63000C24020001CE
61248+:104140001062000E2402FFFF9362003E30420040E6
61249+:104150001440000A2402FFFF8F63000C8F4200749A
61250+:10416000006218233C020800006210241440000280
61251+:10417000000028210060282100051043AC820018AF
61252+:104180003C02080094424B5E3C03C00C000020211E
61253+:10419000004310258F8300200E0004B8AC62001C81
61254+:1041A0008F6200188F8300203C05080094A54B5EA9
61255+:1041B00024040001AC620000AC6000048F66006C57
61256+:1041C0003C02400D00A22825AC6600088F6200DC8E
61257+:1041D000AC62000CAC600010936200050002160097
61258+:1041E000AC620014AC6000180E0004B8AC65001C92
61259+:1041F000020020218FBF00148FB00010A3600005C3
61260+:104200000A00042127BD00188FBF00148FB00010D2
61261+:1042100003E0000827BD00189742007C30C600FF6D
61262+:10422000A08600843047FFFF2402000514C2000B63
61263+:1042300024E3465090A201122C42000710400007D0
61264+:1042400024E30A0090A30112240200140062100467
61265+:1042500000E210210A0010663047FFFF3067FFFFC1
61266+:1042600003E00008A4870014AC87004C8CA201086E
61267+:104270000080402100A0482100E2102330C600FF4A
61268+:104280001840000393AA001324E2FFFCACA201082B
61269+:1042900030C2000110400008000000008D020050F4
61270+:1042A00000E2102304410013240600058D0200548F
61271+:1042B00010E20010000000008D02005414E2001A09
61272+:1042C000000000003C0208008C4200D83042002070
61273+:1042D0001040000A2402000191030078910200833B
61274+:1042E000144300062402000101002021012028219E
61275+:1042F000240600040A00105400000000A1000084FD
61276+:1043000011400009A50200148F4301008F4201F8FB
61277+:104310000440FFFE24020002AF4301C0A34201C4D7
61278+:104320003C021000AF4201F803E00008000000006A
61279+:1043300027BDFFE88FA90028AFBF001000804021F3
61280+:1043400000E918231860007330C600FFA080007CCD
61281+:10435000A08000818CA2010800E210230440004DDF
61282+:10436000000000008C8200509483003C8C84006428
61283+:10437000004748233063FFFF012318210083202BCF
61284+:1043800010800004000000008D0200640A0010B7D5
61285+:1043900000E210219502003C3042FFFF0122102173
61286+:1043A00000E21021AD02005C9502003C8D03005C30
61287+:1043B0003042FFFF0002104000E210210043102BAA
61288+:1043C00010400003000000000A0010C68D02005CCF
61289+:1043D0009502003C3042FFFF0002104000E2102135
61290+:1043E000AD02005CA1000084AD07004C8CA2010866
61291+:1043F00000E210231840000224E2FFFCACA20108F6
61292+:1044000030C200011040000A000000008D02005080
61293+:1044100000E2102304410004010020218D02005419
61294+:1044200014E20003000000000A0010E82406000562
61295+:104430008D02005414E200478FBF00103C020800B8
61296+:104440008C4200D8304200201040000A24020001B3
61297+:1044500091030078910200831443000624020001B6
61298+:1044600001002021240600048FBF00100A00105410
61299+:1044700027BD0018A1000084A50200148F4301008D
61300+:104480008F4201F80440FFFE240200020A00110DD1
61301+:10449000000000008C82005C004910230043102BB8
61302+:1044A00054400001AC87005C9502003C3042FFFFA5
61303+:1044B0000062102B14400007240200029502003C09
61304+:1044C0008D03005C3042FFFF00621821AD03005CE9
61305+:1044D00024020002AD07004CA10200840E000F0A66
61306+:1044E0008F4401001040001B8FBF00108F4301005C
61307+:1044F0008F4201F80440FFFE24020002AF4301C0D6
61308+:10450000A34201C43C021000AF4201F80A0011238B
61309+:104510008FBF001030C200101040000E8FBF00107F
61310+:104520008C83005C9482003C006918233042FFFFBA
61311+:10453000006218213C023FFF3444FFFF0083102B30
61312+:10454000544000010080182101231021AD02005CBD
61313+:104550008FBF001003E0000827BD001827BDFFE84B
61314+:104560008FAA0028AFBF00100080402100EA482336
61315+:104570001920002130C600FF8C83005C8C8200640F
61316+:10458000006A18230043102B5040001000691821C6
61317+:1045900094A2011001221021A4A2011094A20110E2
61318+:1045A0003042FFFF0043102B1440000A3C023FFF43
61319+:1045B00094A2011000431023A4A201109482003C95
61320+:1045C0003042FFFF0A00114200621821A4A001102E
61321+:1045D0003C023FFF3444FFFF0083102B5440000196
61322+:1045E0000080182100671021AD02005CA100007C52
61323+:1045F0000A00118AA100008130C200101040003C66
61324+:10460000000000008C820050004A1023184000383F
61325+:10461000000000009082007C24420001A082007C07
61326+:104620009082007C3C0308008C630024304200FF31
61327+:104630000043102B1440005C8FBF00108CA20108B7
61328+:1046400000E2102318400058000000008C83005442
61329+:104650009482003C006A18233042FFFF0003184395
61330+:10466000000210400043102A104000050000000026
61331+:104670008C820054004A10230A001171000210437A
61332+:104680009482003C3042FFFF00021040AD02006403
61333+:104690009502003C8D0400649503003C3042FFFF0E
61334+:1046A00000021040008220213063FFFF00831821A8
61335+:1046B00001431021AD02005C8D020054ACA2010840
61336+:1046C00024020002A10200840E000F0A8F440100A0
61337+:1046D000104000358FBF00108F4301008F4201F85A
61338+:1046E0000440FFFE240200020A0011B30000000093
61339+:1046F000AD07004C8CA2010800E210231840000214
61340+:1047000024E2FFFCACA2010830C200011040000A04
61341+:10471000000000008D02005000E21023044100045C
61342+:10472000010020218D02005414E20003000000006B
61343+:104730000A0011AA240600058D02005414E2001A92
61344+:104740008FBF00103C0208008C4200D8304200208D
61345+:104750001040000A240200019103007891020083B6
61346+:104760001443000624020001010020212406000455
61347+:104770008FBF00100A00105427BD0018A10000844C
61348+:10478000A50200148F4301008F4201F80440FFFE90
61349+:1047900024020002AF4301C0A34201C43C02100046
61350+:1047A000AF4201F88FBF001003E0000827BD0018DA
61351+:1047B0008FAA00108C8200500080402130C600FF7C
61352+:1047C000004A102300A048211840000700E01821EB
61353+:1047D00024020001A0800084A0A00112A482001481
61354+:1047E0000A001125AFAA0010A0800081AD07004C7F
61355+:1047F0008CA2010800E210231840000224E2FFFC12
61356+:10480000ACA2010830C20001104000080000000006
61357+:104810008D0200500062102304410013240600059D
61358+:104820008D02005410620010000000008D02005440
61359+:1048300014620011000000003C0208008C4200D805
61360+:10484000304200201040000A240200019103007849
61361+:10485000910200831443000624020001010020217C
61362+:1048600001202821240600040A0010540000000042
61363+:10487000A1000084A502001403E00008000000006D
61364+:1048800027BDFFE0AFBF0018274201009046000A95
61365+:104890008C4800148C8B004C9082008430C900FF3F
61366+:1048A00001681823304A00FF1C60001A2D460006DC
61367+:1048B000240200010142100410C00016304300031E
61368+:1048C000012030210100382114600007304C000C19
61369+:1048D00015800009304200301440000B8FBF0018D3
61370+:1048E0000A001214000000000E001125AFAB0010EA
61371+:1048F0000A0012148FBF00180E00109AAFAB001000
61372+:104900000A0012148FBF0018AFAB00100E0011BACE
61373+:10491000AFAA00148FBF001803E0000827BD0020D5
61374+:1049200024020003A08200848C82005403E000086B
61375+:10493000ACA201083C0200080342182190620081E9
61376+:10494000240600433C07601924420001A062008154
61377+:10495000906300813C0208008C4200C0306300FF7D
61378+:10496000146200102403FF803C0208008C4200E027
61379+:104970000082102100431024AF4200243C020800B2
61380+:104980008C4200E03C03000A008210213042007F8C
61381+:104990000342102100431021944500D40A000AF17B
61382+:1049A00030A5FFFF03E000080000000027BDFFE086
61383+:1049B000AFBF0018AFB10014AFB000108F4201803C
61384+:1049C0000080802100A088210E00121B00402021C1
61385+:1049D000A20000848E0200548FBF00188FB0001018
61386+:1049E000AE2201088FB1001403E0000827BD0020AB
61387+:1049F00027BDFFE03C020008AFB00010AFBF0018B9
61388+:104A0000AFB10014034280218F5101409203008412
61389+:104A10008E0400508E02004C14820040306600FF6D
61390+:104A20003C0208008C4200E02403FF800222102197
61391+:104A300000431024AF4200243C0208008C4200E0F6
61392+:104A40009744007C92050081022210213042007FB1
61393+:104A5000034218213C02000A0062182114A0000B36
61394+:104A60003084FFFF2402000554C20014248205DCB8
61395+:104A70009062011224420001A062011224020C8003
61396+:104A8000AF4200240A00127324020005A060011244
61397+:104A90002402000514C20009248205DC9202008170
61398+:104AA0002C4200075040000524820A009203008136
61399+:104AB0002402001400621004008210213044FFFF21
61400+:104AC000A60400140E00121B022020219602003CB6
61401+:104AD0008E03004C022020213042FFFF00021040D4
61402+:104AE000006218210E000250AE03005C9202007DAD
61403+:104AF00002202021344200400E000259A202007D13
61404+:104B00008F4201F80440FFFE24020002AF5101C0B1
61405+:104B1000A34201C43C021000AF4201F88FBF00184D
61406+:104B20008FB100148FB0001003E0000827BD0020F3
61407+:104B300008000ACC08000B1408000B9808000BE4CE
61408+:104B400008000C200A0000280000000000000000FF
61409+:104B50000000000D6370362E322E3300000000007E
61410+:104B60000602030400000000000000000000000036
61411+:104B70000000000000000000000000000000000035
61412+:104B80000000000000000000000000000000002005
61413+:104B90000000000000000000000000000000000015
61414+:104BA0000000000000000000000000000000000005
61415+:104BB00000000000000000000000000000000001F4
61416+:104BC0000000002B000000000000000400030D4066
61417+:104BD00000000000000000000000000000000000D5
61418+:104BE00000000000000000001000000300000000B2
61419+:104BF0000000000D0000000D3C020800244258A4F3
61420+:104C00003C03080024635F70AC4000000043202B8D
61421+:104C10001480FFFD244200043C1D080037BD7FFCCA
61422+:104C200003A0F0213C100800261000A03C1C080046
61423+:104C3000279C58A40E0001AC000000000000000DED
61424+:104C400027BDFFE83C096018AFBF00108D2C500055
61425+:104C5000240DFF7F24080031018D5824356A380C5B
61426+:104C600024070C003C1A8000AD2A50003C04800A46
61427+:104C7000AF4800083C1B8008AF4700240E00091510
61428+:104C8000AF8400100E0008D8000000000E000825B8
61429+:104C9000000000000E001252000000003C046016EC
61430+:104CA0008C8500003C06FFFF3C02535300A61824ED
61431+:104CB0001062004734867C0094C201F2A780002C69
61432+:104CC00010400003A78000CC38581E1EA798002C67
61433+:104CD00094C201F810400004978300CC38591E1E7E
61434+:104CE000A79900CC978300CC2C7F006753E000018C
61435+:104CF000240300669784002C2C82040114400002D7
61436+:104D000000602821240404003C0760008CE904387A
61437+:104D10002403103C3128FFFF1103001F30B9FFFFAF
61438+:104D200057200010A38000CE24020050A38200CEA2
61439+:104D3000939F00CE53E0000FA78500CCA78000CC46
61440+:104D4000978500CC8FBF0010A780002CA78000346F
61441+:104D5000A78000E63C010800AC25008003E00008C5
61442+:104D600027BD0018939F00CE57E0FFF5A78000CC29
61443+:104D7000A78500CC978500CC8FBF0010A784002C9E
61444+:104D8000A7800034A78000E63C010800AC25008025
61445+:104D900003E0000827BD0018A38000CE8CCB003CA8
61446+:104DA000316A00011140000E0000000030A7FFFF33
61447+:104DB00010E0FFDE240200508CCC00C831860001D8
61448+:104DC00014C0FFDC939F00CE0A00007A2402005139
61449+:104DD0008C8F00043C0E60000A00005D01EE302163
61450+:104DE0008CEF0808240D5708000F740211CD000441
61451+:104DF00030B8FFFF240500660A00007B240404008D
61452+:104E00001700FFCC939F00CE0A00007A24020050C6
61453+:104E10008F8600103089FFFF000939408CC30010D5
61454+:104E20003C08005000E82025AF4300388CC5001432
61455+:104E300027420400AF82001CAF45003CAF44003065
61456+:104E40000000000000000000000000000000000062
61457+:104E50000000000000000000000000000000000052
61458+:104E60008F4B0000316A00201140FFFD0000000060
61459+:104E700003E00008000000008F840010948A001AEC
61460+:104E80008C8700243149FFFF000940C000E8302131
61461+:104E9000AF46003C8C8500248F43003C00A31023C8
61462+:104EA00018400029000000008C8B002025620001C2
61463+:104EB0003C0D005035AC0008AF420038AF4C00301C
61464+:104EC00000000000000000000000000000000000E2
61465+:104ED00000000000000000000000000000000000D2
61466+:104EE0008F4F000031EE002011C0FFFD00000000D8
61467+:104EF0008F4A04003C080020AC8A00108F4904044B
61468+:104F0000AC890014AF4800300000000094860018FF
61469+:104F10009487001C00C71821A48300189485001AE8
61470+:104F200024A20001A482001A9498001A9499001EE9
61471+:104F3000133800030000000003E000080000000038
61472+:104F400003E00008A480001A8C8200200A0000DC24
61473+:104F50003C0D00500A0000CD000000003C0308009A
61474+:104F60008C6300208F82001827BDFFE810620008C4
61475+:104F7000AFBF00100E000104AF8300183C0308000F
61476+:104F80008C63002024040001106400048F89001049
61477+:104F90008FBF001003E0000827BD00188FBF00106E
61478+:104FA0003C076012A520000A9528000A34E500108D
61479+:104FB00027BD00183106FFFF03E00008ACA60090F3
61480+:104FC0003C0208008C42002027BDFFC8AFBF003460
61481+:104FD000AFBE0030AFB7002CAFB60028AFB500248D
61482+:104FE000AFB40020AFB3001CAFB20018AFB10014D3
61483+:104FF00010400050AFB000108F840010948600065F
61484+:105000009483000A00C3282330B6FFFF12C0004A71
61485+:105010008FBF003494890018948A000A012A402323
61486+:105020003102FFFF02C2382B14E0000202C020212F
61487+:10503000004020212C8C0005158000020080A0215A
61488+:10504000241400040E0000B3028020218F8700107A
61489+:1050500002809821AF80001494ED000A028088211C
61490+:105060001280004E31B2FFFF3C1770003C1540002B
61491+:105070003C1E60008F8F001C8DEE000001D71824AD
61492+:10508000507500500220202102A3802B160000350D
61493+:105090003C182000507800470220202124100001F5
61494+:1050A0008F83001414600039029158230230F823D2
61495+:1050B0000250C82133F1FFFF1620FFEE3332FFFF0D
61496+:1050C0008F8700103C110020AF510030000000001D
61497+:1050D00094E6000A3C1E601237D5001002662821B3
61498+:1050E000A4E5000A94E2000A94F2000A94F400187D
61499+:1050F0003057FFFF1292003BAEB700908CED0014CA
61500+:105100008CE400100013714001AE4021000E5FC31B
61501+:10511000010E502B008B4821012A1821ACE8001405
61502+:10512000ACE3001002D3382330F6FFFF16C0FFB9FE
61503+:105130008F8400108FBF00348FBE00308FB7002CDB
61504+:105140008FB600288FB500248FB400208FB3001CC9
61505+:105150008FB200188FB100148FB0001003E0000868
61506+:1051600027BD0038107E001B000000001477FFCC24
61507+:10517000241000010E00159B000000008F83001416
61508+:105180001060FFCB0230F823029158238F87001064
61509+:10519000017020210A0001973093FFFF8F830014D4
61510+:1051A0001460FFCB3C110020AF5100300A000163B6
61511+:1051B000000000000E00077D024028210A00015770
61512+:1051C000004080210E00033A024028210A000157C6
61513+:1051D000004080210E001463022020210A000157A4
61514+:1051E000004080210E0000CD000000000A0001797F
61515+:1051F00002D3382327BDFFE8AFB00010AFBF0014C3
61516+:105200000E00003F000000003C028000345000709F
61517+:105210000A0001BA8E0600008F4F000039EE00012F
61518+:1052200031C20001104000248F8600A88E070000C4
61519+:105230003C0C08008D8C003C3C0908008D2900388E
61520+:1052400000E66823018D28210000502100AD302B9D
61521+:10525000012A4021010620213C010800AC25003C28
61522+:10526000AF8700A83C010800AC2400380E000106FE
61523+:10527000000000003C0308008C6300701060FFE633
61524+:10528000006020213C0508008CA500683C06080051
61525+:105290008CC6006C0E00152A000000003C010800BE
61526+:1052A000AC2000708F4F000039EE000131C20001C8
61527+:1052B0001440FFDE8F8600A88E0A00008F8B00A8A6
61528+:1052C0003C0508008CA5003C3C0408008C84003898
61529+:1052D000014B482300A938210082182100E9402B06
61530+:1052E000006810213C010800AC27003C3C0108008C
61531+:1052F000AC2200388F5F01002419FF0024180C0035
61532+:1053000003F9202410980012AF840000AF4400205D
61533+:10531000936D0000240C002031A600FF10CC001279
61534+:10532000240E005010CE00043C194000AF59013843
61535+:105330000A0001B3000000000E0011C800000000C8
61536+:105340003C194000AF5901380A0001B300000000C9
61537+:105350000E00011F000000003C194000AF59013849
61538+:105360000A0001B3000000008F58010000802821CE
61539+:10537000330F00FF01E020210E0002F1AF8F000487
61540+:105380003C194000AF5901380A0001B30000000089
61541+:1053900000A4102B2403000110400009000030215C
61542+:1053A0000005284000A4102B04A0000300031840AF
61543+:1053B0005440FFFC000528405060000A0004182BF0
61544+:1053C0000085382B54E000040003184200C3302548
61545+:1053D00000852023000318421460FFF900052842CD
61546+:1053E0000004182B03E0000800C310218F4201B80D
61547+:1053F0000440FFFE00000000AF4401803C031000A9
61548+:1054000024040040AF450184A3440188A3460189D8
61549+:10541000A747018A03E00008AF4301B83084FFFFCB
61550+:105420000080382130A5FFFF000020210A00022A59
61551+:10543000240600803087FFFF8CA40000240600387B
61552+:105440000A00022A000028218F8300388F8600304E
61553+:105450001066000B008040213C07080024E75A1822
61554+:10546000000328C000A710218C4400002463000121
61555+:10547000108800053063000F5466FFFA000328C04F
61556+:1054800003E00008000010213C07080024E75A1C34
61557+:1054900000A7302103E000088CC200003C0390000C
61558+:1054A0003462000100822025AF4400208F45002097
61559+:1054B00004A0FFFE0000000003E000080000000060
61560+:1054C0003C038000346200010082202503E00008D4
61561+:1054D000AF44002027BDFFE0AFB100143091FFFFC3
61562+:1054E000AFB00010AFBF00181220001300A0802141
61563+:1054F0008CA2000024040002240601401040000F8A
61564+:10550000004028210E000C5C00000000000010216B
61565+:10551000AE000000022038218FBF00188FB10014A8
61566+:105520008FB0001000402021000028210000302111
61567+:105530000A00022A27BD00208CA200000220382188
61568+:105540008FBF00188FB100148FB0001000402021D1
61569+:1055500000002821000030210A00022A27BD002077
61570+:1055600000A010213087FFFF8CA500048C440000B0
61571+:105570000A00022A2406000627BDFFE0AFB0001093
61572+:10558000AFBF0018AFB100149363003E00808021CC
61573+:105590000080282130620040000020211040000FD0
61574+:1055A0008E1100000E000851022020219367000098
61575+:1055B0002404005030E500FF50A400128E0F0000BC
61576+:1055C000022020218FBF00188FB100148FB000106F
61577+:1055D000A762013C0A00091127BD00200E000287C6
61578+:1055E000000000000E0008510220202193670000F7
61579+:1055F0002404005030E500FF14A4FFF20220202113
61580+:105600008E0F00003C1008008E1000503C0D000C66
61581+:10561000240BFF8001F05021314E007F01DA602120
61582+:10562000018D4021014B4824AF4900280220202150
61583+:105630008FBF00188FB100148FB00010A50200D6E4
61584+:1056400027BD00200A000911AF8800D027BDFFE068
61585+:10565000AFBF0018AFB10014AFB0001093660001E7
61586+:10566000008080210E00025630D1000493640005B2
61587+:10567000001029C2A765000034830040A363000521
61588+:105680000E00025F020020210E00091302002021FB
61589+:1056900024020001AF62000C02002821A762001062
61590+:1056A00024040002A762001224060140A76200142D
61591+:1056B0000E000C5CA76200161620000F8FBF0018AA
61592+:1056C000978C00343C0B08008D6B00782588FFFF19
61593+:1056D0003109FFFF256A0001012A382B10E000067E
61594+:1056E000A78800343C0F6006240E001635ED00102C
61595+:1056F000ADAE00508FBF00188FB100148FB00010F6
61596+:1057000003E0000827BD002027BDFFE0AFB1001473
61597+:10571000AFBF0018AFB0001000A088211080000AB1
61598+:105720003C03600024020080108200120000000090
61599+:105730000000000D8FBF00188FB100148FB0001053
61600+:1057400003E0000827BD00208C682BF80500FFFE51
61601+:1057500000000000AC712BC08FBF00188FB1001487
61602+:105760008FB000103C09100027BD002003E00008A6
61603+:10577000AC692BF80E00025600A0202193650005AD
61604+:10578000022020210E00025F30B000FF2403003E03
61605+:105790001603FFE7000000008F4401780480FFFE3D
61606+:1057A000240700073C061000AF51014002202021D1
61607+:1057B000A34701448FBF00188FB100148FB00010B1
61608+:1057C000AF4601780A0002C227BD002027BDFFE8CE
61609+:1057D000AFBF0014AFB000108F50002000000000D9
61610+:1057E0000E000913AF440020AF5000208FBF0014FB
61611+:1057F0008FB0001003E0000827BD00183084FFFFC1
61612+:10580000008038212406003500A020210A00022A49
61613+:10581000000028213084FFFF008038212406003654
61614+:1058200000A020210A00022A0000282127BDFFD065
61615+:10583000AFB3001C3093FFFFAFB50024AFB2001828
61616+:10584000AFBF0028AFB40020AFB10014AFB000105C
61617+:1058500030B5FFFF12600027000090218F90001CE0
61618+:105860008E0300003C0680002402004000033E023C
61619+:1058700000032C0230E4007F006688241482001D9F
61620+:1058800030A500FF8F8300282C68000A510000100B
61621+:105890008F910014000358803C0C0800258C56940E
61622+:1058A000016C50218D49000001200008000000001B
61623+:1058B00002B210213045FFFF0E000236240400849E
61624+:1058C000162000028F90001CAF8000288F910014DA
61625+:1058D000260C002026430001018080213072FFFF4A
61626+:1058E00016200004AF8C001C0253502B1540FFDC27
61627+:1058F00000000000024010218FBF00288FB5002457
61628+:105900008FB400208FB3001C8FB200188FB1001429
61629+:105910008FB0001003E0000827BD0030240E0034D3
61630+:1059200014AE00F9000000009203000E241F168040
61631+:105930003C07000CA36300219202000D0347C8211D
61632+:105940003C066000A3620020961100123C0A7FFF13
61633+:10595000354CFFFFA771003C960B00102403000597
61634+:105960003168FFFFAF6800848E05001CAF5F002820
61635+:105970008F3800008CC4444803057826008F3021FE
61636+:10598000AF66004C8F69004C24CE00013C057F00BF
61637+:10599000AF6900508F740050AF740054AF66007050
61638+:1059A000AF6E00588F6D005824140050AF6D005C2E
61639+:1059B000A3600023AF6C0064A36300378E02001461
61640+:1059C000AF6200488F710048AF7100248E0B001841
61641+:1059D000AF6B006C9208000CA3680036937F003E0A
61642+:1059E00037F90020A379003E8F78007403058024E6
61643+:1059F000360F4000AF6F007493640000308900FFE1
61644+:105A0000513402452404FF803C04080024845A9841
61645+:105A10000E00028D000000003C1008008E105A9805
61646+:105A20000E00025602002021240600042407000173
61647+:105A3000A366007D020020210E00025FA36700051F
61648+:105A40008F5F017807E0FFFE240B0002AF5001409A
61649+:105A5000A34B01448F90001C3C081000AF48017814
61650+:105A60000A000362AF8000282CAD003751A0FF98D8
61651+:105A70008F9100140005A0803C180800271856BC20
61652+:105A8000029878218DEE000001C00008000000009F
61653+:105A90002418000614B80011000000003C0808009B
61654+:105AA0008D085A9824040005AF4800208E1F001866
61655+:105AB000AF7F00188F79004CAF79001C8F650050C4
61656+:105AC000122000C0AF6500700A000362AF84002896
61657+:105AD0002406000710A60083240300063C050800E6
61658+:105AE00024A55A980E000264240400818F90001CA3
61659+:105AF0000011102B0A000362AF8200282407000463
61660+:105B000014A7FFF6240500503C1808008F185A9877
61661+:105B1000AF5800208E0F0008AF6F00408E090008BC
61662+:105B2000AF6900448E14000CAF7400488E0E001054
61663+:105B3000AF6E004C8E0D0010AF6D00848E0A001405
61664+:105B4000AF6A00508E0C0018AF6C00548E04001C1D
61665+:105B5000AF64005893630000306B00FF116501D8FB
61666+:105B6000000000008F7400488F6900400289702394
61667+:105B700005C000042404008C1620FFDE240200036C
61668+:105B8000240400823C05080024A55A980E000287D0
61669+:105B9000000000008F90001C000010210A0003622A
61670+:105BA000AF820028240F000514AFFFCC240520008D
61671+:105BB0003C0708008CE75A98AF4700208E06000487
61672+:105BC000AF66005C9208000824100008A36800215A
61673+:105BD0008F9F001C93F90009A37900208F86001C79
61674+:105BE00090D8000A330400FF10900011000000005C
61675+:105BF0002885000914A0006924020002240A00205C
61676+:105C0000108A000B34058000288D002115A00008A3
61677+:105C100024054000240E0040108E00053C050001C4
61678+:105C200024140080109400023C050002240540006A
61679+:105C30008F7800743C19FF00031980240205782531
61680+:105C4000AF6F007490C4000BA36400818F84001CAC
61681+:105C50009489000C11200192000000009490000C27
61682+:105C60002406FFBF24050004A770003C908F000E9F
61683+:105C7000A36F003E8F84001C9089000FA369003F32
61684+:105C80008F8B001C8D6E00108F54007401D468231C
61685+:105C9000AF6D00608D6A0014AF6A0064956C0018E7
61686+:105CA000A76C00689563001AA763006A8D62001CE8
61687+:105CB000AF62006C9167000EA367003E9368003EE0
61688+:105CC0000106F8241220014BA37F003E8F90001C98
61689+:105CD0000A000362AF8500282407002214A7FF7F73
61690+:105CE000240300073C0B08008D6B5A981220000C0F
61691+:105CF000AF4B00200A000362AF830028240C00335E
61692+:105D000010AC0014240A00283C05080024A55A9869
61693+:105D10000E00023C240400810A0003EB8F90001C5B
61694+:105D20003C04080024845A980E00028D00000000F4
61695+:105D30009363000024110050306200FF10510135C0
61696+:105D4000000000008F90001C000018210A00036270
61697+:105D5000AF8300283C0D08008DAD5A9824040081C3
61698+:105D6000AF4D00203C05080024A55A980E00023CC7
61699+:105D7000A36A00348F90001C240200090A00036209
61700+:105D8000AF82002802B288213225FFFF0E000236C2
61701+:105D9000240400840A0003628F90001C1082FFA478
61702+:105DA00024050400288B000311600170240C0004FA
61703+:105DB000240300015483FF9E240540000A00043B95
61704+:105DC000240501003C04080024845A988F62004C8A
61705+:105DD0000E00028D8F6300508F90001C0000202168
61706+:105DE0000A000362AF8400288E1000042404008A95
61707+:105DF000AF50002093790005333800021700015F8F
61708+:105E0000020028219368002302002821311F00206E
61709+:105E100017E0015A2404008D9367003F2406001206
61710+:105E200030E200FF10460155240400810E000256A6
61711+:105E30000200202193630023240500040200202196
61712+:105E4000346B0042A36B00230E00025FA365007D4C
61713+:105E50008F4401780480FFFE240A0002AF50014005
61714+:105E6000A34A01448F90001C3C0C1000AF4C0178F9
61715+:105E70000A0003EC0011102B8E1000042404008A89
61716+:105E8000AF500020936E000531CD000215A0001622
61717+:105E900002002821936F003F2414000402002821EF
61718+:105EA00031E900FF11340010240400810E00025675
61719+:105EB000020020219362002324080012241FFFFE09
61720+:105EC00034460020A3660023A368003F93790005B1
61721+:105ED00002002021033FC0240E00025FA3780005CA
61722+:105EE00002002821000020210E00033400000000E1
61723+:105EF0000A0003EB8F90001C8E1000043C03000886
61724+:105F00000343A021AF500020928B000024050050D5
61725+:105F1000316400FF10850161240700880200202100
61726+:105F2000000028210E00022A2406000E928D000097
61727+:105F3000240EFF800200282101AE8025A2900000DF
61728+:105F4000240400040E000C5C240600300A0003EB5D
61729+:105F50008F90001C8E0800043C14080026945A9868
61730+:105F60003C010800AC285A98AF480020921F00035B
61731+:105F700033F9000413200002240200122402000658
61732+:105F8000A362003F920B001B2404FFC03165003F59
61733+:105F900000A43825A367003E9206000330C200012A
61734+:105FA00014400132000000008E020008AE8200089A
61735+:105FB0003C0208008C425AA010400131000249C244
61736+:105FC000A76900088E14000C240C0001240300149F
61737+:105FD000AF74002C8E0E0010AF6E0030960D0016C0
61738+:105FE000A76D0038960A0014A76A003AAF6C000C3F
61739+:105FF000A76C0010A76C0012A76C0014A76C001609
61740+:1060000012200136A3630034920F000331F0000226
61741+:106010002E1100018F90001C262200080A00036246
61742+:10602000AF8200288E0400043C0E0008034E30218D
61743+:10603000AF4400208E05000890CD0000240C0050D5
61744+:1060400031AA00FF114C00862407008824060009AD
61745+:106050000E00022A000000000A0003EB8F90001CD3
61746+:106060008E04001C0E00024100000000104000F4ED
61747+:10607000004050218F89001C240700890140202105
61748+:106080008D25001C240600010E00022A00000000DD
61749+:106090000A0003EB8F90001C960D00023C140800D0
61750+:1060A00026945A9831AA0004514000B83C10600070
61751+:1060B0008E0E001C3C010800AC2E5A98AF4E0020FA
61752+:1060C000920700102408001430E200FF144800D6A4
61753+:1060D00000000000960B00023163000114600165AE
61754+:1060E000000000008E020004AE8200083C1408008C
61755+:1060F0008E945AA01280015B000000008F7400741F
61756+:106100003C0380002404000102835825AF6B007417
61757+:10611000A3600005AF64000C3C0708008CE75AA0A0
61758+:106120008F86001CA7640010000711C2A76400122C
61759+:10613000A7640014A7640016A76200088CC80008B2
61760+:1061400024040002AF68002C8CC5000CAF65003041
61761+:1061500090DF0010A37F00348F99001C9330001152
61762+:10616000A37000358F98001C930F0012A36F0036A8
61763+:106170008F89001C912E0013A36E00378F90001C96
61764+:10618000960D0014A76D0038960A0016A76A003A0B
61765+:106190008E0C0018AF6C00245620FDCCAF84002874
61766+:1061A0003C05080024A55A980E0002640000202136
61767+:1061B0008F90001C0A0004A7000020218E1000040C
61768+:1061C00024070081AF500020936900233134001070
61769+:1061D000128000170000000002002021000028218A
61770+:1061E0002406001F0E00022A000000000A0003EB34
61771+:1061F0008F90001C3C05080024A55A980E000287C9
61772+:10620000240400828F90001C000028210A000362F1
61773+:10621000AF8500283C0408008C845A980E0014E8CE
61774+:10622000000000008F90001C0A000482000018216A
61775+:106230000E00025602002021937800230200202144
61776+:10624000370F00100E00025FA36F002300003821FB
61777+:1062500002002021000028210A0005A82406001FB2
61778+:10626000920F000C31E90001112000030000000032
61779+:106270009618000EA4D8002C921F000C33F90002CF
61780+:1062800013200005000038218E0200149608001229
61781+:10629000ACC2001CA4C8001A0A0005432406000969
61782+:1062A0003C05080024A55A980E0002872404008BA0
61783+:1062B0008F90001C0011282B0A000362AF85002874
61784+:1062C000AF6000843C0A08008D4A5A983C0D0800D3
61785+:1062D0008DAD0050240CFF803C02000C014D1821B4
61786+:1062E000006C2024AF4400288E070014306B007F20
61787+:1062F000017A282100A2C821AF2700D88E060014F9
61788+:10630000AF9900D0AF2600DC8E080010251FFFFEDD
61789+:106310000A000408AF3F01083C0508008CA55A9804
61790+:106320003C1908008F39005024CCFFFE00B9C02171
61791+:1063300003047824AF4F00283C1408008E945A9828
61792+:106340003C0908008D2900500289702131CD007F61
61793+:1063500001BA502101478021AE0600D8AF9000D08D
61794+:10636000AE0000DC0A0003B1AE0C0108548CFE3014
61795+:10637000240540000A00043B240510000E00032EF3
61796+:10638000000000000A0003EB8F90001C8E0F442CCD
61797+:106390003C186C62370979703C010800AC205A98AF
61798+:1063A00015E9000824050140979F00349786002CCA
61799+:1063B0000280282103E6C82B132000112404009238
61800+:1063C000240501400E000C7A240400023C01080060
61801+:1063D000AC225A98AF4200203C0508008CA55A9880
61802+:1063E00010A00005240400830E00084500000000F2
61803+:1063F00010400009240400833C05080024A55A9895
61804+:106400000E000264000000008F90001C0011202B81
61805+:106410000A000362AF8400280E0008490000000053
61806+:106420000A00055F8F90001C0E00084D0000000060
61807+:106430003C05080024A55A980A00062F2404008B66
61808+:10644000240400040E000C7A240500301440002AB5
61809+:10645000004050218F89001C240700830140202127
61810+:106460008D25001C0A000551240600018E04000839
61811+:106470000E000241000000000A00051BAE82000869
61812+:106480003C05080024A55A980E00023C240400870D
61813+:106490008F90001C0A0005360011102B8F830038E6
61814+:1064A0008F8600301066FE9D000038213C070800F2
61815+:1064B00024E75A1C000320C0008728218CAC000070
61816+:1064C00011900061246A00013143000F5466FFFA05
61817+:1064D000000320C00A0004F6000038213C05080033
61818+:1064E00024A55A980E000287240400828F90001C75
61819+:1064F0000A000536000010213C0B0008034B202148
61820+:106500002403005024070001AF420020A0830000B4
61821+:10651000A08700018F82001C90480004A08800180A
61822+:106520008F85001C90A60005A08600198F9F001C77
61823+:1065300093F90006A099001A8F90001C921800078A
61824+:10654000A098001B8F94001C928F0008A08F001C45
61825+:106550008F89001C912E0009A08E001D8F8D001CBC
61826+:1065600091AC000AA08C001E8F8B001C3C0C080014
61827+:10657000258C5A1C9163000B3C0B0800256B5A18A4
61828+:10658000A083001F8F87001C90E8000CA0880020CB
61829+:106590008F82001C9045000D24024646A0850021F4
61830+:1065A0008F86001C90DF000EA09F00228F99001C98
61831+:1065B0009330000FA09000238F98001C93140010BC
61832+:1065C000A09400248F8F001C91E90011A089002560
61833+:1065D0008F89001C8F8E00308F900038952D00140D
61834+:1065E000000E18C025C80001A48D002895270016AC
61835+:1065F000006C3021006BC821A487002A9525001863
61836+:106600003108000FA485002CA482002E8D3F001CB1
61837+:10661000ACCA0000AF88003011100006AF3F000088
61838+:10662000000038218D25001C014020210A00055161
61839+:1066300024060001250C00013184000F00003821E0
61840+:106640000A0006B8AF8400383C07080024E75A184F
61841+:106650000087302100003821ACA000000A0004F6B9
61842+:10666000ACC000003C05080024A55A980A00062F7B
61843+:10667000240400878E0400040E0002410000000084
61844+:106680000A00056AAE8200083084FFFF30C600FFB2
61845+:106690008F4201B80440FFFE00064400010430258B
61846+:1066A0003C07200000C720253C031000AF400180BC
61847+:1066B000AF450184AF44018803E00008AF4301B84F
61848+:1066C00027BDFFE8AFB00010AFBF00143C0760006B
61849+:1066D000240600021080000600A080210010102B6C
61850+:1066E0008FBF00148FB0001003E0000827BD001812
61851+:1066F0003C09600EAD2000348CE5201C8F82001C0C
61852+:106700002408FFFC00A81824ACE3201C0E0006D1CE
61853+:106710008C45000C0010102B8FBF00148FB00010A0
61854+:1067200003E0000827BD00183C02600E344701005A
61855+:1067300024090018274A040000000000000000009F
61856+:10674000000000003C06005034C30200AF44003893
61857+:10675000AF45003CAF430030014018218F4B000093
61858+:10676000316800201100FFFD2406007F2408FFFF90
61859+:106770008C6C000024C6FFFF24630004ACEC000016
61860+:1067800014C8FFFB24E70004000000000000000024
61861+:10679000000000003C0F0020AF4F00300000000060
61862+:1067A00024AD020001A5702B2529FFFF008E2021BA
61863+:1067B0001520FFE101A0282103E0000800000000EF
61864+:1067C00027BDFFE0AFB10014AFBF0018AFB000109D
61865+:1067D0003C05600E8CA20034008088211440000625
61866+:1067E0003C0460008C87201C2408FFFC00E8302457
61867+:1067F00034C30001AC83201C8F8B001C24090001D2
61868+:10680000ACA90034956900028D6500148D70000CF0
61869+:106810002D2400818D6700048D660008108000071C
61870+:106820008D6A00102D2C00041580000E30CE00075C
61871+:10683000312D000311A0000B000000002404008B88
61872+:10684000020028210E0006D1240600030011102B9F
61873+:106850008FBF00188FB100148FB0001003E0000844
61874+:1068600027BD002015C0FFF62404008B3C03002048
61875+:10687000AF4300300000000024020001AF8200148A
61876+:106880000000000000000000000000003C1F01505C
61877+:10689000013FC825253800033C0F600EAF47003884
61878+:1068A00000181882AF46003C35E8003CAF59003074
61879+:1068B000274704008F4400003086002010C0FFFDF1
61880+:1068C00000000000106000082466FFFF2403FFFFA3
61881+:1068D0008CEB000024C6FFFF24E70004AD0B000092
61882+:1068E00014C3FFFB250800043C08600EAD09003806
61883+:1068F0000000000000000000000000003C07002035
61884+:10690000AF470030000000000E0006F901402021D2
61885+:1069100002002821000020210E0006D124060003D9
61886+:106920000011102B8FBF00188FB100148FB0001012
61887+:1069300003E0000827BD002027BDFFE0AFB200182C
61888+:106940003092FFFFAFB10014AFBF001CAFB000101A
61889+:106950001640000D000088210A0007AA022010211D
61890+:1069600024050001508500278CE5000C0000000D77
61891+:10697000262300013071FFFF24E200200232382B71
61892+:1069800010E00019AF82001C8F8200141440001622
61893+:106990008F87001C3C0670003C0320008CE5000043
61894+:1069A00000A62024148300108F84003C00054402BC
61895+:1069B0003C09800000A980241480FFE9310600FF13
61896+:1069C0002CCA00095140FFEB262300010006688015
61897+:1069D0003C0E080025CE579801AE60218D8B00003B
61898+:1069E0000160000800000000022010218FBF001C81
61899+:1069F0008FB200188FB100148FB0001003E00008B0
61900+:106A000027BD00200E0006D1240400841600FFD804
61901+:106A10008F87001C0A00078BAF80003C90EF0002BC
61902+:106A200000002021240600090E0006D1000F2E00D0
61903+:106A30008F87001C0010102B0A00078BAF82003CD0
61904+:106A4000020028210E0006DF240400018F87001CAD
61905+:106A50000A00078BAF82003C020028210E0006DFEF
61906+:106A6000000020210A0007C38F87001C0E00071FAB
61907+:106A7000020020210A0007C38F87001C30B0FFFFEF
61908+:106A8000001019C08F5801B80700FFFE3C1F2004FA
61909+:106A90003C191000AF430180AF400184AF5F018813
61910+:106AA000AF5901B80A00078C262300013082FFFF8E
61911+:106AB00014400003000018210004240224030010E5
61912+:106AC000308500FF14A000053087000F2466000801
61913+:106AD0000004220230C300FF3087000F14E00005DD
61914+:106AE000308900032468000400042102310300FF00
61915+:106AF0003089000315200005388B0001246A00024C
61916+:106B000000042082314300FF388B00013164000112
61917+:106B100010800002246C0001318300FF03E00008B4
61918+:106B200000601021308BFFFF000B394230E600FF80
61919+:106B30003C09080025295998000640800109602178
61920+:106B40008D8700003164001F240A0001008A1804A8
61921+:106B500030A500FF00E3202514A000020003102749
61922+:106B600000E22024240F000100CF700401096821F5
61923+:106B7000000E282714800005ADA400008F86000CAD
61924+:106B800000A6102403E00008AF82000C8F88000CE0
61925+:106B900001C8102503E00008AF82000C3C06001F6E
61926+:106BA0003C0360003084FFFF34C5FF8024020020D6
61927+:106BB000AC602008AC60200CAC602010AC652014E8
61928+:106BC000AC642018AC62200000000000000000004F
61929+:106BD00003E000080000000027BDFFE82402FFFFDB
61930+:106BE000AFBF0010AF82000C000020213C0608005F
61931+:106BF00024C659982405FFFF248900010004408021
61932+:106C00003124FFFF010618212C87002014E0FFFA31
61933+:106C1000AC6500000E0008160000202124020001CF
61934+:106C20003C04600024050020AC822018AC852000C4
61935+:106C3000000000000000000000000000244A0001E5
61936+:106C40003142FFFF2C46040014C0FFF78FBF001035
61937+:106C500003E0000827BD00188F8300082C620400A1
61938+:106C600003E00008384200018F830008246200011D
61939+:106C700003E00008AF8200088F8300082462FFFF52
61940+:106C800003E00008AF82000827BDFFE0AFB10014A9
61941+:106C9000AFBF0018AFB000108F6B00303C06600033
61942+:106CA00000808821ACCB20088F6A002C3C02800039
61943+:106CB00024030008ACCA200C9769003A9768003892
61944+:106CC00000092C003107FFFF00A72025ACC42010CD
61945+:106CD000ACC22014ACC32000000000000000000083
61946+:106CE000000000003C0360008C6D200031AC000807
61947+:106CF0001580FFF9000000008C6E201405C00020F4
61948+:106D0000000000000E0007DA8F84000C00024080B3
61949+:106D10003C09080025295998010938218CE4000014
61950+:106D20000E0007DA00028140020220213090FFFFAE
61951+:106D3000020020210E0007F8000028213C0C8000F2
61952+:106D4000022C58253210FFFF3C116000240A00205D
61953+:106D5000AE2B2014AE302018AE2A20000000000018
61954+:106D60000000000000000000020010218FBF00188A
61955+:106D70008FB100148FB0001003E0000827BD002081
61956+:106D80008C6620143C02001F3443FF803C1FFFE848
61957+:106D900000C3C02437F9080003198021001079C20C
61958+:106DA0003C0C8000022C582531F0FFFF3C116000A4
61959+:106DB000240A0020AE2B2014AE302018AE2A20006A
61960+:106DC0000000000000000000000000000200102190
61961+:106DD0008FBF00188FB100148FB0001003E00008BF
61962+:106DE00027BD002027BDFFE8AFB000103402FFFF31
61963+:106DF0003090FFFFAFBF00141202000602002021F6
61964+:106E00000E00081600000000020020210E0007F806
61965+:106E1000240500018F8400088FBF00148FB000107C
61966+:106E20002483FFFF27BD001803E00008AF8300089C
61967+:106E3000000439C230E6003F00043B42000718401E
61968+:106E4000240210002CC4002024C8FFE0AF42002C14
61969+:106E5000246300011480000330A900FF00071840DC
61970+:106E6000310600FF0003608024080001019A5821C8
61971+:106E70003C0A000E00C82804016A382111200005D0
61972+:106E8000000530278CE900000125302503E00008CB
61973+:106E9000ACE600008CEE000001C6682403E00008A8
61974+:106EA000ACED000027BDFFE8AFBF0014AFB000108D
61975+:106EB0003C0460008C8508083403F00030A2F00028
61976+:106EC00050430006240200018C8708083404E000C7
61977+:106ED00030E6F00010C4001E24020002AF82004021
61978+:106EE0003C1060003C0A0200AE0A0814240910009D
61979+:106EF0003C08000E8E03440003482021AF49002CBB
61980+:106F0000240501200E000CC0000030218F830040BA
61981+:106F1000106000043C021691240B0001106B000E5F
61982+:106F20003C023D2C344F0090AE0F44088FBF00143C
61983+:106F30008FB000103C0C6000240E10003C0D0200CD
61984+:106F400027BD0018AD8E442003E00008AD8D081069
61985+:106F50000A0008E7AF8000403C0218DA344F009086
61986+:106F6000AE0F44088FBF00148FB000103C0C6000BF
61987+:106F7000240E10003C0D020027BD0018AD8E4420E9
61988+:106F800003E00008AD8D08100A0008BB24050001CD
61989+:106F90000A0008BB000028213C08080025085DA461
61990+:106FA0002404FFFF010018212402001E2442FFFFD9
61991+:106FB000AC6400000441FFFD246300043C070800AA
61992+:106FC00024E75E208CE5FFFC2404001C240600015D
61993+:106FD000308A001F0146480424840001000910275C
61994+:106FE0002C8300201460FFFA00A22824ACE5FFFCEB
61995+:106FF0003C05666634A4616E3C06080024C65EE06B
61996+:10700000AF840058AF88009C2404FFFF00C0182103
61997+:107010002402001F2442FFFFAC6400000441FFFD76
61998+:10702000246300043C0766663C05080024A55EA0B6
61999+:10703000AF86004834E6616EAF8600982404FFFFF7
62000+:1070400000A018212402000F2442FFFFAC640000BE
62001+:107050000441FFFD246300043C0B66663C06080007
62002+:1070600024C65E203568616EAF8500A4AF880070CD
62003+:107070002404FFFF00C018212402001F2442FFFF48
62004+:10708000AC6400000441FFFD246300043C0D66660F
62005+:107090003C0A0800254A5F6035AC616EAF860090FF
62006+:1070A000AF8C005C2404FFFF014018212402000380
62007+:1070B0002442FFFFAC6400000441FFFD2463000490
62008+:1070C0003C09080025295F708D27FFFC2404000679
62009+:1070D000240500013099001F0325C0042484000109
62010+:1070E000001878272C8E002015C0FFFA00EF3824F6
62011+:1070F000AD27FFFC3C09666624030400240403DC7E
62012+:1071000024050200240600663522616E3C08080052
62013+:1071100025085AA4AF820074AF830044AF83006C8B
62014+:10712000AF830050AF830084AF8A008CAF840064CB
62015+:10713000AF85004CAF860054AF840078AF85006007
62016+:10714000AF86008001001821240200022442FFFFC4
62017+:10715000AC6000000441FFFD24630004240400032C
62018+:107160002403000C3C0A0800254A5AB0AF8A006884
62019+:107170000A00098E2405FFFF000418802484000102
62020+:10718000006858212C8700C014E0FFFBAD650000AB
62021+:107190003C0E666635CD616E240C17A024081800DD
62022+:1071A000AF8D0088AF8C009403E00008AF88007CAE
62023+:1071B0002484007F000421C200004021000030210F
62024+:1071C00000003821000028210A0009A5AF8400A092
62025+:1071D0001060000624E7000100C4302124A500014E
62026+:1071E0002CC20BF51440FFFA2CA300663C090800E2
62027+:1071F00025295F6001201821240200032442FFFF9B
62028+:10720000AC6000000441FFFD2463000410E0001A9C
62029+:1072100024E3FFFF0003294210A0000A0000202100
62030+:107220002406FFFF3C03080024635F602484000100
62031+:107230000085502BAC660000250800011540FFFBBF
62032+:107240002463000430E2001F10400008000868803A
62033+:10725000240C0001004C38040008588001692821E2
62034+:1072600024E6FFFF03E00008ACA6000001A94021CE
62035+:107270002409FFFFAD09000003E000080000000042
62036+:10728000AF4400283C04000C034420210005288260
62037+:107290000A000CC000003021000421803C03600083
62038+:1072A000AC6410080000000000052980AC65100CDB
62039+:1072B0000000000003E000088C62100C27BDFFE80E
62040+:1072C0000080282124040038AFBF00140E0009D527
62041+:1072D000AFB0001024040E00AF4400283C10000C96
62042+:1072E00003502021240500100E000CC000003021A6
62043+:1072F00003501021AC400000AC40000424040038CE
62044+:107300008FBF00148FB0001024053FFF27BD001869
62045+:107310000A0009D58C430000000421803C03600072
62046+:10732000AC641008000000008C62100C03E0000840
62047+:107330000002118227BDFFC8AFB400208F940068FF
62048+:10734000AFBE0030AFB7002CAFB600280000B821A8
62049+:107350000080B021241E00C0AFBF0034AFB50024B0
62050+:10736000AFB3001CAFB20018AFB10014AFB0001043
62051+:107370000A000A12AFA5003C504000018F9400683B
62052+:1073800027DEFFFF13C00028269400048E92000021
62053+:107390003C03080024635DA01240FFF70283102B1A
62054+:1073A0003C04080024845AA4028410230002A8C0CC
62055+:1073B000000098210A000A212411000100118840D0
62056+:1073C000122000260000000002B380210251282470
62057+:1073D0000200202110A0FFF9267300010E0009DE33
62058+:1073E000000000000016684032EC000101AC2021D2
62059+:1073F0000E0009D5020028218F89009426F700018C
62060+:107400008FA6003C3AEB0001316A00012528FFFFFE
62061+:107410000011382702CAB021AF88009416E6FFE7B2
62062+:1074200002479024AE92000002E010218FBF00348A
62063+:107430008FBE00308FB7002C8FB600288FB5002488
62064+:107440008FB400208FB3001C8FB200188FB10014CE
62065+:107450008FB0001003E0000827BD00383C0E080084
62066+:1074600025CE5DA0028E102B0A000A0DAE92000000
62067+:1074700027BDFFD8AFB10014AFB00010AFBF0020E0
62068+:10748000AFB3001CAFB2001800A0882110A0001FED
62069+:10749000000480403C13080026735AA40A000A5ACC
62070+:1074A0002412000112200019261000010E0009F517
62071+:1074B00002002021000231422444FFA0000618806F
62072+:1074C0003045001F2C8217A1007318212631FFFFC1
62073+:1074D0001040FFF400B230048C690000020020214B
62074+:1074E00024053FFF012640241500FFEE0126382524
62075+:1074F0000E0009D5AC6700008F8A009426100001A9
62076+:10750000254700011620FFE9AF8700948FBF0020B8
62077+:107510008FB3001C8FB200188FB100148FB0001011
62078+:1075200003E0000827BD00288F85009C00805821BB
62079+:107530000000402100004821240A001F3C0C0800E4
62080+:10754000258C5E1C3C0D080025AD5DA48CA60000BA
62081+:1075500050C000140000402100AD1023000238C0CC
62082+:10756000240300010A000A930000202115000003F3
62083+:1075700000E410212448202400004821252900018E
62084+:10758000512B00132506DFDC106000062484000167
62085+:1075900000C3702415C0FFF5000318400A000A91CB
62086+:1075A0000000402110AC002624A300040060282124
62087+:1075B000254AFFFF1540FFE5AF85009C512B0004D5
62088+:1075C0002506DFDC0000402103E000080100102157
62089+:1075D0000006614230C5001F000C50803C070800C7
62090+:1075E00024E75DA424040001014730211120000F8D
62091+:1075F00000A420043C05080024A55E20148000059A
62092+:107600002529FFFF24C6000410C50011000000005A
62093+:10761000240400018CCF00000004C0270004204097
62094+:1076200001F868241520FFF5ACCD00008F99007893
62095+:1076300001001021032B482303E00008AF890078E4
62096+:107640003C05080024A55DA40A000A9B0000402117
62097+:107650003C06080024C65DA40A000AB42404000104
62098+:10766000308800FF240200021102000A24030003F4
62099+:107670001103005C8F8900A4240400041104005F3E
62100+:1076800024050005110500670000182103E000082B
62101+:10769000006010218F8900483C0C0800258C5EE0BA
62102+:1076A0003C04080024845F60240300201060000F65
62103+:1076B00000005821240D0002240E00033C0F080096
62104+:1076C00025EF5EE08D27000014E0000B30F9FFFF8E
62105+:1076D000252900040124C02B53000001018048210A
62106+:1076E0002463FFFF5460FFF88D270000016018211C
62107+:1076F00003E0000800601021132000323C0500FF69
62108+:1077000030E200FF004030211040004200005021D4
62109+:1077100024050001000020210005C84000A6C02467
62110+:1077200017000003332500FF14A0FFFB2484000191
62111+:10773000012CC023001828C000AA6021008C502111
62112+:107740003144001F240C0001008C18040003102792
62113+:1077500000E23024110D0041AD260000110E004C56
62114+:10776000000A1840110D00368F87006C510E00562C
62115+:107770008F8C0060240D0004110D005A8F8E008440
62116+:10778000240E0005150EFFDA01601821240B1430B9
62117+:1077900011400006000018218F8400A0246300011E
62118+:1077A000006A402B1500FFFD016458218F8A00807C
62119+:1077B000AF89008C016018212549FFFF0A000AEB00
62120+:1077C000AF89008000E52024000736021080FFD03A
62121+:1077D000240A001800075402314600FF0A000AF389
62122+:1077E000240A00103C0C0800258C5EA03C04080014
62123+:1077F00024845EE00A000ADA240300103C0C08002E
62124+:10780000258C5E203C04080024845EA00A000AD96E
62125+:107810008F89009000071A02306600FF0A000AF301
62126+:10782000240A00088F89008C3C0C0800258C5F60BE
62127+:107830003C04080024845F700A000ADA2403000470
62128+:10784000000A4080250B003024E6FFFF016018216C
62129+:10785000AF8900480A000AEBAF86006C000AC982B3
62130+:10786000001978803C07080024E75EA001E720218A
62131+:10787000000A18428C8F00003079001F032C380456
62132+:107880000007C02701F860240A000B08AC8C000038
62133+:10789000000331420006288000AF28213062001F1B
62134+:1078A0008CB8000024630001004CC804000321428E
62135+:1078B000001938270004108003073024004F2021CE
62136+:1078C0000A000B4CACA60000000A68C025AB0032D1
62137+:1078D000258AFFFF01601821AF8900A40A000AEB86
62138+:1078E000AF8A0060254B1030AF89009001601821ED
62139+:1078F00025C9FFFF0A000AEBAF8900843086000724
62140+:107900002CC2000610400014000000000006408059
62141+:107910003C030800246357BC010338218CE40000B9
62142+:1079200000800008000000002409000310A9000ED8
62143+:1079300000000000240A000510AA000B000000004F
62144+:10794000240B000110AB0008000000008F8C00A089
62145+:1079500010AC00050000000003E00008000010214A
62146+:107960000A000A7900A020210A000AC700C02021CD
62147+:1079700027BDFFE8308400FF240300021083000BC2
62148+:10798000AFBF0010240600031086003A240800044C
62149+:1079900010880068240E0005108E007F2CAF143074
62150+:1079A0008FBF001003E0000827BD00182CA2003094
62151+:1079B0001440FFFC8FBF001024A5FFD0000531C28A
62152+:1079C000000668803C07080024E75EE001A730213C
62153+:1079D0008CC900000005288230AC001F240B000178
62154+:1079E000018B50048F840048012A4025ACC8000058
62155+:1079F0008C83000050600001AF8600488F98006CB7
62156+:107A000030AE000124A6FFFF270F000115C00002C1
62157+:107A1000AF8F006C24A600010006414200082080C0
62158+:107A2000008718218C79000030C2001F2406000155
62159+:107A30000046F804033F382410E0FFDA8FBF00103F
62160+:107A40000005C182001870803C0F080025EF5EA081
62161+:107A500001CF48218D2B00000005684231A5001F91
62162+:107A600000A66004016C502527BD001803E0000843
62163+:107A7000AD2A00002CA7003014E0FFCA8FBF001011
62164+:107A800030B900071723FFC724A8FFCE00086A02F9
62165+:107A9000000D60803C0B0800256B5EA0018B30213F
62166+:107AA0008CC40000000828C230AA001F240800016E
62167+:107AB000014848048F8200A400891825ACC3000047
62168+:107AC0008C5F000053E00001AF8600A40005704009
62169+:107AD000000E7942000F28803C04080024845EE0F8
62170+:107AE00000A418218C6B000025DF000131CD001FA0
62171+:107AF000001F514201A86004016C4825000A108053
62172+:107B0000AC690000004428218CA600008F9800601A
62173+:107B100033F9001F8FBF00100328380400C77825F1
62174+:107B2000270E000127BD0018ACAF000003E00008DD
62175+:107B3000AF8E006024A5EFD02CB804001300FF998D
62176+:107B40008FBF001000053142000658803C0A080033
62177+:107B5000254A5E20016A30218CC4000030A3001F3A
62178+:107B600024090001006910048F9900900082F82513
62179+:107B7000ACDF00008F27000050E00001AF860090CE
62180+:107B80008F8D00848FBF001027BD001825AC000129
62181+:107B900003E00008AF8C008415E0FF828FBF001067
62182+:107BA0008F8600A0000610400046F821001F21002B
62183+:107BB00003E4C8210019384024F8143000B8402BE1
62184+:107BC0001100FF788FBF001024A4EBD00E00021329
62185+:107BD00000C0282100027942000F70803C0D08008F
62186+:107BE00025AD5F6001CD20218C8B0000304C001F43
62187+:107BF00024060001018618048F89008C016350253A
62188+:107C0000AC8A00008D25000050A00001AF84008CDC
62189+:107C10008F9800808FBF001027BD00182708000133
62190+:107C200003E00008AF88008030A5000724030003AC
62191+:107C300010A3001028A2000414400008240700022A
62192+:107C40002403000410A300152408000510A8000F49
62193+:107C50008F8500A003E000080000000014A7FFFDCE
62194+:107C60000080282114C3FFFB240400020A000B8BB0
62195+:107C700000000000240900050080282110C9FFFB36
62196+:107C80002404000303E000080000000014C5FFF115
62197+:107C9000008028210A000B8B24040005240A00011F
62198+:107CA0000080282110CAFFF12404000403E000082A
62199+:107CB0000000000027BDFFE0AFB00010000581C24A
62200+:107CC0002603FFD024C5003F2C6223D024C6007FAA
62201+:107CD000AFB20018AFB10014AFBF001C309100FF6D
62202+:107CE000000691C2000529820200202110400008F0
62203+:107CF0002403FFFF0E000A4B0000000002002021B9
62204+:107D0000022028210E000C390240302100001821E9
62205+:107D10008FBF001C8FB200188FB100148FB00010FD
62206+:107D20000060102103E0000827BD002027BDFFD818
62207+:107D300024A2007FAFB3001CAFB20018000299C2AA
62208+:107D4000309200FF24A3003F02402021026028213E
62209+:107D5000AFB10014AFB00010AFBF00200E000B6E2B
62210+:107D60000003898200408021004020210220282138
62211+:107D700014400009000018218FBF00208FB3001CA1
62212+:107D80008FB200188FB100148FB000100060102166
62213+:107D900003E0000827BD00280E0009FC00000000D9
62214+:107DA00000402821020020211051FFF3001019C0CB
62215+:107DB0000E000A4B00000000020020210240282192
62216+:107DC0000E000C39026030218FBF00208FB3001CE1
62217+:107DD0008FB200188FB100148FB00010000018216E
62218+:107DE0000060102103E0000827BD00283084FFFF59
62219+:107DF00030A5FFFF1080000700001821308200012D
62220+:107E00001040000200042042006518211480FFFB8E
62221+:107E10000005284003E000080060102110C00007A2
62222+:107E2000000000008CA2000024C6FFFF24A500046F
62223+:107E3000AC82000014C0FFFB2484000403E00008AF
62224+:107E40000000000010A0000824A3FFFFAC86000083
62225+:107E500000000000000000002402FFFF2463FFFF79
62226+:107E60001462FFFA2484000403E00008000000000C
62227+:107E700030A5FFFF8F4201B80440FFFE3C076015AC
62228+:107E800000A730253C031000AF440180AF400184BF
62229+:107E9000AF46018803E00008AF4301B88F8500D0EA
62230+:107EA0002C864000008018218CA700840087102BAE
62231+:107EB00014400010000000008CA800842D06400033
62232+:107EC00050C0000F240340008CAA0084008A482B75
62233+:107ED000512000018CA3008400035A42000B208033
62234+:107EE0003C05080024A558200085182103E000085F
62235+:107EF0008C62000014C0FFF4000000002403400066
62236+:107F000000035A42000B20803C05080024A558209D
62237+:107F10000085182103E000088C6200008F8300D0E8
62238+:107F2000906600D024C50001A06500D08F8500D0E8
62239+:107F3000906400D090A200D210440017000000000E
62240+:107F4000936C00788F8B00BC318A00FFA16A000C13
62241+:107F500025490001938700C4312200FF3048007F8B
62242+:107F60001107000B00026827A36200788F4E01788A
62243+:107F700005C0FFFE8F9900B0241800023C0F1000CE
62244+:107F8000AF590140A358014403E00008AF4F017806
62245+:107F90000A000D0931A20080A0A000D00A000CFF49
62246+:107FA000000000008F8700D027BDFFC8AFBF0030A2
62247+:107FB000AFB7002CAFB60028AFB50024AFB4002097
62248+:107FC000AFB3001CAFB20018AFB10014AFB00010D7
62249+:107FD00094E300E094E200E2104300D72405FFFFA1
62250+:107FE0003C047FFF3497FFFF2415FF800A000DF04B
62251+:107FF0003C16000E108A00D18FBF00308F9100B068
62252+:108000003C1808008F18005C001230C0001291402C
62253+:108010000311702101D57824AF4F002C94EC00E2BD
62254+:1080200031CD007F01BA5821318A7FFF0176482186
62255+:10803000000A804002091021945300003C08080007
62256+:108040008D0800580246C02132733FFF001319808B
62257+:10805000010320210224282130BF007F03FAC82118
62258+:1080600000B5A024AF54002C0336A0218E87001049
62259+:108070008E8F003003785821256D008800EF702323
62260+:10808000240C0002AE8E0010AF8D00ACA16C0088F5
62261+:10809000976A003C8E8400308F9100AC0E000CD6A5
62262+:1080A0003150FFFF00024B80020940253C02420094
62263+:1080B00001022025AE2400048E8300048F8D00ACC5
62264+:1080C0008E860000240E0008ADA3001CADA600188B
62265+:1080D000ADA0000CADA00010929F000A33F900FF84
62266+:1080E000A5B90014968500083C1F000CA5A5001634
62267+:1080F0009298000A331100FFA5B100209690000865
62268+:1081000024180005A5B00022ADA00024928F000B1A
62269+:108110002410C00031E700FFA5A70002A1AE0001B6
62270+:108120008E8C00308F8B00AC8F8400B0AD6C00085B
62271+:108130003C0A08008D4A005401444821013540247E
62272+:10814000AF4800283C0208008C4200540044302113
62273+:1081500030C3007F007AC821033F282102458821CF
62274+:10816000AF9100BCAF8500C0A23800008F8A00BC70
62275+:108170002403FFBF2418FFDF954F000201F03824CD
62276+:1081800000F37025A54E0002914D000231AC003F76
62277+:10819000358B0040A14B00028F8600BC8F8900D038
62278+:1081A000ACC000048D28007C3C098000ACC80008ED
62279+:1081B00090C4000D3082007FA0C2000D8F8500BCEE
62280+:1081C00090BF000D03E3C824A0B9000D8F9100BC3F
62281+:1081D0009233000D02789024A232000D8E9000346C
62282+:1081E0008F8B00BCAD7000108E87002C8E8F0030FE
62283+:1081F00000EF7023AD6E0014916D001831AC007F5C
62284+:10820000A16C00188F9F00BC8E8A00308FE8001888
62285+:10821000015720240109302400C41025AFE20018C2
62286+:108220009283000AA3E3001C969900088F8500BC86
62287+:108230008F9800D0A4B9001E8E9000308E8400303C
62288+:108240000E0002138F0500848F8500D0000291403C
62289+:108250000002990090AF00BC0253882100403021F9
62290+:1082600031E7000210E0000302118021000290803B
62291+:108270000212802190B900BC3327000410E00002F4
62292+:108280000006F880021F80218E9800308F8B00BC82
62293+:1082900024068000330F0003000F702331CD00034C
62294+:1082A000020D6021AD6C000494A400E294AA00E2E7
62295+:1082B00094B000E231497FFF2522000130537FFF57
62296+:1082C0000206182400734025A4A800E294A400E24A
62297+:1082D0003C1408008E94006030917FFF123400221D
62298+:1082E000000000000E000CF6000000008F8700D098
62299+:1082F0000000282194F300E094F000E21213000F34
62300+:108300008FBF003090E900D090E800D1313200FFFB
62301+:10831000310400FF0244302B14C0FF36264A00010E
62302+:1083200090EE00D2264B000131CD00FF008D602180
62303+:10833000158BFF338F9100B08FBF00308FB7002CAB
62304+:108340008FB600288FB500248FB400208FB3001C97
62305+:108350008FB200188FB100148FB0001000A0102150
62306+:1083600003E0000827BD003894A300E20066402423
62307+:10837000A4A800E290A400E290B900E2309100FFCE
62308+:108380000011A1C20014F827001F39C03332007F4A
62309+:10839000024730250A000DE8A0A600E23084FFFF66
62310+:1083A00030A5FFFFAF440018AF45001C03E00008F4
62311+:1083B0008F42001427BDFFB8AFB000208F9000D0CF
62312+:1083C0003084FFFFAFA40010AFBF0044AFBE004039
62313+:1083D000AFB7003CAFB60038AFB50034AFB4003033
62314+:1083E000AFB3002CAFB20028AFB10024A7A0001893
62315+:1083F000920600D1920500D030C400FF30A300FFE8
62316+:108400000064102B10400122AFA00014920900D08C
62317+:108410008FB50010312800FF0088382324F4FFFFB7
62318+:108420000014882B0015982B02339024524001260B
62319+:108430008FB40014961E0012961F00108FB7001004
62320+:1084400003DFC823001714000019C400000224032E
62321+:108450000018140302E2B02A52C00001004020219B
62322+:108460000284282B10A0000200801821028018210D
62323+:1084700000033C0000071C033064FFFF2C8600094A
62324+:1084800014C000020060B821241700088E0A0008FA
62325+:10849000001769808E09000C31ABFFFF3C0C001007
62326+:1084A000016C402527520400AF4A0038AF9200B853
62327+:1084B000AF49003CAF480030000000000000000061
62328+:1084C00000000000000000000000000000000000AC
62329+:1084D00000000000000000008F4F000031EE00207F
62330+:1084E00011C0FFFD0017982A027110240A000E83A4
62331+:1084F0000000B02155E001019258000131130080C5
62332+:10850000126001CF012020219655001232A5FFFFF5
62333+:108510000E000CCBA7B500188F9000D00291A023BD
62334+:1085200026CD00018F9100B8000DB4000016B403F1
62335+:108530002638004002D7582A0014882B2405000151
62336+:108540000300902101711024AF9800B8AFA500146A
62337+:10855000104001BC8F8900B03C0C08008D8C005489
62338+:10856000240BFF80921E00D001895021014B28244A
62339+:10857000921900D0AF4500288E4700103C08080033
62340+:108580008D0800583C1808008F18005430E33FFF56
62341+:108590000003218001043021012658212402FF809C
62342+:1085A0000162F824920C00D0AF5F002C92480000CA
62343+:1085B00033D100FF333500FF0309982100117140CA
62344+:1085C000001578C0326D007F01CF382101BA282113
62345+:1085D000318300FF3164007F3C0A000C00AA88212F
62346+:1085E0000367F02100033140009A10213108003F59
62347+:1085F0003C1F000E00D1C021005F982127D90088C0
62348+:108600002D150008AF9100C0AF9900ACAF9800BC29
62349+:10861000AF9300B412A0018A00008821240E00014B
62350+:10862000010E4004310D005D11A0FFB2310F0002B8
62351+:108630008E4A00283C0300803C04FFEFAE6A000035
62352+:108640008E450024A260000A3488FFFFAE65000456
62353+:108650009247002C3C1FFF9F37FEFFFFA267000CD4
62354+:108660008E62000C3C180040A267000B00433025CE
62355+:1086700000C8C824033E88240238A825AE75000C23
62356+:108680008E490004AE6000183C0F00FFAE69001474
62357+:108690008E4D002C35EEFFFF8F8B00B001AE6024B5
62358+:1086A000AE6C00108E470008A660000896450012C8
62359+:1086B000AE6700208E42000C30B03FFF00105180AA
62360+:1086C000AE6200248E5E0014014B182130A400011C
62361+:1086D000AE7E00288E590018000331C2000443808A
62362+:1086E000AE79002C8E51001C00C8F821A67F001C1A
62363+:1086F000AE710030965800028E550020A678001EFC
62364+:10870000AE75003492490033313000045600000544
62365+:10871000925000008F8C00D08D8B007CAE6B0030AF
62366+:10872000925000008F8F00BCA1F00000924E0033E9
62367+:1087300031CD000251A00007925E00018F8900BC7C
62368+:108740002418FF80913100000311A825A1350000F5
62369+:10875000925E00018F9900BC2409FFBF240BFFDF4C
62370+:10876000A33E00018F9500BC92B8000D3311007F2D
62371+:10877000A2B1000D8F8E00BC91D0000D02097824AB
62372+:10878000A1CF000D8F8800BC8E6D0014910A000DE2
62373+:108790002DAC0001000C2940014B382400E51825C0
62374+:1087A000A103000D964200128F8800BC8F8700D075
62375+:1087B000A50200028E45000490FF00BC30A4000317
62376+:1087C0000004302330DE000300BE102133F9000224
62377+:1087D00017200002244400342444003090E200BCFE
62378+:1087E00000A2302430DF000417E0000224830004DC
62379+:1087F000008018218F8F00AC24090002AD03000413
62380+:10880000A1E90000924E003F8F8D00ACA1AE0001A7
62381+:108810008F9500AC924C003F8E440004A6AC000241
62382+:10882000976B003C0E000CD63170FFFF00025380A6
62383+:10883000020A38253C05420000E51825AEA30004D5
62384+:108840008F8600AC8E480038ACC800188E440034C7
62385+:10885000ACC4001CACC0000CACC00010A4C0001420
62386+:10886000A4C00016A4C00020A4C00022ACC00024F4
62387+:108870008E6400145080000124040001ACC4000880
62388+:108880000E000CF6241100010A000E768F9000D025
62389+:10889000920F00D2920E00D08FB5001031EB00FF86
62390+:1088A00031CD00FF008D6023016C50212554FFFF66
62391+:1088B0000014882B0015982B023390241640FEDDFF
62392+:1088C000000000008FB400148FBF00448FBE004032
62393+:1088D0003A8200018FB7003C8FB600388FB5003464
62394+:1088E0008FB400308FB3002C8FB200288FB10024DA
62395+:1088F0008FB0002003E0000827BD0048331100209E
62396+:10890000122000EF24150001921E00BC241F00015C
62397+:108910000000A82133D900011320000DAFBF001CB7
62398+:108920008E4400148E0800840088102B144000022E
62399+:10893000008030218E0600848E03006400C3A82BC3
62400+:1089400016A0000200C020218E0400640080A8212F
62401+:108950008E4700148E05006400E5302B14C0000221
62402+:1089600000E020218E0400640095F02313C0000471
62403+:108970008FAC001C240A0002AFAA001C8FAC001CA4
62404+:10898000028C582B156000A8000018218E4F00386B
62405+:108990008E6D000C3C0E0080AE6F00008E4A0034DD
62406+:1089A0003C10FF9F01AE5825AE6A00049246003F7E
62407+:1089B000360CFFFF016C38243C0500203C03FFEF20
62408+:1089C000A266000B00E510253468FFFF8F8700B812
62409+:1089D0000048F8243C04000803E4C825AE79000CE4
62410+:1089E0008CF80014AE60001802BE7821AE78001436
62411+:1089F0008CF10018AE71001C8CE90008AE690024EF
62412+:108A00008CEE000CAE6F002CAE600028AE6E002025
62413+:108A1000A6600038A660003A8CED001401B58023F2
62414+:108A2000021E902312400011AE72001090EA003D29
62415+:108A30008E6500048E640000000A310000A6C82183
62416+:108A4000000010210326402B0082F82103E8C021FA
62417+:108A5000AE790004AE78000090F1003DA271000AEA
62418+:108A60008F8900B895320006A67200088F9800AC76
62419+:108A70002419000202A02021A31900009769003CDC
62420+:108A80008F9200AC0E000CD63131FFFF00027B80CC
62421+:108A90008F8500B8022F68253C0E420001AE80256C
62422+:108AA000AE5000048F8400AC8CAC0038AC8C001845
62423+:108AB0008CAB0034AC8B001CAC80000CAC80001084
62424+:108AC000A4800014A4800016A4800020A4800022AA
62425+:108AD000AC80002490A7003FA487000212A00135BB
62426+:108AE0002403000153C0000290A2003D90A2003E6A
62427+:108AF00024480001A08800018F9F00ACAFF500085A
62428+:108B00008F8300D024070034906600BC30C500027B
62429+:108B100050A00001240700308F9200B88F8A00BC5B
62430+:108B2000906D00BC924B00002412C00032A50003DF
62431+:108B3000A14B00008F8600B88F8800BC240200047F
62432+:108B400090C400010045182330790003A1040001FE
62433+:108B50008F8A00BC8F9F00B800F53821955800021D
62434+:108B600097E9001200F9382103128824312F3FFFC2
62435+:108B7000022F7025A54E00029150000231A800047A
62436+:108B8000320C003F358B0040A14B000212A00002C6
62437+:108B90008F8500BC00E838218F8E00D0ACA7000480
62438+:108BA000240BFFBF8DCD007C2EA400012403FFDF2A
62439+:108BB000ACAD000890B0000D00044140320C007FC5
62440+:108BC000A0AC000D8F8600BC90CA000D014B102494
62441+:108BD000A0C2000D8F8700BC90E5000D00A3F82413
62442+:108BE00003E8C825A0F9000D8F9100B88F8D00BC57
62443+:108BF0008E380020ADB800108E290024ADA90014D5
62444+:108C00008E2F0028ADAF00188E2E002C0E000CF613
62445+:108C1000ADAE001C8FB0001C240C0002120C00EE44
62446+:108C20008F9000D08FA3001C006088211460000288
62447+:108C30000060A8210000A02156A0FE390291A023C7
62448+:108C40000014882B8FA90010960700103C1E0020EE
62449+:108C50000136402302C750213112FFFFA60A00103F
62450+:108C6000AFB20010AF5E0030000000009617001099
62451+:108C7000961300121277008F000000008E05000C82
62452+:108C80008E0B00080016698000AD7021000DC7C36F
62453+:108C900001CDA82B0178782101F56021AE0E000CE2
62454+:108CA000AE0C00088FB300100013B82B02378024DD
62455+:108CB0001200FF048F9000D00A000E3C000000005C
62456+:108CC0008E4D0038A6600008240B0003AE6D000036
62457+:108CD0008E500034A260000A8F9800B8AE70000475
62458+:108CE0003C0500809311003FA26B000C8E6F000CBE
62459+:108CF0003C0EFF9FA271000B01E5102535CCFFFF54
62460+:108D00003C03FFEF8F9200B8004C30243464FFFF27
62461+:108D100000C4F824AE7F000C8E590014964800124F
62462+:108D20008F8A00B0AE7900108E490014AE60001832
62463+:108D3000AE600020AE690014AE6000248E470018BB
62464+:108D400031093FFF0009F180AE6700288E4D000811
62465+:108D500003CA802131180001AE6D00308E4F000C27
62466+:108D60008F8C00AC001089C200185B80022B282178
62467+:108D7000240E0002A665001CA6600036AE6F002C13
62468+:108D8000A18E00009763003C8F8A00AC3C04420037
62469+:108D90003062FFFF00443025AD4600048F9F00B8CD
62470+:108DA000240700012411C0008FF30038240600348A
62471+:108DB000AD5300188FF90034AD59001CAD40000CC4
62472+:108DC000AD400010A5400014A5400016A5400020AD
62473+:108DD000A5400022AD400024A5550002A147000196
62474+:108DE0008F9E00AC8F8800B88F9200BCAFD5000872
62475+:108DF000910D0000A24D00008F9000B88F8B00BC39
62476+:108E000092180001A17800018F8400BC94850002B3
62477+:108E100000B1782401E97025A48E0002908C000234
62478+:108E20003183003FA08300028F8300D08F8400BC79
62479+:108E3000906200BC305300025260000124060030F2
62480+:108E4000AC8600048C6F007C2403FFBF02A0882145
62481+:108E5000AC8F0008908E000D31CC007FA08C000DEF
62482+:108E60008F8600BC90C2000D00432024A0C4000DDA
62483+:108E70008F8900BC913F000D37F90020A139000D0A
62484+:108E80008F8800B88F9300BC8D070020AE6700105C
62485+:108E90008D0A0024AE6A00148D1E0028AE7E0018D4
62486+:108EA0008D12002C0E000CF6AE72001C0A00103D54
62487+:108EB0008F9000D0960E00148E03000431CCFFFF7B
62488+:108EC000000C10C000622021AF44003C8E1F000443
62489+:108ED0008F46003C03E6C8231B20003C0000000036
62490+:108EE0008E0F000025E200013C05001034B500089B
62491+:108EF000AF420038AF550030000000000000000015
62492+:108F00000000000000000000000000000000000061
62493+:108F100000000000000000008F580000330B00200C
62494+:108F20001160FFFD000000008F5304003C0D002085
62495+:108F3000AE1300088F570404AE17000CAF4D00307D
62496+:108F4000000000003C0608008CC600442416000106
62497+:108F500010D600BD00000000961F00123C0508005E
62498+:108F60008CA5004000BFC821A61900129609001464
62499+:108F700025270001A6070014960A00143144FFFFBC
62500+:108F80005486FF498FB30010A60000140E000E1681
62501+:108F900030A5FFFF3C0408008C84002496030012D7
62502+:108FA0000044102300623023A60600120A00105964
62503+:108FB0008FB30010A08300018F8200AC2404000155
62504+:108FC000AC4400080A000FF08F8300D08E0200002E
62505+:108FD0000A0010EA3C0500108F8200C08FA7001C19
62506+:108FE000921800D0920B00D0920E00D0331100FFE7
62507+:108FF000316900FF00117940000928C001E56021B6
62508+:1090000031C300FF036C50210003314000C2C8216E
62509+:10901000255F0088AF9F00ACAF9900BCA1470088D6
62510+:109020009768003C03C020218F9100AC0E000CD645
62511+:109030003110FFFF00026B80020DC0253C0442008E
62512+:109040008F8D00B803045825AE2B00048DA900387D
62513+:109050008F8B00AC0000882100118100AD690018E1
62514+:109060008DAF00343C087FFF3504FFFFAD6F001C5F
62515+:1090700091AC003E8D65001C8D660018000C190037
62516+:10908000000C770200A33821020E102500E3F82B14
62517+:1090900000C2C821033F5021AD67001CAD6A001813
62518+:1090A000AD60000CAD60001091B8003E24050005D5
62519+:1090B00003C45024A578001495A9000403C02021FE
62520+:1090C000A569001691AF003EA56F002095B1000480
62521+:1090D000A5710022AD60002491AE003FA56E000294
62522+:1090E00091B0003E91AC003D01901023244300015B
62523+:1090F000A16300018F8600AC8F9F00BCACDE00082E
62524+:10910000A3E500008F9000BC8F9900B82405FFBF35
62525+:1091100096070002973800120247782433093FFF70
62526+:1091200001E98825A6110002921200022418FFDF2F
62527+:10913000324E003F35CD0040A20D00028F8600BCAC
62528+:109140008F8C00D02412FFFFACC000048D8B007CFC
62529+:109150003C0C8000ACCB000890C2000D3043007F77
62530+:10916000A0C3000D8F8700BC90FF000D03E5C8244D
62531+:10917000A0F9000D8F9100BC9229000D01387824D0
62532+:10918000A22F000D8F9000BCAE120010AE1500147F
62533+:10919000920E00182415FF8002AE6825A20D00185B
62534+:1091A0008F8500BC8F8300B88CAB0018016C102435
62535+:1091B000004A3025ACA600189068003EA0A8001C0C
62536+:1091C0008F9F00B88F8700BC8F9800D097F900045C
62537+:1091D000A4F9001E0E0002138F0500848F8600D0B4
62538+:1091E000000279400002490090D200BC01E98821C8
62539+:1091F000004028213255000212A0000303D1202193
62540+:109200000002A8800095202190CD00BC31B200045E
62541+:109210001240000333DF0003000540800088202156
62542+:10922000240600048F9E00BC00DFC8233327000300
62543+:1092300000875021AFCA00040E000CF6A665003866
62544+:109240000A0010388F9000D0961E00123C080800CB
62545+:109250008D080024011E9021A61200120A00105948
62546+:109260008FB3001027BDFFE03C1808008F18005096
62547+:10927000AFB00010AFBF0018AFB10014AF8400B0A2
62548+:1092800093710074030478212410FF8031EE007F75
62549+:109290003225007F01F0582401DA68213C0C000AD5
62550+:1092A000A38500C401AC2821AF4B002494A9001071
62551+:1092B0009768000690A600620080382124020030E2
62552+:1092C0000109202330C300F0AF8500D010620019DF
62553+:1092D0003090FFFF90AE0062240DFFF0240A005092
62554+:1092E00001AE6024318B00FF116A002F00000000E6
62555+:1092F00016000007241F0C00AF5F00248FB100147C
62556+:109300008FBF00188FB0001003E0000827BD0020B9
62557+:109310000E000E1C02002021241F0C00AF5F002451
62558+:109320008FB100148FBF00188FB0001003E0000849
62559+:1093300027BD002094A200E094A400E290BF011396
62560+:10934000008218263079FFFF33E700C014E00009DF
62561+:109350002F31000116000038000000005620FFE603
62562+:10936000241F0C000E000D18000000000A0011ED73
62563+:10937000241F0C001620FFDE000000000E000D1858
62564+:10938000000000001440FFDC241F0C001600002227
62565+:109390008F8300D0906901133122003FA062011336
62566+:1093A0000A0011ED241F0C0094AF00D48F8600D466
62567+:1093B00000E02821240400050E000C5C31F0FFFFC2
62568+:1093C0001440000524030003979100E600001821D3
62569+:1093D0002625FFFFA78500E68F5801B80700FFFE8E
62570+:1093E0003C196013AF400180241F0C00AF50018472
62571+:1093F000007938253C101000AF4701888FB1001468
62572+:10940000AF5001B8AF5F00248FB000108FBF0018BD
62573+:1094100003E0000827BD00200E000E1C02002021E2
62574+:109420005040FFB5241F0C008F8300D090690113BA
62575+:109430000A0012163122003F0E000E1C02002021ED
62576+:109440001440FFAD241F0C00122000078F8300D0B2
62577+:10945000906801133106003F34C20040A06201133E
62578+:109460000A0011ED241F0C000E000D180000000072
62579+:109470005040FFA1241F0C008F8300D0906801137F
62580+:109480003106003F0A00124634C20040AF9B00C8BC
62581+:1094900003E00008AF8000EC3089FFFF0009404284
62582+:1094A0002D020041000921801440000200095040B3
62583+:1094B00024080040000830C0000811400046582130
62584+:1094C000256701A800E2C821272F007F2418FF800C
62585+:1094D00001F818240064302100CA702125CC00FF57
62586+:1094E000240DFF00018D202425650088240A0088B2
62587+:1094F0003C010800AC2A004C3C010800AC2500509F
62588+:10950000AF8400D43C010800AC2900603C01080095
62589+:10951000AC2800643C010800AC2700543C01080062
62590+:10952000AC2300583C010800AC26005C03E00008B6
62591+:1095300000000000308300FF30C6FFFF30E400FF72
62592+:109540008F4201B80440FFFE00034C00012438257F
62593+:109550003C08600000E820253C031000AF45018076
62594+:10956000AF460184AF44018803E00008AF4301B86F
62595+:109570008F86001C3C096012352700108CCB00043C
62596+:109580003C0C600E35850010316A00062D48000144
62597+:10959000ACE800C48CC40004ACA431808CC20008C8
62598+:1095A00094C30002ACA2318403E00008A78300E466
62599+:1095B0003C0308008C6300508F8400E88F86001CF9
62600+:1095C0002402FF800064C0210302C824AF59002890
62601+:1095D0008CCD00043305007F00BA78213C0E000CCE
62602+:1095E00001EE2821ACAD00588CC80008AF8500D032
62603+:1095F0003C076012ACA8005C8CCC001034E8001072
62604+:10960000ACAC000C8CCB000CACAB000894AA0014E2
62605+:109610003C0208008C42004425490001A4A9001422
62606+:1096200094A400143083FFFF106200178F8400D0D1
62607+:109630003C0A08008D4A0040A4AA00128CCE0018F3
62608+:10964000AC8E00248CCD0014AC8D00208CC700188B
62609+:10965000AC87002C8CCC001424060001AC8C0028B4
62610+:109660008D0B00BC5166001A8D0200B48D0200B84B
62611+:10967000A482003A948F003AA48F003C948800D4CE
62612+:1096800003E000083102FFFF3C0908008D29002497
62613+:10969000A4A000148F8400D0A4A900128CCE0018BE
62614+:1096A000AC8E00248CCD0014AC8D00208CC700182B
62615+:1096B000AC87002C8CCC001424060001AC8C002854
62616+:1096C0008D0B00BC5566FFEA8D0200B88D0200B418
62617+:1096D000A482003A948F003AA48F003C948800D46E
62618+:1096E00003E000083102FFFF8F86001C3C0C0800DD
62619+:1096F0008D8C0050240BFF808CCD00083C03000CA7
62620+:10970000000D51C0018A4021010B4824AF8A00E8B6
62621+:10971000AF49002890C700073105007F00BA10212B
62622+:109720000043282130E4000410800039AF8500D0C8
62623+:1097300090CF000731EE000811C000380000000093
62624+:109740008CD9000C8CC400140324C02B13000030EF
62625+:10975000000000008CC2000CACA200648CCD00188C
62626+:109760002402FFF8ACAD00688CCC0010ACAC0080DB
62627+:109770008CCB000CACAB00848CCA001CACAA007C67
62628+:1097800090A900BC01224024A0A800BC90C30007FF
62629+:109790003067000810E000048F8500D090AF00BC57
62630+:1097A00035EE0001A0AE00BC90D9000733380001AF
62631+:1097B000130000088F8300D08F8700D0240400346A
62632+:1097C00090E800BC35030002A0E300BC8F8300D00A
62633+:1097D000AC6400C090C900073126000210C000052B
62634+:1097E00000000000906A00BC35420004A06200BC8A
62635+:1097F0008F8300D09065011330AD003FA06D011341
62636+:109800008F8C00D0958B00D403E000083162FFFFFD
62637+:109810008CC200140A001305000000000A001306A1
62638+:10982000ACA0006427BDFFD8AFB000108F90001C23
62639+:10983000AFBF0024AFB40020AFB20018AFB1001426
62640+:10984000AFB3001C9613000E3C07600A3C14600680
62641+:109850003264FFFF369300100E00125534F40410EA
62642+:109860008F8400D43C11600E0E00099B363100102D
62643+:10987000920E00153C0708008CE700603C12601255
62644+:1098800031CD000FA38D00F08E0E00048E0D000868
62645+:1098900096080012961F00109619001A9618001EBE
62646+:1098A000960F001C310CFFFF33EBFFFF332AFFFF45
62647+:1098B0003309FFFF31E6FFFF3C010800AC2B0040FD
62648+:1098C0003C010800AC2C00243C010800AC2A0044F8
62649+:1098D000AE293178AE26317C92020015960300162F
62650+:1098E00036520010304400FF3065FFFF3C06080090
62651+:1098F0008CC60064AE243188AE4500B492080014D2
62652+:1099000096190018241F0001011FC004332FFFFF08
62653+:109910003C0508008CA50058AE5800B8AE4F00BCFE
62654+:10992000920C0014AF8E00D8AF8D00DC318B00FF9D
62655+:10993000AE4B00C0920A0015AE670048AE66004C00
62656+:10994000314900FFAE4900C8AE65007C3C03080009
62657+:109950008C6300503C0408008C84004C3C080800D8
62658+:109960008D0800543C0208008C42005C8FBF00242C
62659+:10997000AE6300808FB00010AE8300748FB3001C04
62660+:10998000AE22319CAE4200DCAE2731A0AE2631A41F
62661+:10999000AE24318CAE233190AE283194AE2531986F
62662+:1099A000AE870050AE860054AE8500708FB10014B3
62663+:1099B000AE4700E0AE4600E4AE4400CCAE4300D07B
62664+:1099C000AE4800D4AE4500D88FB400208FB2001846
62665+:1099D00003E0000827BD002827BDFFE0AFB1001459
62666+:1099E000AFBF0018241100010E000845AFB00010F1
62667+:1099F00010510005978400E6978300CC0083102B5C
62668+:109A0000144000088F8500D4240700028FBF00187F
62669+:109A10008FB100148FB0001000E0102103E00008A7
62670+:109A200027BD00200E000C7A24040005AF8200E858
62671+:109A30001040FFF6240700020E0008498F90001C1A
62672+:109A4000979F00E68F9900E88F8D00C827EF0001EF
62673+:109A5000240E0050AF590020A78F00E6A1AE0000F1
62674+:109A60003C0C08008D8C00648F8600C8240A80009E
62675+:109A7000000C5E00ACCB0074A4C0000694C9000AC0
62676+:109A8000241FFF803C0D000C012AC024A4D8000A2A
62677+:109A900090C8000A24182000011F1825A0C3000A3E
62678+:109AA0008F8700C8A0E000788F8500C800003821AB
62679+:109AB000A0A000833C0208008C4200508F8400E884
62680+:109AC0000044782101FFC824AF590028960B0002FA
62681+:109AD00031EE007F01DA6021018D3021A4CB00D46A
62682+:109AE000960A0002AF8600D03C0E000425492401EE
62683+:109AF000A4C900E68E080004ACC800048E03000868
62684+:109B0000ACC30000A4C00010A4C00014A0C000D0CA
62685+:109B10008F8500D02403FFBFA0A000D13C04080023
62686+:109B20008C8400648F8200D0A04400D28E1F000C71
62687+:109B30008F8A00D0978F00E4AD5F001C8E19001053
62688+:109B400024100030AD590018A5400030A551005434
62689+:109B5000A5510056A54F0016AD4E0068AD580080C7
62690+:109B6000AD580084914D006231AC000F358B001070
62691+:109B7000A14B00628F8600D090C900633128007F1E
62692+:109B8000A0C800638F8400D02406FFFF9085006387
62693+:109B900000A31024A08200638F9100D000E0102168
62694+:109BA000923F00BC37F90001A23900BC8F8A00D077
62695+:109BB000938F00F0AD580064AD5000C0914E00D3BB
62696+:109BC000000F690031CC000F018D5825A14B00D347
62697+:109BD0008F8500D08F8900DCACA900E88F8800D881
62698+:109BE0008FBF00188FB100148FB0001027BD002068
62699+:109BF000ACA800ECA4A600D6A4A000E0A4A000E2BB
62700+:109C000003E000080000000027BDFFE0AFB0001037
62701+:109C10008F90001CAFB10014AFBF00188E19000464
62702+:109C20003C1808008F180050240FFF80001989C0CD
62703+:109C30000238702131CD007F01CF602401BA50215C
62704+:109C40003C0B000CAF4C0028014B4021950900D47F
62705+:109C5000950400D68E0700043131FFFFAF8800D095
62706+:109C60000E000913000721C08E0600048F8300C870
62707+:109C7000000629C0AF4500209064003E30820040BD
62708+:109C8000144000068F8400D0341FFFFF948300D659
62709+:109C90003062FFFF145F000400000000948400D6CF
62710+:109CA0000E0008A83084FFFF8E050004022030213A
62711+:109CB0008FBF00188FB100148FB000102404002251
62712+:109CC00000003821000529C00A00127C27BD0020B1
62713+:109CD00027BDFFE0AFB100143091FFFFAFB000101F
62714+:109CE000AFBF00181220001D000080218F86001CCD
62715+:109CF0008CC500002403000600053F020005140285
62716+:109D000030E4000714830015304500FF2CA800063E
62717+:109D10001100004D000558803C0C0800258C57D4DC
62718+:109D2000016C50218D490000012000080000000056
62719+:109D30008F8E00EC240D000111CD005900000000B1
62720+:109D4000260B00013170FFFF24CA00200211202BD6
62721+:109D5000014030211480FFE6AF8A001C0200102170
62722+:109D60008FBF00188FB100148FB0001003E00008FF
62723+:109D700027BD0020938700CE14E00038240400148F
62724+:109D80000E001338000000008F86001C2402000122
62725+:109D90000A00147FAF8200EC8F8900EC24080002D7
62726+:109DA0001128003B2404001300002821000030216A
62727+:109DB000240700010E00127C000000000A00147F3E
62728+:109DC0008F86001C8F8700EC2405000214E5FFF647
62729+:109DD000240400120E0012E9000000008F8500E844
62730+:109DE00000403021240400120E00127C00003821B3
62731+:109DF0000A00147F8F86001C8F8300EC241F000351
62732+:109E0000147FFFD0260B00010E00129B0000000003
62733+:109E10008F8500E800403021240200022404001055
62734+:109E200000003821AF8200EC0E00127C0000000020
62735+:109E30000A00147F8F86001C8F8F00EC240600021E
62736+:109E400011E6000B0000000024040010000028218F
62737+:109E5000000030210A00149C240700010000282182
62738+:109E60000E00127C000030210A00147F8F86001C37
62739+:109E70000E0013A500000000144000128F99001C72
62740+:109E80008F86001C240200030A00147FAF8200ECBE
62741+:109E90000E001431000000000A00147F8F86001CA1
62742+:109EA0000E00128B000000002402000224040014A3
62743+:109EB0000000282100003021000038210A0014B9D8
62744+:109EC000AF8200EC004038212404001097380002D3
62745+:109ED000000028210E00127C3306FFFF0A00147FC9
62746+:109EE0008F86001C8F8400C83C077FFF34E6FFFF8D
62747+:109EF0008C8500742402000100A61824AC83007431
62748+:109F000003E00008A082000510A000362CA200800B
62749+:109F1000274A04003C0B000524090080104000077C
62750+:109F20002408008030A6000F00C540212D030081C9
62751+:109F30001460000200A0482124080080AF4B0030CC
62752+:109F400000000000000000000000000011000009F7
62753+:109F500000003821014030218C8D000024E70004EE
62754+:109F600000E8602BACCD0000248400041580FFFACB
62755+:109F700024C60004000000000000000000000000F3
62756+:109F80003C0E0006010E3825AF47003000000000EF
62757+:109F900000000000000000008F4F000031E80010BA
62758+:109FA0001100FFFD000000008F42003C8F43003C89
62759+:109FB0000049C8210323C02B130000040000000047
62760+:109FC0008F4C003825860001AF4600388F47003C93
62761+:109FD00000A9282300E96821AF4D003C14A0FFCE62
62762+:109FE0002CA2008003E000080000000027BDFFD085
62763+:109FF0003C020002AFB100143C11000CAF45003828
62764+:10A00000AFB3001CAF46003C00809821AF42003047
62765+:10A0100024050088AF44002803512021AFBF002849
62766+:10A02000AFB50024AFB40020AFB200180E0014F199
62767+:10A03000AFB000103C1F08008FFF004C3C18080018
62768+:10A040008F1800642410FF8003F3A82132B9007F29
62769+:10A0500002B078240018A0C0033A70210018914083
62770+:10A0600001D12021AF4F00280E0014F10254282105
62771+:10A070003C0D08008DAD00502405012001B358218E
62772+:10A08000316C007F01705024019A48210131202158
62773+:10A090000E0014F1AF4A00283C0808008D08005457
62774+:10A0A0003C0508008CA500640113382130E6007FD0
62775+:10A0B00000F0182400DA202100912021AF4300286D
62776+:10A0C0000E0014F1000529403C0208008C420058A3
62777+:10A0D0003C1008008E1000601200001C0053882104
62778+:10A0E0002415FF800A0015743C14000C3226007FF2
62779+:10A0F0000235182400DA202102402821AF4300282D
62780+:10A10000009420210E0014F12610FFC01200000F51
62781+:10A11000023288212E05004110A0FFF42412100005
62782+:10A120003226007F001091800235182400DA2021A9
62783+:10A1300002402821AF430028009420210E0014F192
62784+:10A14000000080211600FFF3023288213C0B08003A
62785+:10A150008D6B005C240AFF802405000201734021FE
62786+:10A16000010A4824AF4900283C0408009484006296
62787+:10A170003110007F021A88213C07000C0E000CAA47
62788+:10A180000227982100402821026020218FBF00284B
62789+:10A190008FB500248FB400208FB3001C8FB200183D
62790+:10A1A0008FB100148FB000100A0014F127BD0030E9
62791+:10A1B0008F83001C8C62000410400003000000002C
62792+:10A1C00003E00008000000008C6400108C650008AB
62793+:10A1D0000A00152A8C66000C000000000000001B1D
62794+:10A1E0000000000F0000000A000000080000000648
62795+:10A1F000000000050000000500000004000000044D
62796+:10A200000000000300000003000000030000000342
62797+:10A210000000000300000002000000020000000235
62798+:10A220000000000200000002000000020000000226
62799+:10A230000000000200000002000000020000000216
62800+:10A240000000000200000002000000020000000206
62801+:10A2500000000001000000010000000108000F24C0
62802+:10A2600008000D6C08000FB80800106008000F4CC3
62803+:10A2700008000F8C0800119408000D88080011B820
62804+:10A2800008000DD8080015540800151C08000D889A
62805+:10A2900008000D8808000D880800124008001240D0
62806+:10A2A00008000D8808000D88080014E008000D88DB
62807+:10A2B00008000D8808000D8808000D88080013B4F8
62808+:10A2C00008000D8808000D8808000D8808000D881A
62809+:10A2D00008000D8808000D8808000D8808000D880A
62810+:10A2E00008000D8808000D8808000D8808000D88FA
62811+:10A2F00008000D8808000D8808000FAC08000D88C4
62812+:10A3000008000D880800167808000D8808000D88E0
62813+:10A3100008000D8808000D8808000D8808000D88C9
62814+:10A3200008000D8808000D8808000D8808000D88B9
62815+:10A3300008000D8808000D8808000D8808000D88A9
62816+:10A3400008000D8808000D8808000D88080014100A
62817+:10A3500008000D8808000D8808001334080012A4B6
62818+:10A3600008001E2C08001EFC08001F1408001F28EF
62819+:10A3700008001F3808001E2C08001E2C08001E2C88
62820+:10A3800008001ED808002E1408002E1C08002DE41A
62821+:10A3900008002DF008002DFC08002E08080052F4DB
62822+:10A3A000080052B40800528008005254080052308D
62823+:10A3B000080051EC0A000C840000000000000000BE
62824+:10A3C0000000000D727870362E322E33000000002F
62825+:10A3D000060203030000000000000001000000006E
62826+:10A3E000000000000000000000000000000000006D
62827+:10A3F000000000000000000000000000000000005D
62828+:10A40000000000000000000000000000000000004C
62829+:10A41000000000000000000000000000000000003C
62830+:10A42000000000000000000000000000000000002C
62831+:10A43000000000000000000000000000000000001C
62832+:10A44000000000000000000000000000000000000C
62833+:10A4500000000000000000000000000000000000FC
62834+:10A4600000000000000000000000000000000000EC
62835+:10A4700000000000000000000000000000000000DC
62836+:10A4800000000000000000000000000000000000CC
62837+:10A4900000000000000000000000000000000000BC
62838+:10A4A00000000000000000000000000000000000AC
62839+:10A4B000000000000000000000000000000000009C
62840+:10A4C000000000000000000000000000000000008C
62841+:10A4D000000000000000000000000000000000007C
62842+:10A4E000000000000000000000000000000000006C
62843+:10A4F000000000000000000000000000000000005C
62844+:10A50000000000000000000000000000000000004B
62845+:10A51000000000000000000000000000000000003B
62846+:10A52000000000000000000000000000000000002B
62847+:10A53000000000000000000000000000000000001B
62848+:10A54000000000000000000000000000000000000B
62849+:10A5500000000000000000000000000000000000FB
62850+:10A5600000000000000000000000000000000000EB
62851+:10A5700000000000000000000000000000000000DB
62852+:10A5800000000000000000000000000000000000CB
62853+:10A5900000000000000000000000000000000000BB
62854+:10A5A00000000000000000000000000000000000AB
62855+:10A5B000000000000000000000000000000000009B
62856+:10A5C000000000000000000000000000000000008B
62857+:10A5D000000000000000000000000000000000007B
62858+:10A5E000000000000000000000000000000000006B
62859+:10A5F000000000000000000000000000000000005B
62860+:10A60000000000000000000000000000000000004A
62861+:10A61000000000000000000000000000000000003A
62862+:10A62000000000000000000000000000000000002A
62863+:10A63000000000000000000000000000000000001A
62864+:10A64000000000000000000000000000000000000A
62865+:10A6500000000000000000000000000000000000FA
62866+:10A6600000000000000000000000000000000000EA
62867+:10A6700000000000000000000000000000000000DA
62868+:10A6800000000000000000000000000000000000CA
62869+:10A6900000000000000000000000000000000000BA
62870+:10A6A00000000000000000000000000000000000AA
62871+:10A6B000000000000000000000000000000000009A
62872+:10A6C000000000000000000000000000000000008A
62873+:10A6D000000000000000000000000000000000007A
62874+:10A6E000000000000000000000000000000000006A
62875+:10A6F000000000000000000000000000000000005A
62876+:10A700000000000000000000000000000000000049
62877+:10A710000000000000000000000000000000000039
62878+:10A720000000000000000000000000000000000029
62879+:10A730000000000000000000000000000000000019
62880+:10A740000000000000000000000000000000000009
62881+:10A7500000000000000000000000000000000000F9
62882+:10A7600000000000000000000000000000000000E9
62883+:10A7700000000000000000000000000000000000D9
62884+:10A7800000000000000000000000000000000000C9
62885+:10A7900000000000000000000000000000000000B9
62886+:10A7A00000000000000000000000000000000000A9
62887+:10A7B0000000000000000000000000000000000099
62888+:10A7C0000000000000000000000000000000000089
62889+:10A7D0000000000000000000000000000000000079
62890+:10A7E0000000000000000000000000000000000069
62891+:10A7F0000000000000000000000000000000000059
62892+:10A800000000000000000000000000000000000048
62893+:10A810000000000000000000000000000000000038
62894+:10A820000000000000000000000000000000000028
62895+:10A830000000000000000000000000000000000018
62896+:10A840000000000000000000000000000000000008
62897+:10A8500000000000000000000000000000000000F8
62898+:10A8600000000000000000000000000000000000E8
62899+:10A8700000000000000000000000000000000000D8
62900+:10A8800000000000000000000000000000000000C8
62901+:10A8900000000000000000000000000000000000B8
62902+:10A8A00000000000000000000000000000000000A8
62903+:10A8B0000000000000000000000000000000000098
62904+:10A8C0000000000000000000000000000000000088
62905+:10A8D0000000000000000000000000000000000078
62906+:10A8E0000000000000000000000000000000000068
62907+:10A8F0000000000000000000000000000000000058
62908+:10A900000000000000000000000000000000000047
62909+:10A910000000000000000000000000000000000037
62910+:10A920000000000000000000000000000000000027
62911+:10A930000000000000000000000000000000000017
62912+:10A940000000000000000000000000000000000007
62913+:10A9500000000000000000000000000000000000F7
62914+:10A9600000000000000000000000000000000000E7
62915+:10A9700000000000000000000000000000000000D7
62916+:10A9800000000000000000000000000000000000C7
62917+:10A9900000000000000000000000000000000000B7
62918+:10A9A00000000000000000000000000000000000A7
62919+:10A9B0000000000000000000000000000000000097
62920+:10A9C0000000000000000000000000000000000087
62921+:10A9D0000000000000000000000000000000000077
62922+:10A9E0000000000000000000000000000000000067
62923+:10A9F0000000000000000000000000000000000057
62924+:10AA00000000000000000000000000000000000046
62925+:10AA10000000000000000000000000000000000036
62926+:10AA20000000000000000000000000000000000026
62927+:10AA30000000000000000000000000000000000016
62928+:10AA40000000000000000000000000000000000006
62929+:10AA500000000000000000000000000000000000F6
62930+:10AA600000000000000000000000000000000000E6
62931+:10AA700000000000000000000000000000000000D6
62932+:10AA800000000000000000000000000000000000C6
62933+:10AA900000000000000000000000000000000000B6
62934+:10AAA00000000000000000000000000000000000A6
62935+:10AAB0000000000000000000000000000000000096
62936+:10AAC0000000000000000000000000000000000086
62937+:10AAD0000000000000000000000000000000000076
62938+:10AAE0000000000000000000000000000000000066
62939+:10AAF0000000000000000000000000000000000056
62940+:10AB00000000000000000000000000000000000045
62941+:10AB10000000000000000000000000000000000035
62942+:10AB20000000000000000000000000000000000025
62943+:10AB30000000000000000000000000000000000015
62944+:10AB40000000000000000000000000000000000005
62945+:10AB500000000000000000000000000000000000F5
62946+:10AB600000000000000000000000000000000000E5
62947+:10AB700000000000000000000000000000000000D5
62948+:10AB800000000000000000000000000000000000C5
62949+:10AB900000000000000000000000000000000000B5
62950+:10ABA00000000000000000000000000000000000A5
62951+:10ABB0000000000000000000000000000000000095
62952+:10ABC0000000000000000000000000000000000085
62953+:10ABD0000000000000000000000000000000000075
62954+:10ABE0000000000000000000000000000000000065
62955+:10ABF0000000000000000000000000000000000055
62956+:10AC00000000000000000000000000000000000044
62957+:10AC10000000000000000000000000000000000034
62958+:10AC20000000000000000000000000000000000024
62959+:10AC30000000000000000000000000000000000014
62960+:10AC40000000000000000000000000000000000004
62961+:10AC500000000000000000000000000000000000F4
62962+:10AC600000000000000000000000000000000000E4
62963+:10AC700000000000000000000000000000000000D4
62964+:10AC800000000000000000000000000000000000C4
62965+:10AC900000000000000000000000000000000000B4
62966+:10ACA00000000000000000000000000000000000A4
62967+:10ACB0000000000000000000000000000000000094
62968+:10ACC0000000000000000000000000000000000084
62969+:10ACD0000000000000000000000000000000000074
62970+:10ACE0000000000000000000000000000000000064
62971+:10ACF0000000000000000000000000000000000054
62972+:10AD00000000000000000000000000000000000043
62973+:10AD10000000000000000000000000000000000033
62974+:10AD20000000000000000000000000000000000023
62975+:10AD30000000000000000000000000000000000013
62976+:10AD40000000000000000000000000000000000003
62977+:10AD500000000000000000000000000000000000F3
62978+:10AD600000000000000000000000000000000000E3
62979+:10AD700000000000000000000000000000000000D3
62980+:10AD800000000000000000000000000000000000C3
62981+:10AD900000000000000000000000000000000000B3
62982+:10ADA00000000000000000000000000000000000A3
62983+:10ADB0000000000000000000000000000000000093
62984+:10ADC0000000000000000000000000000000000083
62985+:10ADD0000000000000000000000000000000000073
62986+:10ADE0000000000000000000000000000000000063
62987+:10ADF0000000000000000000000000000000000053
62988+:10AE00000000000000000000000000000000000042
62989+:10AE10000000000000000000000000000000000032
62990+:10AE20000000000000000000000000000000000022
62991+:10AE30000000000000000000000000000000000012
62992+:10AE40000000000000000000000000000000000002
62993+:10AE500000000000000000000000000000000000F2
62994+:10AE600000000000000000000000000000000000E2
62995+:10AE700000000000000000000000000000000000D2
62996+:10AE800000000000000000000000000000000000C2
62997+:10AE900000000000000000000000000000000000B2
62998+:10AEA00000000000000000000000000000000000A2
62999+:10AEB0000000000000000000000000000000000092
63000+:10AEC0000000000000000000000000000000000082
63001+:10AED0000000000000000000000000000000000072
63002+:10AEE0000000000000000000000000000000000062
63003+:10AEF0000000000000000000000000000000000052
63004+:10AF00000000000000000000000000000000000041
63005+:10AF10000000000000000000000000000000000031
63006+:10AF20000000000000000000000000000000000021
63007+:10AF30000000000000000000000000000000000011
63008+:10AF40000000000000000000000000000000000001
63009+:10AF500000000000000000000000000000000000F1
63010+:10AF600000000000000000000000000000000000E1
63011+:10AF700000000000000000000000000000000000D1
63012+:10AF800000000000000000000000000000000000C1
63013+:10AF900000000000000000000000000000000000B1
63014+:10AFA00000000000000000000000000000000000A1
63015+:10AFB0000000000000000000000000000000000091
63016+:10AFC0000000000000000000000000000000000081
63017+:10AFD0000000000000000000000000000000000071
63018+:10AFE0000000000000000000000000000000000061
63019+:10AFF0000000000000000000000000000000000051
63020+:10B000000000000000000000000000000000000040
63021+:10B010000000000000000000000000000000000030
63022+:10B020000000000000000000000000000000000020
63023+:10B030000000000000000000000000000000000010
63024+:10B040000000000000000000000000000000000000
63025+:10B0500000000000000000000000000000000000F0
63026+:10B0600000000000000000000000000000000000E0
63027+:10B0700000000000000000000000000000000000D0
63028+:10B0800000000000000000000000000000000000C0
63029+:10B0900000000000000000000000000000000000B0
63030+:10B0A00000000000000000000000000000000000A0
63031+:10B0B0000000000000000000000000000000000090
63032+:10B0C0000000000000000000000000000000000080
63033+:10B0D0000000000000000000000000000000000070
63034+:10B0E0000000000000000000000000000000000060
63035+:10B0F0000000000000000000000000000000000050
63036+:10B10000000000000000000000000000000000003F
63037+:10B11000000000000000000000000000000000002F
63038+:10B12000000000000000000000000000000000001F
63039+:10B13000000000000000000000000000000000000F
63040+:10B1400000000000000000000000000000000000FF
63041+:10B1500000000000000000000000000000000000EF
63042+:10B1600000000000000000000000000000000000DF
63043+:10B1700000000000000000000000000000000000CF
63044+:10B1800000000000000000000000000000000000BF
63045+:10B1900000000000000000000000000000000000AF
63046+:10B1A000000000000000000000000000000000009F
63047+:10B1B000000000000000000000000000000000008F
63048+:10B1C000000000000000000000000000000000007F
63049+:10B1D000000000000000000000000000000000006F
63050+:10B1E000000000000000000000000000000000005F
63051+:10B1F000000000000000000000000000000000004F
63052+:10B20000000000000000000000000000000000003E
63053+:10B21000000000000000000000000000000000002E
63054+:10B22000000000000000000000000000000000001E
63055+:10B23000000000000000000000000000000000000E
63056+:10B2400000000000000000000000000000000000FE
63057+:10B2500000000000000000000000000000000000EE
63058+:10B2600000000000000000000000000000000000DE
63059+:10B2700000000000000000000000000000000000CE
63060+:10B2800000000000000000000000000000000000BE
63061+:10B2900000000000000000000000000000000000AE
63062+:10B2A000000000000000000000000000000000009E
63063+:10B2B000000000000000000000000000000000008E
63064+:10B2C000000000000000000000000000000000007E
63065+:10B2D000000000000000000000000000000000006E
63066+:10B2E000000000000000000000000000000000005E
63067+:10B2F000000000000000000000000000000000004E
63068+:10B30000000000000000000000000000000000003D
63069+:10B31000000000000000000000000000000000002D
63070+:10B32000000000000000000000000000000000001D
63071+:10B33000000000000000000000000000000000000D
63072+:10B3400000000000000000000000000000000000FD
63073+:10B3500000000000000000000000000000000000ED
63074+:10B3600000000000000000000000000000000000DD
63075+:10B3700000000000000000000000000000000000CD
63076+:10B3800000000000000000000000000000000000BD
63077+:10B3900000000000000000000000000000000000AD
63078+:10B3A000000000000000000000000000000000009D
63079+:10B3B000000000000000000000000000000000008D
63080+:10B3C000000000000000000000000000000000007D
63081+:10B3D000000000000000000000000000000000006D
63082+:10B3E000000000000000000000000000000000005D
63083+:10B3F000000000000000000000000000000000004D
63084+:10B40000000000000000000000000000000000003C
63085+:10B41000000000000000000000000000000000002C
63086+:10B42000000000000000000000000000000000001C
63087+:10B43000000000000000000000000000000000000C
63088+:10B4400000000000000000000000000000000000FC
63089+:10B4500000000000000000000000000000000000EC
63090+:10B4600000000000000000000000000000000000DC
63091+:10B4700000000000000000000000000000000000CC
63092+:10B4800000000000000000000000000000000000BC
63093+:10B4900000000000000000000000000000000000AC
63094+:10B4A000000000000000000000000000000000009C
63095+:10B4B000000000000000000000000000000000008C
63096+:10B4C000000000000000000000000000000000007C
63097+:10B4D000000000000000000000000000000000006C
63098+:10B4E000000000000000000000000000000000005C
63099+:10B4F000000000000000000000000000000000004C
63100+:10B50000000000000000000000000000000000003B
63101+:10B51000000000000000000000000000000000002B
63102+:10B52000000000000000000000000000000000001B
63103+:10B53000000000000000000000000000000000000B
63104+:10B5400000000000000000000000000000000000FB
63105+:10B5500000000000000000000000000000000000EB
63106+:10B5600000000000000000000000000000000000DB
63107+:10B5700000000000000000000000000000000000CB
63108+:10B5800000000000000000000000000000000000BB
63109+:10B5900000000000000000000000000000000000AB
63110+:10B5A000000000000000000000000000000000009B
63111+:10B5B000000000000000000000000000000000008B
63112+:10B5C000000000000000000000000000000000007B
63113+:10B5D000000000000000000000000000000000006B
63114+:10B5E000000000000000000000000000000000005B
63115+:10B5F000000000000000000000000000000000004B
63116+:10B60000000000000000000000000000000000003A
63117+:10B61000000000000000000000000000000000002A
63118+:10B62000000000000000000000000000000000001A
63119+:10B63000000000000000000000000000000000000A
63120+:10B6400000000000000000000000000000000000FA
63121+:10B6500000000000000000000000000000000000EA
63122+:10B6600000000000000000000000000000000000DA
63123+:10B6700000000000000000000000000000000000CA
63124+:10B6800000000000000000000000000000000000BA
63125+:10B6900000000000000000000000000000000000AA
63126+:10B6A000000000000000000000000000000000009A
63127+:10B6B000000000000000000000000000000000008A
63128+:10B6C000000000000000000000000000000000007A
63129+:10B6D000000000000000000000000000000000006A
63130+:10B6E000000000000000000000000000000000005A
63131+:10B6F000000000000000000000000000000000004A
63132+:10B700000000000000000000000000000000000039
63133+:10B710000000000000000000000000000000000029
63134+:10B720000000000000000000000000000000000019
63135+:10B730000000000000000000000000000000000009
63136+:10B7400000000000000000000000000000000000F9
63137+:10B7500000000000000000000000000000000000E9
63138+:10B7600000000000000000000000000000000000D9
63139+:10B7700000000000000000000000000000000000C9
63140+:10B7800000000000000000000000000000000000B9
63141+:10B7900000000000000000000000000000000000A9
63142+:10B7A0000000000000000000000000000000000099
63143+:10B7B0000000000000000000000000000000000089
63144+:10B7C0000000000000000000000000000000000079
63145+:10B7D0000000000000000000000000000000000069
63146+:10B7E0000000000000000000000000000000000059
63147+:10B7F0000000000000000000000000000000000049
63148+:10B800000000000000000000000000000000000038
63149+:10B810000000000000000000000000000000000028
63150+:10B820000000000000000000000000000000000018
63151+:10B830000000000000000000000000000000000008
63152+:10B8400000000000000000000000000000000000F8
63153+:10B8500000000000000000000000000000000000E8
63154+:10B8600000000000000000000000000000000000D8
63155+:10B8700000000000000000000000000000000000C8
63156+:10B8800000000000000000000000000000000000B8
63157+:10B8900000000000000000000000000000000000A8
63158+:10B8A0000000000000000000000000000000000098
63159+:10B8B0000000000000000000000000000000000088
63160+:10B8C0000000000000000000000000000000000078
63161+:10B8D0000000000000000000000000000000000068
63162+:10B8E0000000000000000000000000000000000058
63163+:10B8F0000000000000000000000000000000000048
63164+:10B900000000000000000000000000000000000037
63165+:10B910000000000000000000000000000000000027
63166+:10B920000000000000000000000000000000000017
63167+:10B930000000000000000000000000000000000007
63168+:10B9400000000000000000000000000000000000F7
63169+:10B9500000000000000000000000000000000000E7
63170+:10B9600000000000000000000000000000000000D7
63171+:10B9700000000000000000000000000000000000C7
63172+:10B9800000000000000000000000000000000000B7
63173+:10B9900000000000000000000000000000000000A7
63174+:10B9A0000000000000000000000000000000000097
63175+:10B9B0000000000000000000000000000000000087
63176+:10B9C0000000000000000000000000000000000077
63177+:10B9D0000000000000000000000000000000000067
63178+:10B9E0000000000000000000000000000000000057
63179+:10B9F0000000000000000000000000000000000047
63180+:10BA00000000000000000000000000000000000036
63181+:10BA10000000000000000000000000000000000026
63182+:10BA20000000000000000000000000000000000016
63183+:10BA30000000000000000000000000000000000006
63184+:10BA400000000000000000000000000000000000F6
63185+:10BA500000000000000000000000000000000000E6
63186+:10BA600000000000000000000000000000000000D6
63187+:10BA700000000000000000000000000000000000C6
63188+:10BA800000000000000000000000000000000000B6
63189+:10BA900000000000000000000000000000000000A6
63190+:10BAA0000000000000000000000000000000000096
63191+:10BAB0000000000000000000000000000000000086
63192+:10BAC0000000000000000000000000000000000076
63193+:10BAD0000000000000000000000000000000000066
63194+:10BAE0000000000000000000000000000000000056
63195+:10BAF0000000000000000000000000000000000046
63196+:10BB00000000000000000000000000000000000035
63197+:10BB10000000000000000000000000000000000025
63198+:10BB20000000000000000000000000000000000015
63199+:10BB30000000000000000000000000000000000005
63200+:10BB400000000000000000000000000000000000F5
63201+:10BB500000000000000000000000000000000000E5
63202+:10BB600000000000000000000000000000000000D5
63203+:10BB700000000000000000000000000000000000C5
63204+:10BB800000000000000000000000000000000000B5
63205+:10BB900000000000000000000000000000000000A5
63206+:10BBA0000000000000000000000000000000000095
63207+:10BBB0000000000000000000000000000000000085
63208+:10BBC0000000000000000000000000000000000075
63209+:10BBD0000000000000000000000000000000000065
63210+:10BBE0000000000000000000000000000000000055
63211+:10BBF0000000000000000000000000000000000045
63212+:10BC00000000000000000000000000000000000034
63213+:10BC10000000000000000000000000000000000024
63214+:10BC20000000000000000000000000000000000014
63215+:10BC30000000000000000000000000000000000004
63216+:10BC400000000000000000000000000000000000F4
63217+:10BC500000000000000000000000000000000000E4
63218+:10BC600000000000000000000000000000000000D4
63219+:10BC700000000000000000000000000000000000C4
63220+:10BC800000000000000000000000000000000000B4
63221+:10BC900000000000000000000000000000000000A4
63222+:10BCA0000000000000000000000000000000000094
63223+:10BCB0000000000000000000000000000000000084
63224+:10BCC0000000000000000000000000000000000074
63225+:10BCD0000000000000000000000000000000000064
63226+:10BCE0000000000000000000000000000000000054
63227+:10BCF0000000000000000000000000000000000044
63228+:10BD00000000000000000000000000000000000033
63229+:10BD10000000000000000000000000000000000023
63230+:10BD20000000000000000000000000000000000013
63231+:10BD30000000000000000000000000000000000003
63232+:10BD400000000000000000000000000000000000F3
63233+:10BD500000000000000000000000000000000000E3
63234+:10BD600000000000000000000000000000000000D3
63235+:10BD700000000000000000000000000000000000C3
63236+:10BD800000000000000000000000000000000000B3
63237+:10BD900000000000000000000000000000000000A3
63238+:10BDA0000000000000000000000000000000000093
63239+:10BDB0000000000000000000000000000000000083
63240+:10BDC0000000000000000000000000000000000073
63241+:10BDD0000000000000000000000000000000000063
63242+:10BDE0000000000000000000000000000000000053
63243+:10BDF0000000000000000000000000000000000043
63244+:10BE00000000000000000000000000000000000032
63245+:10BE10000000000000000000000000000000000022
63246+:10BE20000000000000000000000000000000000012
63247+:10BE30000000000000000000000000000000000002
63248+:10BE400000000000000000000000000000000000F2
63249+:10BE500000000000000000000000000000000000E2
63250+:10BE600000000000000000000000000000000000D2
63251+:10BE700000000000000000000000000000000000C2
63252+:10BE800000000000000000000000000000000000B2
63253+:10BE900000000000000000000000000000000000A2
63254+:10BEA0000000000000000000000000000000000092
63255+:10BEB0000000000000000000000000000000000082
63256+:10BEC0000000000000000000000000000000000072
63257+:10BED0000000000000000000000000000000000062
63258+:10BEE0000000000000000000000000000000000052
63259+:10BEF0000000000000000000000000000000000042
63260+:10BF00000000000000000000000000000000000031
63261+:10BF10000000000000000000000000000000000021
63262+:10BF20000000000000000000000000000000000011
63263+:10BF30000000000000000000000000000000000001
63264+:10BF400000000000000000000000000000000000F1
63265+:10BF500000000000000000000000000000000000E1
63266+:10BF600000000000000000000000000000000000D1
63267+:10BF700000000000000000000000000000000000C1
63268+:10BF800000000000000000000000000000000000B1
63269+:10BF900000000000000000000000000000000000A1
63270+:10BFA0000000000000000000000000000000000091
63271+:10BFB0000000000000000000000000000000000081
63272+:10BFC0000000000000000000000000000000000071
63273+:10BFD0000000000000000000000000000000000061
63274+:10BFE0000000000000000000000000000000000051
63275+:10BFF0000000000000000000000000000000000041
63276+:10C000000000000000000000000000000000000030
63277+:10C010000000000000000000000000000000000020
63278+:10C020000000000000000000000000000000000010
63279+:10C030000000000000000000000000000000000000
63280+:10C0400000000000000000000000000000000000F0
63281+:10C0500000000000000000000000000000000000E0
63282+:10C0600000000000000000000000000000000000D0
63283+:10C0700000000000000000000000000000000000C0
63284+:10C0800000000000000000000000000000000000B0
63285+:10C0900000000000000000000000000000000000A0
63286+:10C0A0000000000000000000000000000000000090
63287+:10C0B0000000000000000000000000000000000080
63288+:10C0C0000000000000000000000000000000000070
63289+:10C0D0000000000000000000000000000000000060
63290+:10C0E0000000000000000000000000000000000050
63291+:10C0F0000000000000000000000000000000000040
63292+:10C10000000000000000000000000000000000002F
63293+:10C11000000000000000000000000000000000001F
63294+:10C12000000000000000000000000000000000000F
63295+:10C1300000000000000000000000000000000000FF
63296+:10C1400000000000000000000000000000000000EF
63297+:10C1500000000000000000000000000000000000DF
63298+:10C1600000000000000000000000000000000000CF
63299+:10C1700000000000000000000000000000000000BF
63300+:10C1800000000000000000000000000000000000AF
63301+:10C19000000000000000000000000000000000009F
63302+:10C1A000000000000000000000000000000000008F
63303+:10C1B000000000000000000000000000000000007F
63304+:10C1C000000000000000000000000000000000006F
63305+:10C1D000000000000000000000000000000000005F
63306+:10C1E000000000000000000000000000000000004F
63307+:10C1F000000000000000000000000000000000003F
63308+:10C20000000000000000000000000000000000002E
63309+:10C21000000000000000000000000000000000001E
63310+:10C22000000000000000000000000000000000000E
63311+:10C2300000000000000000000000000000000000FE
63312+:10C2400000000000000000000000000000000000EE
63313+:10C2500000000000000000000000000000000000DE
63314+:10C2600000000000000000000000000000000000CE
63315+:10C2700000000000000000000000000000000000BE
63316+:10C2800000000000000000000000000000000000AE
63317+:10C29000000000000000000000000000000000009E
63318+:10C2A000000000000000000000000000000000008E
63319+:10C2B000000000000000000000000000000000007E
63320+:10C2C000000000000000000000000000000000006E
63321+:10C2D000000000000000000000000000000000005E
63322+:10C2E000000000000000000000000000000000004E
63323+:10C2F000000000000000000000000000000000003E
63324+:10C30000000000000000000000000000000000002D
63325+:10C31000000000000000000000000000000000001D
63326+:10C32000000000000000000000000000000000000D
63327+:10C3300000000000000000000000000000000000FD
63328+:10C3400000000000000000000000000000000000ED
63329+:10C3500000000000000000000000000000000000DD
63330+:10C3600000000000000000000000000000000000CD
63331+:10C3700000000000000000000000000000000000BD
63332+:10C3800000000000000000000000000000000000AD
63333+:10C39000000000000000000000000000000000009D
63334+:10C3A000000000000000000000000000000000008D
63335+:10C3B000000000000000000000000000000000007D
63336+:10C3C000000000000000000000000000000000006D
63337+:10C3D000000000000000000000000000000000005D
63338+:10C3E000000000000000000000000000000000004D
63339+:10C3F000000000000000000000000000000000003D
63340+:10C40000000000000000000000000000000000002C
63341+:10C41000000000000000000000000000000000001C
63342+:10C42000000000000000000000000000000000000C
63343+:10C4300000000000000000000000000000000000FC
63344+:10C4400000000000000000000000000000000000EC
63345+:10C4500000000000000000000000000000000000DC
63346+:10C4600000000000000000000000000000000000CC
63347+:10C4700000000000000000000000000000000000BC
63348+:10C4800000000000000000000000000000000000AC
63349+:10C49000000000000000000000000000000000009C
63350+:10C4A000000000000000000000000000000000008C
63351+:10C4B000000000000000000000000000000000007C
63352+:10C4C000000000000000000000000000000000006C
63353+:10C4D000000000000000000000000000000000005C
63354+:10C4E000000000000000000000000000000000004C
63355+:10C4F000000000000000000000000000000000003C
63356+:10C50000000000000000000000000000000000002B
63357+:10C51000000000000000000000000000000000001B
63358+:10C52000000000000000000000000000000000000B
63359+:10C5300000000000000000000000000000000000FB
63360+:10C5400000000000000000000000000000000000EB
63361+:10C5500000000000000000000000000000000000DB
63362+:10C5600000000000000000000000000000000000CB
63363+:10C5700000000000000000000000000000000000BB
63364+:10C5800000000000000000000000000000000000AB
63365+:10C59000000000000000000000000000000000009B
63366+:10C5A000000000000000000000000000000000008B
63367+:10C5B000000000000000000000000000000000007B
63368+:10C5C000000000000000000000000000000000006B
63369+:10C5D000000000000000000000000000000000005B
63370+:10C5E000000000000000000000000000000000004B
63371+:10C5F000000000000000000000000000000000003B
63372+:10C60000000000000000000000000000000000002A
63373+:10C61000000000000000000000000000000000001A
63374+:10C62000000000000000000000000000000000000A
63375+:10C6300000000000000000000000000000000000FA
63376+:10C6400000000000000000000000000000000000EA
63377+:10C6500000000000000000000000000000000000DA
63378+:10C6600000000000000000000000000000000000CA
63379+:10C6700000000000000000000000000000000000BA
63380+:10C6800000000000000000000000000000000000AA
63381+:10C69000000000000000000000000000000000009A
63382+:10C6A000000000000000000000000000000000008A
63383+:10C6B000000000000000000000000000000000007A
63384+:10C6C000000000000000000000000000000000006A
63385+:10C6D000000000000000000000000000000000005A
63386+:10C6E000000000000000000000000000000000004A
63387+:10C6F000000000000000000000000000000000003A
63388+:10C700000000000000000000000000000000000029
63389+:10C710000000000000000000000000000000000019
63390+:10C720000000000000000000000000000000000009
63391+:10C7300000000000000000000000000000000000F9
63392+:10C7400000000000000000000000000000000000E9
63393+:10C7500000000000000000000000000000000000D9
63394+:10C7600000000000000000000000000000000000C9
63395+:10C7700000000000000000000000000000000000B9
63396+:10C7800000000000000000000000000000000000A9
63397+:10C790000000000000000000000000000000000099
63398+:10C7A0000000000000000000000000000000000089
63399+:10C7B0000000000000000000000000000000000079
63400+:10C7C0000000000000000000000000000000000069
63401+:10C7D0000000000000000000000000000000000059
63402+:10C7E0000000000000000000000000000000000049
63403+:10C7F0000000000000000000000000000000000039
63404+:10C800000000000000000000000000000000000028
63405+:10C810000000000000000000000000000000000018
63406+:10C820000000000000000000000000000000000008
63407+:10C8300000000000000000000000000000000000F8
63408+:10C8400000000000000000000000000000000000E8
63409+:10C8500000000000000000000000000000000000D8
63410+:10C8600000000000000000000000000000000000C8
63411+:10C8700000000000000000000000000000000000B8
63412+:10C8800000000000000000000000000000000000A8
63413+:10C890000000000000000000000000000000000098
63414+:10C8A0000000000000000000000000000000000088
63415+:10C8B0000000000000000000000000000000000078
63416+:10C8C0000000000000000000000000000000000068
63417+:10C8D0000000000000000000000000000000000058
63418+:10C8E0000000000000000000000000000000000048
63419+:10C8F0000000000000000000000000000000000038
63420+:10C900000000000000000000000000000000000027
63421+:10C910000000000000000000000000000000000017
63422+:10C920000000000000000000000000000000000007
63423+:10C9300000000000000000000000000000000000F7
63424+:10C9400000000000000000000000000000000000E7
63425+:10C9500000000000000000000000000000000000D7
63426+:10C9600000000000000000000000000000000000C7
63427+:10C9700000000000000000000000000000000000B7
63428+:10C9800000000000000000000000000000000000A7
63429+:10C990000000000000000000000000000000000097
63430+:10C9A0000000000000000000000000000000000087
63431+:10C9B0000000000000000000000000000000000077
63432+:10C9C0000000000000000000000000000000000067
63433+:10C9D0000000000000000000000000000000000057
63434+:10C9E0000000000000000000000000000000000047
63435+:10C9F0000000000000000000000000000000000037
63436+:10CA00000000000000000000000000000000000026
63437+:10CA10000000000000000000000000000000000016
63438+:10CA20000000000000000000000000000000000006
63439+:10CA300000000000000000000000000000000000F6
63440+:10CA400000000000000000000000000000000000E6
63441+:10CA500000000000000000000000000000000000D6
63442+:10CA600000000000000000000000000000000000C6
63443+:10CA700000000000000000000000000000000000B6
63444+:10CA800000000000000000000000000000000000A6
63445+:10CA90000000000000000000000000000000000096
63446+:10CAA0000000000000000000000000000000000086
63447+:10CAB0000000000000000000000000000000000076
63448+:10CAC0000000000000000000000000000000000066
63449+:10CAD0000000000000000000000000000000000056
63450+:10CAE0000000000000000000000000000000000046
63451+:10CAF0000000000000000000000000000000000036
63452+:10CB00000000000000000000000000000000000025
63453+:10CB10000000000000000000000000000000000015
63454+:10CB20000000000000000000000000000000000005
63455+:10CB300000000000000000000000000000000000F5
63456+:10CB400000000000000000000000000000000000E5
63457+:10CB500000000000000000000000000000000000D5
63458+:10CB600000000000000000000000000000000000C5
63459+:10CB700000000000000000000000000000000000B5
63460+:10CB800000000000000000000000000000000000A5
63461+:10CB90000000000000000000000000000000000095
63462+:10CBA0000000000000000000000000000000000085
63463+:10CBB0000000000000000000000000000000000075
63464+:10CBC0000000000000000000000000000000000065
63465+:10CBD0000000000000000000000000000000000055
63466+:10CBE0000000000000000000000000000000000045
63467+:10CBF0000000000000000000000000000000000035
63468+:10CC00000000000000000000000000000000000024
63469+:10CC10000000000000000000000000000000000014
63470+:10CC20000000000000000000000000000000000004
63471+:10CC300000000000000000000000000000000000F4
63472+:10CC400000000000000000000000000000000000E4
63473+:10CC500000000000000000000000000000000000D4
63474+:10CC600000000000000000000000000000000000C4
63475+:10CC700000000000000000000000000000000000B4
63476+:10CC800000000000000000000000000000000000A4
63477+:10CC90000000000000000000000000000000000094
63478+:10CCA0000000000000000000000000000000000084
63479+:10CCB0000000000000000000000000000000000074
63480+:10CCC0000000000000000000000000000000000064
63481+:10CCD0000000000000000000000000000000000054
63482+:10CCE0000000000000000000000000000000000044
63483+:10CCF0000000000000000000000000000000000034
63484+:10CD00000000000000000000000000000000000023
63485+:10CD10000000000000000000000000000000000013
63486+:10CD20000000000000000000000000000000000003
63487+:10CD300000000000000000000000000000000000F3
63488+:10CD400000000000000000000000000000000000E3
63489+:10CD500000000000000000000000000000000000D3
63490+:10CD600000000000000000000000000000000000C3
63491+:10CD700000000000000000000000000000000000B3
63492+:10CD800000000000000000000000000000000000A3
63493+:10CD90000000000000000000000000000000000093
63494+:10CDA0000000000000000000000000000000000083
63495+:10CDB0000000000000000000000000000000000073
63496+:10CDC0000000000000000000000000000000000063
63497+:10CDD0000000000000000000000000000000000053
63498+:10CDE0000000000000000000000000000000000043
63499+:10CDF0000000000000000000000000000000000033
63500+:10CE00000000000000000000000000000000000022
63501+:10CE10000000000000000000000000000000000012
63502+:10CE20000000000000000000000000000000000002
63503+:10CE300000000000000000000000000000000000F2
63504+:10CE400000000000000000000000000000000000E2
63505+:10CE500000000000000000000000000000000000D2
63506+:10CE600000000000000000000000000000000000C2
63507+:10CE700000000000000000000000000000000000B2
63508+:10CE800000000000000000000000000000000000A2
63509+:10CE90000000000000000000000000000000000092
63510+:10CEA0000000000000000000000000000000000082
63511+:10CEB0000000000000000000000000000000000072
63512+:10CEC0000000000000000000000000000000000062
63513+:10CED0000000000000000000000000000000000052
63514+:10CEE0000000000000000000000000000000000042
63515+:10CEF0000000000000000000000000000000000032
63516+:10CF00000000000000000000000000000000000021
63517+:10CF10000000000000000000000000000000000011
63518+:10CF20000000000000000000000000000000000001
63519+:10CF300000000000000000000000000000000000F1
63520+:10CF400000000000000000000000000000000000E1
63521+:10CF500000000000000000000000000000000000D1
63522+:10CF600000000000000000000000000000000000C1
63523+:10CF700000000000000000000000000000000000B1
63524+:10CF800000000000000000000000000000000000A1
63525+:10CF90000000000000000000000000000000000091
63526+:10CFA0000000000000000000000000000000000081
63527+:10CFB0000000000000000000000000000000000071
63528+:10CFC0000000000000000000000000000000000061
63529+:10CFD0000000000000000000000000000000000051
63530+:10CFE0000000000000000000000000000000000041
63531+:10CFF0000000000000000000000000000000000031
63532+:10D000000000000000000000000000000000000020
63533+:10D010000000000000000000000000000000000010
63534+:10D020000000000000000000000000000000000000
63535+:10D0300000000000000000000000000000000000F0
63536+:10D0400000000000000000000000000000000000E0
63537+:10D0500000000000000000000000000000000000D0
63538+:10D0600000000000000000000000000000000000C0
63539+:10D0700000000000000000000000000000000000B0
63540+:10D0800000000000000000000000000000000000A0
63541+:10D090000000000000000000000000000000000090
63542+:10D0A0000000000000000000000000000000000080
63543+:10D0B0000000000000000000000000000000000070
63544+:10D0C0000000000000000000000000000000000060
63545+:10D0D0000000000000000000000000000000000050
63546+:10D0E0000000000000000000000000000000000040
63547+:10D0F0000000000000000000000000000000000030
63548+:10D10000000000000000000000000000000000001F
63549+:10D11000000000000000000000000000000000000F
63550+:10D1200000000000000000000000000000000000FF
63551+:10D1300000000000000000000000000000000000EF
63552+:10D1400000000000000000000000000000000000DF
63553+:10D1500000000000000000000000000000000000CF
63554+:10D1600000000000000000000000000000000000BF
63555+:10D1700000000000000000000000000000000000AF
63556+:10D18000000000000000000000000000000000009F
63557+:10D19000000000000000000000000000000000008F
63558+:10D1A000000000000000000000000000000000007F
63559+:10D1B000000000000000000000000000000000006F
63560+:10D1C000000000000000000000000000000000005F
63561+:10D1D000000000000000000000000000000000004F
63562+:10D1E000000000000000000000000000000000003F
63563+:10D1F000000000000000000000000000000000002F
63564+:10D20000000000000000000000000000000000001E
63565+:10D21000000000000000000000000000000000000E
63566+:10D2200000000000000000000000000000000000FE
63567+:10D2300000000000000000000000000000000000EE
63568+:10D2400000000000000000000000000000000000DE
63569+:10D2500000000000000000000000000000000000CE
63570+:10D2600000000000000000000000000000000000BE
63571+:10D2700000000000000000000000000000000000AE
63572+:10D28000000000000000000000000000000000009E
63573+:10D29000000000000000000000000000000000008E
63574+:10D2A000000000000000000000000000000000007E
63575+:10D2B000000000000000000000000000000000006E
63576+:10D2C000000000000000000000000000000000005E
63577+:10D2D000000000000000000000000000000000004E
63578+:10D2E000000000000000000000000000000000003E
63579+:10D2F000000000000000000000000000000000002E
63580+:10D30000000000000000000000000000000000001D
63581+:10D31000000000000000000000000000000000000D
63582+:10D3200000000000000000000000000000000000FD
63583+:10D3300000000000000000000000000000000000ED
63584+:10D3400000000000000000000000000000000000DD
63585+:10D3500000000000000000000000000000000000CD
63586+:10D3600000000000000000000000000000000000BD
63587+:10D3700000000000000000000000000000000000AD
63588+:10D38000000000000000000000000000000000009D
63589+:10D39000000000000000000000000000000000008D
63590+:10D3A000000000000000000000000000000000007D
63591+:10D3B000000000000000000000000000000000006D
63592+:10D3C000000000000000000000000000000000005D
63593+:10D3D000000000000000000000000000000000004D
63594+:10D3E000000000000000000000000000000000003D
63595+:10D3F000000000000000000000000000000000002D
63596+:10D40000000000000000000000000000000000001C
63597+:10D41000000000000000000000000000000000000C
63598+:10D4200000000000000000000000000000000000FC
63599+:10D4300000000000000000000000000000000000EC
63600+:10D4400000000000000000000000000000000000DC
63601+:10D4500000000000000000000000000000000000CC
63602+:10D4600000000000000000000000000000000000BC
63603+:10D4700000000000000000000000000000000000AC
63604+:10D48000000000000000000000000000000000009C
63605+:10D49000000000000000000000000000000000008C
63606+:10D4A000000000000000000000000000000000007C
63607+:10D4B000000000000000000000000000000000006C
63608+:10D4C000000000000000000000000000000000005C
63609+:10D4D000000000000000000000000000000000004C
63610+:10D4E000000000000000000000000000000000003C
63611+:10D4F000000000000000000000000000000000002C
63612+:10D50000000000000000000000000000000000001B
63613+:10D51000000000000000000000000000000000000B
63614+:10D5200000000000000000000000000000000000FB
63615+:10D5300000000000000000000000000000000000EB
63616+:10D5400000000000000000000000000000000000DB
63617+:10D5500000000000000000000000000000000000CB
63618+:10D5600000000000000000000000000000000000BB
63619+:10D5700000000000000000000000000000000000AB
63620+:10D58000000000000000000000000000000000009B
63621+:10D59000000000000000008000000000000000000B
63622+:10D5A000000000000000000000000000000000007B
63623+:10D5B00000000000000000000000000A0000000061
63624+:10D5C0000000000000000000100000030000000048
63625+:10D5D0000000000D0000000D3C02080024427340D2
63626+:10D5E0003C030800246377CCAC4000000043202BB0
63627+:10D5F0001480FFFD244200043C1D080037BD7FFC61
63628+:10D6000003A0F0213C100800261032103C1C08003A
63629+:10D61000279C73400E0010FE000000000000000D6B
63630+:10D6200030A5FFFF30C600FF274301808F4201B8BD
63631+:10D630000440FFFE24020002AC640000A465000860
63632+:10D64000A066000AA062000B3C021000AC67001844
63633+:10D6500003E00008AF4201B83C0360008C624FF861
63634+:10D660000440FFFE3C020200AC644FC0AC624FC4F9
63635+:10D670003C02100003E00008AC624FF89482000CFA
63636+:10D680002486001400A0382100021302000210803A
63637+:10D690000082402100C8102B1040005700000000FD
63638+:10D6A00090C300002C6200095040005190C200015C
63639+:10D6B000000310803C030800246372F00043102133
63640+:10D6C0008C420000004000080000000090C30001F0
63641+:10D6D0002402000A1462003A000000000106102330
63642+:10D6E0002C42000A1440003624C600028CE20000DE
63643+:10D6F00034420100ACE2000090C2000090C300017F
63644+:10D7000090C4000290C5000300031C000002160034
63645+:10D710000043102500042200004410250045102578
63646+:10D7200024C60004ACE2000490C2000090C30001D3
63647+:10D7300090C4000290C500030002160000031C0004
63648+:10D740000043102500042200004410250045102548
63649+:10D7500024C600040A000CB8ACE2000890C3000123
63650+:10D76000240200041462001624C6000290C20000C5
63651+:10D7700090C400018CE30000000212000044102558
63652+:10D780003463000424C60002ACE2000C0A000CB8AA
63653+:10D79000ACE3000090C300012402000314620008FF
63654+:10D7A00024C600028CE2000090C3000024C60001E1
63655+:10D7B00034420008A0E300100A000CB8ACE20000FC
63656+:10D7C00003E000082402000190C3000124020002CB
63657+:10D7D0001062000224C40002010020210A000CB8DB
63658+:10D7E000008030210A000CB824C6000190C200015C
63659+:10D7F0000A000CB800C2302103E00008000010212C
63660+:10D8000027BDFFE8AFBF0014AFB000100E00130239
63661+:10D8100000808021936200052403FFFE0200202186
63662+:10D82000004310248FBF00148FB00010A3620005C6
63663+:10D830000A00130B27BD001827BDFFE8AFB000108A
63664+:10D84000AFBF00140E000F3C0080802193620000E7
63665+:10D8500024030050304200FF14430004240201005E
63666+:10D86000AF4201800A000D3002002021AF4001804C
63667+:10D87000020020218FBF00148FB000100A000FE7B4
63668+:10D8800027BD001827BDFF80AFBE0078AFB700747A
63669+:10D89000AFB20060AFBF007CAFB60070AFB5006C38
63670+:10D8A000AFB40068AFB30064AFB1005CAFB0005874
63671+:10D8B0008F5001283C0208008C4231A02403FF80D5
63672+:10D8C0009365003F0202102100431024AF42002460
63673+:10D8D0003C0208008C4231A09364000530B200FF86
63674+:10D8E000020210213042007F034218210004202749
63675+:10D8F0003C02000A0062182130840001AF8300144A
63676+:10D900000000F0210000B82114800053AFA00050A7
63677+:10D9100093430116934401128F450104306300FFC5
63678+:10D920003C020001308400FF00A2282403431021A0
63679+:10D9300003441821245640002467400014A001CD60
63680+:10D940002402000193620000304300FF2402002003
63681+:10D950001062000524020050106200060000000062
63682+:10D960000A000D74000000000000000D0A000D7D8B
63683+:10D97000AFA000303C1E080027DE738C0A000D7D2E
63684+:10D98000AFA000303C0208008C4200DC24420001C1
63685+:10D990003C010800AC2200DC0E00139F00000000D8
63686+:10D9A0000A000F318FBF007C8F4201043C0300202E
63687+:10D9B00092D3000D004310240002202B00042140CC
63688+:10D9C000AFA400308F4301043C02004000621824E1
63689+:10D9D000146000023485004000802821326200205B
63690+:10D9E000AFA500301440000234A6008000A0302112
63691+:10D9F00010C0000BAFA6003093C500088F67004C25
63692+:10DA00000200202100052B0034A5008130A5F08103
63693+:10DA10000E000C9B30C600FF0A000F2E0000000015
63694+:10DA20009362003E304200401040000F2402000488
63695+:10DA300056420007240200120200202100E02821A3
63696+:10DA40000E0013F702C030210A000F318FBF007C97
63697+:10DA500016420005000000000E000D2100002021EC
63698+:10DA60000A000F318FBF007C9743011A96C4000E45
63699+:10DA700093620035326500043075FFFF00442004D6
63700+:10DA8000AFA400548ED1000410A000158ED400085D
63701+:10DA90009362003E3042004010400007000000004A
63702+:10DAA0000E0013E0022020211040000D00000000B5
63703+:10DAB0000A000F2E000000008F6200440222102393
63704+:10DAC0000440016A000000008F6200480222102317
63705+:10DAD00004410166240400160A000E218FC20004CE
63706+:10DAE0008F6200480222102304400008000000005A
63707+:10DAF0003C0208008C423100244200013C01080035
63708+:10DB0000AC2231000A000F23000000008F620040A9
63709+:10DB100002221023184000128F8400143C020800D7
63710+:10DB20008C423100327300FC0000A8212442000125
63711+:10DB30003C010800AC2231008F6300409482011C3C
63712+:10DB4000022318233042FFFF0043102A50400010E8
63713+:10DB50002402000C8F6200400A000DF20222102302
63714+:10DB60009483011C9762003C0043102B1040000678
63715+:10DB7000000000009482011C00551023A482011CA7
63716+:10DB80000A000DF72402000CA480011C2402000CE2
63717+:10DB9000AFA200308F620040005120231880000D9A
63718+:10DBA00002A4102A1440012600000000149500066B
63719+:10DBB00002A410233A620001304200011440012007
63720+:10DBC0000000000002A41023022488210A000E098C
63721+:10DBD0003055FFFF00002021326200021040001A81
63722+:10DBE000326200109362003E30420040504000110B
63723+:10DBF0008FC200040E00130202002021240200182C
63724+:10DC0000A362003F936200052403FFFE020020216F
63725+:10DC1000004310240E00130BA362000524040039F6
63726+:10DC2000000028210E0013C9240600180A000F3036
63727+:10DC300024020001240400170040F809000000003D
63728+:10DC40000A000F302402000110400108000000000B
63729+:10DC50008F63004C8F620054028210231C4001032A
63730+:10DC600002831023044200010060A021AFA4001829
63731+:10DC7000AFB10010AFB50014934201208F65004092
63732+:10DC80009763003C304200FF034210210044102102
63733+:10DC90008FA400543063FFFF244240000083182B00
63734+:10DCA0008FA40030AFA20020AFA50028008320255C
63735+:10DCB000AFA40030AFA50024AFA0002CAFB4003457
63736+:10DCC0009362003E30420008504000118FC20000B5
63737+:10DCD00002C0202127A500380E000CB2AFA00038EA
63738+:10DCE0005440000B8FC200008FA200383042010068
63739+:10DCF000504000078FC200008FA3003C8F6200607D
63740+:10DD00000062102304430001AF6300608FC2000073
63741+:10DD10000040F80927A400108FA200303042000212
63742+:10DD200054400001327300FE9362003E30420040D6
63743+:10DD3000104000378FA200248F6200541682001A10
63744+:10DD40003262000124020014124200102A4200151F
63745+:10DD500010400006240200162402000C12420007A4
63746+:10DD6000326200010A000E7D000000001242000530
63747+:10DD7000326200010A000E7D000000000A000E78E9
63748+:10DD80002417000E0A000E78241700100A000E7CDB
63749+:10DD900024170012936200232403FFBD00431024C4
63750+:10DDA000A362002332620001104000198FA20024F8
63751+:10DDB0002402000C1242000E2A42000D1040000600
63752+:10DDC0002402000E2402000A124200078FA200243F
63753+:10DDD0000A000E9524420001124200088FA200247E
63754+:10DDE0000A000E95244200010A000E932417000831
63755+:10DDF0002402000E16E20002241700162417001059
63756+:10DE00008FA2002424420001AFA200248FA200248C
63757+:10DE10008FA300148F76004000431021AF620040B2
63758+:10DE20008F8200149442011C104000090000000081
63759+:10DE30008F6200488F6400409763003C00441023C9
63760+:10DE40003063FFFF0043102A104000088FA20054E7
63761+:10DE5000936400368F6300403402FFFC008210049C
63762+:10DE600000621821AF6300488FA200548FA60030D3
63763+:10DE70000282902130C200081040000E0000000015
63764+:10DE80008F6200581642000430C600FF9742011A04
63765+:10DE90005040000134C6001093C500088FA700341D
63766+:10DEA0000200202100052B0034A500800E000C9BF1
63767+:10DEB00030A5F0808F620040005610231840001BF0
63768+:10DEC0008FA200183C0208008C42319830420010AA
63769+:10DED0001040000D24020001976200681440000AFF
63770+:10DEE000240200018F8200149442011C1440000699
63771+:10DEF00024020001A76200689742007A244200646D
63772+:10DF00000A000EE9A7620012A76200120E001302B7
63773+:10DF1000020020219362007D2403000102002021E1
63774+:10DF2000344200010A000EE7AFA300501840000A77
63775+:10DF3000000000000E001302020020219362007D09
63776+:10DF40002403000102002021AFA30050344200044A
63777+:10DF50000E00130BA362007D9362003E304200402E
63778+:10DF60001440000C326200011040000A0000000062
63779+:10DF70008F6300408FC20004240400182463000152
63780+:10DF80000040F809AF6300408FA200300A000F3054
63781+:10DF9000304200048F620058105200100000000050
63782+:10DFA0008F620018022210231C4000082404000184
63783+:10DFB0008F62001816220009000000008F62001C0A
63784+:10DFC000028210230440000500000000AF720058D8
63785+:10DFD000AFA40050AF710018AF74001C12E0000B2A
63786+:10DFE0008FA200500E00130202002021A377003FF1
63787+:10DFF0000E00130B0200202102E030212404003720
63788+:10E000000E0013C9000028218FA200501040000309
63789+:10E01000000000000E000CA90200202112A0000543
63790+:10E02000000018218FA2003030420004504000113F
63791+:10E0300000601021240300010A000F30006010214D
63792+:10E040000E001302020020219362007D02002021B5
63793+:10E05000344200040E00130BA362007D0E000CA9D5
63794+:10E06000020020210A000F3024020001AF400044CA
63795+:10E07000240200018FBF007C8FBE00788FB7007430
63796+:10E080008FB600708FB5006C8FB400688FB30064DA
63797+:10E090008FB200608FB1005C8FB0005803E00008C1
63798+:10E0A00027BD00808F4201B80440FFFE2402080013
63799+:10E0B000AF4201B803E00008000000003C02000885
63800+:10E0C00003421021944200483084FFFF2484001250
63801+:10E0D0003045FFFF10A0001700A4102B10400016C1
63802+:10E0E00024020003934201202403001AA343018B5E
63803+:10E0F000304200FF2446FFFE8F82000000A6182B4E
63804+:10E100003863000100021382004310241040000510
63805+:10E110008F84000434820001A746019403E00008C4
63806+:10E12000AF8200042402FFFE0082102403E00008F6
63807+:10E13000AF8200042402000303E00008A342018B25
63808+:10E1400027BDFFE0AFB10014AFB00010AFBF0018A3
63809+:10E1500030B0FFFF30D1FFFF8F4201B80440FFFE17
63810+:10E1600000000000AF440180AF4400200E000F42C9
63811+:10E17000020020218F8300008F840004A750019AA1
63812+:10E18000A750018EA74301908F8300083082800042
63813+:10E19000AF4301A8A75101881040000E8F820004F0
63814+:10E1A00093420116304200FC24420004005A102120
63815+:10E1B0008C4240003042FFFF144000068F82000472
63816+:10E1C0003C02FFFF34427FFF00821024AF82000434
63817+:10E1D0008F8200042403BFFF00431024A74201A63E
63818+:10E1E0009743010C8F42010400031C003042FFFFE3
63819+:10E1F00000621825AF4301AC3C021000AF4201B8E9
63820+:10E200008FBF00188FB100148FB0001003E000081A
63821+:10E2100027BD00208F470070934201128F830000BA
63822+:10E2200027BDFFF0304200FF00022882306201006B
63823+:10E23000000030211040004324A40003306240005D
63824+:10E24000104000103062200000041080005A10219D
63825+:10E250008C43400024A4000400041080AFA30000FD
63826+:10E26000005A10218C424000AFA2000493420116D4
63827+:10E27000304200FC005A10218C4240000A000FC0BE
63828+:10E28000AFA200081040002F0000302100041080D1
63829+:10E29000005A10218C43400024A400040004108084
63830+:10E2A000AFA30000005A10218C424000AFA000082C
63831+:10E2B000AFA200048FA80008000030210000202138
63832+:10E2C000240A00083C0908002529010003A41021A4
63833+:10E2D000148A000300042A001100000A0000000054
63834+:10E2E00090420000248400012C83000C00A2102125
63835+:10E2F00000021080004910218C4200001460FFF3DE
63836+:10E3000000C230263C0408008C8431048F42007027
63837+:10E310002C83002010600009004738233C030800CC
63838+:10E32000246331080004108000431021248300017D
63839+:10E33000AC4700003C010800AC233104AF86000864
63840+:10E340002406000100C0102103E0000827BD0010D2
63841+:10E350003C0208008C42003827BDFFD0AFB5002436
63842+:10E36000AFB40020AFB10014AFBF0028AFB3001CA2
63843+:10E37000AFB20018AFB00010000088213C150800B3
63844+:10E3800026B50038144000022454FFFF0000A021ED
63845+:10E390009742010E8F8400003042FFFF308340001F
63846+:10E3A0001060000A245200043C0200200082102465
63847+:10E3B00050400007308280008F8200042403BFFF9A
63848+:10E3C000008318240A0010103442100030828000AC
63849+:10E3D0001040000A3C020020008210241040000778
63850+:10E3E0008F8200043C03FFFF34637FFF0083182407
63851+:10E3F00034428000AF820004AF8300000E000F980B
63852+:10E400000000000014400007000000009743011EB8
63853+:10E410009742011C3063FFFF0002140000621825C0
63854+:10E42000AF8300089742010C8F4340003045FFFF47
63855+:10E430003402FFFF14620003000000000A001028ED
63856+:10E44000241100208F42400030420100544000015E
63857+:10E45000241100108F8400003082100050400014FE
63858+:10E4600036310001308200201440000B3C021000C5
63859+:10E47000008210245040000E363100013C030E0093
63860+:10E480003C020DFF008318243442FFFF0043102B91
63861+:10E4900050400007363100013C0208008C42002C3D
63862+:10E4A000244200013C010800AC22002C363100055A
63863+:10E4B0003C0608008CC6003454C000238F85000041
63864+:10E4C0008F820004304240005440001F8F850000BE
63865+:10E4D0003C021F01008210243C0310005443001A28
63866+:10E4E0008F85000030A20200144000178F850000C5
63867+:10E4F0003250FFFF363100028F4201B80440FFFE68
63868+:10E5000000000000AF400180020020210E000F42F9
63869+:10E51000AF4000208F8300042402BFFFA750019A60
63870+:10E52000006218248F820000A750018EA751018835
63871+:10E53000A74301A6A74201903C021000AF4201B8D8
63872+:10E540000A0010F5000010213C02100000A2102467
63873+:10E550001040003A0000000010C0000F0000000052
63874+:10E5600030A201001040000C3C0302003C020F00EE
63875+:10E5700000A2102410430008000000008F82000851
63876+:10E58000005410240055102190420004244200043D
63877+:10E590000A00109F000221C00000000000051602C2
63878+:10E5A0003050000F3A0300022E4203EF38420001C0
63879+:10E5B0002C6300010062182414600073240200011F
63880+:10E5C0003C0308008C6300D02E06000C386200016A
63881+:10E5D0002C4200010046102414400015001021C0F8
63882+:10E5E0002602FFFC2C4200045440001100002021B0
63883+:10E5F000386200022C420001004610241040000343
63884+:10E60000000512420A00109F000020210010182B64
63885+:10E610000043102450400006001021C000002021BB
63886+:10E620003245FFFF0E000F633226FFFB001021C0B2
63887+:10E630003245FFFF0A0010F2362600028F424000EA
63888+:10E640003C0308008C630024304201001040004667
63889+:10E6500030620001322200043070000D14400002CC
63890+:10E660002413000424130002000512C238420001E2
63891+:10E670002E4303EF304200013863000100431025B0
63892+:10E68000104000033231FFFB2402FFFB0202802412
63893+:10E6900010C000183202000130A201001040001525
63894+:10E6A000320200013C020F0000A210243C030200D1
63895+:10E6B0001043000F8F8200082403FFFE0203802412
63896+:10E6C00000541024005510219042000402333025DC
63897+:10E6D0002442000412000002000221C03226FFFF83
63898+:10E6E0000E000F633245FFFF1200002700001021CB
63899+:10E6F000320200011040000D320200042402000129
63900+:10E7000012020002023330253226FFFF00002021D2
63901+:10E710000E000F633245FFFF2402FFFE0202802439
63902+:10E7200012000019000010213202000410400016EF
63903+:10E7300024020001240200041202000202333025E8
63904+:10E740003226FFFF3245FFFF0E000F632404010055
63905+:10E750002402FFFB020280241200000B00001021A3
63906+:10E760000A0010F5240200011040000700001021EB
63907+:10E770003245FFFF36260002000020210E000F6305
63908+:10E7800000000000000010218FBF00288FB500247A
63909+:10E790008FB400208FB3001C8FB200188FB100140B
63910+:10E7A0008FB0001003E0000827BD003027BDFFD068
63911+:10E7B000AFB000103C04600CAFBF002CAFB6002817
63912+:10E7C000AFB50024AFB40020AFB3001CAFB2001847
63913+:10E7D000AFB100148C8250002403FF7F3C1A8000EC
63914+:10E7E000004310243442380CAC8250002402000351
63915+:10E7F0003C106000AF4200088E0208083C1B8008F5
63916+:10E800003C010800AC2000203042FFF038420010EC
63917+:10E810002C4200010E001B8DAF8200183C04FFFF4C
63918+:10E820003C020400348308063442000CAE0219484E
63919+:10E83000AE03194C3C0560168E0219808CA30000B3
63920+:10E840003442020000641824AE0219803C02535383
63921+:10E850001462000334A47C008CA200040050202128
63922+:10E860008C82007C8C830078AF820010AF83000C18
63923+:10E870008F55000032A200031040FFFD32A20001BC
63924+:10E880001040013D32A200028F420128AF42002019
63925+:10E890008F4201048F430100AF8200000E000F3C45
63926+:10E8A000AF8300043C0208008C4200C01040000806
63927+:10E8B0008F8400003C0208008C4200C42442000106
63928+:10E8C0003C010800AC2200C40A00126900000000EC
63929+:10E8D0003C020010008210241440010C8F830004BD
63930+:10E8E0003C0208008C4200203C0308008C63003886
63931+:10E8F00000008821244200013C010800AC220020D5
63932+:10E900003C16080026D60038146000022474FFFF6D
63933+:10E910000000A0219742010E308340003042FFFFEB
63934+:10E920001060000A245200043C02002000821024DF
63935+:10E9300050400007308280008F8200042403BFFF14
63936+:10E94000008318240A0011703442100030828000C5
63937+:10E950001040000A3C0200200082102410400007F2
63938+:10E960008F8200043C03FFFF34637FFF0083182481
63939+:10E9700034428000AF820004AF8300000E000F9885
63940+:10E980000000000014400007000000009743011E33
63941+:10E990009742011C3063FFFF00021400006218253B
63942+:10E9A000AF8300089742010C8F4340003045FFFFC2
63943+:10E9B0003402FFFF14620003000000000A00118807
63944+:10E9C000241100208F4240003042010054400001D9
63945+:10E9D000241100108F840000308210005040001479
63946+:10E9E00036310001308200201440000B3C02100040
63947+:10E9F000008210245040000E363100013C030E000E
63948+:10EA00003C020DFF008318243442FFFF0043102B0B
63949+:10EA100050400007363100013C0208008C42002CB7
63950+:10EA2000244200013C010800AC22002C36310005D4
63951+:10EA30003C0608008CC6003454C000238F850000BB
63952+:10EA40008F820004304240005440001F8F85000038
63953+:10EA50003C021F01008210243C0310005443001AA2
63954+:10EA60008F85000030A20200144000178F8500003F
63955+:10EA70003250FFFF363100028F4201B80440FFFEE2
63956+:10EA800000000000AF400180020020210E000F4274
63957+:10EA9000AF4000208F8300042402BFFFA750019ADB
63958+:10EAA000006218248F820000A750018EA7510188B0
63959+:10EAB000A74301A6A74201903C021000AF4201B853
63960+:10EAC0000A001267000010213C02100000A210246E
63961+:10EAD0001040003A0000000010C0000F00000000CD
63962+:10EAE00030A201001040000C3C0302003C020F0069
63963+:10EAF00000A2102410430008000000008F820008CC
63964+:10EB000000541024005610219042000424420004B6
63965+:10EB10000A0011FF000221C00000000000051602DB
63966+:10EB20003050000F3A0300022E4203EF384200013A
63967+:10EB30002C63000100621824146000852402000187
63968+:10EB40003C0308008C6300D02E06000C38620001E4
63969+:10EB50002C4200010046102414400015001021C072
63970+:10EB60002602FFFC2C42000454400011000020212A
63971+:10EB7000386200022C42000100461024504000037D
63972+:10EB8000000512420A0011FF000020210010182B7E
63973+:10EB90000043102450400006001021C00000202136
63974+:10EBA0003245FFFF0E000F633226FFFB001021C02D
63975+:10EBB0003245FFFF0A001252362600028F42400003
63976+:10EBC0003C0308008C6300243042010010400046E2
63977+:10EBD00030620001322200043070000D1440000247
63978+:10EBE0002413000424130002000512C2384200015D
63979+:10EBF0002E4303EF3042000138630001004310252B
63980+:10EC0000104000033231FFFB2402FFFB020280248C
63981+:10EC100010C000183202000130A20100104000159F
63982+:10EC2000320200013C020F0000A210243C0302004B
63983+:10EC30001043000F8F8200082403FFFE020380248C
63984+:10EC40000054102400561021904200040233302555
63985+:10EC50002442000412000002000221C03226FFFFFD
63986+:10EC60000E000F633245FFFF120000390000102133
63987+:10EC7000320200011040000D3202000424020001A3
63988+:10EC800012020002023330253226FFFF000020214D
63989+:10EC90000E000F633245FFFF2402FFFE02028024B4
63990+:10ECA0001200002B00001021320200041040002846
63991+:10ECB0002402000124020004120200020233302563
63992+:10ECC0003226FFFF3245FFFF0E000F6324040100D0
63993+:10ECD0002402FFFB020280241200001D000010210C
63994+:10ECE0000A001267240200015040001900001021A0
63995+:10ECF0003245FFFF36260002000020210E000F6380
63996+:10ED0000000000000A001267000010212402BFFF6B
63997+:10ED1000006210241040000800000000240287FF59
63998+:10ED200000621024144000083C020060008210249D
63999+:10ED300010400005000000000E000D34000000002F
64000+:10ED40000A001267000000000E0012C70000000059
64001+:10ED5000104000063C0240008F4301243C0260202A
64002+:10ED6000AC430014000000003C024000AF420138F8
64003+:10ED70000000000032A200021040FEBD00000000B2
64004+:10ED80008F4201403C044000AF4200208F430148C5
64005+:10ED90003C02700000621824106400420000000071
64006+:10EDA0000083102B144000063C0260003C0220004F
64007+:10EDB000106200073C0240000A0012C3000000007D
64008+:10EDC0001062003C3C0240000A0012C30000000038
64009+:10EDD0008F4501408F4601448F42014800021402D2
64010+:10EDE000304300FF240200041462000A274401801B
64011+:10EDF0008F4201B80440FFFE2402001CAC850000D5
64012+:10EE0000A082000B3C021000AF4201B80A0012C3FE
64013+:10EE10003C0240002402000914620012000616029F
64014+:10EE2000000229C0AF4500208F4201B80440FFFE18
64015+:10EE30002402000124030003AF450180A343018B9A
64016+:10EE4000A740018EA740019AA7400190AF4001A8BA
64017+:10EE5000A7420188A74201A6AF4001AC3C021000C6
64018+:10EE6000AF4201B88F4201B80440FFFE000000002D
64019+:10EE7000AC8500008F42014800021402A482000801
64020+:10EE800024020002A082000B8F420148A4820010DD
64021+:10EE90003C021000AC860024AF4201B80A0012C345
64022+:10EEA0003C0240000E001310000000000A0012C3D4
64023+:10EEB0003C0240000E001BC2000000003C0240006B
64024+:10EEC000AF420178000000000A00112F000000008E
64025+:10EED0008F4201003042003E144000112402000124
64026+:10EEE000AF4000488F420100304207C0104000058B
64027+:10EEF00000000000AF40004CAF40005003E00008AD
64028+:10EF000024020001AF400054AF4000408F42010096
64029+:10EF10003042380054400001AF4000442402000158
64030+:10EF200003E00008000000008F4201B80440FFFE2B
64031+:10EF300024020001AF440180AF400184A74501884D
64032+:10EF4000A342018A24020002A342018B9742014A94
64033+:10EF500014C00004A7420190AF4001A40A0012EFC0
64034+:10EF60003C0210008F420144AF4201A43C02100059
64035+:10EF7000AF4001A803E00008AF4201B88F4201B8DA
64036+:10EF80000440FFFE24020002AF440180AF4401842C
64037+:10EF9000A7450188A342018AA342018B9742014AF7
64038+:10EFA000A7420190AF4001A48F420144AF4201A8A3
64039+:10EFB0003C02100003E00008AF4201B83C029000A0
64040+:10EFC0003442000100822025AF4400208F420020FF
64041+:10EFD0000440FFFE0000000003E000080000000005
64042+:10EFE0003C028000344200010082202503E000083A
64043+:10EFF000AF44002027BDFFE8AFBF0014AFB0001042
64044+:10F000008F50014093430149934201489344014882
64045+:10F01000306300FF304200FF00021200006228252A
64046+:10F020002402001910620076308400802862001AE1
64047+:10F030001040001C24020020240200081062007707
64048+:10F04000286200091040000E2402000B2402000177
64049+:10F0500010620034286200025040000524020006BD
64050+:10F0600050600034020020210A00139A00000000C2
64051+:10F0700010620030020020210A00139A00000000F4
64052+:10F080001062003B2862000C504000022402000E77
64053+:10F090002402000910620056020020210A00139A7F
64054+:10F0A0000000000010620056286200211040000F8E
64055+:10F0B000240200382402001C106200582862001D3F
64056+:10F0C000104000062402001F2402001B1062004CA6
64057+:10F0D000000000000A00139A000000001062004ABD
64058+:10F0E000020020210A00139A00000000106200456F
64059+:10F0F0002862003910400007240200802462FFCB00
64060+:10F100002C42000210400045020020210A00139604
64061+:10F110000000302110620009000000000A00139A6C
64062+:10F12000000000001480003D020020210A0013901E
64063+:10F130008FBF00140A001396240600018F4201B805
64064+:10F140000440FFFE24020002A342018BA745018870
64065+:10F150009742014AA74201908F420144A74201927F
64066+:10F160003C021000AF4201B80A00139C8FBF00148C
64067+:10F170009742014A144000290000000093620005F4
64068+:10F180003042000414400025000000000E0013026D
64069+:10F190000200202193620005020020213442000475
64070+:10F1A0000E00130BA36200059362000530420004B9
64071+:10F1B00014400002000000000000000D93620000F7
64072+:10F1C00024030020304200FF14430014000000001C
64073+:10F1D0008F4201B80440FFFE24020005AF500180B9
64074+:10F1E000A342018B3C0210000A00139AAF4201B8FF
64075+:10F1F0008FBF00148FB000100A0012F227BD001854
64076+:10F200000000000D02002021000030218FBF0014FB
64077+:10F210008FB000100A0012DD27BD00180000000D9D
64078+:10F220008FBF00148FB0001003E0000827BD001846
64079+:10F2300027BDFFE8AFBF00100E000F3C000000002C
64080+:10F24000AF4001808FBF0010000020210A000FE7AF
64081+:10F2500027BD00183084FFFF30A5FFFF00001821F4
64082+:10F260001080000700000000308200011040000202
64083+:10F2700000042042006518210A0013AB0005284055
64084+:10F2800003E000080060102110C0000624C6FFFF44
64085+:10F290008CA2000024A50004AC8200000A0013B573
64086+:10F2A0002484000403E000080000000010A000080F
64087+:10F2B00024A3FFFFAC860000000000000000000057
64088+:10F2C0002402FFFF2463FFFF1462FFFA248400047A
64089+:10F2D00003E0000800000000308300FF30A500FFBD
64090+:10F2E00030C600FF274701808F4201B80440FFFE6F
64091+:10F2F000000000008F42012834634000ACE20000AF
64092+:10F3000024020001ACE00004A4E30008A0E2000A2B
64093+:10F3100024020002A0E2000B3C021000A4E5001051
64094+:10F32000ACE00024ACE00028A4E6001203E00008F2
64095+:10F33000AF4201B827BDFFE8AFBF00109362003FA6
64096+:10F3400024030012304200FF1043000D00803021E2
64097+:10F350008F620044008210230440000A8FBF001017
64098+:10F360008F620048240400390000282100C21023C5
64099+:10F3700004410004240600120E0013C9000000001E
64100+:10F380008FBF00102402000103E0000827BD001811
64101+:10F3900027BDFFC8AFB20030AFB1002CAFBF003403
64102+:10F3A000AFB0002890C5000D0080902130A400105F
64103+:10F3B0001080000B00C088218CC300088F620054AD
64104+:10F3C0001062000730A20005144000B524040001BB
64105+:10F3D0000E000D21000020210A0014BB0040202156
64106+:10F3E00030A200051040000930A30012108000ACCC
64107+:10F3F000240400018E2300088F620054146200A9C7
64108+:10F400008FBF00340A00142C240400382402001298
64109+:10F41000146200A3240400010220202127A500106B
64110+:10F420000E000CB2AFA000101040001102402021CD
64111+:10F430008E220008AF620084AF6000400E0013020D
64112+:10F44000000000009362007D024020213442002031
64113+:10F450000E00130BA362007D0E000CA902402021B8
64114+:10F46000240400382405008D0A0014B82406001274
64115+:10F470009362003E304200081040000F8FA200103F
64116+:10F4800030420100104000078FA300148F6200601B
64117+:10F490000062102304430008AF6300600A001441B7
64118+:10F4A00000000000AF6000609362003E2403FFF79D
64119+:10F4B00000431024A362003E9362003E30420008E5
64120+:10F4C000144000022406000300003021936200343F
64121+:10F4D000936300378F640084304200FF306300FF85
64122+:10F4E00000661821000318800043282100A4202B67
64123+:10F4F0001080000B000000009763003C8F620084C6
64124+:10F500003063FFFF004510230062182B14600004D5
64125+:10F51000000000008F6200840A00145D0045802313
64126+:10F520009762003C3050FFFF8FA300103062000450
64127+:10F5300010400004000628808FA2001C0A001465F9
64128+:10F540000202102B2E02021850400003240202185F
64129+:10F550000A00146E020510233063000410600003DB
64130+:10F56000004510238FA2001C00451023004080217D
64131+:10F570002C42008054400001241000800E00130231
64132+:10F580000240202124020001AF62000C9362003E81
64133+:10F59000001020403042007FA362003E8E22000413
64134+:10F5A00024420001AF620040A770003C8F6200500F
64135+:10F5B0009623000E00431021AF6200588F62005066
64136+:10F5C00000441021AF62005C8E220004AF6200187C
64137+:10F5D0008E220008AF62001C8FA20010304200088B
64138+:10F5E0005440000A93A20020A360003693620036C4
64139+:10F5F0002403FFDFA36200359362003E0043102422
64140+:10F60000A362003E0A0014988E220008A36200350F
64141+:10F610008E220008AF62004C8F6200248F6300408E
64142+:10F6200000431021AF6200489362000024030050A1
64143+:10F63000304200FF144300122403FF803C02080004
64144+:10F640008C4231A00242102100431024AF42002816
64145+:10F650003C0208008C4231A08E2400083C03000CC0
64146+:10F66000024210213042007F03421021004310214A
64147+:10F67000AC4400D88E230008AF820014AC4300DCF9
64148+:10F680000E00130B02402021240400380000282122
64149+:10F690002406000A0E0013C9000000002404000123
64150+:10F6A0008FBF00348FB200308FB1002C8FB0002894
64151+:10F6B0000080102103E0000827BD003827BDFFF8B7
64152+:10F6C00027420180AFA20000308A00FF8F4201B8BC
64153+:10F6D0000440FFFE000000008F4601283C020800A5
64154+:10F6E0008C4231A02403FF80AF86004800C2102165
64155+:10F6F00000431024AF4200243C0208008C4231A099
64156+:10F700008FA900008FA8000000C210213042007FA6
64157+:10F71000034218213C02000A00621821946400D4BC
64158+:10F720008FA700008FA5000024020002AF83001401
64159+:10F73000A0A2000B8FA30000354260003084FFFFC1
64160+:10F74000A4E200083C021000AD260000AD04000455
64161+:10F75000AC60002427BD0008AF4201B803E00008F8
64162+:10F76000240200018F88003C938200288F830014BC
64163+:10F770003C07080024E7779800481023304200FF38
64164+:10F78000304900FC246500888F860040304A000321
64165+:10F790001120000900002021248200048CA3000015
64166+:10F7A000304400FF0089102AACE3000024A50004C7
64167+:10F7B0001440FFF924E70004114000090000202153
64168+:10F7C0002482000190A30000304400FF008A102B27
64169+:10F7D000A0E3000024A500011440FFF924E7000184
64170+:10F7E00030C20003144000048F85003C3102000346
64171+:10F7F0001040000D0000000010A0000900002021B2
64172+:10F800002482000190C30000304400FF0085102BCB
64173+:10F81000A0E3000024C600011440FFF924E7000122
64174+:10F8200003E00008000000001100FFFD000020219F
64175+:10F83000248200048CC30000304400FF0088102B99
64176+:10F84000ACE3000024C600041440FFF924E70004E0
64177+:10F8500003E00008000000008F83003C9382002832
64178+:10F8600030C600FF30A500FF00431023304300FFE7
64179+:10F870008F820014008038210043102114C0000240
64180+:10F88000244800880083382130E20003144000053A
64181+:10F8900030A2000314400003306200031040000D4A
64182+:10F8A0000000000010A000090000202124820001B7
64183+:10F8B00090E30000304400FF0085102BA1030000FE
64184+:10F8C00024E700011440FFF92508000103E00008C7
64185+:10F8D0000000000010A0FFFD000020212482000491
64186+:10F8E0008CE30000304400FF0085102BAD030000C6
64187+:10F8F00024E700041440FFF92508000403E0000891
64188+:10F90000000000000080482130AAFFFF30C600FF41
64189+:10F9100030E7FFFF274801808F4201B80440FFFE17
64190+:10F920008F820048AD0200008F420124AD02000426
64191+:10F930008D220020A5070008A102000A240200165B
64192+:10F94000A102000B934301208D2200088D240004A6
64193+:10F95000306300FF004310219783003A00441021D8
64194+:10F960008D250024004310233C0308008C6331A044
64195+:10F970008F840014A502000C246300E82402FFFF1A
64196+:10F98000A50A000EA5030010A5060012AD0500187B
64197+:10F99000AD020024948201142403FFF73042FFFFDC
64198+:10F9A000AD0200288C820118AD02002C3C02100030
64199+:10F9B000AD000030AF4201B88D220020004310247A
64200+:10F9C00003E00008AD2200208F82001430E7FFFF23
64201+:10F9D00000804821904200D330A5FFFF30C600FFD1
64202+:10F9E0000002110030420F0000E238252748018054
64203+:10F9F0008F4201B80440FFFE8F820048AD02000034
64204+:10FA00008F420124AD0200048D220020A5070008CA
64205+:10FA1000A102000A24020017A102000B9343012057
64206+:10FA20008D2200088D240004306300FF0043102164
64207+:10FA30009783003A004410218F8400140043102360
64208+:10FA40003C0308008C6331A0A502000CA505000E44
64209+:10FA5000246300E8A5030010A5060012AD00001401
64210+:10FA60008D220024AD0200188C82005CAD02001CC7
64211+:10FA70008C820058AD0200202402FFFFAD0200245A
64212+:10FA8000948200E63042FFFFAD02002894820060BD
64213+:10FA9000948300BE30427FFF3063FFFF00021200FC
64214+:10FAA00000431021AD02002C3C021000AD000030DC
64215+:10FAB000AF4201B8948200BE2403FFF700A21021D8
64216+:10FAC000A48200BE8D2200200043102403E0000821
64217+:10FAD000AD220020274301808F4201B80440FFFE81
64218+:10FAE0008F8200249442001C3042FFFF000211C0AC
64219+:10FAF000AC62000024020019A062000B3C0210005E
64220+:10FB0000AC60003003E00008AF4201B88F87002CE2
64221+:10FB100030C300FF8F4201B80440FFFE8F820048CF
64222+:10FB200034636000ACA2000093820044A0A20005F0
64223+:10FB30008CE20010A4A20006A4A300088C8200207E
64224+:10FB40002403FFF7A0A2000A24020002A0A2000BD7
64225+:10FB50008CE20000ACA200108CE20004ACA2001405
64226+:10FB60008CE2001CACA200248CE20020ACA2002895
64227+:10FB70008CE2002CACA2002C8C820024ACA20018D9
64228+:10FB80003C021000AF4201B88C82002000431024D8
64229+:10FB900003E00008AC8200208F86001427BDFFE838
64230+:10FBA000AFBF0014AFB0001090C20063304200201D
64231+:10FBB0001040000830A500FF8CC2007C2403FFDF4A
64232+:10FBC00024420001ACC2007C90C2006300431024B8
64233+:10FBD000A0C2006310A000238F830014275001806F
64234+:10FBE000020028210E0015D6240600828F82001400
64235+:10FBF000904200633042004050400019A38000440E
64236+:10FC00008F83002C8F4201B80440FFFE8F82004892
64237+:10FC1000AE02000024026082A60200082402000254
64238+:10FC2000A202000B8C620008AE0200108C62000C75
64239+:10FC3000AE0200148C620014AE0200188C62001830
64240+:10FC4000AE0200248C620024AE0200288C620028E0
64241+:10FC5000AE02002C3C021000AF4201B8A380004469
64242+:10FC60008F8300148FBF00148FB000109062006368
64243+:10FC700027BD00183042007FA06200639782003ADF
64244+:10FC80008F86003C8F850014938300280046102344
64245+:10FC9000A782003AA4A000E490A400638F820040F1
64246+:10FCA000AF83003C2403FFBF0046102100832024C3
64247+:10FCB000AF820040A0A400638F820014A04000BD6A
64248+:10FCC0008F82001403E00008A44000BE8F8A001455
64249+:10FCD00027BDFFE0AFB10014AFB000108F88003C2B
64250+:10FCE000AFBF00189389001C954200E430D100FF9B
64251+:10FCF0000109182B0080802130AC00FF3047FFFF46
64252+:10FD00000000582114600003310600FF012030215B
64253+:10FD1000010958239783003A0068102B1440003CD7
64254+:10FD20000000000014680007240200018E02002079
64255+:10FD30002403FFFB34E7800000431024AE020020C0
64256+:10FD40002402000134E70880158200053165FFFFB9
64257+:10FD50000E001554020020210A00169102002021F5
64258+:10FD60000E001585020020218F8400482743018062
64259+:10FD70008F4201B80440FFFE24020018AC6400006A
64260+:10FD8000A062000B8F840014948200E6A46200102D
64261+:10FD90003C021000AC600030AF4201B894820060B9
64262+:10FDA00024420001A4820060948200603C030800A9
64263+:10FDB0008C63318830427FFF5443000F02002021C2
64264+:10FDC000948200602403800000431024A482006019
64265+:10FDD0009082006090830060304200FF000211C2F8
64266+:10FDE00000021027000211C03063007F0062182556
64267+:10FDF000A083006002002021022028218FBF00186C
64268+:10FE00008FB100148FB000100A0015F927BD002033
64269+:10FE1000914200632403FF8000431025A142006348
64270+:10FE20009782003A3048FFFF110000209383001CA6
64271+:10FE30008F840014004B1023304600FF948300E4AD
64272+:10FE40002402EFFF0168282B00621824A48300E439
64273+:10FE500014A000038E020020010058210000302170
64274+:10FE60002403FFFB34E7800000431024AE0200208F
64275+:10FE700024020001158200053165FFFF0E001554B4
64276+:10FE8000020020210A0016B99783003A0E0015855A
64277+:10FE9000020020219783003A8F82003CA780003A1D
64278+:10FEA00000431023AF82003C9383001C8F82001418
64279+:10FEB0008FBF00188FB100148FB0001027BD002035
64280+:10FEC00003E00008A04300BD938200442403000126
64281+:10FED00027BDFFE8004330042C420020AFB00010E3
64282+:10FEE000AFBF00142410FFFE10400005274501801D
64283+:10FEF0003C0208008C4231900A0016D600461024BD
64284+:10FF00003C0208008C423194004610241440000743
64285+:10FF1000240600848F8300142410FFFF9062006287
64286+:10FF20003042000F34420040A06200620E0015D63D
64287+:10FF300000000000020010218FBF00148FB00010DD
64288+:10FF400003E0000827BD00188F83002427BDFFE0D1
64289+:10FF5000AFB20018AFB10014AFB00010AFBF001CBB
64290+:10FF60009062000D00A0902130D100FF3042007F50
64291+:10FF7000A062000D8F8500148E4300180080802140
64292+:10FF80008CA2007C146200052402000E90A2006383
64293+:10FF9000344200200A0016FFA0A200630E0016C51E
64294+:10FFA000A38200442403FFFF104300472404FFFF03
64295+:10FFB00052200045000020218E4300003C0200102A
64296+:10FFC00000621024504000043C020008020020217E
64297+:10FFD0000A00170E24020015006210245040000988
64298+:10FFE0008E45000002002021240200140E0016C5D8
64299+:10FFF000A38200442403FFFF104300332404FFFFC7
64300+:020000021000EC
64301+:100000008E4500003C02000200A2102410400016A1
64302+:100010003C0200048F8600248CC200148CC30010A4
64303+:100020008CC40014004310230044102B50400005E2
64304+:10003000020020218E43002C8CC2001010620003AD
64305+:10004000020020210A00173F240200123C02000493
64306+:1000500000A210245040001C00002021020020219A
64307+:100060000A00173F2402001300A2102410400006CB
64308+:100070008F8300248C620010504000130000202168
64309+:100080000A001739020020218C6200105040000441
64310+:100090008E42002C020020210A00173F240200118A
64311+:1000A00050400009000020210200202124020017F6
64312+:1000B0000E0016C5A38200442403FFFF1043000274
64313+:1000C0002404FFFF000020218FBF001C8FB2001806
64314+:1000D0008FB100148FB000100080102103E00008E1
64315+:1000E00027BD00208F83001427BDFFD8AFB40020A8
64316+:1000F000AFB3001CAFB20018AFB10014AFB0001026
64317+:10010000AFBF0024906200638F91002C2412FFFF88
64318+:100110003442004092250000A06200638E2200104D
64319+:100120000080982130B0003F105200060360A021EB
64320+:100130002402000D0E0016C5A38200441052005484
64321+:100140002404FFFF8F8300148E2200188C63007C30
64322+:1001500010430007026020212402000E0E0016C585
64323+:10016000A38200442403FFFF104300492404FFFF3F
64324+:1001700024040020120400048F83001490620063A2
64325+:1001800034420020A06200638F85003410A000205C
64326+:1001900000000000560400048F8200140260202139
64327+:1001A0000A0017902402000A9683000A9442006015
64328+:1001B0003042FFFF144300048F8200202404FFFD1F
64329+:1001C0000A0017B7AF82003C3C0208008C42318C19
64330+:1001D0000045102B14400006026020210000282159
64331+:1001E0000E001646240600010A0017B70000202161
64332+:1001F0002402002D0E0016C5A38200442403FFFF35
64333+:10020000104300232404FFFF0A0017B70000202139
64334+:10021000160400058F8400148E2300142402FFFFAF
64335+:100220005062001802602021948200602442000184
64336+:10023000A4820060948200603C0308008C633188D3
64337+:1002400030427FFF5443000F0260202194820060FF
64338+:100250002403800000431024A48200609082006088
64339+:1002600090830060304200FF000211C2000210279C
64340+:10027000000211C03063007F00621825A083006077
64341+:10028000026020210E0015F9240500010000202144
64342+:100290008FBF00248FB400208FB3001C8FB20018D2
64343+:1002A0008FB100148FB000100080102103E000080F
64344+:1002B00027BD00288F83001427BDFFE8AFB00010D2
64345+:1002C000AFBF0014906200638F87002C00808021F4
64346+:1002D000344200408CE60010A06200633C0308003A
64347+:1002E0008C6331B030C23FFF0043102B1040004EF2
64348+:1002F0008F8500302402FF8090A3000D004310245E
64349+:10030000304200FF504000490200202100061382C5
64350+:10031000304800032402000255020044020020215C
64351+:1003200094A2001C8F85001424030023A4A20114AE
64352+:100330008CE60000000616023042003F1043001019
64353+:100340003C0300838CE300188CA2007C1062000642
64354+:100350002402000E0E0016C5A38200442403FFFFF2
64355+:10036000104300382404FFFF8F8300149062006361
64356+:1003700034420020A06200630A0017FC8F8300242F
64357+:1003800000C31024144300078F83002490A200624E
64358+:100390003042000F34420020A0A20062A38800383F
64359+:1003A0008F8300249062000D3042007FA062000D18
64360+:1003B0008F83003410600018020020218F840030E9
64361+:1003C0008C8200100043102B1040000924020018FA
64362+:1003D000020020210E0016C5A38200442403FFFF63
64363+:1003E000104300182404FFFF0A00182400002021F5
64364+:1003F0008C820010240500010200202100431023FC
64365+:100400008F830024240600010E001646AC62001003
64366+:100410000A001824000020210E0015F9240500010F
64367+:100420000A00182400002021020020212402000DCF
64368+:100430008FBF00148FB0001027BD00180A0016C52A
64369+:10044000A38200448FBF00148FB0001000801021E1
64370+:1004500003E0000827BD001827BDFFC8AFB2002089
64371+:10046000AFBF0034AFB60030AFB5002CAFB400283A
64372+:10047000AFB30024AFB1001CAFB000188F46012805
64373+:100480003C0308008C6331A02402FF80AF86004843
64374+:1004900000C318213065007F03452821006218241D
64375+:1004A0003C02000AAF43002400A2282190A200626F
64376+:1004B00000809021AF850014304200FF000211023D
64377+:1004C000A382003890A200BC304200021440000217
64378+:1004D00024030034240300308F820014A3830028F7
64379+:1004E000938300388C4200C0A3800044AF82003C5C
64380+:1004F000240200041062031C8F84003C8E4400041C
64381+:10050000508003198F84003C8E4200103083FFFF1F
64382+:10051000A784003A106002FFAF8200408F8400146D
64383+:100520002403FF809082006300621024304200FFA9
64384+:10053000144002CF9785003A9383003824020002CA
64385+:1005400030B6FFFF14620005000088219382002866
64386+:100550002403FFFD0A001B19AF82003C8F82003C80
64387+:1005600002C2102B144002A18F8400400E0014EC34
64388+:1005700000000000938300283C040800248477983E
64389+:10058000240200341462002EAF84002C3C0A0800C0
64390+:100590008D4A77C82402FFFFAFA2001000803821E7
64391+:1005A0002405002F3C09080025297398240800FF22
64392+:1005B0002406FFFF90E2000024A3FFFF00062202B2
64393+:1005C00000C21026304200FF0002108000491021B6
64394+:1005D0008C420000306500FF24E7000114A8FFF5FD
64395+:1005E0000082302600061027AFA20014AFA2001030
64396+:1005F0000000282127A7001027A6001400C51023FB
64397+:100600009044000324A2000100A71821304500FFF8
64398+:100610002CA200041440FFF9A06400008FA2001077
64399+:100620001142000724020005024020210E0016C5D9
64400+:10063000A38200442403FFFF104300642404FFFF4F
64401+:100640003C0208009042779C104000098F82001401
64402+:10065000024020212402000C0E0016C5A382004493
64403+:100660002403FFFF104300592404FFFF8F8200146E
64404+:10067000A380001C3C0308008C63779C8C440080A2
64405+:100680003C0200FF3442FFFF006218240083202B4D
64406+:1006900010800008AF83003402402021240200199A
64407+:1006A0000E0016C5A38200442403FFFF1043004739
64408+:1006B0002404FFFF8F87003C9782003A8F85003427
64409+:1006C000AF8700200047202310A0003BA784003AFA
64410+:1006D0008F86001430A200030002102390C300BCD8
64411+:1006E0003050000300B0282100031882307300014D
64412+:1006F0000013108000A228213C0308008C6331A065
64413+:100700008F8200483084FFFF0085202B004310219A
64414+:1007100010800011244200888F84002C1082000E6B
64415+:100720003C033F013C0208008C42779800431024B0
64416+:100730003C0325001443000630E500FF8C820000D6
64417+:10074000ACC200888C8200100A0018E9ACC2009884
64418+:100750000E001529000030219382001C8F850014A3
64419+:100760008F830040020238218F82003CA387001C47
64420+:1007700094A400E4006218218F82003434841000B5
64421+:10078000AF83004000503021A4A400E41260000EAA
64422+:10079000AF86003C24E20004A382001C94A200E483
64423+:1007A00024C30004AF83003C34422000A4A200E430
64424+:1007B0000A001906000020218F820040AF80003C13
64425+:1007C00000471021AF820040000020212414FFFFC9
64426+:1007D000109402112403FFFF3C0808008D0877A83D
64427+:1007E0003C0208008C4231B03C03080090637798CB
64428+:1007F00031043FFF0082102B1040001B3067003F88
64429+:100800003C0208008C4231A88F83004800042180FC
64430+:1008100000621821006418213062007F0342282101
64431+:100820003C02000C00A228213C020080344200015E
64432+:100830003066007800C230252402FF800062102458
64433+:10084000AF42002830640007AF4208048F820014D2
64434+:100850000344202124840940AF460814AF850024B6
64435+:10086000AF840030AC4301189383003824020003A6
64436+:10087000146201CF240200012402002610E201D1FB
64437+:1008800028E2002710400013240200322402002234
64438+:1008900010E201CC28E200231040000824020024CA
64439+:1008A0002402002010E201B82402002110E20147D6
64440+:1008B000024020210A001AFB2402000B10E201C1B1
64441+:1008C0002402002510E20010024020210A001AFB39
64442+:1008D0002402000B10E201AE28E2003310400006B3
64443+:1008E0002402003F2402003110E2009A024020213D
64444+:1008F0000A001AFB2402000B10E201A5024020218D
64445+:100900000A001AFB2402000B8F90002C3C03080005
64446+:100910008C6331B08F8500308E0400100000A82158
64447+:100920008CB3001430823FFF0043102B8CB10020A9
64448+:100930005040018F0240202190A3000D2402FF802F
64449+:1009400000431024304200FF504001890240202122
64450+:10095000000413823042000314400185024020212C
64451+:1009600094A3001C8F8200148E040028A443011459
64452+:100970008CA20010026218231064000302402021A0
64453+:100980000A00197C2402001F8F82003400621021AB
64454+:100990000262102B104000088F83002402402021A7
64455+:1009A000240200180E0016C5A382004410540174DE
64456+:1009B0002404FFFF8F8300248F8400348C62001096
64457+:1009C0000224882100441023AC6200108F8200149E
64458+:1009D000AC7100208C4200680051102B10400009BF
64459+:1009E0008F830030024020212402001D0E0016C516
64460+:1009F000A38200442403FFFF104301612404FFFF8E
64461+:100A00008F8300308E0200248C6300241043000783
64462+:100A1000024020212402001C0E0016C5A3820044BF
64463+:100A20002403FFFF104301562404FFFF8F8400249A
64464+:100A30008C82002424420001AC8200241233000482
64465+:100A40008F8200148C4200685622000E8E02000035
64466+:100A50008E0200003C030080004310241440000D6F
64467+:100A60002402001A024020210E0016C5A382004471
64468+:100A70002403FFFF104301422404FFFF0A0019BAB8
64469+:100A80008E0200143C0300800043102450400003F9
64470+:100A90008E020014AC8000208E0200142411FFFF8F
64471+:100AA0001051000E3C0308003C0208008C423190BB
64472+:100AB000004310242403001B14400007A3830044B8
64473+:100AC0000E0016C5024020211051012D2404FFFF05
64474+:100AD0000A0019CB8E030000A38000448E0300009F
64475+:100AE0003C02000100621024104000123C02008011
64476+:100AF0000062102414400008024020212402001A41
64477+:100B00000E0016C5A38200442403FFFF1043011CFE
64478+:100B10002404FFFF02402021020028210E0016E5D8
64479+:100B2000240600012403FFFF104301152404FFFFE6
64480+:100B3000241500018F83002402A0302102402021CF
64481+:100B40009462003624050001244200010A001ADFE5
64482+:100B5000A46200368F90002C3C0308008C6331B0F7
64483+:100B60008E13001032623FFF0043102B10400089AB
64484+:100B70008F8400302402FF809083000D00431024F6
64485+:100B8000304200FF104000842402000D0013138245
64486+:100B900030420003240300011443007F2402000DAF
64487+:100BA0009082000D30420008544000048F820034CF
64488+:100BB000024020210A001A102402002450400004A0
64489+:100BC0008E03000C024020210A001A102402002784
64490+:100BD0008C82002054620006024020218E0300080F
64491+:100BE0008C820024506200098E02001402402021F1
64492+:100BF000240200200E0016C5A38200441054007188
64493+:100C00002403FFFF0A001A458F8400242411FFFFEC
64494+:100C1000145100048F860014024020210A001A405B
64495+:100C2000240200258E0300188CC2007C1062000391
64496+:100C30002402000E0A001A40024020218E030024E4
64497+:100C40008C82002810620003240200210A001A404E
64498+:100C5000024020218E0500288C82002C10A2000367
64499+:100C60002402001F0A001A40024020218E03002C9B
64500+:100C700014600003240200230A001A4002402021CD
64501+:100C80008CC200680043102B104000032402002691
64502+:100C90000A001A40024020218C82001400651821AD
64503+:100CA0000043102B104000088F84002402402021B4
64504+:100CB000240200220E0016C5A382004410510041F8
64505+:100CC0002403FFFF8F8400242403FFF79082000D8C
64506+:100CD00000431024A082000D8F8600143C030800FE
64507+:100CE0008C6331AC8F82004894C400E08F8500246F
64508+:100CF0000043102130847FFF000420400044102175
64509+:100D00003043007F034320213C03000E0083202159
64510+:100D10002403FF8000431024AF42002CA493000062
64511+:100D20008CA2002824420001ACA200288CA2002C36
64512+:100D30008E03002C00431021ACA2002C8E02002C4C
64513+:100D4000ACA200308E020014ACA2003494A2003A8F
64514+:100D500024420001A4A2003A94C600E03C0208002C
64515+:100D60008C4231B024C4000130837FFF1462000F35
64516+:100D700000803021240280000082302430C2FFFF36
64517+:100D8000000213C2304200FF000210270A001A7E40
64518+:100D9000000233C02402000D024020210E0016C5BF
64519+:100DA000A38200440A001A84004018218F82001494
64520+:100DB00002402021240500010E0015F9A44600E0A0
64521+:100DC000000018210A001B16006088218F90002C5B
64522+:100DD0003C0308008C6331B08E05001030A23FFF49
64523+:100DE0000043102B104000612402FF808F840030EC
64524+:100DF0009083000D00431024304200FF5040005CFF
64525+:100E0000024020218F8200341040000B0005138225
64526+:100E10008F8200149763000A944200603042FFFF03
64527+:100E200014430005000513828F8200202404FFFD77
64528+:100E30000A001AF3AF82003C304200031440000E57
64529+:100E40000000000092020002104000058E03002402
64530+:100E500050600015920300030A001AAF02402021DF
64531+:100E60008C82002450620010920300030240202173
64532+:100E70000A001AB72402000F9082000D30420008C9
64533+:100E80005440000992030003024020212402001074
64534+:100E90000E0016C5A38200442403FFFF1043003850
64535+:100EA0002404FFFF92030003240200025462000C9A
64536+:100EB000920200038F820034544000099202000322
64537+:100EC000024020212402002C0E0016C5A3820044FB
64538+:100ED0002403FFFF1043002A2404FFFF92020003B3
64539+:100EE0000200282102402021384600102CC60001B3
64540+:100EF0002C4200010E0016E5004630252410FFFFAD
64541+:100F00001050001F2404FFFF8F8300341060001373
64542+:100F1000024020213C0208008C42318C0043102BFF
64543+:100F200014400007000000000000282124060001F2
64544+:100F30000E001646000000000A001AF300002021EF
64545+:100F40002402002D0E0016C5A38200441050000C90
64546+:100F50002404FFFF0A001AF3000020210E0015F9F7
64547+:100F6000240500010A001AF300002021024020217C
64548+:100F70002402000D0E0016C5A3820044004020216B
64549+:100F80000A001B16008088211514000E00000000C6
64550+:100F90000E00174C024020210A001B160040882139
64551+:100FA0000E0016C5A38200440A001B1600408821CB
64552+:100FB00014620017022018212402002314E2000505
64553+:100FC0002402000B0E0017C0024020210A001B164D
64554+:100FD0000040882102402021A38200440E0016C553
64555+:100FE0002411FFFF0A001B170220182130A500FF63
64556+:100FF0000E001529240600019783003A8F82003CD9
64557+:10100000A780003A00431023AF82003C0220182141
64558+:101010001220003E9782003A2402FFFD5462003EF7
64559+:101020008E4300208E4200048F830014005610234C
64560+:10103000AE420004906200633042007FA062006311
64561+:101040008E4200208F840014A780003A34420002B0
64562+:10105000AE420020A48000E4908200632403FFBF1E
64563+:1010600000431024A08200630A001B598E43002015
64564+:101070009082006300621024304200FF1040002381
64565+:101080009782003A90820088908300BD2485008872
64566+:101090003042003F2444FFE02C820020A383001C48
64567+:1010A00010400019AF85002C2402000100821804B2
64568+:1010B000306200191440000C3C02800034420002EF
64569+:1010C000006210241440000B306200201040000F1A
64570+:1010D0009782003A90A600010240202124050001D9
64571+:1010E0000A001B5330C60001024020210A001B5297
64572+:1010F00024050001024020210000282124060001CF
64573+:101100000E001646000000009782003A1440FD04CD
64574+:101110008F8400148E4300203062000410400012BF
64575+:101120008F84003C2402FFFB00621024AE420020AA
64576+:10113000274301808F4201B80440FFFE8F820048A0
64577+:10114000AC6200008F420124AC6200042402608380
64578+:10115000A462000824020002A062000B3C021000FE
64579+:10116000AF4201B88F84003C8F8300148FBF0034DE
64580+:101170008FB600308FB5002C8FB400288FB30024B9
64581+:101180008FB200208FB1001C8FB000182402000124
64582+:1011900027BD003803E00008AC6400C030A500FFA4
64583+:1011A0002403000124A900010069102B1040000C49
64584+:1011B00000004021240A000100A31023004A380443
64585+:1011C00024630001308200010069302B10400002CE
64586+:1011D000000420420107402554C0FFF800A310235B
64587+:1011E00003E00008010010213C020800244260A432
64588+:1011F0003C010800AC22738C3C02080024425308D6
64589+:101200003C010800AC2273902402000627BDFFE0D9
64590+:101210003C010800A02273943C021EDCAFB200180F
64591+:10122000AFB10014AFBF001CAFB0001034526F411B
64592+:1012300000008821240500080E001B7A02202021CE
64593+:10124000001180803C07080024E773980002160014
64594+:1012500002071821AC6200000000282124A200012E
64595+:101260003045FFFF8C6200002CA6000804410002FC
64596+:10127000000220400092202614C0FFF8AC64000059
64597+:10128000020780218E0400000E001B7A2405002036
64598+:10129000262300013071FFFF2E2301001460FFE5BB
64599+:1012A000AE0200008FBF001C8FB200188FB1001477
64600+:1012B0008FB0001003E0000827BD002027BDFFD835
64601+:1012C000AFB3001CAFB20018AFBF0020AFB1001425
64602+:1012D000AFB000108F5101408F48014800089402C0
64603+:1012E000324300FF311300FF8F4201B80440FFFE7C
64604+:1012F00027500180AE1100008F420144AE0200046D
64605+:1013000024020002A6120008A202000B240200140C
64606+:10131000AE1300241062002528620015104000085A
64607+:101320002402001524020010106200302402001272
64608+:10133000106200098FBF00200A001CB58FB3001C8B
64609+:101340001062007024020022106200378FBF00205C
64610+:101350000A001CB58FB3001C3C0208008C4231A06F
64611+:101360002403FF800222102100431024AF420024F6
64612+:101370003C0208008C4231A0022210213042007F42
64613+:10138000034218213C02000A00621821166000BCCA
64614+:10139000AF830014906200623042000F344200308C
64615+:1013A000A06200620A001CB48FBF00203C046000F1
64616+:1013B0008C832C083C02F0033442FFFF00621824A7
64617+:1013C000AC832C083C0208008C4231A08C832C0892
64618+:1013D000244200740002108200021480006218256A
64619+:1013E000AC832C080A001CB48FBF00203C0208000C
64620+:1013F0008C4231A02403FF800222102100431024DC
64621+:10140000AF4200243C0208008C4231A03C03000A99
64622+:10141000022210213042007F03421021004310219C
64623+:101420000A001CB3AF8200143C0208008C4231A0B9
64624+:101430002405FF800222102100451024AF42002421
64625+:101440003C0208008C4231A0022210213042007F71
64626+:10145000034218213C02000A0062182190620063D6
64627+:1014600000A21024304200FF10400085AF8300141A
64628+:1014700024620088944300123C0208008C4231A888
64629+:1014800030633FFF00031980022210210043102126
64630+:101490003043007F03432021004510243C03000C0F
64631+:1014A00000832021AF4200289082000D00A210246A
64632+:1014B000304200FF10400072AF8400249082000D83
64633+:1014C000304200101440006F8FBF00200E0015C87E
64634+:1014D000000000008F4201B80440FFFE0000000041
64635+:1014E000AE1100008F420144AE020004240200024B
64636+:1014F000A6120008A202000BAE1300240A001CB4BE
64637+:101500008FBF00202406FF8002261024AF42002057
64638+:101510003C0208008C4231A031043FFF00042180CE
64639+:101520000222102100461024AF4200243C03080090
64640+:101530008C6331A83C0208008C4231A03227007F26
64641+:101540000223182102221021006418213042007F5A
64642+:101550003064007F034228213C02000A0066182400
64643+:1015600000A22821034420213C02000C00822021FB
64644+:10157000AF4300283C020008034718210062902175
64645+:10158000AF850014AF8400240E0015C8010080212F
64646+:101590008F4201B80440FFFE8F8200248F84001424
64647+:1015A000274501809042000DACB10000A4B00006B8
64648+:1015B000000216000002160300021027000237C2C4
64649+:1015C00014C00016248200889442001232033FFFA8
64650+:1015D00030423FFF14430012240260829083006374
64651+:1015E0002402FF8000431024304200FF5040000CD2
64652+:1015F00024026082908200623042000F3442004038
64653+:10160000A082006224026084A4A200082402000DCB
64654+:10161000A0A200050A001C9E3C0227002402608252
64655+:10162000A4A20008A0A000053C02270000061C00A0
64656+:101630000062182524020002A0A2000BACA3001037
64657+:10164000ACA00014ACA00024ACA00028ACA0002CDE
64658+:101650008E42004C8F840024ACA200189083000DB1
64659+:101660002402FF8000431024304200FF1040000598
64660+:101670008FBF00209082000D3042007FA082000DBD
64661+:101680008FBF00208FB3001C8FB200188FB10014E1
64662+:101690008FB000103C02100027BD002803E00008B6
64663+:1016A000AF4201B80800343008003430080033A8D5
64664+:1016B000080033E0080034140800343808003438D7
64665+:1016C00008003438080033180A0001240000000024
64666+:1016D000000000000000000D747061362E322E33C1
64667+:1016E00000000000060203010000000000000000EE
64668+:1016F00000000000000000000000000000000000EA
64669+:1017000000000000000000000000000000000000D9
64670+:1017100000000000000000000000000000000000C9
64671+:1017200000000000000000000000000000000000B9
64672+:1017300000000000000000000000000000000000A9
64673+:101740000000000000000000000000000000000099
64674+:101750000000000000000000000000001000000376
64675+:10176000000000000000000D0000000D3C02080019
64676+:1017700024421C003C03080024632094AC40000079
64677+:101780000043202B1480FFFD244200043C1D080070
64678+:1017900037BD2FFC03A0F0213C1008002610049058
64679+:1017A0003C1C0800279C1C000E00015C000000008F
64680+:1017B0000000000D3084FFFF308200078F85001885
64681+:1017C00010400002248300073064FFF800853021B8
64682+:1017D00030C41FFF03441821247B4000AF85001C48
64683+:1017E000AF84001803E00008AF4400843084FFFF9A
64684+:1017F000308200078F8500208F860028104000026D
64685+:10180000248300073064FFF8008520210086182B10
64686+:1018100014600002AF8500240086202303442821A1
64687+:1018200034068000AF840020AF44008000A6202151
64688+:1018300003E00008AF84003827BDFFD8AFB3001C19
64689+:10184000AFB20018AFB00010AFBF0024AFB400209B
64690+:10185000AFB100143C0860088D1450002418FF7FBD
64691+:101860003C1A8000029898243672380CAD12500051
64692+:101870008F5100083C07601C3C08600036300001B6
64693+:10188000AF500008AF800018AF400080AF40008428
64694+:101890008CE600088D0F08083C0760168CEC0000F1
64695+:1018A00031EEFFF039CA00103C0DFFFF340B800011
64696+:1018B0003C030080034B48212D440001018D282466
64697+:1018C0003C0253533C010800AC230420AF8900388C
64698+:1018D000AF860028AF840010275B400014A20003ED
64699+:1018E00034E37C008CF90004032818218C7F007CF1
64700+:1018F0008C6500783C0280003C0B08008D6B048CEA
64701+:101900003C0A08008D4A048834520070AF85003CC0
64702+:10191000AF9F00403C13080026731C440240A021E6
64703+:101920008E4800008F46000038C30001306400017B
64704+:1019300010800017AF880034028048218D2F0000EE
64705+:101940003C0508008CA5045C3C1808008F1804585E
64706+:1019500001E8102300A280210000C8210202402BD0
64707+:1019600003198821022838213C010800AC30045CAE
64708+:101970003C010800AC2704588F4E000039CD00010F
64709+:1019800031AC00011580FFED01E04021AF8F003444
64710+:101990008E5100003C0708008CE7045C3C0D0800F9
64711+:1019A0008DAD04580228802300F0602100007021D2
64712+:1019B0000190302B01AE1821006620213C01080067
64713+:1019C000AC2C045C3C010800AC2404588F46010890
64714+:1019D0008F47010030C92000AF860000AF87000CA0
64715+:1019E0001120000A00C040213C1808008F18042C68
64716+:1019F000270800013C010800AC28042C3C184000DA
64717+:101A0000AF5801380A000196000000009749010410
64718+:101A100000002821014550213122FFFF0162582199
64719+:101A20000162F82B015F502130D902003C0108000F
64720+:101A3000AC2B048C3C010800AC2A0488172000154C
64721+:101A400024040F0010E400130000000024080D001F
64722+:101A500010E8023B30CD000611A0FFE93C18400021
64723+:101A6000936E00002409001031C400F01089027147
64724+:101A700024020070108202E58F880014250F0001F7
64725+:101A8000AF8F00143C184000AF5801380A0001968F
64726+:101A900000000000974C01041180FFD93C18400061
64727+:101AA00030C34000146000A1000000008F460178A0
64728+:101AB00004C0FFFE8F87003824100800240F0008A0
64729+:101AC0008CE30008AF500178A74F0140A7400142C6
64730+:101AD000974E01048F86000031C9FFFF30CD000111
64731+:101AE00011A002E1012040212531FFFE241800024F
64732+:101AF000A75801463228FFFFA75101483C190800AA
64733+:101B00008F39043C172002D08F8C000C30DF00206E
64734+:101B100017E00002240400092404000130C20C0074
64735+:101B2000240504005045000134840004A744014A00
64736+:101B30003C1108008E3104203C1800483C10000184
64737+:101B40000238182530CF00020070282511E000046B
64738+:101B5000000018213C19010000B9282524030001C8
64739+:101B600030DF000453E00005AF8300083C0600109E
64740+:101B700000A6282524030001AF830008AF4510000C
64741+:101B80000000000000000000000000000000000055
64742+:101B90008F83000810600023000000008F451000B4
64743+:101BA00004A1FFFE000000001060001E0000000005
64744+:101BB0008F4410003C0C0020008C102410400019B1
64745+:101BC0008F8E000031CD000211A000160000000031
64746+:101BD000974F101415E000130000000097591008EB
64747+:101BE0003338FFFF271100060011188200033080F0
64748+:101BF00000C7282132300001322300031200032CD9
64749+:101C00008CA200000000000D00C7F821AFE2000028
64750+:101C10003C0508008CA5043024A600013C01080006
64751+:101C2000AC2604308F6D00003402FFFFAF8D00043E
64752+:101C30008CEC0000118202A6000020218CED000037
64753+:101C400031AC01001180028A000000003C02080053
64754+:101C50008C4204743C0308008C63044C3C1F080055
64755+:101C60008FFF04703C1808008F1804480048382182
64756+:101C70000068802100E8282B03E430210208402B73
64757+:101C80000304882100C57021022878213C01080046
64758+:101C9000AC30044C3C010800AC2F04483C01080067
64759+:101CA000AC2704743C010800AC2E04708F8400182B
64760+:101CB0000120302131290007249F000833F91FFF3C
64761+:101CC00003594021AF84001CAF990018251B400028
64762+:101CD000AF590084112000038F83002024C2000725
64763+:101CE0003046FFF88F84002800C3282100A4302B41
64764+:101CF00014C00002AF83002400A428230345602100
64765+:101D0000340D8000018D10213C0F1000AF850020A4
64766+:101D1000AF820038AF450080AF4F01788F88001444
64767+:101D2000250F00010A0001EFAF8F00148F62000839
64768+:101D30008F670000240500300007760231C300F0F1
64769+:101D4000106500A7240F0040546FFF4C8F880014CB
64770+:101D50008F4B01780560FFFE0000000030CA0200D2
64771+:101D600015400003000612820000000D00061282DA
64772+:101D7000304D0003000D4900012D18210003808023
64773+:101D8000020D402100086080019380218E1F000019
64774+:101D900017E00002000000000000000D8F6E00043C
64775+:101DA00005C202BD92070006920E000592020004D1
64776+:101DB0003C090001000E18800070F8218FED00181A
64777+:101DC000277100082448000501A96021000830821D
64778+:101DD000AFEC0018022020210E00059E26050014FD
64779+:101DE000920A00068F7900043C0B7FFF000A2080D6
64780+:101DF000009178218DF800043566FFFF0326282422
64781+:101E000003053821ADE70004920E0005920D000491
64782+:101E1000960C0008000E10800051C8218F2300008E
64783+:101E2000974901043C07FFFF006758243128FFFF52
64784+:101E3000010DF82103EC50233144FFFF01643025EC
64785+:101E4000AF260000920300072418000110780275E5
64786+:101E5000240F0003106F0285000000008E050010A3
64787+:101E60002419000AA7590140A7450142921800040D
64788+:101E70008F860000240F0001A7580144A7400146A7
64789+:101E80009747010430D100023C050041A7470148B3
64790+:101E900000001821A74F014A1220000330CB000494
64791+:101EA0003C0501412403000151600005AF83000897
64792+:101EB0003C06001000A6282524030001AF8300087B
64793+:101EC000AF4510000000000000000000000000000E
64794+:101ED000000000008F8A000811400004000000008C
64795+:101EE0008F4410000481FFFE000000008F6B000093
64796+:101EF000920800043C1108008E310444AF8B0004AA
64797+:101F000097590104311800FF3C0E08008DCE0440A3
64798+:101F10003325FFFF0305382102276021000010212F
64799+:101F2000250F000A31E8FFFF0187482B01C2682115
64800+:101F300001A9F821311000073C010800AC2C044431
64801+:101F40003C010800AC3F0440120000038F8C0018D5
64802+:101F50002506000730C8FFF8010C682131BF1FFFBC
64803+:101F6000AF8C001CAF9F0018AF5F00849744010442
64804+:101F7000035F80213084FFFF308A00071140000397
64805+:101F8000261B4000248900073124FFF88F8200209F
64806+:101F90008F850028008220210085702B15C000024B
64807+:101FA000AF820024008520233C0B08008D6B048C3D
64808+:101FB0003C0A08008D4A04880344882134038000C9
64809+:101FC000022310213C0F1000AF840020AF820038A4
64810+:101FD000AF440080AF4F01780A0002968F8800144A
64811+:101FE0008F5001780600FFFE30D10200162000035A
64812+:101FF000000612820000000D00061282305F00030E
64813+:10200000001F1900007F302100062080009FC8219A
64814+:1020100000194880013380218E180000130000024F
64815+:10202000000000000000000D8F6C000C058001FB1B
64816+:102030008F870038240E0001AE0E00008CE30008EC
64817+:10204000A20000078F65000400055402314D00FF17
64818+:1020500025A80005000830822CCB00411560000245
64819+:10206000A20A00040000000D8F7800043C03FFFF6B
64820+:1020700000E02821330BFFFF256C000B000C1082C1
64821+:1020800000022080008748218D3F000026040014B4
64822+:10209000A618000803E3C8240E00059EAD39000011
64823+:1020A0008F4F01083C11100001F1382410E001AB02
64824+:1020B00000000000974D01049208000725AAFFECDC
64825+:1020C000350600023144FFFFA2060007960600080D
64826+:1020D0002CC7001354E0000592030007921100077B
64827+:1020E000362F0001A20F00079203000724180001F9
64828+:1020F000107801C224090003106901D58F880038C7
64829+:1021000030CBFFFF257100020011788331E400FF1E
64830+:1021100000042880A20F000500A848218D2D000092
64831+:10212000974A01043C0EFFFF01AEF8243143FFFF44
64832+:10213000006B1023244CFFFE03ECC825AD390000D2
64833+:10214000920600053C03FFF63462FFFF30D800FF23
64834+:102150000018388000F08821922F00143C04FF7F83
64835+:102160003487FFFF31EE000F01C65821316500FFB3
64836+:1021700000055080015068218DAC00200148F821F5
64837+:10218000A20B00060182C824AE0C000CAFF9000CB3
64838+:10219000920900068E11000C032778240009C080E4
64839+:1021A0000310702195C60026030828210227202449
64840+:1021B000AE04000CADCF0020ADC60024ACA60010CC
64841+:1021C0008F8800003C0B08008D6B048C3C0A0800D3
64842+:1021D0008D4A0488241F001024190002A75F0140C3
64843+:1021E000A7400142A7400144A7590146974901046D
64844+:1021F00024070001310600022538FFFEA7580148D8
64845+:102200003C050009A747014A10C00003000018213F
64846+:102210003C05010924030001310C00045180000534
64847+:10222000AF8300083C08001000A828252403000103
64848+:10223000AF830008AF451000000000000000000060
64849+:1022400000000000000000009205000424AE00021F
64850+:1022500031CD0007000D182330620007AE020010D8
64851+:102260008F90000812000004000000008F4F100043
64852+:1022700005E1FFFE000000008F7100008F8E001846
64853+:102280003C0308008C630444AF91000497450104AB
64854+:1022900025CF001031E61FFF30A2FFFFAF8E001CDC
64855+:1022A000AF860018AF4600842449FFFE3C0C0800AE
64856+:1022B0008D8C0440974D010401208021000947C303
64857+:1022C0000070C02131A9FFFF0310F82B0188C8213D
64858+:1022D000033F202103463821313100073C0108002B
64859+:1022E000AC3804443C010800AC2404401220000334
64860+:1022F00024FB40002527000730E9FFF88F860020E7
64861+:102300008F8400280126382100E4C02B170000022A
64862+:10231000AF86002400E438230347202134198000CD
64863+:10232000009910213C0F1000AF870020AF820038C9
64864+:10233000AF470080AF4F01780A0002968F880014E3
64865+:102340009747010410E0FDAE3C1840008F5801781B
64866+:102350000700FFFE30C5400010A000033C1F00082E
64867+:102360000000000D3C1F0008AF5F01402410080072
64868+:102370008F860000AF5001789744010430D90001E6
64869+:10238000132000ED3086FFFF24CCFFFE240D000259
64870+:10239000A74D0146A74C01488F9100182408000D55
64871+:1023A000A748014A8F630000262F000831E21FFF73
64872+:1023B0000342702130C90007AF830004AF91001CB5
64873+:1023C000AF82001800C03821AF4200841120000302
64874+:1023D00025DB400024D800073307FFF88F85002055
64875+:1023E0008F84002800E5302100C4382B14E000025F
64876+:1023F000AF85002400C430238F8400140346F821E5
64877+:10240000340C8000AF86002003EC8021AF460080B2
64878+:10241000249900013C0610003C184000AF460178AA
64879+:10242000AF900038AF990014AF5801380A000196F8
64880+:10243000000000008F630000975101043067FFFF28
64881+:102440003228FFFF8F4F017805E0FFFE30EC0007D8
64882+:10245000000CF82333F0000724F9FFFE2404000ADF
64883+:10246000A7440140A7500142A7590144A740014693
64884+:10247000A74801488F45010830B800201700000226
64885+:10248000240300092403000130CD0002A743014AC0
64886+:102490003C04004111A00003000018213C0401414C
64887+:1024A0002403000130C9000451200005AF83000857
64888+:1024B0003C0600100086202524030001AF8300089D
64889+:1024C000AF44100000000000000000000000000009
64890+:1024D000000000008F8E000811C000040000000002
64891+:1024E0008F4210000441FFFE000000008F7F0000BB
64892+:1024F000276400088F91003CAF9F0004948500087A
64893+:102500009490000A9499000C30AFFFFF0010C400B3
64894+:102510003323FFFF11F100A6030320253C0E080022
64895+:102520008DCE04443C0C08008D8C044000E88821CA
64896+:102530002626FFFE01C628210000682100A6F82BF0
64897+:10254000018D2021009F80213C010800AC2504441E
64898+:102550003C010800AC30044024E200083042FFFF98
64899+:102560003047000710E000038F830018244F000756
64900+:1025700031E2FFF83106FFFF30C800070043802139
64901+:1025800032191FFF0359C021AF83001CAF990018F7
64902+:10259000271B4000AF590084110000038F8C0020DE
64903+:1025A00024C5000730A6FFF88F84002800CC28211E
64904+:1025B00000A4F82B17E00002AF8C002400A428230D
64905+:1025C000AF850020AF4500803C0408008C840434B3
64906+:1025D00003454821340E8000012E6821108000053B
64907+:1025E000AF8D0038939100172406000E12260011BB
64908+:1025F0002407043F3C021000AF4201788F8800148A
64909+:10260000250F00010A0001EFAF8F00140E0005C472
64910+:1026100000E020218F8800143C0B08008D6B048C97
64911+:102620003C0A08008D4A0488250F00010A0001EFCA
64912+:10263000AF8F00143C021000A7470148AF42017859
64913+:102640000A0004CE8F88001424040F001184003D7A
64914+:1026500030CE002015C0000224030009240300012D
64915+:102660000A00021AA743014A0A00020DA7400146C8
64916+:1026700094EF000894F1000A94F0000C8F8C003C59
64917+:10268000001174003207FFFF31EDFFFF11AC00377E
64918+:1026900001C720253C1808008F1804443C0F08008F
64919+:1026A0008DEF0440000080210308682101A8382B29
64920+:1026B00001F0702101C760213C010800AC2D0444E9
64921+:1026C0003C010800AC2C04400A00027A8F840018F8
64922+:1026D0003C0208008C42047C3C0308008C630454D8
64923+:1026E0003C1F08008FFF04783C1808008F18045026
64924+:1026F000004838210068802100E8282B03E43021BD
64925+:102700000208402B0304882100C57021022878218B
64926+:102710003C010800AC3004543C010800AC2F0450CC
64927+:102720003C010800AC27047C3C010800AC2E047876
64928+:102730000A00027A8F840018A74001460A00043577
64929+:102740008F91001830CD002015A0FFC52403000D87
64930+:10275000240300050A00021AA743014A974E010408
64931+:1027600025C5FFF00A00038130A4FFFF8F980040C9
64932+:102770001498FFC8000010213C0508008CA5046CCB
64933+:102780003C1F08008FFF046800A8C8210328302BD5
64934+:1027900003E22021008640213C010800AC39046C92
64935+:1027A0003C010800AC2804680A00027A8F840018F3
64936+:1027B0008F8C0040148CFF5900E8C8213C18080099
64937+:1027C0008F18046C3C1108008E3104682723FFFE2B
64938+:1027D00003034821000010210123302B0222702125
64939+:1027E00001C668213C010800AC29046C3C010800CA
64940+:1027F000AC2D04680A0004A524E200088F88003884
64941+:102800003C03FFFF8D02000C0043F82403E4C825BD
64942+:10281000AD19000C0A00038F30CBFFFF0A0003C381
64943+:10282000AE000000974A0104920400048E26000CBA
64944+:10283000014458212579FFF200C7C0243325FFFF4A
64945+:1028400003053825AE27000C0A0002E68E050010AD
64946+:102850003C0DFFFF8D0A0010014D582401646025D6
64947+:10286000AD0C00100A00038F30CBFFFF974301042B
64948+:10287000920E00048E290010006E1021244DFFEEF0
64949+:102880000127602431A8FFFF0188F825AE3F001022
64950+:102890000A0002E68E0500108E0F000CAE0000004C
64951+:1028A00000078880023028210A0002B8ACAF00205F
64952+:1028B0001460000D3058FFFF3C04FFFF0044682403
64953+:1028C00001A47026000E602B000D102B004CF82484
64954+:1028D00013E00002000000000000000D8CAF0000BB
64955+:1028E0000A00025001E410253B03FFFF0003882B80
64956+:1028F0000018802B0211202410800002000000002C
64957+:102900000000000D8CB900000A0002503722FFFFC2
64958+:102910003084FFFF30A5FFFF108000070000182162
64959+:10292000308200011040000200042042006518219E
64960+:102930001480FFFB0005284003E000080060102120
64961+:1029400010C00007000000008CA2000024C6FFFF9A
64962+:1029500024A50004AC82000014C0FFFB2484000402
64963+:1029600003E000080000000010A0000824A3FFFFFF
64964+:10297000AC86000000000000000000002402FFFF01
64965+:102980002463FFFF1462FFFA2484000403E00008BC
64966+:1029900000000000308EFFFF30D8FFFF00057C00F4
64967+:1029A00001F8602539CDFFFF01AC5021014C582BB7
64968+:1029B000014B4821000944023127FFFF00E8302184
64969+:1029C0000006240230C5FFFF00A418213862FFFF73
64970+:1029D00003E000083042FFFF3C0C08008D8C0484AB
64971+:1029E000240BFF8027BDFFD001845021014B4824D8
64972+:1029F000AF4900203C0808008D080484AFB20020D5
64973+:102A0000AFB00018AFBF0028AFB30024AFB1001CB7
64974+:102A1000936600040104382130E4007F009A1021FD
64975+:102A20003C0300080043902130C500200360802152
64976+:102A30003C080111277B000814A000022646007004
64977+:102A40002646006C9213000497510104920F000473
64978+:102A50003267000F322EFFFF31ED004001C72823FF
64979+:102A600011A0000500004821925900BC3338000431
64980+:102A70001700009000000000924300BC307F00046B
64981+:102A800013E0000F0000000010A0000D0000000087
64982+:102A9000960E0002240AFF8000A7602125CDFFFECC
64983+:102AA000A74D1016920B0004014B2024308200FF2A
64984+:102AB00010400085010C40253C0F0400010F40250B
64985+:102AC0008F5301780660FFFE2404000AA7440140EA
64986+:102AD000960D00022404000931AC0007000C5823B5
64987+:102AE000316A0007A74A0142960200022443FFFE12
64988+:102AF000A7430144A7400146975F0104A75F01482F
64989+:102B00008F590108333800205300000124040001CC
64990+:102B1000920F000431EE001015C000023483001043
64991+:102B200000801821A743014A0000000000000000B7
64992+:102B30000000000000000000AF481000000000008E
64993+:102B40000000000000000000000000008F51100095
64994+:102B50000621FFFE3113FFFF12600003000000009A
64995+:102B60008F481018ACC8000096030006307FFFFFA6
64996+:102B700027F900020019988200138880023B302157
64997+:102B80008CD800001520005700183402920300046E
64998+:102B90002405FF8000A3F82433F100FF1220002C4D
64999+:102BA00000000000924700BC30F2000212400028F2
65000+:102BB00000000000974B100C2562FFFEA742101684
65001+:102BC000000000003C0A040035490030AF49100005
65002+:102BD00000000000000000000000000000000000F5
65003+:102BE0008F4C10000581FFFE000000009749100C7B
65004+:102BF0008F51101C00C020213127FFFF24F200302C
65005+:102C0000001218820003288000BBF8213226FFFF43
65006+:102C1000AFF100000E0005B300112C020013C880B4
65007+:102C2000033B98218E78000000027400AFB80010BA
65008+:102C30008FA80010310FFFFFAFAF00108FA400105E
65009+:102C400001C46825AFAD00108FA60010AE6600006D
65010+:102C500097730008976D000A9766000C8F8A003CF6
65011+:102C6000000D5C0030CCFFFF3262FFFF104A0036DF
65012+:102C7000016C2025960600023C10100024D30008A9
65013+:102C80000E00013B3264FFFF974C01040E00014926
65014+:102C90003184FFFFAF5001788FBF00288FB300242D
65015+:102CA0008FB200208FB1001C8FB0001803E0000825
65016+:102CB00027BD003010A0FF700000000024A5FFFC1D
65017+:102CC0000A0005EC240900048CD10000AF51101853
65018+:102CD0008F5301780660FF7A2404000A0A00060177
65019+:102CE0000000000000A7C8218F8800388F4E101CFC
65020+:102CF0000019C0820018788001E82021AC8E000005
65021+:102D0000000E2C0200C020210E0005B331C6FFFFCB
65022+:102D1000023B28218CAD000000025400004030210D
65023+:102D2000AFAD00108FAC0010318BFFFFAFAB0010C8
65024+:102D30008FA2001001424825AFA900108FA70010F4
65025+:102D40000A000631ACA700008F8F0040148FFFC926
65026+:102D50000000000097420104960B00023C050800A9
65027+:102D60008CA5046C3049FFFF316AFFFF3C1108005D
65028+:102D70008E310468012A382124F2FFFE00B240217E
65029+:102D80000012FFC30112C82B023FC02103192021EA
65030+:102D90003C010800AC28046C3C010800AC24046829
65031+:102DA0000A00066B0000000000A4102B1040000970
65032+:102DB000240300010005284000A4102B04A00003F8
65033+:102DC000000318405440FFFC000528401060000735
65034+:102DD000000000000085302B14C0000200031842E0
65035+:102DE000008520231460FFFB0005284203E0000853
65036+:102DF000008010218F85002C27BDFFE800053027BB
65037+:102E00002CC300012CA400020083102510400003F5
65038+:102E1000AFBF00102405007FAF85002C00052827D8
65039+:102E200030A5FFFF0E000592240426F58F830030A5
65040+:102E3000240402BD004030210083382B10E000093B
65041+:102E400024050001000420400083102B04800003AF
65042+:102E5000000528405440FFFC0004204010A000085A
65043+:102E600000C350210064402B1500000200052842D9
65044+:102E70000064182314A0FFFB0004204200C350216B
65045+:102E80008FBF0010000A4C02312200FF27BD00183E
65046+:102E9000AF8A002C03E00008AF8900300A00002A46
65047+:102EA00000000000000000000000000D7478703683
65048+:102EB0002E322E3300000000060203000000000046
65049+:102EC000000001360000EA60000000000000000081
65050+:102ED00000000000000000000000000000000000F2
65051+:102EE00000000000000000000000000000000000E2
65052+:102EF00000000000000000000000000000000016BC
65053+:102F000000000000000000000000000000000000C1
65054+:102F100000000000000000000000000000000000B1
65055+:102F200000000000000000000000000000000000A1
65056+:102F3000000000000000138800000000000005DC15
65057+:102F4000000000000000000010000003000000006E
65058+:102F50000000000D0000000D3C02080024423C204F
65059+:102F60003C03080024633DD4AC4000000043202B08
65060+:102F70001480FFFD244200043C1D080037BD7FFC87
65061+:102F800003A0F0213C100800261000A83C1C0800FB
65062+:102F9000279C3C200E0002BA000000000000000D3B
65063+:102FA0008F8300383C088000350700708CE50000F6
65064+:102FB000008330253C02900000C22025AF85003000
65065+:102FC000AF4400208F4900200520FFFE3C03800015
65066+:102FD000346200708C4500008F8600303C19080078
65067+:102FE0008F39007C3C0E08008DCE007800A620238F
65068+:102FF00003245821000078210164682B01CF60214F
65069+:10300000018D50213C010800AC2B007C3C010800E4
65070+:10301000AC2A007803E00008000000000A0000412C
65071+:10302000240400018F8400383C05800034A2000194
65072+:103030000082182503E00008AF43002003E00008E9
65073+:10304000000010213084FFFF30A5FFFF1080000733
65074+:1030500000001821308200011040000200042042CC
65075+:10306000006518211480FFFB0005284003E00008DC
65076+:103070000060102110C00007000000008CA20000BA
65077+:1030800024C6FFFF24A50004AC82000014C0FFFB8F
65078+:103090002484000403E000080000000010A00008E1
65079+:1030A00024A3FFFFAC860000000000000000000029
65080+:1030B0002402FFFF2463FFFF1462FFFA248400044C
65081+:1030C00003E0000800000000308AFFFF93A800130F
65082+:1030D000A74A014497490E1630C600FF3C02100073
65083+:1030E000A7490146AF450148A3460152A748015AE6
65084+:1030F000AF4701608FA400188FA30014A7440158A4
65085+:10310000AF43015403E00008AF42017803E0000838
65086+:10311000000000003C038000346200708C49000015
65087+:103120008F8800002484000727BDFFF83084FFF853
65088+:10313000AF890030974D008A31ACFFFFAFAC000083
65089+:103140008FAB0000016850232547FFFF30E61FFFCB
65090+:1031500000C4282B14A0FFF73C0C8000358B0070B6
65091+:103160008D6A00003C0708008CE700843C060800DC
65092+:103170008CC6008000081082014918230002788064
65093+:1031800000E370210000202101C3C82B00C4C0212E
65094+:1031900001FA4021031948212502400027BD0008FB
65095+:1031A0003C010800AC2E00843C010800AC290080E2
65096+:1031B00003E00008000000008F8200002486000762
65097+:1031C00030C5FFF800A2182130641FFF03E000089B
65098+:1031D000AF8400008F8700388F8A004027BDFFB87A
65099+:1031E0008F860044AFB60040AFBF0044AFB5003C8F
65100+:1031F000AFB40038AFB30034AFB20030AFB1002C81
65101+:10320000AFB000288F4501048D4900ACAF47008066
65102+:103210008CC8002000A938230000B021AF480E1050
65103+:103220008F440E1000004821AF440E148CC20024BD
65104+:10323000AF420E188F430E18AF430E1C10E001254D
65105+:103240002D230001936B0008116000D400000000E2
65106+:10325000976E001031CDFFFF00ED602B158000CF81
65107+:103260000000000097700010320FFFFFAF4F0E00FC
65108+:103270008F520000325100081220FFFD00000000B4
65109+:1032800097540E088F460E043285FFFF30B30001BD
65110+:1032900012600132000000000000000D30B8A040B4
65111+:1032A00024150040131500C030A9A0001120012DE5
65112+:1032B00000000000937F000813E0000800000000F9
65113+:1032C00097630010306BFFFF00CB402B1100000311
65114+:1032D00030AC00401180012300000000A785003CB5
65115+:1032E000AF8600349366000800E02821AFA70020D5
65116+:1032F00014C0012427B30020AF60000C9782003C6B
65117+:103300003047400014E00002240300162403000E9E
65118+:1033100024194007A363000AAF790014938A003E82
65119+:103320008F740014315800070018AA4002959025A8
65120+:10333000AF7200149784003C8F700014309100101D
65121+:1033400002117825AF6F0014978E003C31CD000834
65122+:1033500011A00147000028218F6700143C021000D3
65123+:103360003C0C810000E22825AF65001497460E0A48
65124+:103370002408000E3405FFFC30C3FFFF006C582505
65125+:10338000AF6B0004A3680002937F000A27E90004E2
65126+:10339000A369000A9786003C9363000A30CC1F00A3
65127+:1033A000000C598301634021251F0028A37F0009D9
65128+:1033B00097490E0CA769001093790009272A00028B
65129+:1033C000315800070018A82332B10007A371000B81
65130+:1033D00093740009976400108F910034978F003C1C
65131+:1033E000329200FF024480210205702131ED00403D
65132+:1033F00011A0000531C4FFFF0091282B3C12800072
65133+:1034000010A000140000A0210224382B14E0011B9E
65134+:103410008FA500208F4D0E14AF4D0E108F420E1C45
65135+:10342000AF420E18AF440E008F4F000031EE00087F
65136+:1034300011C0FFFD0000000097540E080080882195
65137+:1034400000009021A794003C8F500E04241400012A
65138+:10345000AF900034976400103095FFFF8E68000035
65139+:103460000111F82317E00009AE7F00008F650014FA
65140+:103470008F8B004434A60040AF6600148F4C0E10B2
65141+:10348000AD6C00208F430E18AD63002493670008D5
65142+:1034900014E000D2000000000E00009E2404001082
65143+:1034A0008F8900483C08320000402821312600FF67
65144+:1034B0000006FC0003E8502525390001AF990048BB
65145+:1034C000AC4A0000937800099370000A330400FFAF
65146+:1034D00000047400320F00FF01CF6825AC4D0004DA
65147+:1034E0008F820048064000EAACA20008ACA0000CA5
65148+:1034F0009783003C306B0008156000022628000608
65149+:1035000026280002974E0E148F450E1C8F6700046C
65150+:10351000936D000231C4FFFF31A200FFAFA2001083
65151+:103520008F6C0014AFA800180E00008BAFAC001415
65152+:10353000240400100E0000C7000000008E7200007E
65153+:1035400016400005000000008F6400142405FFBF32
65154+:1035500000859824AF7300148F79000C033538214F
65155+:10356000AF67000C9375000816A00008000000006B
65156+:1035700012800006000000008F7F00143C0BEFFF5C
65157+:103580003568FFFE03E84824AF690014A3740008FF
65158+:103590008FA500200A00024602202021AF470E001E
65159+:1035A0000A0000F5000000008F5901780720FFFE97
65160+:1035B000241F08008F840000AF5F0178974B008ABA
65161+:1035C000316AFFFF014448232528FFFF31021FFF16
65162+:1035D0002C4300081460FFF9000000008F8E0048A3
65163+:1035E0008F8D003800C048210344202125C60001EA
65164+:1035F000240C0F00AF86004800E9382324864000E1
65165+:1036000031CA00FF11AC0005240800019391003E6F
65166+:103610003230000700107A4035E80001000AAC00A3
65167+:103620003C18010002B8A025AC9440008F930048DC
65168+:1036300030B2003630A40008ACD3000410800097EC
65169+:1036400001123025974E0E0A8F8D00003C0281003A
65170+:1036500031CCFFFF25AB0008018240253C03100060
65171+:1036600031651FFF25390006241F000EAF48016099
65172+:1036700000C33025A75F015AAF850000A759015844
65173+:1036800014E0000A8F93003824120F0052720002D7
65174+:103690002416000134C600408F580E108F94004449
65175+:1036A000AE9800208F550E18AE9500248F450E144D
65176+:1036B000AF4501448F590E1CAF590148A34A01522E
65177+:1036C0003C0A1000AF460154AF4A017814E0FEDD19
65178+:1036D0002D2300010076A025128000178FBF004423
65179+:1036E0008F84003824160F0010960084000000001C
65180+:1036F0008F45017804A0FFFE24150F001095006E81
65181+:10370000000000008F470E14240202403C1F1000EE
65182+:10371000AF4701448F440E1CAF440148A3400152FF
65183+:10372000A740015AAF400160A7400158AF42015481
65184+:10373000AF5F01788FBF00448FB600408FB5003C6B
65185+:103740008FB400388FB300348FB200308FB1002CAB
65186+:103750008FB0002803E0000827BD004814C0FED049
65187+:1037600030B8A0408F420E148F84004400004821DE
65188+:10377000AC8200208F510E1CAC9100240A00020E76
65189+:103780002D2300018F910034978A003C3C12800069
65190+:103790000220A821315800401700FF300000A0216E
65191+:1037A000976900108F9200343139FFFF13320035D2
65192+:1037B00000002021008048211480FEA000A03821B4
65193+:1037C0008F420E148F840044AC8200208F510E1C57
65194+:1037D000AC9100240A00020E2D230001936A000917
65195+:1037E0009378000B315000FF330F00FF020F702160
65196+:1037F00025C2000A3050FFFF0E00009E020020216B
65197+:103800008F8600483C1F410024CD0001AF8D004849
65198+:10381000936C000930C600FF00064400318300FFAE
65199+:10382000246B0002010B4825013FC825AC5900005C
65200+:103830008F67000C97440E1400F22825AC45000455
65201+:103840008F450E1C8F670004936A00023084FFFFCF
65202+:10385000315800FFAFB800108F6F0014AFB10018DF
65203+:103860000E00008BAFAF00140A0001A60200202159
65204+:10387000AF6000040A00013EA36000020A00024695
65205+:1038800000002021000090210A0001702414000192
65206+:103890003C1280000A000195ACB2000C8F91000030
65207+:1038A00025240002A744015826300008320F1FFFCC
65208+:1038B0000A0001F9AF8F0000AF40014C1120002C2D
65209+:1038C000000000008F590E10AF5901448F430E18AD
65210+:1038D000240200403C1F1000AF430148A3400152A6
65211+:1038E000A740015AAF400160A7400158AF420154C0
65212+:1038F000AF5F01780A0002278FBF00441120000645
65213+:103900000000000097460E0830CC004015800002F1
65214+:10391000000000000000000D8F4D017805A0FFFEA3
65215+:103920000000000097530E103C120500240E2000EA
65216+:10393000326AFFFF0152C025AF58014C8F4F0E1461
65217+:103940003C021000AF4F01448F500E1CAF50014895
65218+:10395000A34001528F840038A740015AAF40016054
65219+:10396000A7400158AF4E01540A000215AF4201783A
65220+:103970008F490E14AF4901448F430E1C0A00028E7A
65221+:10398000240200403C0E20FF27BDFFE03C1A8000CF
65222+:103990003C0F800835CDFFFDAFBF001CAFB2001853
65223+:1039A000AFB10014AFB00010AF8F0040AF4D0E00AC
65224+:1039B0000000000000000000000000000000000007
65225+:1039C000000000003C0C00FF358BFFFDAF4B0E00EC
65226+:1039D0003C0660048CC95000240AFF7F3C11600043
65227+:1039E000012A40243507380CACC750008E24043817
65228+:1039F00024050009AF4500083083FFFF38622F71AE
65229+:103A00002450C0B3AF8000480E000068AF800000B3
65230+:103A100052000001AE20442C0E0004353C11800001
65231+:103A20000E000ED9363000708F8A00403C1208001C
65232+:103A300026523C88020088218E0800008F5F00001B
65233+:103A40003BF900013338000113000017AF88003044
65234+:103A5000022048218D2700003C0F08008DEF006CEC
65235+:103A60003C0C08008D8C006800E8C02301F8282178
65236+:103A70000000682100B8302B018D582101664021DB
65237+:103A80003C010800AC25006C3C010800AC28006833
65238+:103A90008F44000038830001306200011440FFEDC4
65239+:103AA00000E04021AF8700308E0C00003C0508008C
65240+:103AB0008CA5006C3C0408008C84006801883023CD
65241+:103AC00000A638210000102100E6402B00821821BA
65242+:103AD0000068F8213C010800AC27006C3C0108009C
65243+:103AE000AC3F00688F49010025590088AF99004418
65244+:103AF000AF890038AF4900208E070000AF87003043
65245+:103B00008F4D017805A0FFFE000000008E0600002A
65246+:103B10003C0B08008D6B00743C0408008C84007022
65247+:103B200000C728230165F8210000102103E5402B80
65248+:103B30000082382100E8C821240908003C0108005F
65249+:103B4000AC3F00743C010800AC390070AF4901780B
65250+:103B500093580108A398003E938F003E31EE000178
65251+:103B600015C000158F830038240E0D00106E00194B
65252+:103B7000240F0F00106F001D00000000915900007D
65253+:103B800024180050332900FF113800043C1F400066
65254+:103B9000AF5F01380A0002E7000000000E00090EC6
65255+:103BA000000000008F8A00403C1F4000AF5F0138DA
65256+:103BB0000A0002E700000000938D003E31AC0006D1
65257+:103BC000000C51000E0000CE0152D8210A00034320
65258+:103BD0008F8A00403C1B0800277B3D080E0000CE6A
65259+:103BE000000000000A0003438F8A00403C1B0800CD
65260+:103BF000277B3D280E0000CE000000000A00034392
65261+:103C00008F8A004090AA00018FAB00108CAC00108E
65262+:103C10003C0300FF8D680004AD6C00208CAD0014E7
65263+:103C200000E060213462FFFFAD6D00248CA7001816
65264+:103C30003C09FF000109C024AD6700288CAE001CC0
65265+:103C40000182C82403197825AD6F0004AD6E002CE5
65266+:103C50008CAD0008314A00FFAD6D001C94A9000234
65267+:103C60003128FFFFAD68001090A70000A56000029A
65268+:103C7000A1600004A167000090A30002306200FF71
65269+:103C80000002198210600005240500011065000E75
65270+:103C90000000000003E00008A16A00018CD80028A1
65271+:103CA000354A0080AD7800188CCF0014AD6F001439
65272+:103CB0008CCE0030AD6E00088CC4002CA16A0001CF
65273+:103CC00003E00008AD64000C8CCD001CAD6D001845
65274+:103CD0008CC90014AD6900148CC80024AD680008BC
65275+:103CE0008CC70020AD67000C8CC200148C8300646C
65276+:103CF0000043C82B13200007000000008CC20014F2
65277+:103D0000144CFFE400000000354A008003E0000886
65278+:103D1000A16A00018C8200640A000399000000007F
65279+:103D200090AA000027BDFFF88FA9001CA3AA0000DD
65280+:103D30008FAE00003C0FFF808FA8001835E2FFFF18
65281+:103D40008CCD002C01C26024AFAC0000A120000487
65282+:103D500000E06021A7A000028FB800008D270004BA
65283+:103D60000188182100A0582100C05021006D28268C
65284+:103D70003C06FF7F3C0F00FF2CAD000135EEFFFF3E
65285+:103D800034D9FFFF3C02FF0003193024000D1DC091
65286+:103D9000010EC82400E2C02400C370250319782551
65287+:103DA000AD2E0000AD2F00048D450024AFAE000005
65288+:103DB000AD2500088D4D00202405FFFFAD2D000C22
65289+:103DC000956800023107FFFFAD27001091660018CB
65290+:103DD00030C200FF000219C2506000018D4500345E
65291+:103DE000AD2500148D67000827BD0008AD27001C15
65292+:103DF0008C8B00CCAD2C0028AD20002CAD2B0024EA
65293+:103E0000AD20001803E00008AD20002027BDFFE032
65294+:103E1000AFB20018AFB10014AFB00010AFBF001CBC
65295+:103E20009098000000C088213C0D00FF330F007FF8
65296+:103E3000A0CF0000908E000135ACFFFF3C0AFF00D0
65297+:103E4000A0CE000194A6001EA22000048CAB00149A
65298+:103E50008E29000400A08021016C2824012A40241E
65299+:103E60000080902101052025A6260002AE24000432
65300+:103E700026050020262400080E00007624060002F5
65301+:103E800092470000260500282624001400071E0083
65302+:103E90000003160324060004044000032403FFFF6C
65303+:103EA000965900023323FFFF0E000076AE23001068
65304+:103EB000262400248FBF001C8FB200188FB100147D
65305+:103EC0008FB0001024050003000030210A0000809C
65306+:103ED00027BD002027BDFFD8AFB1001CAFB0001830
65307+:103EE000AFBF002090A80000240200018FB0003C6A
65308+:103EF0003103003F00808821106200148FAA00382F
65309+:103F0000240B0005506B0016AFAA001000A0202162
65310+:103F100000C028210E0003DC02003021922400BCE6
65311+:103F2000308300021060000326060030ACC00000A1
65312+:103F300024C600048FBF00208FB1001C8FB0001872
65313+:103F400000C0102103E0000827BD002801403821EF
65314+:103F50000E00035AAFB000100A0004200000000059
65315+:103F60000E0003A1AFB000140A00042000000000FE
65316+:103F70003C02000A034218213C04080024843D6CE2
65317+:103F80002405001A000030210A000080AF8300548D
65318+:103F90003C038000346200708C48000000A058216F
65319+:103FA00000C04821308A00FFAF8800308F4401787C
65320+:103FB0000480FFFE3C0C8000358600708CC500003C
65321+:103FC0003C0308008C6300743C1808008F180070D4
65322+:103FD00000A82023006468210000C82101A4782BD8
65323+:103FE0000319702101CF60213C010800AC2D007441
65324+:103FF0003C010800AC2C00708F480E14AF480144FF
65325+:10400000AF47014CA34A0152A74B01589346010800
65326+:1040100030C5000854A0000135291000934B090059
65327+:1040200024070050316A00FF11470007000000001C
65328+:104030008F450E1CAF450148AF4901543C091000A3
65329+:1040400003E00008AF490178934D010831A800084A
65330+:104050001100001000000000934F010831EE001025
65331+:1040600051C00001352900083C04080090843DD06F
65332+:10407000A34401508F4309A4AF4301488F4209A0D4
65333+:10408000AF420144AF4901543C09100003E000086D
65334+:10409000AF4901783C1908008F393D8C333800084E
65335+:1040A0005700FFF1352900080A00047300000000E2
65336+:1040B00024070040AF470814AF4008108F4209445E
65337+:1040C0008F4309508F4409548F45095C8F46094C32
65338+:1040D000AF820064AF830050AF84004CAF85005CBA
65339+:1040E00003E00008AF8600609346010930C5007FF9
65340+:1040F000000518C0000521400083102103E00008DE
65341+:10410000244200883C09080091293D9124A800021E
65342+:104110003C05110000093C0000E8302500C51825C9
65343+:1041200024820008AC83000003E00008AC80000497
65344+:104130009347010B8F4A002C974F09083C18000E3B
65345+:104140000358482131EEFFFF000E41C0AF48002C5C
65346+:1041500097430908952C001A008040212403000190
65347+:10416000318BFFFFAC8B00008D2D001C00A058216F
65348+:1041700000C06021AC8D00048D24002030E7004099
65349+:10418000AD04000891220019304400031083004858
65350+:104190002885000214A00062240600021086005642
65351+:1041A00024190003109900660000000010E0003A96
65352+:1041B000000000003C07080094E73D8624E200016F
65353+:1041C000934F0934934709219525002A31EE00FFCA
65354+:1041D000000E488230ED00FF978700580009360036
65355+:1041E000000D1C003044FFFF00C310250044C02513
65356+:1041F00000A778213C19400003197025000F4C00DE
65357+:10420000AD090004AD0E0000934D09203C030006EB
65358+:1042100025090014000D360000C32025AD04000858
65359+:104220008F59092C24E5000130A27FFFAD19000C45
65360+:104230008F580930A782005825020028AD180010B9
65361+:104240008F4F0938AD0F0014AD2B00048F4E09407D
65362+:10425000AD2E0008934D09373C05080090A53D9010
65363+:104260008F4409488F46094031A700FF00EC182110
65364+:10427000008678230003C7000005CC0003196025E1
65365+:1042800031E8FFFC01885825AD2B000CAD20001053
65366+:1042900003E00008AF4A002C3C0D080095AD3D86B8
65367+:1042A0003C0E080095CE3D800A0004C901AE1021E5
65368+:1042B0003C05080094A53D8A3C06080094C63D8054
65369+:1042C0003C18080097183D7C952E002400A6782104
65370+:1042D00001F86823000E240025A2FFF200821825B1
65371+:1042E00024190800AD03000CAD190014AD00001036
65372+:1042F0000A0004C4250800189526002495250028E6
65373+:104300000006C40000057C00370E810035ED080072
65374+:10431000AD0E000CAD0D00100A0004C425080014F9
65375+:104320001480FFA200000000952400240004140063
65376+:1043300034430800AD03000C0A0004C42508001033
65377+:104340003C03080094633D8A3C05080094A53D8029
65378+:104350003C06080094C63D7C953900249538002819
65379+:10436000006520210086782300196C000018740075
65380+:1043700025E2FFEE01C2202535A3810024190800A3
65381+:10438000AD03000CAD040010AD190018AD00001411
65382+:104390000A0004C42508001C03E00008240201F4FC
65383+:1043A00027BDFFE8AFB00010AFBF00140E000060E3
65384+:1043B0000080802124050040AF4508148F83005001
65385+:1043C0008F84004C8F85005C0070182100641023DE
65386+:1043D00018400004AF830050AF6300548F66005450
65387+:1043E000AF86004C1200000C000000008F440074E7
65388+:1043F000936800813409FA002D07000710E00005DA
65389+:1044000000891021936C0081240B01F4018B50046E
65390+:1044100001441021AF62000C8F4E095C01C5682376
65391+:1044200019A000048FBF00148F4F095CAF8F005C90
65392+:104430008FBF00148FB000100A00006227BD001863
65393+:104440008F8400648F8300508F82004CAF640044DF
65394+:10445000AF63005003E00008AF6200543C038000EB
65395+:10446000346200708C43000027BDFFF8308700FFE6
65396+:1044700030A900FF30C800FFAF8300308F440178BF
65397+:104480000480FFFE3C028000345900708F38000029
65398+:10449000A3A700033C0708008CE700748FAC000062
65399+:1044A0003C0608008CC60070030378233C0E7FFF97
65400+:1044B00000EFC82135CDFFFF00005021018D2824D9
65401+:1044C00000CA1821000847C0032F202B00A8102580
65402+:1044D0000064C021AFA200003C010800AC390074A8
65403+:1044E0003C010800AC380070934F010AA3A0000201
65404+:1044F0003C0E80FFA3AF00018FAC0000312B007F8A
65405+:1045000035CDFFFF018D4824000B5600012A4025C0
65406+:10451000240730002406FF803C05100027BD00085A
65407+:10452000AF48014CAF470154A7400158A346015280
65408+:1045300003E00008AF45017827BDFFE8AFBF0014D6
65409+:10454000AFB000108F6500743C068000309000FF13
65410+:1045500000A620250E000060AF6400749363000580
65411+:10456000346200080E000062A362000502002021F0
65412+:104570008FBF00148FB00010240500052406000131
65413+:104580000A00057027BD001827BDFFE03C0380002E
65414+:10459000AFB00010AFBF0018AFB1001434620070AC
65415+:1045A0008C470000309000FF30A800FFAF8700303C
65416+:1045B0008F4401780480FFFE3C18800037110070A2
65417+:1045C0008E2F00003C0D08008DAD00743C0A0800E1
65418+:1045D0008D4A007001E7702301AE282100005821A8
65419+:1045E00000AE302B014B4821012638213C01080048
65420+:1045F000AC250074000088213C010800AC27007045
65421+:104600001100000F000000008F6200742619FFFFE8
65422+:104610003208007F0002FE0233E5007F150000062D
65423+:10462000332200FF2407FF800207202624A3FFFF78
65424+:1046300000838025320200FF0040802124111008F1
65425+:104640000E000060000000008F49081831250004AA
65426+:1046500014A0FFFD3218007F001878C000187140C8
65427+:1046600001CF682125AC0088AF4C0818274A098083
65428+:104670008D4B0020AF4B01448D460024AF460148CE
65429+:10468000A35001500E000062A740015802201021E3
65430+:104690008FBF00188FB100148FB0001003E0000826
65431+:1046A00027BD002027BDFFE8308400FFAFBF00100A
65432+:1046B0000E0005BB30A500FF8F8300508FBF001098
65433+:1046C000344500402404FF903C02100027BD001830
65434+:1046D000AF43014CA3440152AF45015403E000082D
65435+:1046E000AF4201789343093E306200081040000D4C
65436+:1046F0003C0901013528080AAC8800008F47007486
65437+:10470000AC8700043C06080090C63D9030C5001000
65438+:1047100050A00006AC8000088F6A0060AC8A0008D8
65439+:104720002484000C03E00008008010210A00062207
65440+:104730002484000C27BDFFE8AFBF0014AFB0001009
65441+:104740009346093F00A050210005288000853823AA
65442+:1047500030C200FF240300063C09080095293D866D
65443+:1047600024E8FFD824050004104300372406000283
65444+:104770009750093C3C0F020400063400320EFFFF44
65445+:1047800001CF6825AC8D0000934C093E318B002091
65446+:104790001160000800000000934309363C02010349
65447+:1047A000345F0300307900FF033FC0252405000873
65448+:1047B000AC98000493430934935909210005F88209
65449+:1047C000306200FF0002C082332F00FF00186E002D
65450+:1047D000000F740001AE6025018920253C094000CE
65451+:1047E00000898025ACF0FFD8934309378F4F0948E3
65452+:1047F0008F580940306200FF004AC821033F7021F2
65453+:1048000001F86023000E6F0001A650253185FFFCE2
65454+:10481000001F58800145482501683821AD09002056
65455+:104820000E00006024F00028240400040E00006242
65456+:10483000A364003F020010218FBF00148FB000104E
65457+:1048400003E0000827BD00180A0006352406001200
65458+:1048500027BDFFD024090010AFB60028AFB5002453
65459+:10486000AFB40020AFB10014AFB000103C0108009D
65460+:10487000A0293D90AFBF002CAFB3001CAFB2001811
65461+:1048800097480908309400FF3C02000E3107FFFFF3
65462+:10489000000731C0AF46002C974409089344010B30
65463+:1048A00030B500FF03428021308300300000B0218A
65464+:1048B0001060012500008821240C00043C01080040
65465+:1048C000A02C3D90934B093E000B5600000A2E038E
65466+:1048D00004A0016000000000AF400048934F010BAE
65467+:1048E00031EE002011C00006000000009358093E80
65468+:1048F00000189E0000139603064001890000000086
65469+:104900009344010B30830040106000038F930050EC
65470+:104910008F8200502453FFFF9347093E30E6000882
65471+:1049200014C0000224120003000090219619002CEC
65472+:1049300093580934934F0937A7990058330C00FF57
65473+:1049400031EE00FF024E6821000D5880016C5021AD
65474+:10495000015140213C010800A4283D869205001821
65475+:1049600030A900FF010918213C010800A4233D885B
65476+:104970009211001816200002000000000000000D37
65477+:104980003C010800A4233D8A3C010800A4203D808E
65478+:104990003C010800A4203D7C935F010B3063FFFFC6
65479+:1049A00033F00040120000022464000A2464000B6B
65480+:1049B0003091FFFF0E00009E022020219358010B32
65481+:1049C0003C08080095083D8A0040202100185982C3
65482+:1049D000316700010E00049A01072821934C010B56
65483+:1049E0008F4B002C974E09083C0F000E034F4021BF
65484+:1049F00031CDFFFF000D51C0AF4A002C974309088D
65485+:104A00009505001A004038212404000130A9FFFF59
65486+:104A1000AC4900008D06001C00404821318A00404E
65487+:104A2000AC4600048D020020ACE20008910300199E
65488+:104A300030630003106400EC28790002172001188D
65489+:104A4000241000021070010C241F0003107F011EAF
65490+:104A500000000000114000DE000000003C090800DA
65491+:104A600095293D8625220001935F0934934E092143
65492+:104A70009504002A33F900FF0019C08231CF00FFEE
65493+:104A8000978E005800184600000F6C00010D80251D
65494+:104A90003045FFFF02051025008E50213C034000E9
65495+:104AA00000433025000A6400ACEC0004ACE60000D2
65496+:104AB000935F09203C19000624EC0014001FC60077
65497+:104AC00003197825ACEF00088F48092C25CD00018B
65498+:104AD00031A57FFFACE8000C8F500930A785005846
65499+:104AE00024E80028ACF000108F4409380100802130
65500+:104AF000ACE40014AD9300048F530940AD9300085B
65501+:104B0000934A09373C19080093393D908F4309486F
65502+:104B10008F460940314200FF0052F82100667023A1
65503+:104B2000001F7F000019C40001F8282531CDFFFCCB
65504+:104B300000AD2025AD84000CAD800010AF4B002CE3
65505+:104B4000934B093E317300081260000D3C060101D1
65506+:104B500034CC080AACEC00288F530074AD13000469
65507+:104B60003C0B0800916B3D903167001050E0000352
65508+:104B7000AD0000088F6A0060AD0A00082510000C27
65509+:104B800012C0003D000000009343093F24160006B8
65510+:104B900024060004306200FF105600C924070002FA
65511+:104BA0009758093C3C0F0204330DFFFF01AF40252D
65512+:104BB000AE0800009345093E30A400201080000894
65513+:104BC00000000000935309363C0B0103357F0300BE
65514+:104BD000327900FF033F7025AE0E00042406000862
65515+:104BE000934F093493480921312AFFFF31ED00FF2B
65516+:104BF000000D1082310300FF0002B60000032C00FC
65517+:104C000002C56025018A9825001220803C094000D9
65518+:104C10000204502302695825AD4BFFD8935F093732
65519+:104C20008F4F09488F58094033F900FF0332702134
65520+:104C30000006B08201D668210007440001F828234D
65521+:104C4000000D1F000068302530A2FFFC2547FFD86B
65522+:104C500000C260250016808002074821ACEC0020CD
65523+:104C6000253000280E00006024120004A372003FCB
65524+:104C70000E000062000000009347010B30F200407C
65525+:104C8000124000053C1900FF8E180000372EFFFF70
65526+:104C9000030E3024AE0600000E0000C702202021C3
65527+:104CA0003C10080092103D90321100031220000FBA
65528+:104CB00002A028218F89005025330001AF930050B6
65529+:104CC000AF7300508F6B00540173F8231BE0000298
65530+:104CD000026020218F640054AF6400548F4C007434
65531+:104CE000258401F4AF64000C02A028210280202159
65532+:104CF000A76000680E0005BB3C1410008F850050B3
65533+:104D000034550006AF45014C8F8A00488FBF002CF8
65534+:104D10008FB3001C25560001AF9600488FB20018D3
65535+:104D2000A34A01528FB60028AF5501548FB1001429
65536+:104D3000AF5401788FB500248FB400208FB00010DD
65537+:104D400003E0000827BD00309358093E00189E007C
65538+:104D500000139603064200362411000293440923EF
65539+:104D6000308300021060FEDD8F8600608F8200506D
65540+:104D700014C2FEDA000000000E0000600000000017
65541+:104D80009369003F24070016312800FF1107000C2B
65542+:104D9000240500083C0C0800918C3D90358B0001E7
65543+:104DA0003C010800A02B3D90936A003F314300FF77
65544+:104DB00010650065240D000A106D005E2402000CD1
65545+:104DC0000E000062000000000A00069000000000D3
65546+:104DD0003C09080095293D863C0A0800954A3D801B
65547+:104DE0000A0006F3012A10213C09080095293D8A92
65548+:104DF0003C04080094843D803C06080094C63D7C39
65549+:104E000095030024012410210046F8230003CC0060
65550+:104E100027F0FFF20330C025240F0800ACF8000C87
65551+:104E2000ACEF0014ACE000100A0006EE24E7001816
65552+:104E30003C010800A0313D90935F093E241600011B
65553+:104E400033F900201720FEA5241100080A0006905F
65554+:104E5000241100048F6E00848F4D094011A0FE9E26
65555+:104E6000AF8E0050240F00143C010800A02F3D908D
65556+:104E70000A00068F00000000950E0024950D002802
65557+:104E8000000E6400000D2C003589810034A6080056
65558+:104E9000ACE9000CACE600100A0006EE24E70014B2
65559+:104EA0001460FEEC000000009502002400021C00CB
65560+:104EB00034640800ACE4000C0A0006EE24E700109D
65561+:104EC0000A000741240700123C02080094423D8A70
65562+:104ED0003C06080094C63D803C03080094633D7C7A
65563+:104EE00095100024951900280046F82103E3C023FB
65564+:104EF00000106C0000197400270FFFEE01CF282569
65565+:104F000035AC8100ACEC000CACE5001024070800C7
65566+:104F1000AD2700182527001C0A0006EEAD2000145E
65567+:104F20008F7F004CAF7F00548F7900540A000699A0
65568+:104F3000AF790050A362003F0E0000620000000045
65569+:104F40000A00069000000000240200140A0008274E
65570+:104F5000A362003F27BDFFE8308400FFAFBF001011
65571+:104F60000E0005BB30A500FF9378007E9379007F8B
65572+:104F7000936E00809368007A332F00FF001866005C
65573+:104F8000000F6C0031CB00FF018D4825000B520053
65574+:104F90008FBF0010012A3825310600FF344470000D
65575+:104FA00000E628252402FF813C03100027BD0018DD
65576+:104FB000AF45014CAF440154A342015203E0000845
65577+:104FC000AF43017827BDFFD8AFB20018AFB10014CE
65578+:104FD000AFB00010AFBF0020AFB3001C9342010977
65579+:104FE000308600FF30B000FF000618C23204000215
65580+:104FF0003071000114800005305200FF93670005F6
65581+:1050000030E5000810A0000D30C80010024020213B
65582+:105010000E0005A702202821240400018FBF0020D4
65583+:105020008FB3001C8FB200188FB100148FB0001026
65584+:105030000080102103E0000827BD00281500003281
65585+:105040000000000093430109000028213062007F26
65586+:10505000000220C00002F94003E49821267900886C
65587+:10506000033B98218E7800248E6F0008130F0046B2
65588+:10507000000000008F640084241800020004FD82F8
65589+:1050800033F900031338007C0000000093660083AE
65590+:10509000934A0109514600043205007C10A00060CB
65591+:1050A000000000003205007C14A0005302402021C3
65592+:1050B00016200006320400018E7F00248F5901045F
65593+:1050C00017F9FFD600002021320400011080000AE9
65594+:1050D000024020218F4209408F9300641053000644
65595+:1050E000000000000E00066D022028218F430940B9
65596+:1050F000AF630044024020210E0006020220282156
65597+:105100000A000860240400013C0908008D2900649D
65598+:10511000252600013C010800AC26006416000012A0
65599+:10512000000000008F6D00843C0E00C001AE6024C2
65600+:1051300015800005024020210E00082E02202821A3
65601+:105140000A00086024040001240500040E00057014
65602+:1051500024060001024020210E00082E02202821F2
65603+:105160000A000860240400010E000041240400012C
65604+:10517000936B007D020B50250E000062A36A007D38
65605+:105180000A0008A38F6D00848F6600748F480104A5
65606+:105190008E67002400064E021507FFB63126007FF9
65607+:1051A000936B008326440001308A007F1146004340
65608+:1051B000316300FF5464FFB08F6400842645000112
65609+:1051C00030B1007F30A200FF122600042405000148
65610+:1051D000004090210A00087624110001240FFF806E
65611+:1051E000024F702401CF9026324200FF00409021F0
65612+:1051F0000A000876241100010E00066D0220282105
65613+:10520000321800301300FFAA321000820240202121
65614+:105210000E0005A7022028210A00086024040001CE
65615+:105220008F6E00743C0F80002405000301CF902591
65616+:10523000AF72007493710083240600010E000570A4
65617+:10524000322400FF0E00004124040001936D007D14
65618+:10525000020D60250E000062A36C007D3C0B08006F
65619+:105260008D6B0054257000013C010800AC300054E7
65620+:105270000A000860240400018F6800743C09800063
65621+:105280002405000401093825AF6700749363008387
65622+:10529000240600010E000570306400FF0E0000417E
65623+:1052A000240400019362007D020298250E00006232
65624+:1052B000A373007D0A00086024040001324D0080C1
65625+:1052C00039AC0080546CFF6C8F6400840A0008C9FC
65626+:1052D0002645000127BDFFC83C0A0008AFBF0030CB
65627+:1052E000AFB5002CAFB40028AFB30024AFB200209C
65628+:1052F000AFB1001CAFB00018034AD8212409004008
65629+:10530000AF490814AF4008108F4209448F43095039
65630+:105310008F4609548F47095C8F48094C9344010814
65631+:105320009345010BAF820064308400FF30A500FF7D
65632+:10533000AF830050AF86004CAF87005C0E00084A78
65633+:10534000AF8800601440017D8FBF0030A760006807
65634+:10535000934D0900240B00503C15080026B53D482C
65635+:1053600031AC00FF3C12080026523D58118B00035F
65636+:10537000000000000000A8210000902193510109C5
65637+:105380008F9F005024040010322E007F000E68C052
65638+:10539000000E6140018D282124B40088AF54081804
65639+:1053A0008F4901048F4A09A43C0B000E034BC02116
65640+:1053B000012A10233C010800AC223D6C8F430958A0
65641+:1053C0003C010800A0243D9097470908007F302346
65642+:1053D0003C010800AC263D7030E8FFFF0008C9C062
65643+:1053E0003C010800AC3F3D94AF59002C974209089E
65644+:1053F0009710002C8EB10000930F001803749821B1
65645+:10540000A7900058AF9300440220F80931F000FF44
65646+:10541000304E000215C001B2304F000111E0014FC3
65647+:10542000000000009343093E3066000814C00002EB
65648+:10543000241400030000A0218F5809A424130001A4
65649+:105440003C010800AC383D98934F0934935109371B
65650+:1054500031EC00FF322E00FF028E6821000D288003
65651+:1054600000AC5021015058213C010800A42B3D887C
65652+:105470003C010800A42A3D8693490934312200FFEB
65653+:1054800002022021249000103C010800A4303D8439
65654+:10549000240700068F9F00503C010800AC273D8C7C
65655+:1054A0008F88005C8F59095800008021011F282334
65656+:1054B00004A00149033F20230480014700A4302BAE
65657+:1054C00010C00149000000003C010800AC253D70FF
65658+:1054D0008E4200000040F809000000003043000246
65659+:1054E000146000F80040882130440001548000100E
65660+:1054F0008E4200043C0908008D293D743C0AC0001E
65661+:10550000012A8025AF500E008F45000030AB000807
65662+:105510001160FFFD00000000974D0E0824100001EF
65663+:10552000A78D003C8F4C0E04AF8C00348E420004DB
65664+:105530000040F8090000000002228825322E0002F7
65665+:1055400015C00180000000003C09080095293D7C41
65666+:105550003C06080094C63D883C0A0800954A3D7EFA
65667+:105560003C1908008F393D74012660213C18080061
65668+:105570008F183D983C03080094633D92018A2021D6
65669+:105580008F4E09400329F821248F000203E32821CC
65670+:10559000031968213C010800A42C3D8AAF8E0064E9
65671+:1055A0003C010800AC2D3D983C010800A4253D803D
65672+:1055B0000E00009E31E4FFFF8F870048004020214D
65673+:1055C0003C010800A0273D918E42000824E800011C
65674+:1055D000AF8800480040F809000000009344010B28
65675+:1055E0008F4C002C974A09083C0B000E034B4021BE
65676+:1055F0003149FFFF000919C08F8B0050AF43002CC9
65677+:10560000974309089506001A00403821308A004067
65678+:1056100030DFFFFFAC5F00008D19001C0040482107
65679+:10562000AC5900048D180020AC580008910F0019E7
65680+:1056300031E30003107300F0000000002862000254
65681+:105640001440010924050002106500FD240D00032B
65682+:10565000106D010D00000000114000D90000000095
65683+:105660003C0A0800954A3D8625420001934D0934C5
65684+:1056700093580921950E002A31A300FF00032082D0
65685+:10568000331F00FF9798005800047E00001FCC00D5
65686+:1056900001F940253049FFFF0109102501D83021CB
65687+:1056A0003C0540000045502500066C00ACED0004B0
65688+:1056B000ACEA0000934309203C04000624ED0014EA
65689+:1056C0000003FE0003E4C825ACF900088F49092C4B
65690+:1056D000270F000131EE7FFFACE9000C8F48093045
65691+:1056E000A78E005824E90028ACE800108F4509383F
65692+:1056F00001204021ACE50014ADAB00048F4209400D
65693+:10570000ADA20008934B09373C1F080093FF3D9062
65694+:105710008F4309488F4A0940316600FF00D4202199
65695+:10572000006A78230004C700001FCC000319282555
65696+:1057300031EEFFFC00AE1025ADA2000CADA00010B4
65697+:10574000AF4C002C934C093E318B00085160000F88
65698+:105750008E58000C3C06010134CA080AACEA002845
65699+:105760008F4B0074AD2B00043C0C0800918C3D90D5
65700+:105770003187001050E00003AD2000088F62006008
65701+:10578000AD2200082528000C8E58000C0300F809F3
65702+:10579000010020213C19080097393D8A3C1F080070
65703+:1057A00097FF3D7E033F782125E900020E0000C7E8
65704+:1057B0003124FFFF3C0E08008DCE3D6C3C080800F4
65705+:1057C0008D083D7401C828233C010800AC253D6CC0
65706+:1057D00014A00006000000003C0308008C633D8C10
65707+:1057E000346400403C010800AC243D8C1200007081
65708+:1057F0008F8C00448F470E108F900044AE0700201E
65709+:105800008F4D0E18AE0D00243C10080096103D8000
65710+:105810000E0000600000000024020040AF420814A7
65711+:105820008F8600508F8A004C00D01821006A5823C0
65712+:1058300019600004AF830050AF6300548F650054BB
65713+:10584000AF85004C1200000C000000008F44007473
65714+:10585000936800813409FA002D0E000711C000057D
65715+:1058600000891821937F0081241901F403F9780439
65716+:1058700001E41821AF63000C8F44095C8F83005C46
65717+:105880000083C0231B000003000000008F50095C50
65718+:10589000AF90005C0E000062000000008F8C005092
65719+:1058A0008E4700103C010800AC2C3D9400E0F80944
65720+:1058B000000000003C0D08008DAD3D6C55A0FEF5CC
65721+:1058C000240700068F450024975909088F8B006430
65722+:1058D0008F9400503C0F001F978200588F86005411
65723+:1058E0008F93004C3328FFFF35E9FF8000A9502437
65724+:1058F000000871C032320100AF4E0024A4C2002C57
65725+:10590000AF4A0024AF6B0044AF740050AF73005433
65726+:105910001640008032380010570000868EA4000424
65727+:10592000322300405460001B8EB100088EB0000C82
65728+:105930000200F809000000008FBF00308FB5002C76
65729+:105940008FB400288FB300248FB200208FB1001CC9
65730+:105950008FB0001803E0000827BD00389347010905
65731+:105960008F8800380007FE0003E8C825AF59008083
65732+:105970008F5809A08F5309A4AFB80010AF580E1468
65733+:105980008FB40010AF540E10AF530E1C0A00096202
65734+:10599000AF530E180220F809000000008EB0000C72
65735+:1059A0000200F809000000000A000AA88FBF0030BA
65736+:1059B000A5800020A59300220A000A5BAD93002475
65737+:1059C0003C09080095293D863C06080094C63D80A8
65738+:1059D0000A0009F4012610213C010800AC203D70AA
65739+:1059E0000A00098E8E4200003C010800AC243D7084
65740+:1059F0000A00098E8E4200003C03080094633D8A31
65741+:105A00003C04080094843D803C1F080097FF3D7CC7
65742+:105A1000951800240064C821033F782300186C0007
65743+:105A200025EEFFF201AE2825AC45000C240208004B
65744+:105A3000ACE20014ACE000100A0009EF24E7001803
65745+:105A400095060024950900280006240000091C0082
65746+:105A5000349F810034790800ACFF000CACF90010D1
65747+:105A60000A0009EF24E700141460FEFB00000000A8
65748+:105A70009518002400187C0035EE0800ACEE000CF0
65749+:105A80000A0009EF24E700103C07080094E73D8076
65750+:105A90003C04080094843D8A3C03080094633D7CE8
65751+:105AA00095190024951800280087F82103E378232E
65752+:105AB0002407080000192C0000186C0025EEFFEEEA
65753+:105AC00001AE302534A28100AD2700182527001C27
65754+:105AD000AD22000CAD2600100A0009EFAD20001425
65755+:105AE00093520109000028210E000602324400FFF3
65756+:105AF0008FBF00308FB5002C8FB400288FB30024E7
65757+:105B00008FB200208FB1001C8FB0001803E0000896
65758+:105B100027BD0038935F010933E400FF0E00066DD6
65759+:105B200000002821323800105300FF7E322300404D
65760+:105B30008EA400040080F809000000000A000AA2F8
65761+:105B4000322300401200FF5F000000008F540E144B
65762+:105B50008F920044AE5400208F530E1C0A000A8A14
65763+:105B6000AE5300248F82001C008040213C040100C1
65764+:105B70009047008530E3002010600009000000001D
65765+:105B80003C0708008CE73D948F83001800E3202336
65766+:105B9000048000089389000414E30003010020211D
65767+:105BA00003E00008008010213C04010003E000082D
65768+:105BB000008010211120000B006738238F8C0020FB
65769+:105BC00024090034918B00BC316A0002514000016D
65770+:105BD0002409003000E9682B15A0FFF10100202105
65771+:105BE00000E938232419FFFC00B9C02400F9782407
65772+:105BF00000F8702B15C0FFEA01E8202130C2000335
65773+:105C00000002182314C00012306900030000302184
65774+:105C100000A9702101C6682100ED602B1180FFE012
65775+:105C20003C0401002D2F00010006482B01053821FE
65776+:105C300001E9302414C0FFDA24E4FFFC2419FFFC3E
65777+:105C400000B9C0240308202103E0000800801021CF
65778+:105C50008F8B002024060004916A00BC31440004AC
65779+:105C60001480FFEC00A970210A000B5E00003021B7
65780+:105C700027BDFFE8AFBF00108F460100934A01091E
65781+:105C80003C1F08008FFF00902407FF80314F00FF6A
65782+:105C900031E8007F0008614003E6C821032CC021E1
65783+:105CA00027090120012770243C010800A02F3DD0C6
65784+:105CB000AF4E080C3C0D08008DAD00903C040080F8
65785+:105CC0003482000301A65821016C182124650120AB
65786+:105CD00030AA007801424025AF48081C3C1F08004C
65787+:105CE0008FFF00908F88004003E6C0213319000722
65788+:105CF00003074824033A7821AF49002825E909C061
65789+:105D0000952E00023C0D08008DAD008C3C0A080069
65790+:105D10008D4A009031CC3FFF01A61821000C59801C
65791+:105D2000006B282100A72024AF44002C95220002FC
65792+:105D30003C1F08008FFF008C9107008530593FFF02
65793+:105D400003E678210019C1800146702101F868211D
65794+:105D500031CC007F31AB007F019A2821017A50219C
65795+:105D60003C03000C3C04000E00A328210144102138
65796+:105D700030E6002027470980AF82002CAF88001C46
65797+:105D8000AF890024AF85002010C00006AF8700282F
65798+:105D90008D0200508CA4010C0044302318C0007701
65799+:105DA00000000000910C0085240DFFDF018D3824D8
65800+:105DB000A10700858F8B001C8F8900248F87002806
65801+:105DC0008D65004CAF850018912F000D31EE00203D
65802+:105DD00011C000170000000024090001A38900047D
65803+:105DE000AF80000C8CE400248F85000C240A00088E
65804+:105DF000AF800008AF8000103C010800A42A3D7E5F
65805+:105E00003C010800A4203D920E000B32000030211E
65806+:105E10008F8500248FBF0010AF82001490A8000D62
65807+:105E200027BD00180008394203E0000830E20001F5
65808+:105E3000913F00022418000133F900FF001921826C
65809+:105E400010980039240800021088005B8F86002C0F
65810+:105E50008CE5002414A0001B8F9F002091220000DD
65811+:105E6000240A00053046003F10CA00472404000100
65812+:105E70008F860008A3840004AF860010AF86000C54
65813+:105E80008CE400248F85000C240A00083C010800E3
65814+:105E9000A42A3D7E3C010800A4203D920E000B3256
65815+:105EA000000000008F8500248FBF0010AF82001417
65816+:105EB00090A8000D27BD00180008394203E0000833
65817+:105EC00030E200018CF800088CF900248FEE00C449
65818+:105ED000A38000048CE40024AF8E000C8F85000C9E
65819+:105EE0008F86000803197823240A0008AF8F00105A
65820+:105EF0003C010800A42A3D7E3C010800A4203D92FC
65821+:105F00000E000B32000000008F8500248FBF0010B0
65822+:105F1000AF82001490A8000D27BD00180008394278
65823+:105F200003E0000830E20001912300003062003FEE
65824+:105F3000104400278F8500208CE400241480002169
65825+:105F4000000000008D2E00183C187FFF8F85002078
65826+:105F5000370FFFFF01CF1824AF8300088F9F000881
65827+:105F60008CA8008403E8C82B1720000203E020213E
65828+:105F70008CA400840A000BEDAF8400088CA3010CF4
65829+:105F80000A000BCBAF8300188D2C00188F860008F9
65830+:105F90003C0D7FFF8F89002035A3FFFF018358242C
65831+:105FA00024040001AF8B0010AD2000CCA3840004BA
65832+:105FB0000A000BF9AF86000C8CCA00140A000BED26
65833+:105FC000AF8A00088CA300C80A000C30AF83000819
65834+:105FD0008F84002C8CAC00648C8D0014018D582BA8
65835+:105FE00011600004000000008CA200640A000C3064
65836+:105FF000AF8200088C8200140A000C30AF820008C7
65837+:106000008F85000C27BDFFE0AFBF0018AFB10014B3
65838+:1060100014A00007AFB000108F86002424020005F2
65839+:1060200090C400003083003F106200B68F840020CF
65840+:106030008F91000800A080218F8C00283C0508006B
65841+:106040008CA53D708D8B000431663FFF00C5502B41
65842+:106050005540000100C02821938D000411A0007359
65843+:1060600000B0F82B8F98002024040034930F00BC5C
65844+:1060700031EE000251C000012404003000A4C82BFE
65845+:10608000172000D10000000000A4282300B0F82B46
65846+:106090003C010800A4243D7C17E000680200202198
65847+:1060A0003C0308008C633D6C0083102B54400001BE
65848+:1060B000008018218F8800243C010800AC233D7427
65849+:1060C000000048219104000D308300205060000141
65850+:1060D0008F490E188F8300140123382B10E00059CC
65851+:1060E000000000003C0408008C843D7400895821A5
65852+:1060F000006B502B114000560090602B006930233C
65853+:1061000000C020213C010800AC263D7412000003B1
65854+:10611000241FFFFC1090008A32270003009FC82430
65855+:106120003C010800AC393D743C010800A4203D92BC
65856+:106130008F84000C120400078F830020AF910008A9
65857+:10614000020020218C7100CCAF90000C26300001A1
65858+:10615000AC7000CC3C0208008C423D748F8A001069
65859+:10616000240700180082202301422823AF84000C5A
65860+:1061700010800002AF850010240700108F86001CDD
65861+:106180003C010800A0273D902407004090CC0085EA
65862+:10619000318B00C0116700408F8D001414A00015D2
65863+:1061A00000002021934A01098F420974314500FF04
65864+:1061B0000002260224A300013090007F3071007F8E
65865+:1061C0001230007A2407FF80A0C300833C09080036
65866+:1061D0008D293D8C8F880024240D0002352C000869
65867+:1061E0003C010800A02D3DD13C010800AC2C3D8CA9
65868+:1061F00024040010910E000D31C6002010C00005CF
65869+:1062000000801821240800013C010800AC283D74DE
65870+:10621000348300018FBF00188FB100148FB00010BD
65871+:106220000060102103E0000827BD00203C010800A9
65872+:10623000A4203D7C13E0FF9A020020210A000C817B
65873+:1062400000A020213C0408008C843D740090602B49
65874+:106250001180FFAE000000003C0F080095EF3D7C70
65875+:1062600001E4702101C6682B11A000072C820004F4
65876+:106270003C1F60008FF954043338003F1700FFE5DE
65877+:10628000240300422C8200041040FFA0240300429B
65878+:106290000A000CDF8FBF0018152DFFC000000000A2
65879+:1062A0008CDF00743C0380002405FF8003E3C825D5
65880+:1062B000ACD9007490D80085240E0004240400108A
65881+:1062C000330F003F01E54025A0C800858F880024DA
65882+:1062D0003C010800A02E3DD1240300019106000DD1
65883+:1062E00030C9002015200003000000003C03080016
65884+:1062F0008C633D743C010800AC233D6C0A000CD655
65885+:10630000000000008F8700108C88008400E8282B94
65886+:1063100014A0000200E088218C910084240900016F
65887+:10632000A38900048F440E18022028210E000B328E
65888+:1063300002203021022080210A000C67AF82001465
65889+:1063400000071823306600033C010800A4263D9294
65890+:10635000122000058F8C0020918B00BC316A000454
65891+:106360001540001524CD00043C0F080095EF3D9228
65892+:1063700001E4702100AE302B50C0FF6E8F84000C02
65893+:106380002C85000514A0FFA32403004230980003CD
65894+:1063900017000002009818232483FFFC3C0108002A
65895+:1063A000AC233D740A000CA30000000000A7582491
65896+:1063B0000A000CCB016718263C010800A42D3D9271
65897+:1063C0000A000D33000000003C010800AC203D74C1
65898+:1063D0000A000CDE240300428F83001014600007C3
65899+:1063E000000010218F88002424050005910600007C
65900+:1063F00030C400FF108500030000000003E0000827
65901+:1064000000000000910A0018314900FF000939C25C
65902+:1064100014E0FFFA8F85001C3C04080094843D7C46
65903+:106420003C0308008C633D943C1908008F393D748F
65904+:106430003C0F080095EF3D920064C0218CAD0054E4
65905+:106440000319702101CF6021018D58231960001DAF
65906+:1064500000000000910E001C8F8C002C974B0E103A
65907+:1064600031CD00FF8D850004016D30238D88000043
65908+:1064700030CEFFFF000E510000AAC82100003821D5
65909+:1064800001072021032A182B0083C021AD990004A5
65910+:10649000AD980000918F000A01CF6821A18D000AFC
65911+:1064A0008F88002C974B0E12A50B0008950A003818
65912+:1064B00025490001A50900389107000D34E60008C0
65913+:1064C000A106000D03E000080000000027BDFFE06A
65914+:1064D000938700048F8F00248FAD00143C0E7FFF44
65915+:1064E0008F89000C35C8FFFFAFBF001CAFB000188C
65916+:1064F00001A8182491EA000D000717C03C1FBFFF38
65917+:10650000006258252D2E00018F90001837F9FFFFEB
65918+:106510003C1808008F183D943C0F080095EF3D8A09
65919+:1065200001796824000E47803C07EFFF3C05F0FF2F
65920+:1065300001A818253149002034E2FFFF34ACFFFFE9
65921+:106540000310582327A500102406000225EA0002A4
65922+:1065500000621824008080211520000200004021E4
65923+:106560008F480E1CA7AA0012056000372407000000
65924+:1065700030FF00FF001FCF008F8B001C00793825F3
65925+:10658000AFA70014916F00853C08080091083D9169
65926+:106590003C18DFFF31EE00C0370AFFFF000E182B5A
65927+:1065A0003C1F080097FF3D8400EA6824A3A800115F
65928+:1065B0000003174001A248258FB90010AFA90014AD
65929+:1065C0003C0A0800914A3D93A7BF00168FA800140B
65930+:1065D000032CC0243C0B01003C0F0FFF030B1825BC
65931+:1065E0003147000335EEFFFF010C68240007160059
65932+:1065F000006EF8243C09700001A2C82503E9582563
65933+:10660000AFB90014AFAB00100E000076A3A00015C8
65934+:106610008F8C0024260200089186000D30C40020D3
65935+:10662000108000068FBF001C3C05080094A53D802B
65936+:1066300024B0FFFF3C010800A4303D808FB000185B
65937+:1066400003E0000827BD00208F9800140118502B8C
65938+:106650005540FFC7240700010A000DB630FF00FFB8
65939+:106660009382000427BDFFE0AFBF00181040000F69
65940+:10667000008050218F880024240B00058F8900089A
65941+:10668000910700008F8400200100282130E3003FA3
65942+:106690008F86002C106B000800003821AFA9001075
65943+:1066A0000E00040EAFAA0014A38000048FBF0018D0
65944+:1066B00003E0000827BD00208D1900183C0F0800DA
65945+:1066C0008DEF3D748F9800103C027FFF8D08001401
65946+:1066D000345FFFFF033F682401F8702101AE60239F
65947+:1066E00001883821AFA900100E00040EAFAA0014D3
65948+:1066F0000A000E04A38000048F8700243C050800D4
65949+:1067000094A53D923C0208008C423D8C90E6000D21
65950+:106710000005240030C300201060002C00444025F8
65951+:106720008F85001C00006021240B000190A30085D0
65952+:1067300000004821240A00013C0F800035EE007063
65953+:106740008DC70000AF8700308F5801780700FFFE2B
65954+:106750003C038000347900708F3800003C0508004D
65955+:106760008CA500743C0D08008DAD007003077823E4
65956+:1067700000AF38210000102100EF302B01A22021B2
65957+:10678000008618213C010800AC2700743C01080079
65958+:10679000AC230070AF4B01483C1908008F393D9481
65959+:1067A000A7490144A74A0146AF59014C3C0B0800D8
65960+:1067B000916B3D91A34B0152AF4801543C0810002E
65961+:1067C000A74C015803E00008AF4801788F4B0E1C1E
65962+:1067D0003C0A08008D4A3D7497490E16974D0E14D9
65963+:1067E00001456021312AFFFF0A000E2731A9FFFF72
65964+:1067F0008F8300249064000D308200201040002917
65965+:10680000000000000000482100005021000040214D
65966+:106810003C07800034EB00708D670000AF870030CC
65967+:106820008F4C01780580FFFE3C0D800035AC007078
65968+:106830008D8B00003C0508008CA500743C0408000A
65969+:106840008C8400700167302300A67821000010219D
65970+:1068500001E6C82B0082C021031970213C01080009
65971+:10686000AC2F00743C010800AC2E0070AF49014809
65972+:106870003C0D08008DAD3D94A7480144240900401B
65973+:10688000A74A01463C081000240AFF91AF4D014C75
65974+:10689000A34A0152AF490154A740015803E0000840
65975+:1068A000AF4801788F490E1897460E1297450E1083
65976+:1068B00030CAFFFF0A000E5D30A8FFFF8F8300245F
65977+:1068C00027BDFFF89064000D308200201040003A90
65978+:1068D00000000000240B000100004821240A0001F0
65979+:1068E0003C088000350700708CE30000AF83003067
65980+:1068F0008F4C01780580FFFE3C0E80003C040800B0
65981+:1069000090843DD035C700708CEC00003C05080039
65982+:106910008CA50074A3A400033C1908008F390070F3
65983+:106920008FAD00000183302300A638210000102124
65984+:106930000322782100E6C02B01F8602101AE40253A
65985+:10694000AFA800003C010800AC2700743C0108001F
65986+:10695000AC2C00709346010A3C04080090843DD1A1
65987+:10696000A3A00002A3A600018FA300003C0580FFA6
65988+:106970003099007F34A2FFFF006278240019C6001E
65989+:1069800001F87025240D3000AF4E014C27BD0008E2
65990+:10699000AF4D0154A7400158AF4B0148A7490144EE
65991+:1069A000A74A01463C091000240AFF80A34A01526D
65992+:1069B00003E00008AF4901788F4B0E1897460E127E
65993+:1069C00097450E1030CAFFFF0A000E9130A9FFFF55
65994+:1069D0008F85001C2402008090A40085308300C0B5
65995+:1069E000106200058F8600208F8800088F87000CBA
65996+:1069F000ACC800C8ACC700C403E000080000000039
65997+:106A00003C0A0800254A39543C09080025293A2047
65998+:106A10003C08080025082DD43C07080024E73B3437
65999+:106A20003C06080024C637C43C05080024A5353CB4
66000+:106A30003C040800248431643C0308002463385C6F
66001+:106A40003C020800244236303C010800AC2A3D508C
66002+:106A50003C010800AC293D4C3C010800AC283D48F5
66003+:106A60003C010800AC273D543C010800AC263D64C5
66004+:106A70003C010800AC253D5C3C010800AC243D58BD
66005+:106A80003C010800AC233D683C010800AC223D609D
66006+:086A900003E000080000000013
66007+:00000001FF
66008diff --git a/firmware/bnx2/bnx2-mips-09-6.2.1b.fw.ihex b/firmware/bnx2/bnx2-mips-09-6.2.1b.fw.ihex
66009new file mode 100644
66010index 0000000..43d7c4f
66011--- /dev/null
66012+++ b/firmware/bnx2/bnx2-mips-09-6.2.1b.fw.ihex
66013@@ -0,0 +1,6496 @@
66014+:10000000080001180800000000005594000000C816
66015+:1000100000000000000000000000000008005594EF
66016+:10002000000000380000565C080000A00800000036
66017+:100030000000574400005694080059200000008436
66018+:100040000000ADD808005744000001C00000AE5CBD
66019+:100050000800321008000000000092580000B01C98
66020+:10006000000000000000000000000000080092589E
66021+:100070000000033C000142740800049008000400E2
66022+:10008000000012FC000145B000000000000000006C
66023+:1000900000000000080016FC00000004000158AC3D
66024+:1000A000080000A80800000000003D00000158B052
66025+:1000B00000000000000000000000000008003D00FB
66026+:1000C00000000030000195B00A000046000000006A
66027+:1000D000000000000000000D636F6D362E322E31DF
66028+:1000E00062000000060201020000000000000003A0
66029+:1000F000000000C800000032000000030000000003
66030+:1001000000000000000000000000000000000000EF
66031+:1001100000000010000001360000EA600000000549
66032+:1001200000000000000000000000000000000008C7
66033+:1001300000000000000000000000000000000000BF
66034+:1001400000000000000000000000000000000000AF
66035+:10015000000000000000000000000000000000009F
66036+:10016000000000020000000000000000000000008D
66037+:10017000000000000000000000000000000000007F
66038+:10018000000000000000000000000010000000005F
66039+:10019000000000000000000000000000000000005F
66040+:1001A000000000000000000000000000000000004F
66041+:1001B000000000000000000000000000000000003F
66042+:1001C000000000000000000000000000000000002F
66043+:1001D000000000000000000000000000000000001F
66044+:1001E0000000000010000003000000000000000DEF
66045+:1001F0000000000D3C020800244256083C030800A1
66046+:1002000024635754AC4000000043202B1480FFFDB2
66047+:10021000244200043C1D080037BD9FFC03A0F021D0
66048+:100220003C100800261001183C1C0800279C5608AA
66049+:100230000E000256000000000000000D27BDFFB4B4
66050+:10024000AFA10000AFA20004AFA30008AFA4000C50
66051+:10025000AFA50010AFA60014AFA70018AFA8001CF0
66052+:10026000AFA90020AFAA0024AFAB0028AFAC002C90
66053+:10027000AFAD0030AFAE0034AFAF0038AFB8003C28
66054+:10028000AFB90040AFBC0044AFBF00480E001544FA
66055+:10029000000000008FBF00488FBC00448FB90040B1
66056+:1002A0008FB8003C8FAF00388FAE00348FAD003078
66057+:1002B0008FAC002C8FAB00288FAA00248FA90020C0
66058+:1002C0008FA8001C8FA700188FA600148FA5001000
66059+:1002D0008FA4000C8FA300088FA200048FA1000040
66060+:1002E00027BD004C3C1B60108F7A5030377B502864
66061+:1002F00003400008AF7A00008F82002427BDFFE092
66062+:10030000AFB00010AFBF0018AFB100148C42000CAA
66063+:100310003C1080008E110100104000348FBF001887
66064+:100320000E000D84000000008F85002024047FFF54
66065+:100330000091202BACB100008E030104960201084D
66066+:1003400000031C003042FFFF00621825ACA300042C
66067+:100350009202010A96030114304200FF3063FFFF4E
66068+:100360000002140000431025ACA200089603010C03
66069+:100370009602010E00031C003042FFFF00621825A8
66070+:10038000ACA3000C960301109602011200031C009E
66071+:100390003042FFFF00621825ACA300108E02011846
66072+:1003A000ACA200148E02011CACA20018148000083C
66073+:1003B0008F820024978200003C0420050044182509
66074+:1003C00024420001ACA3001C0A0000C6A782000062
66075+:1003D0003C0340189442001E00431025ACA2001CB0
66076+:1003E0000E000DB8240400018FBF00188FB1001457
66077+:1003F0008FB000100000102103E0000827BD00208E
66078+:100400003C0780008CE202B834E50100044100089A
66079+:10041000240300013C0208008C42006024420001D9
66080+:100420003C010800AC22006003E0000800601021DD
66081+:100430003C0208008C42005C8CA4002094A30016AF
66082+:100440008CA6000494A5000E24420001ACE40280B6
66083+:100450002463FFFC3C010800AC22005C3C0210005D
66084+:10046000A4E30284A4E5028600001821ACE6028819
66085+:10047000ACE202B803E000080060102127BDFFE0F5
66086+:100480003C028000AFB0001034420100AFBF001C3E
66087+:10049000AFB20018AFB100148C43000094450008BF
66088+:1004A0002462FE002C42038110400003000381C23D
66089+:1004B0000A00010226100004240201001462000553
66090+:1004C0003C1180003C02800890420004305000FF44
66091+:1004D0003C11800036320100964300143202000FB6
66092+:1004E00000021500004310253C0308008C63004403
66093+:1004F00030A40004AE220080246300013C01080007
66094+:10050000AC2300441080000730A200028FBF001C03
66095+:100510008FB200188FB100148FB000100A0000CE07
66096+:1005200027BD00201040002D0000182130A20080BF
66097+:1005300010400005362200708E44001C0E000C672F
66098+:10054000240500A0362200708C4400008F82000C2D
66099+:10055000008210232C43012C10600004AF82001095
66100+:10056000240300010A000145AF84000C8E42000400
66101+:100570003C036020AF84000CAC6200143C02080015
66102+:100580008C42005850400015000018218C62000475
66103+:10059000240301FE304203FF144300100000182121
66104+:1005A0002E020004104000032E0200080A00014041
66105+:1005B0000000802114400003000000000A000140F8
66106+:1005C0002610FFF90000000D2402000202021004B0
66107+:1005D0003C036000AC626914000018218FBF001C4E
66108+:1005E0008FB200188FB100148FB00010006010217E
66109+:1005F00003E0000827BD00203C0480008C8301003C
66110+:1006000024020100506200033C0280080000000D3B
66111+:100610003C02800890430004000010213063000F6A
66112+:1006200000031D0003E00008AC8300800004188074
66113+:100630002782FF9C00621821000410C00044102390
66114+:100640008C640000000210C03C030800246356E4E0
66115+:10065000004310213C038000AC64009003E00008DC
66116+:10066000AF8200243C0208008C42011410400019A3
66117+:100670003084400030A2007F000231C03C02020002
66118+:100680001080001400A218253C026020AC43001426
66119+:100690003C0408008C8456B83C0308008C630110AD
66120+:1006A0003C02800024050900AC4500200086202182
66121+:1006B000246300013C028008AC4400643C01080053
66122+:1006C000AC2301103C010800AC2456B803E000083C
66123+:1006D000000000003C02602003E00008AC4500146C
66124+:1006E00003E000080000102103E0000800001021D2
66125+:1006F00030A2000810400008240201003C0208005B
66126+:100700008C42010C244200013C010800AC22010C87
66127+:1007100003E0000800000000148200080000000050
66128+:100720003C0208008C4200FC244200013C0108000D
66129+:10073000AC2200FC0A0001A330A200203C02080009
66130+:100740008C420084244200013C010800AC22008459
66131+:1007500030A200201040000830A200103C02080027
66132+:100760008C420108244200013C010800AC2201082F
66133+:1007700003E0000800000000104000080000000036
66134+:100780003C0208008C420104244200013C010800A4
66135+:10079000AC22010403E00008000000003C02080055
66136+:1007A0008C420100244200013C010800AC220100FF
66137+:1007B00003E000080000000027BDFFE0AFB1001417
66138+:1007C0003C118000AFB20018AFBF001CAFB00010EA
66139+:1007D0003632010096500008320200041040000733
66140+:1007E000320300028FBF001C8FB200188FB10014BB
66141+:1007F0008FB000100A0000CE27BD00201060000B53
66142+:10080000020028218E2401000E00018A0000000051
66143+:100810003202008010400003240500A10E000C6786
66144+:100820008E44001C0A0001E3240200018E2301040F
66145+:100830008F82000810430006020028218E24010048
66146+:100840000E00018A000000008E220104AF82000821
66147+:10085000000010218FBF001C8FB200188FB1001450
66148+:100860008FB0001003E0000827BD00202C82000498
66149+:1008700014400002000018212483FFFD240200021E
66150+:10088000006210043C03600003E00008AC626914DD
66151+:1008900027BDFFE0AFBF001CAFB20018AFB100141E
66152+:1008A000AFB000103C048000948201083043700017
66153+:1008B000240220001062000A2862200154400052E5
66154+:1008C0008FBF001C24024000106200482402600018
66155+:1008D0001062004A8FBF001C0A0002518FB200183C
66156+:1008E00034820100904300098C5000189451000C90
66157+:1008F000240200091062001C0000902128620009F7
66158+:10090000144000218F8200242402000A5062001249
66159+:10091000323100FF2402000B1062000F00000000C3
66160+:100920002402000C146200188F8200243C0208008C
66161+:100930008C4256B824030900AC83002000501021DB
66162+:100940003C038008AC6200643C010800AC2256B84D
66163+:100950000A0002508FBF001C0E0001E900102602A1
66164+:100960000A0002308F8200240E0001E900102602E6
66165+:100970003C0380089462001A8C72000C3042FFFF26
66166+:10098000020280258F8200248C42000C5040001E01
66167+:100990008FBF001C0E000D84000000003C02800090
66168+:1009A00034420100944300088F82002400031C009D
66169+:1009B0009444001E8F82002000641825AC50000073
66170+:1009C00024040001AC510004AC520008AC40000CFF
66171+:1009D000AC400010AC400014AC4000180E000DB844
66172+:1009E000AC43001C0A0002508FBF001C0E000440E4
66173+:1009F000000000000A0002508FBF001C0E000C9F78
66174+:100A0000000000008FBF001C8FB200188FB10014CF
66175+:100A10008FB000100000102103E0000827BD002067
66176+:100A200027BDFFD8AFB400203C036010AFBF002447
66177+:100A3000AFB3001CAFB20018AFB10014AFB00010DC
66178+:100A40008C6450002402FF7F3C1408002694563822
66179+:100A5000008220243484380CAC6450003C028000B6
66180+:100A6000240300370E0014B0AC4300083C07080014
66181+:100A700024E70618028010212404001D2484FFFFAF
66182+:100A8000AC4700000481FFFD244200043C02080042
66183+:100A9000244207C83C010800AC2256403C02080032
66184+:100AA000244202303C030800246306203C04080072
66185+:100AB000248403B43C05080024A506F03C06080085
66186+:100AC00024C62C9C3C010800AC2256803C02080045
66187+:100AD000244205303C010800AC2756843C01080044
66188+:100AE000AC2656943C010800AC23569C3C010800FF
66189+:100AF000AC2456A03C010800AC2556A43C010800DB
66190+:100B0000AC2256A83C010800AC23563C3C0108002E
66191+:100B1000AC2456443C010800AC2056603C0108005F
66192+:100B2000AC2556643C010800AC2056703C0108001E
66193+:100B3000AC27567C3C010800AC2656903C010800CE
66194+:100B4000AC2356980E00056E00000000AF80000C2C
66195+:100B50003C0280008C5300008F8300043C0208009C
66196+:100B60008C420020106200213262000700008821C0
66197+:100B70002792FF9C3C100800261056E43C02080017
66198+:100B80008C42002024050001022518040043202483
66199+:100B90008F820004004310245044000C26310001D1
66200+:100BA00010800008AF9000248E4300003C028000BB
66201+:100BB000AC4300900E000D4BAE05000C0A0002C1C4
66202+:100BC00026310001AE00000C263100012E22000269
66203+:100BD000261000381440FFE9265200043C020800A9
66204+:100BE0008C420020AF820004326200071040FFD91F
66205+:100BF0003C028000326200011040002D326200028F
66206+:100C00003C0580008CA2010000002021ACA2002045
66207+:100C10008CA301042C42078110400008ACA300A85B
66208+:100C200094A2010824032000304270001443000302
66209+:100C30003C02800890420005304400FF0E0001593C
66210+:100C4000000000003C0280009042010B304300FF96
66211+:100C50002C62001E54400004000310800E00018628
66212+:100C60000A0002EC00000000005410218C42000039
66213+:100C70000040F80900000000104000043C02800021
66214+:100C80008C4301043C026020AC4300143C02080089
66215+:100C90008C4200343C0440003C03800024420001AC
66216+:100CA000AC6401383C010800AC220034326200021E
66217+:100CB00010400010326200043C1080008E0201409F
66218+:100CC000000020210E000159AE0200200E00038317
66219+:100CD000000000003C024000AE0201783C02080027
66220+:100CE0008C420038244200013C010800AC2200384C
66221+:100CF000326200041040FF973C0280003C108000EC
66222+:100D00008E020180000020210E000159AE02002059
66223+:100D10008E03018024020F00546200073C02800809
66224+:100D20008E0201883C0300E03042FFFF00431025A3
66225+:100D30000A000328AE020080344200809042000086
66226+:100D400024030050304200FF14430007000000005D
66227+:100D50000E000362000000001440000300000000C9
66228+:100D60000E000971000000003C0208008C42003CAB
66229+:100D70003C0440003C03800024420001AC6401B804
66230+:100D80003C010800AC22003C0A0002A33C028000A7
66231+:100D90003C02900034420001008220253C02800089
66232+:100DA000AC4400203C0380008C6200200440FFFE25
66233+:100DB0000000000003E00008000000003C0280008A
66234+:100DC000344300010083202503E00008AC440020E8
66235+:100DD00027BDFFE0AFB10014AFB000100080882144
66236+:100DE000AFBF00180E00033230B000FF8F83FF94B6
66237+:100DF000022020219062002502028025A07000259B
66238+:100E00008C7000183C0280000E00033D020280241A
66239+:100E10001600000B8FBF00183C0480008C8201F884
66240+:100E20000440FFFE348201C024030002AC510000E4
66241+:100E3000A04300043C021000AC8201F88FBF0018F0
66242+:100E40008FB100148FB0001003E0000827BD002010
66243+:100E500027BDFFE83C028000AFBF00103442018094
66244+:100E6000944300048C4400083063020010600005C5
66245+:100E7000000028210E00100C000000000A0003787A
66246+:100E8000240500013C02FF000480000700821824B2
66247+:100E90003C02040014620004240500018F82FF94C8
66248+:100EA00090420008240500018FBF001000A010210F
66249+:100EB00003E0000827BD00188F82FF982405000179
66250+:100EC000A040001A3C028000344201400A00034264
66251+:100ED0008C4400008F85FF9427BDFFE0AFBF001C4E
66252+:100EE000AFB20018AFB10014AFB0001090A2000074
66253+:100EF000304400FF38830020388200300003182B74
66254+:100F00000002102B0062182410600003240200501D
66255+:100F1000148200A88FBF001C90A20005304200017F
66256+:100F2000104000A48FBF001C3C02800034420140EE
66257+:100F3000904200082443FFFF2C6200051040009EF1
66258+:100F40008FB20018000310803C030800246355ACE6
66259+:100F5000004310218C420000004000080000000007
66260+:100F60003C028000345101400E0003328E24000008
66261+:100F70008F92FF948E2200048E50000C1602000205
66262+:100F800024020001AE42000C0E00033D8E2400003E
66263+:100F90008E220004145000068FBF001C8FB2001870
66264+:100FA0008FB100148FB000100A000F7827BD002009
66265+:100FB0008E42000C0A000419000000003C0480006E
66266+:100FC0003482014094A300108C4200043063FFFF80
66267+:100FD0001443001C0000000024020001A4A2001021
66268+:100FE0008C8202380441000F3C0380003C02003F29
66269+:100FF0003448F0003C0760003C06FFC08CE22BBC8C
66270+:1010000000461824004810240002130200031D8229
66271+:10101000106200583C0280008C8202380440FFF7C6
66272+:101020003C038000346201408C44000034620200C2
66273+:10103000AC4400003C021000AC6202380A00043BE1
66274+:101040008FBF001C94A200100A00041900000000C9
66275+:10105000240200201482000F3C0280003C03800028
66276+:1010600094A20012346301408C6300043042FFFFFD
66277+:10107000146200050000000024020001A4A2001276
66278+:101080000A0004028FBF001C94A200120A00041977
66279+:1010900000000000345101400E0003328E24000095
66280+:1010A0008F92FF948E230004964200123050FFFF6F
66281+:1010B0001603000224020001A64200120E00033DA6
66282+:1010C0008E2400008E220004160200068FBF001C32
66283+:1010D0008FB200188FB100148FB000100A00037C8B
66284+:1010E00027BD0020964200120A00041900000000EB
66285+:1010F0003C03800094A20014346301408C6300041C
66286+:101100003042FFFF14620008240200018FBF001C60
66287+:101110008FB200188FB100148FB00010A4A2001479
66288+:101120000A00146327BD002094A20014144000217B
66289+:101130008FBF001C0A000435000000003C03800043
66290+:1011400094A20016346301408C6300043042FFFF18
66291+:101150001462000D240200018FBF001C8FB2001822
66292+:101160008FB100148FB00010A4A200160A000B1457
66293+:1011700027BD00209442007824420004A4A200105D
66294+:101180000A00043B8FBF001C94A200162403000138
66295+:101190003042FFFF144300078FBF001C3C020800D1
66296+:1011A0008C420070244200013C010800AC22007017
66297+:1011B0008FBF001C8FB200188FB100148FB00010C9
66298+:1011C00003E0000827BD002027BDFFD8AFB20018FC
66299+:1011D0008F92FF94AFB10014AFBF0020AFB3001CDB
66300+:1011E000AFB000103C028000345101008C5001006F
66301+:1011F0009242000092230009304400FF2402001FA5
66302+:10120000106200AB28620020104000192402003850
66303+:101210002862000A1040000D2402000B286200081A
66304+:101220001040002E8F820024046001042862000216
66305+:101230001440002A8F820024240200061062002637
66306+:101240008FBF00200A00055F8FB3001C1062006092
66307+:101250002862000B144000FA8FBF00202402000E09
66308+:10126000106200788F8200240A00055F8FB3001C93
66309+:10127000106200D2286200391040000A2402008067
66310+:1012800024020036106200E528620037104000C3D7
66311+:1012900024020035106200D98FBF00200A00055FCC
66312+:1012A0008FB3001C1062002D2862008110400006E0
66313+:1012B000240200C824020039106200C98FBF002038
66314+:1012C0000A00055F8FB3001C106200A28FBF0020D0
66315+:1012D0000A00055F8FB3001C8F8200248C42000C33
66316+:1012E000104000D78FBF00200E000D8400000000CA
66317+:1012F0003C038000346301008C6200008F85002075
66318+:10130000946700089466000CACA200008C64000492
66319+:101310008F82002400063400ACA400049448001E10
66320+:101320008C62001800073C0000E83825ACA20008D9
66321+:101330008C62001C24040001ACA2000C9062000A24
66322+:1013400000C23025ACA60010ACA00014ACA0001860
66323+:10135000ACA7001C0A00051D8FBF00208F8200244F
66324+:101360008C42000C104000B68FBF00200E000D8490
66325+:10137000000000008F820024962400089625000CAF
66326+:101380009443001E000422029626000E8F82002045
66327+:10139000000426000083202500052C003C0300806B
66328+:1013A00000A6282500832025AC400000AC400004A6
66329+:1013B000AC400008AC40000CAC450010AC40001440
66330+:1013C000AC400018AC44001C0A00051C24040001B9
66331+:1013D0009622000C14400018000000009242000504
66332+:1013E0003042001014400014000000000E000332D0
66333+:1013F0000200202192420005020020213442001008
66334+:101400000E00033DA242000592420000240300208A
66335+:10141000304200FF10430089020020218FBF0020CE
66336+:101420008FB3001C8FB200188FB100148FB0001062
66337+:101430000A00107527BD00280000000D0A00055E97
66338+:101440008FBF00208C42000C1040007D8FBF002019
66339+:101450000E000D84000000008E2200048F84002006
66340+:101460009623000CAC8200003C0280089445002CBE
66341+:101470008F82002400031C0030A5FFFF9446001E4D
66342+:101480003C02400E0065182500C23025AC830004E4
66343+:10149000AC800008AC80000CAC800010AC80001464
66344+:1014A000AC800018AC86001C0A00051C2404000156
66345+:1014B0000E000332020020218F93FF9802002021AA
66346+:1014C0000E00033DA660000C020020210E00034226
66347+:1014D000240500018F8200248C42000C104000582B
66348+:1014E0008FBF00200E000D84000000009622000C2B
66349+:1014F0008F83002000021400AC700000AC62000476
66350+:10150000AC6000088E4400388F820024AC64000C6C
66351+:101510008E46003C9445001E3C02401FAC66001005
66352+:1015200000A228258E62000424040001AC6200148D
66353+:10153000AC600018AC65001C8FBF00208FB3001C8E
66354+:101540008FB200188FB100148FB000100A000DB8D0
66355+:1015500027BD0028240200201082003A8FB3001C0F
66356+:101560000E000F5E00000000104000358FBF00200D
66357+:101570003C0480008C8201F80440FFFE348201C0EC
66358+:1015800024030002AC500000A04300043C02100001
66359+:10159000AC8201F80A00055E8FBF00200200202106
66360+:1015A0008FBF00208FB3001C8FB200188FB10014C2
66361+:1015B0008FB000100A000EA727BD00289625000C4A
66362+:1015C000020020218FBF00208FB3001C8FB20018B3
66363+:1015D0008FB100148FB000100A000ECC27BD002878
66364+:1015E000020020218FB3001C8FB200188FB10014AD
66365+:1015F0008FB000100A000EF727BD00289225000DBD
66366+:10160000020020218FB3001C8FB200188FB100148C
66367+:101610008FB000100A000F4827BD002802002021CB
66368+:101620008FBF00208FB3001C8FB200188FB1001441
66369+:101630008FB000100A000F1F27BD00288FBF0020A9
66370+:101640008FB3001C8FB200188FB100148FB0001040
66371+:1016500003E0000827BD00283C0580008CA202782A
66372+:101660000440FFFE34A2024024030002AC44000008
66373+:10167000A04300043C02100003E00008ACA2027882
66374+:10168000A380001803E00008A38000193C03800039
66375+:101690008C6202780440FFFE8F82001CAC62024024
66376+:1016A00024020002A06202443C02100003E0000891
66377+:1016B000AC6202783C02600003E000088C425404F3
66378+:1016C0009083003024020005008040213063003FF9
66379+:1016D0000000482114620005000050219082004C57
66380+:1016E0009483004E304900FF306AFFFFAD00000CCC
66381+:1016F000AD000010AD000024950200148D05001C03
66382+:101700008D0400183042FFFF004910230002110031
66383+:10171000000237C3004038210086202300A2102B8E
66384+:101720000082202300A72823AD05001CAD0400186B
66385+:10173000A5090014A5090020A50A001603E0000869
66386+:10174000A50A002203E000080000000027BDFFD822
66387+:10175000AFB200183C128008AFB40020AFB3001C39
66388+:10176000AFB10014AFBF0024AFB00010365101007C
66389+:101770003C0260008C4254049222000C3C1408008D
66390+:10178000929400F7304300FF2402000110620032FF
66391+:101790000080982124020002146200353650008037
66392+:1017A0000E00143D000000009202004C2403FF8054
66393+:1017B0003C0480003042007F000211C024420240FD
66394+:1017C0000262102100431824AC8300949245000863
66395+:1017D0009204004C3042007F3C03800614850007D1
66396+:1017E000004380212402FFFFA22200112402FFFFF8
66397+:1017F000A62200120A0005D22402FFFF9602002052
66398+:10180000A222001196020022A62200128E020024BB
66399+:101810003C048008AE2200143485008090A2004C65
66400+:1018200034830100A06200108CA2003CAC6200185E
66401+:101830008C820068AC6200F48C820064AC6200F0C0
66402+:101840008C82006CAC6200F824020001A0A2006847
66403+:101850000A0005EE3C0480080E001456000000004B
66404+:1018600036420080A04000680A0005EE3C04800873
66405+:10187000A2000068A20000690A0006293C02800854
66406+:10188000348300808C62003834850100AC62006CC7
66407+:1018900024020001A062006990A200D59083000894
66408+:1018A000305100FF3072007F12320019001111C058
66409+:1018B00024420240026210212403FF8000431824C6
66410+:1018C0003C048000AC8300943042007F3C038006DF
66411+:1018D000004380218E02000C1040000D02002021E8
66412+:1018E0000E00057E0000000026220001305100FF9E
66413+:1018F0009203003C023410260002102B0002102339
66414+:101900003063007F022288240A0005F8A203003C0D
66415+:101910003C088008350401008C8200E03507008017
66416+:10192000ACE2003C8C8200E0AD02000090E5004C8F
66417+:10193000908600D590E3004C908400D52402FF806F
66418+:1019400000A228243063007F308400FF00A62825F1
66419+:101950000064182A1060000230A500FF38A500803E
66420+:10196000A0E5004CA10500093C0280089043000E50
66421+:10197000344400803C058000A043000A8C8300189A
66422+:101980003C027FFF3442FFFF00621824AC83001842
66423+:101990008CA201F80440FFFE00000000ACB301C0BF
66424+:1019A0008FBF00248FB400208FB3001C8FB20018AB
66425+:1019B0008FB100148FB0001024020002A0A201C455
66426+:1019C00027BD00283C02100003E00008ACA201F88B
66427+:1019D00090A2000024420001A0A200003C030800E5
66428+:1019E0008C6300F4304200FF144300020080302179
66429+:1019F000A0A0000090A200008F84001C000211C073
66430+:101A00002442024024830040008220212402FF80DF
66431+:101A1000008220243063007F3C02800A006218218B
66432+:101A20003C028000AC44002403E00008ACC300008A
66433+:101A300094820006908300058C85000C8C86001033
66434+:101A40008C8700188C88001C8C8400203C010800C6
66435+:101A5000A42256C63C010800A02356C53C0108003C
66436+:101A6000AC2556CC3C010800AC2656D03C01080001
66437+:101A7000AC2756D83C010800AC2856DC3C010800D5
66438+:101A8000AC2456E003E00008000000003C0280089F
66439+:101A9000344201008C4400343C038000346504006F
66440+:101AA000AC6400388C420038AF850028AC62003C42
66441+:101AB0003C020005AC6200300000000000000000A5
66442+:101AC00003E00008000000003C020006308400FF34
66443+:101AD000008220253C028000AC4400300000000061
66444+:101AE00000000000000000003C0380008C62000049
66445+:101AF000304200101040FFFD3462040003E0000893
66446+:101B0000AF82002894C200003C080800950800CA73
66447+:101B100030E7FFFF0080482101021021A4C200002D
66448+:101B200094C200003042FFFF00E2102B544000013D
66449+:101B3000A4C7000094A200003C0308008C6300CC02
66450+:101B400024420001A4A2000094A200003042FFFF42
66451+:101B5000144300073C0280080107102BA4A00000DA
66452+:101B60005440000101003821A4C700003C02800855
66453+:101B7000344601008CC3002894A200003C0480007D
66454+:101B80003042FFFE000210C000621021AC82003C17
66455+:101B90008C82003C006218231860000400000000E2
66456+:101BA0008CC200240A0006BA244200018CC2002420
66457+:101BB000AC8200383C020050344200103C038000EC
66458+:101BC000AC620030000000000000000000000000D7
66459+:101BD0008C620000304200201040FFFD0000000039
66460+:101BE00094A200003C04800030420001000210C0BA
66461+:101BF000004410218C430400AD2300008C420404F7
66462+:101C0000AD2200043C02002003E00008AC8200305A
66463+:101C100027BDFFE0AFB20018AFB10014AFB00010A5
66464+:101C2000AFBF001C94C2000000C080213C1208001D
66465+:101C3000965200C624420001A6020000960300004E
66466+:101C400094E2000000E03021144300058FB1003021
66467+:101C50000E00068F024038210A0006F10000000045
66468+:101C60008C8300048C82000424420040046100073D
66469+:101C7000AC8200048C8200040440000400000000D8
66470+:101C80008C82000024420001AC8200009602000019
66471+:101C90003042FFFF50520001A600000096220000D3
66472+:101CA00024420001A62200003C02800834420100C8
66473+:101CB000962300009442003C144300048FBF001C94
66474+:101CC00024020001A62200008FBF001C8FB2001862
66475+:101CD0008FB100148FB0001003E0000827BD002072
66476+:101CE00027BDFFE03C028008AFBF0018344201006E
66477+:101CF0008C4800343C03800034690400AC68003830
66478+:101D00008C42003830E700FFAF890028AC62003C0D
66479+:101D10003C020005AC620030000000000000000042
66480+:101D200000000000000000000000000000000000B3
66481+:101D30008C82000C8C82000C97830016AD22000070
66482+:101D40008C82001000604021AD2200048C820018BB
66483+:101D5000AD2200088C82001CAD22000C8CA2001465
66484+:101D6000AD2200108C820020AD220014908200056C
66485+:101D7000304200FF00021200AD2200188CA20018B1
66486+:101D8000AD22001C8CA2000CAD2200208CA2001001
66487+:101D9000AD2200248CA2001CAD2200288CA20020C1
66488+:101DA000AD22002C3402FFFFAD260030AD20003400
66489+:101DB000506200013408FFFFAD28003850E00011E8
66490+:101DC0003C0280083C048008348401009482005066
66491+:101DD0003042FFFFAD22003C9483004494850044D0
66492+:101DE000240200013063FFFF000318C200641821C1
66493+:101DF0009064006430A5000700A210040A00075C8C
66494+:101E00000044102534420100AD20003C94430044BE
66495+:101E1000944400443063FFFF000318C2006218219D
66496+:101E200030840007906500642402000100821004E1
66497+:101E30000002102700451024A0620064000000008A
66498+:101E400000000000000000003C0200063442004098
66499+:101E50003C038000AC620030000000000000000085
66500+:101E6000000000008C620000304200101040FFFDB6
66501+:101E70003C06800834C201503463040034C7014A70
66502+:101E800034C4013434C5014034C60144AFA200104B
66503+:101E90000E0006D2AF8300288FBF001803E00008B1
66504+:101EA00027BD00208F8300143C0608008CC600E884
66505+:101EB0008F82001C30633FFF000319800046102111
66506+:101EC000004310212403FF80004318243C068000B7
66507+:101ED000ACC300283042007F3C03800C004330211B
66508+:101EE00090C2000D30A500FF0000382134420010E0
66509+:101EF000A0C2000D8F8900143C028008344201000A
66510+:101F00009443004400091382304800032402000176
66511+:101F1000A4C3000E1102000B2902000210400005AC
66512+:101F2000240200021100000C240300010A0007A48F
66513+:101F30000000182111020006000000000A0007A49A
66514+:101F4000000018218CC2002C0A0007A424430001C1
66515+:101F50008CC20014244300018CC200180043102BD3
66516+:101F60005040000A240700012402002714A20003A5
66517+:101F70003C0380080A0007B1240700013463010014
66518+:101F80009462004C24420001A462004C00091382B8
66519+:101F9000304300032C620002104000090080282119
66520+:101FA000146000040000000094C200340A0007C15D
66521+:101FB0003046FFFF8CC600380A0007C10080282188
66522+:101FC000000030213C040800248456C00A000706A3
66523+:101FD0000000000027BDFF90AFB60068AFB50064F9
66524+:101FE000AFB40060AFB3005CAFB20058AFB1005403
66525+:101FF000AFBF006CAFB000508C9000000080B021EB
66526+:102000003C0208008C4200E8960400328F83001CDA
66527+:102010002414FF8030843FFF0062182100042180D7
66528+:1020200000641821007410243C13800000A090214B
66529+:1020300090A50000AE620028920400323C02800CA1
66530+:102040003063007F00628821308400C02402004099
66531+:10205000148200320000A8218E3500388E2200182C
66532+:102060001440000224020001AE2200189202003C3B
66533+:10207000304200201440000E8F83001C000511C068
66534+:102080002442024000621821306400783C02008043
66535+:102090000082202500741824AE630800AE64081086
66536+:1020A0008E2200188E03000800431021AE22001873
66537+:1020B0008E22002C8E230018244200010062182B6F
66538+:1020C0001060004300000000924200002442000122
66539+:1020D000A24200003C0308008C6300F4304200FF81
66540+:1020E00050430001A2400000924200008F84001C77
66541+:1020F000000211C024420240248300403063007F6C
66542+:10210000008220213C02800A0094202400621821D1
66543+:10211000AE6400240A0008D2AEC30000920300326D
66544+:102120002402FFC000431024304200FF1440000589
66545+:1021300024020001AE220018962200340A00084250
66546+:102140003055FFFF8E22001424420001AE220018F9
66547+:102150009202003000021600000216030441001C27
66548+:10216000000000009602003227A400100080282101
66549+:10217000A7A20016960200320000302124070001B9
66550+:102180003042FFFFAF8200140E000706AFA0001C14
66551+:10219000960200328F83001C3C0408008C8400E807
66552+:1021A00030423FFF000211800064182100621821B4
66553+:1021B00000741024AE62002C3063007F3C02800E5D
66554+:1021C000006218219062000D3042007FA062000D75
66555+:1021D0009222000D304200105040007892420000E0
66556+:1021E0003C028008344401009482004C8EC30000FD
66557+:1021F0003C130800967300C62442FFFFA482004CE3
66558+:10220000946200329623000E3054FFFF3070FFFFBF
66559+:102210003C0308008C6300D000701807A7A30038A7
66560+:102220009482003E3063FFFF3042FFFF14620007DC
66561+:10223000000000008C8200303C038000244200300B
66562+:10224000AC62003C0A00086A8C82002C9482004038
66563+:102250003042FFFF5462000927A400408C820038FE
66564+:102260003C03800024420030AC62003C8C8200348D
66565+:10227000AC6200380A0008793C03800027A50038CA
66566+:1022800027A60048026038210E00068FA7A000484C
66567+:102290008FA300403C02800024630030AC43003830
66568+:1022A0008FA30044AC43003C3C0380003C0200058B
66569+:1022B000AC6200303C028008344401009482004249
66570+:1022C000346304003042FFFF0202102B1440000769
66571+:1022D000AF8300289482004E9483004202021021B2
66572+:1022E000004310230A00088F3043FFFF9483004E01
66573+:1022F00094820042026318210050102300621823C8
66574+:102300003063FFFF3C028008344401009482003CAB
66575+:102310003042FFFF14430003000000000A00089F42
66576+:10232000240300019482003C3042FFFF0062102B26
66577+:10233000144000058F8200289482003C0062102324
66578+:102340003043FFFF8F820028AC550000AC400004F2
66579+:10235000AC540008AC43000C3C02000634420010B0
66580+:102360003C038000AC620030000000000000000070
66581+:10237000000000008C620000304200101040FFFDA1
66582+:102380003C04800834840100001018C20064182145
66583+:102390009065006432020007240600010046100424
66584+:1023A00000451025A0620064948300429622000E2E
66585+:1023B00050430001A386001892420000244200010D
66586+:1023C000A24200003C0308008C6300F4304200FF8E
66587+:1023D00050430001A2400000924200008F84001C84
66588+:1023E000000211C0244202402483004000822021C8
66589+:1023F0002402FF80008220243063007F3C02800A98
66590+:10240000006218213C028000AC440024AEC30000EE
66591+:102410008FBF006C8FB600688FB500648FB400600A
66592+:102420008FB3005C8FB200588FB100548FB0005052
66593+:1024300003E0000827BD007027BDFFD8AFB3001C24
66594+:10244000AFB20018AFB10014AFB00010AFBF0020A2
66595+:102450000080982100E0802130B1FFFF0E000D8444
66596+:1024600030D200FF0000000000000000000000006B
66597+:102470008F8200208F830024AC510000AC520004F6
66598+:10248000AC530008AC40000CAC400010AC40001451
66599+:10249000AC4000189463001E02038025AC50001C61
66600+:1024A0000000000000000000000000002404000103
66601+:1024B0008FBF00208FB3001C8FB200188FB10014A3
66602+:1024C0008FB000100A000DB827BD002830A5FFFF0F
66603+:1024D0000A0008DC30C600FF3C02800834430100DB
66604+:1024E0009462000E3C080800950800C63046FFFFC5
66605+:1024F00014C000043402FFFF946500EA0A000929B1
66606+:102500008F84001C10C20027000000009462004E5F
66607+:102510009464003C3045FFFF00A6102300A6182B52
66608+:102520003087FFFF106000043044FFFF00C5102318
66609+:1025300000E210233044FFFF0088102B1040000EF3
66610+:1025400000E810233C028008344401002403000109
66611+:1025500034420080A44300162402FFFFA482000E30
66612+:10256000948500EA8F84001C0000302130A5FFFF15
66613+:102570000A0009013C0760200044102A10400009AD
66614+:102580003C0280083443008094620016304200010F
66615+:10259000104000043C0280009442007E244200145B
66616+:1025A000A462001603E000080000000027BDFFE061
66617+:1025B0003C028008AFBF001CAFB0001834420100DD
66618+:1025C000944300429442004C104000193068FFFFD1
66619+:1025D0009383001824020001146200298FBF001C9D
66620+:1025E0003C06800834D00100000810C200501021C1
66621+:1025F000904200643103000734C70148304200FFB5
66622+:10260000006210073042000134C9014E34C4012C6D
66623+:1026100034C5013E1040001634C601420E0006D2F9
66624+:10262000AFA90010960200420A0009463048FFFF99
66625+:102630003C028008344401009483004494820042A8
66626+:102640001043000F8FBF001C94820044A4820042FC
66627+:1026500094820050A482004E8C820038AC820030FC
66628+:1026600094820040A482003E9482004AA4820048E2
66629+:102670008FBF001C8FB000180A00090427BD00207E
66630+:102680008FB0001803E0000827BD002027BDFFA081
66631+:10269000AFB1004C3C118000AFBF0058AFB3005445
66632+:1026A000AFB20050AFB000483626018890C2000398
66633+:1026B0003044007FA3A400108E32018090C200003D
66634+:1026C0003043007F240200031062003BAF92001CE5
66635+:1026D00028620004104000062402000424020002C4
66636+:1026E000106200098FBF00580A000B0F8FB300540F
66637+:1026F0001062004D240200051062014E8FBF005889
66638+:102700000A000B0F8FB30054000411C002421021C5
66639+:102710002404FF8024420240004410242643004049
66640+:10272000AE2200243063007F3C02800A0062182140
66641+:102730009062003CAFA3003C00441025A062003C26
66642+:102740008FA3003C9062003C304200401040016C7E
66643+:102750008FBF00583C108008A3800018361001007D
66644+:102760008E0200E08C63003427A4003C27A50010F3
66645+:10277000004310210E0007C3AE0200E093A2001038
66646+:102780003C038000A20200D58C6202780440FFFE68
66647+:102790008F82001CAC62024024020002A06202444C
66648+:1027A0003C021000AC6202780E0009390000000003
66649+:1027B0000A000B0E8FBF00583C05800890C3000133
66650+:1027C00090A2000B1443014E8FBF005834A4008028
66651+:1027D0008C8200189082004C90A200083C0260009D
66652+:1027E0008C4254048C8300183C027FFF3442FFFF6C
66653+:1027F000006218243C0208008C4200B4AC8300182C
66654+:102800003C038000244200013C010800AC2200B4DB
66655+:102810008C6201F80440FFFE8F82001CAC6201C094
66656+:102820000A000AD6240200023C10800890C300016E
66657+:102830009202000B144301328FBF005827A40018E6
66658+:1028400036050110240600033C0260008C4254044B
66659+:102850000E000E470000000027A40028360501F0F6
66660+:102860000E000E47240600038FA200283603010045
66661+:10287000AE0200648FA2002CAE0200688FA200306E
66662+:10288000AE02006C93A40018906300D52402FF8070
66663+:102890000082102400431025304900FF3084007F5F
66664+:1028A0003122007F0082102A544000013929008023
66665+:1028B000000411C0244202402403FF800242102180
66666+:1028C00000431024AE220094264200403042007F94
66667+:1028D0003C038006004340218FA3001C2402FFFF1D
66668+:1028E000AFA800403C130800927300F71062003359
66669+:1028F00093A2001995030014304400FF3063FFFFDA
66670+:102900000064182B106000100000000095040014F3
66671+:102910008D07001C8D0600183084FFFF0044202323
66672+:102920000004210000E438210000102100E4202BE5
66673+:1029300000C2302100C43021AD07001CAD060018D4
66674+:102940000A000A2F93A20019950400148D07001C99
66675+:102950008D0600183084FFFF008220230004210030
66676+:10296000000010210080182100C2302300E4202B39
66677+:1029700000C4302300E33823AD07001CAD06001867
66678+:1029800093A200198FA30040A462001497A2001A1A
66679+:10299000A46200168FA2001CAC6200108FA2001C63
66680+:1029A000AC62000C93A20019A462002097A2001A46
66681+:1029B000A46200228FA2001CAC6200243C048008A8
66682+:1029C000348300808C6200388FA20020012088218F
66683+:1029D000AC62003C8FA20020AC82000093A20018E1
66684+:1029E000A062004C93A20018A0820009A0600068B9
66685+:1029F00093A20018105100512407FF803229007F54
66686+:102A0000000911C024420240024210213046007FDA
66687+:102A10003C03800000471024AC6200943C02800616
66688+:102A200000C2302190C2003CAFA60040000020212F
66689+:102A300000471025A0C2003C8FA80040950200026C
66690+:102A4000950300148D07001C3042FFFF3063FFFF29
66691+:102A50008D060018004310230002110000E2382107
66692+:102A600000E2102B00C4302100C23021AD07001C51
66693+:102A7000AD06001895020002A5020014A50000167C
66694+:102A80008D020008AD0200108D020008AD02000C9E
66695+:102A900095020002A5020020A50000228D02000878
66696+:102AA000AD0200249102003C304200401040001A68
66697+:102AB000262200013C108008A3A90038A38000183A
66698+:102AC000361001008E0200E08D03003427A4004080
66699+:102AD00027A50038004310210E0007C3AE0200E016
66700+:102AE00093A200383C038000A20200D58C620278D9
66701+:102AF0000440FFFE8F82001CAC62024024020002F0
66702+:102B0000A06202443C021000AC6202780E00093957
66703+:102B100000000000262200013043007F14730004EF
66704+:102B2000004020212403FF8002231024004320269C
66705+:102B300093A200180A000A4B309100FF93A40018DA
66706+:102B40008FA3001C2402FFFF1062000A308900FFDF
66707+:102B500024820001248300013042007F14530005C9
66708+:102B6000306900FF2403FF800083102400431026F7
66709+:102B7000304900FF3C028008904200080120882173
66710+:102B8000305000FF123000193222007F000211C0C5
66711+:102B900002421021244202402403FF8000431824F3
66712+:102BA0003C048000AC8300943042007F3C038006EC
66713+:102BB000004310218C43000C004020211060000BCA
66714+:102BC000AFA200400E00057E000000002623000199
66715+:102BD0002405FF803062007F145300020225202468
66716+:102BE000008518260A000AAF307100FF3C048008F7
66717+:102BF000348400808C8300183C027FFF3442FFFF46
66718+:102C000000621824AC8300183C0380008C6201F839
66719+:102C10000440FFFE00000000AC7201C0240200026C
66720+:102C2000A06201C43C021000AC6201F80A000B0E65
66721+:102C30008FBF00583C04800890C300019082000BB5
66722+:102C40001443002F8FBF0058349000809202000878
66723+:102C500030420040104000200000000092020008B6
66724+:102C60000002160000021603044100050240202164
66725+:102C70000E000ECC240500930A000B0E8FBF0058E7
66726+:102C80009202000924030018304200FF1443000D93
66727+:102C900002402021240500390E000E64000030217E
66728+:102CA0000E0003328F84001C8F82FF9424030012D5
66729+:102CB000A04300090E00033D8F84001C0A000B0E88
66730+:102CC0008FBF0058240500360E000E64000030212E
66731+:102CD0000A000B0E8FBF00580E0003320240202165
66732+:102CE000920200058F84001C344200200E00033D38
66733+:102CF000A20200050E0010758F84001C8FBF0058C3
66734+:102D00008FB300548FB200508FB1004C8FB0004889
66735+:102D100003E0000827BD00603C0280083445010044
66736+:102D20003C0280008C42014094A3000E0000302140
66737+:102D300000402021AF82001C3063FFFF3402FFFF00
66738+:102D4000106200063C0760202402FFFFA4A2000ED0
66739+:102D500094A500EA0A00090130A5FFFF03E000087E
66740+:102D60000000000027BDFFC83C0280003C06800830
66741+:102D7000AFB5002CAFB1001CAFBF0030AFB400281E
66742+:102D8000AFB30024AFB20020AFB00018345101003F
66743+:102D900034C501008C4301008E2200148CA400E491
66744+:102DA0000000A821AF83001C0044102318400052EB
66745+:102DB000A38000188E22001400005021ACA200E471
66746+:102DC00090C3000890A200D53073007FA3A200102A
66747+:102DD0008CB200E08CB400E4304200FF1053003BA2
66748+:102DE00093A200108F83001C2407FF80000211C0F3
66749+:102DF0000062102124420240246300400047102456
66750+:102E00003063007F3C0980003C08800A006818217C
66751+:102E1000AD2200248C62003427A4001427A50010E2
66752+:102E2000024280210290102304400028AFA3001426
66753+:102E30009062003C00E21024304200FF1440001970
66754+:102E4000020090219062003C34420040A062003CAD
66755+:102E50008F86001C93A3001024C200403042007FE4
66756+:102E6000004828213C0208008C4200F42463000141
66757+:102E7000306400FF14820002A3A30010A3A000107E
66758+:102E800093A20010AFA50014000211C0244202401A
66759+:102E900000C2102100471024AD2200240A000B4577
66760+:102EA00093A200100E0007C3000000003C0280083F
66761+:102EB00034420100AC5000E093A30010240A00014A
66762+:102EC000A04300D50A000B4593A200102402000184
66763+:102ED000154200093C0380008C6202780440FFFE2A
66764+:102EE0008F82001CAC62024024020002A0620244F5
66765+:102EF0003C021000AC6202789222000B2403000214
66766+:102F0000304200FF144300720000000096220008C7
66767+:102F1000304300FF24020082146200402402008437
66768+:102F20003C028000344901008D22000C95230006EC
66769+:102F3000000216023063FFFF3045003F24020027E5
66770+:102F400010A2000FAF83001428A200281040000830
66771+:102F5000240200312402002110A2000924020025CD
66772+:102F600010A20007938200190A000BBD00000000A8
66773+:102F700010A20007938200190A000BBD0000000098
66774+:102F80000E000777012020210A000C3D0000000000
66775+:102F90003C0380008C6202780440FFFE8F82001C9C
66776+:102FA000AC62024024020002A06202443C02100013
66777+:102FB000AC6202780A000C3D000000009523000678
66778+:102FC000912400058D25000C8D2600108D270018FA
66779+:102FD0008D28001C8D290020244200013C0108009E
66780+:102FE000A42356C63C010800A02456C53C01080095
66781+:102FF000AC2556CC3C010800AC2656D03C0108005C
66782+:10300000AC2756D83C010800AC2856DC3C0108002F
66783+:10301000AC2956E00A000C3DA38200191462000A94
66784+:10302000240200813C02800834420100944500EAF9
66785+:10303000922600058F84001C30A5FFFF30C600FFDC
66786+:103040000A000BFE3C0760211462005C00000000D7
66787+:103050009222000A304300FF306200201040000737
66788+:10306000306200403C02800834420100944500EA8E
66789+:103070008F84001C0A000BFC24060040104000074F
66790+:10308000000316003C02800834420100944500EA27
66791+:103090008F84001C0A000BFC24060041000216036A
66792+:1030A000044100463C02800834420100944500EA95
66793+:1030B0008F84001C2406004230A5FFFF3C076019E6
66794+:1030C0000E000901000000000A000C3D0000000095
66795+:1030D0009222000B24040016304200FF1044000628
66796+:1030E0003C0680009222000B24030017304200FFB0
66797+:1030F000144300320000000034C5010090A2000B10
66798+:10310000304200FF1444000B000080218CA20020FC
66799+:103110008CA400202403FF800043102400021140EF
66800+:103120003084007F004410253C032000004310251C
66801+:10313000ACC2083094A2000800021400000214037C
66802+:10314000044200012410000194A2000830420080D3
66803+:103150005040001A0200A82194A20008304220002A
66804+:10316000504000160200A8218CA300183C021C2D20
66805+:10317000344219ED106200110200A8213C0208003F
66806+:103180008C4200D4104000053C0280082403000457
66807+:1031900034420100A04300FC3C028008344201009C
66808+:1031A000944500EA8F84001C2406000630A5FFFF2A
66809+:1031B0000E0009013C0760210200A8210E00093918
66810+:1031C000000000009222000A304200081040000473
66811+:1031D00002A010210E0013790000000002A01021AF
66812+:1031E0008FBF00308FB5002C8FB400288FB3002420
66813+:1031F0008FB200208FB1001C8FB0001803E00008D0
66814+:1032000027BD00382402FF80008220243C02900069
66815+:1032100034420007008220253C028000AC4400209C
66816+:103220003C0380008C6200200440FFFE0000000090
66817+:1032300003E00008000000003C0380002402FF803F
66818+:10324000008220243462000700822025AC64002024
66819+:103250008C6200200440FFFE0000000003E0000834
66820+:103260000000000027BDFFD8AFB3001CAFB10014B1
66821+:10327000AFB00010AFBF0020AFB200183C1180000B
66822+:103280003C0280088E32002034530100AE2400201E
66823+:10329000966300EA000514003C074000004738250B
66824+:1032A00000A08021000030210E0009013065FFFFE1
66825+:1032B000240200A1160200022402FFFFA2620009FC
66826+:1032C000AE3200208FBF00208FB3001C8FB20018D9
66827+:1032D0008FB100148FB0001003E0000827BD002854
66828+:1032E0003C0280082403000527BDFFE834420100AA
66829+:1032F000A04300FCAFBF00103C0280008C420100E4
66830+:10330000240500A1004020210E000C67AF82001CA4
66831+:103310003C0380008C6202780440FFFE8F82001C18
66832+:103320008FBF001027BD0018AC62024024020002CB
66833+:10333000A06202443C021000AC62027803E0000884
66834+:103340000000000027BDFFE83C068000AFBF001072
66835+:1033500034C7010094E20008304400FF3883008243
66836+:10336000388200842C6300012C4200010062182581
66837+:103370001060002D24020083938200195040003B0E
66838+:103380008FBF00103C020800904256CC8CC4010054
66839+:103390003C06080094C656C63045003F38A30032AC
66840+:1033A00038A2003F2C6300012C4200010062182566
66841+:1033B000AF84001CAF860014A380001914600007BE
66842+:1033C00000E020212402002014A2001200000000CE
66843+:1033D0003402FFFF14C2000F00000000240200208E
66844+:1033E00014A2000500E028218CE300142402FFFF52
66845+:1033F0005062000B8FBF00103C040800248456C0AC
66846+:10340000000030210E000706240700010A000CD638
66847+:103410008FBF00100E000777000000008FBF001064
66848+:103420000A00093927BD001814820004240200850F
66849+:103430008CC501040A000CE1000020211482000662
66850+:103440002482FF808CC50104240440008FBF00103B
66851+:103450000A00016727BD0018304200FF2C4200021D
66852+:1034600010400004240200228FBF00100A000B2726
66853+:1034700027BD0018148200048F8200248FBF001023
66854+:103480000A000C8627BD00188C42000C1040001E5C
66855+:1034900000E0282190E300092402001814620003D0
66856+:1034A000240200160A000CFC240300081462000722
66857+:1034B00024020017240300123C02800834420080DA
66858+:1034C000A04300090A000D0994A7000854620007F0
66859+:1034D00094A700088F82FF942404FFFE9043000508
66860+:1034E00000641824A043000594A7000890A6001BC0
66861+:1034F0008CA4000094A500068FBF001000073C00BC
66862+:103500000A0008DC27BD00188FBF001003E0000888
66863+:1035100027BD00188F8500243C04800094A2002A57
66864+:103520008CA30034000230C02402FFF000C210243B
66865+:1035300000621821AC83003C8CA200303C03800068
66866+:10354000AC8200383C02005034420010AC620030C3
66867+:103550000000000000000000000000008C6200007D
66868+:10356000304200201040FFFD30C20008104000062D
66869+:103570003C0280008C620408ACA200208C62040C27
66870+:103580000A000D34ACA200248C430400ACA300203C
66871+:103590008C420404ACA200243C0300203C028000C6
66872+:1035A000AC4300303C0480008C8200300043102487
66873+:1035B0001440FFFD8F8600243C020040AC820030A6
66874+:1035C00094C3002A94C2002894C4002C94C5002EF1
66875+:1035D00024630001004410213064FFFFA4C20028CE
66876+:1035E00014850002A4C3002AA4C0002A03E0000836
66877+:1035F000000000008F84002427BDFFE83C05800404
66878+:1036000024840010AFBF00100E000E472406000AED
66879+:103610008F840024948200129483002E3042000F85
66880+:10362000244200030043180424027FFF0043102BB0
66881+:1036300010400002AC8300000000000D0E000D13CE
66882+:10364000000000008F8300248FBF001027BD0018EA
66883+:10365000946200149463001A3042000F00021500B7
66884+:10366000006218253C02800003E00008AC4300A083
66885+:103670008F8300243C028004944400069462001A64
66886+:103680008C650000A4640016004410233042FFFF44
66887+:103690000045102B03E00008384200018F8400240D
66888+:1036A0003C0780049486001A8C85000094E2000692
66889+:1036B000A482001694E3000600C310233042FFFFEB
66890+:1036C0000045102B384200011440FFF8A483001677
66891+:1036D00003E00008000000008F8400243C02800406
66892+:1036E000944200069483001A8C850000A482001680
66893+:1036F000006210233042FFFF0045102B38420001CA
66894+:103700005040000D8F850024006030213C0780046C
66895+:1037100094E20006A482001694E3000600C310237E
66896+:103720003042FFFF0045102B384200011440FFF8E3
66897+:10373000A48300168F8500243C03800034620400BB
66898+:103740008CA40020AF820020AC6400388CA200243E
66899+:10375000AC62003C3C020005AC62003003E00008B3
66900+:10376000ACA000048F8400243C0300068C8200047B
66901+:1037700000021140004310253C038000AC62003081
66902+:103780000000000000000000000000008C6200004B
66903+:10379000304200101040FFFD34620400AC80000491
66904+:1037A00003E00008AF8200208F86002427BDFFE0E1
66905+:1037B000AFB10014AFB00010AFBF00188CC300044D
66906+:1037C0008CC500248F820020309000FF94C4001A22
66907+:1037D00024630001244200202484000124A7002047
66908+:1037E000ACC30004AF820020A4C4001AACC70024FC
66909+:1037F00004A100060000882104E2000594C2001A1A
66910+:103800008CC2002024420001ACC2002094C2001AE5
66911+:1038100094C300282E040001004310262C4200010E
66912+:10382000004410245040000594C2001A24020001F4
66913+:10383000ACC2000894C2001A94C300280010202BC8
66914+:10384000004310262C4200010044102514400007BC
66915+:10385000000000008CC20008144000042402001084
66916+:103860008CC300041462000F8F8500240E000DA786
66917+:10387000241100018F820024944300289442001AEE
66918+:1038800014430003000000000E000D1300000000B0
66919+:10389000160000048F8500240E000D840000000037
66920+:1038A0008F85002494A2001E94A4001C24420001D1
66921+:1038B0003043FFFF14640002A4A2001EA4A0001E57
66922+:1038C0001200000A3C02800494A2001494A3001A7F
66923+:1038D0003042000F00021500006218253C028000F3
66924+:1038E000AC4300A00A000E1EACA0000894420006E3
66925+:1038F00094A3001A8CA40000A4A200160062102356
66926+:103900003042FFFF0044102B384200011040000DF0
66927+:1039100002201021006030213C07800494E2000660
66928+:10392000A4A2001694E3000600C310233042FFFF58
66929+:103930000044102B384200011440FFF8A4A30016E5
66930+:10394000022010218FBF00188FB100148FB000101B
66931+:1039500003E0000827BD002003E00008000000008D
66932+:103960008F82002C3C03000600021140004310250A
66933+:103970003C038000AC62003000000000000000004A
66934+:10398000000000008C620000304200101040FFFD7B
66935+:1039900034620400AF82002803E00008AF80002CEE
66936+:1039A00003E000080000102103E000080000000010
66937+:1039B0003084FFFF30A5FFFF0000182110800007B2
66938+:1039C000000000003082000110400002000420428C
66939+:1039D000006518210A000E3D0005284003E000089C
66940+:1039E0000060102110C0000624C6FFFF8CA200005A
66941+:1039F00024A50004AC8200000A000E4724840004C1
66942+:103A000003E000080000000010A0000824A3FFFF4E
66943+:103A1000AC86000000000000000000002402FFFF50
66944+:103A20002463FFFF1462FFFA2484000403E000080B
66945+:103A3000000000003C0280083442008024030001A2
66946+:103A4000AC43000CA4430010A4430012A443001490
66947+:103A500003E00008A44300168F82002427BDFFD88E
66948+:103A6000AFB3001CAFB20018AFB10014AFB000107C
66949+:103A7000AFBF00208C47000C248200802409FF8007
66950+:103A80003C08800E3043007F008080213C0A80008B
66951+:103A9000004920240068182130B100FF30D200FF17
66952+:103AA00010E000290000982126020100AD44002CFE
66953+:103AB000004928243042007F004820219062000005
66954+:103AC00024030050304200FF1443000400000000B3
66955+:103AD000AD45002C948200EA3053FFFF0E000D84A8
66956+:103AE000000000008F8200248F83002000112C0032
66957+:103AF0009442001E001224003484000100A22825F4
66958+:103B00003C02400000A22825AC7000008FBF0020BE
66959+:103B1000AC6000048FB20018AC7300088FB10014C1
66960+:103B2000AC60000C8FB3001CAC6400108FB00010B0
66961+:103B3000AC60001424040001AC60001827BD00280C
66962+:103B40000A000DB8AC65001C8FBF00208FB3001CAD
66963+:103B50008FB200188FB100148FB0001003E000087E
66964+:103B600027BD00283C06800034C201009043000FAE
66965+:103B7000240200101062000E2865001110A000073A
66966+:103B800024020012240200082405003A10620006F4
66967+:103B90000000302103E0000800000000240500358B
66968+:103BA0001462FFFC000030210A000E6400000000D7
66969+:103BB0008CC200748F83FF9424420FA003E000089E
66970+:103BC000AC62000C27BDFFE8AFBF00100E0003423F
66971+:103BD000240500013C0480088FBF0010240200016E
66972+:103BE00034830080A462001227BD00182402000163
66973+:103BF00003E00008A080001A27BDFFE0AFB2001864
66974+:103C0000AFB10014AFB00010AFBF001C30B2FFFF67
66975+:103C10000E000332008088213C028008345000806E
66976+:103C20009202000924030004304200FF1443000CF8
66977+:103C30003C028008124000082402000A0E000E5BBD
66978+:103C400000000000920200052403FFFE0043102440
66979+:103C5000A202000524020012A20200093C02800810
66980+:103C600034420080022020210E00033DA0400027A6
66981+:103C700016400003022020210E000EBF00000000AD
66982+:103C800002202021324600FF8FBF001C8FB2001897
66983+:103C90008FB100148FB00010240500380A000E64A4
66984+:103CA00027BD002027BDFFE0AFBF001CAFB200184A
66985+:103CB000AFB10014AFB000100E00033200808021BD
66986+:103CC0000E000E5B000000003C02800834450080BE
66987+:103CD00090A2000924120018305100FF1232000394
66988+:103CE0000200202124020012A0A2000990A20005D7
66989+:103CF0002403FFFE004310240E00033DA0A2000594
66990+:103D00000200202124050020163200070000302187
66991+:103D10008FBF001C8FB200188FB100148FB000103D
66992+:103D20000A00034227BD00208FBF001C8FB200187D
66993+:103D30008FB100148FB00010240500390A000E6402
66994+:103D400027BD002027BDFFE83C028000AFB0001077
66995+:103D5000AFBF0014344201009442000C2405003629
66996+:103D60000080802114400012304600FF0E00033214
66997+:103D7000000000003C02800834420080240300124E
66998+:103D8000A043000990430005346300100E000E5B51
66999+:103D9000A04300050E00033D020020210200202167
67000+:103DA0000E000342240500200A000F3C0000000022
67001+:103DB0000E000E64000000000E00033202002021FD
67002+:103DC0003C0280089043001B2405FF9F0200202135
67003+:103DD000006518248FBF00148FB00010A043001B93
67004+:103DE0000A00033D27BD001827BDFFE0AFBF001844
67005+:103DF000AFB10014AFB0001030B100FF0E000332BD
67006+:103E0000008080213C02800824030012344200809C
67007+:103E10000E000E5BA04300090E00033D02002021AE
67008+:103E200002002021022030218FBF00188FB1001422
67009+:103E30008FB00010240500350A000E6427BD002055
67010+:103E40003C0480089083000E9082000A1443000B0B
67011+:103E5000000028218F82FF942403005024050001D4
67012+:103E600090420000304200FF1443000400000000B4
67013+:103E70009082000E24420001A082000E03E00008A0
67014+:103E800000A010213C0380008C6201F80440FFFE7A
67015+:103E900024020002AC6401C0A06201C43C02100014
67016+:103EA00003E00008AC6201F827BDFFE0AFB20018E4
67017+:103EB0003C128008AFB10014AFBF001CAFB00010BF
67018+:103EC00036510080922200092403000A304200FF8C
67019+:103ED0001443003E000000008E4300048E22003890
67020+:103EE000506200808FBF001C92220000240300500B
67021+:103EF000304200FF144300253C0280008C42014008
67022+:103F00008E4300043642010002202821AC43001CED
67023+:103F10009622005C8E2300383042FFFF00021040E2
67024+:103F200000621821AE23001C8E4300048E2400384A
67025+:103F30009622005C006418233042FFFF0003184300
67026+:103F4000000210400043102A10400006000000004C
67027+:103F50008E4200048E230038004310230A000FAA6B
67028+:103F6000000220439622005C3042FFFF0002204006
67029+:103F70003C0280083443010034420080ACA4002C91
67030+:103F8000A040002424020001A062000C0E000F5E7D
67031+:103F900000000000104000538FBF001C3C02800056
67032+:103FA0008C4401403C0380008C6201F80440FFFE19
67033+:103FB00024020002AC6401C0A06201C43C021000F3
67034+:103FC000AC6201F80A0010078FBF001C92220009A2
67035+:103FD00024030010304200FF144300043C02800020
67036+:103FE0008C4401400A000FEE0000282192220009B3
67037+:103FF00024030016304200FF14430006240200147C
67038+:10400000A22200093C0280008C4401400A001001F9
67039+:104010008FBF001C8E2200388E23003C00431023EB
67040+:10402000044100308FBF001C92220027244200016F
67041+:10403000A2220027922200272C42000414400016DE
67042+:104040003C1080009222000924030004304200FF4B
67043+:10405000144300093C0280008C4401408FBF001CC7
67044+:104060008FB200188FB100148FB000102405009398
67045+:104070000A000ECC27BD00208C440140240500938B
67046+:104080008FBF001C8FB200188FB100148FB00010CA
67047+:104090000A000F4827BD00208E0401400E000332A5
67048+:1040A000000000008E4200042442FFFFAE420004E4
67049+:1040B0008E22003C2442FFFFAE22003C0E00033D56
67050+:1040C0008E0401408E0401408FBF001C8FB2001887
67051+:1040D0008FB100148FB00010240500040A000342C1
67052+:1040E00027BD00208FB200188FB100148FB00010D0
67053+:1040F00003E0000827BD00203C0680008CC2018838
67054+:104100003C038008346500809063000E00021402B6
67055+:10411000304400FF306300FF1464000E3C0280084E
67056+:1041200090A20026304200FF104400098F82FF94C5
67057+:10413000A0A400262403005090420000304200FF5B
67058+:1041400014430006000000000A0005A18CC4018091
67059+:104150003C02800834420080A044002603E00008AE
67060+:104160000000000027BDFFE030E700FFAFB20018FD
67061+:10417000AFBF001CAFB10014AFB0001000809021A1
67062+:1041800014E0000630C600FF000000000000000D33
67063+:10419000000000000A001060240001163C038008A3
67064+:1041A0009062000E304200FF14460023346200800B
67065+:1041B00090420026304200FF1446001F000000001D
67066+:1041C0009062000F304200FF1446001B0000000008
67067+:1041D0009062000A304200FF144600038F90FF9463
67068+:1041E0000000000D8F90FF948F82FF983C1180009B
67069+:1041F000AE05003CAC450000A066000A0E0003328C
67070+:104200008E240100A20000240E00033D8E24010034
67071+:104210003C0380008C6201F80440FFFE240200028F
67072+:10422000AC7201C0A06201C43C021000AC6201F893
67073+:104230000A0010618FBF001C000000000000000D8C
67074+:10424000000000002400013F8FBF001C8FB2001847
67075+:104250008FB100148FB0001003E0000827BD0020CC
67076+:104260008F83FF943C0280008C44010034420100A3
67077+:104270008C65003C9046001B0A00102724070001B3
67078+:104280003C0280089043000E9042000A0043102632
67079+:10429000304200FF03E000080002102B27BDFFE0C2
67080+:1042A0003C028008AFB10014AFB00010AFBF0018DF
67081+:1042B0003450008092020005240300303042003068
67082+:1042C00014430085008088218F8200248C42000CDA
67083+:1042D000104000828FBF00180E000D840000000007
67084+:1042E0008F860020ACD100009202000892030009E2
67085+:1042F000304200FF00021200306300FF004310252F
67086+:10430000ACC200049202004D000216000002160327
67087+:1043100004410005000000003C0308008C630048D5
67088+:104320000A00109F3C1080089202000830420040B2
67089+:10433000144000030000182192020027304300FFC0
67090+:104340003C108008361100809222004D00031E00B0
67091+:10435000304200FF0002140000621825ACC30008C0
67092+:104360008E2400308F820024ACC4000C8E250034D3
67093+:104370009443001E3C02C00BACC50010006218251F
67094+:104380008E22003800002021ACC200148E22003C96
67095+:10439000ACC200180E000DB8ACC3001C8E020004A5
67096+:1043A0008F8400203C058000AC8200008E2200201B
67097+:1043B000AC8200048E22001CAC8200088E220058C1
67098+:1043C0008CA3007400431021AC82000C8E22002CC0
67099+:1043D000AC8200108E2200408E23004400021400A4
67100+:1043E00000431025AC8200149222004D240300806B
67101+:1043F000304200FF1443000400000000AC800018AD
67102+:104400000A0010E38F8200248E23000C2402000196
67103+:104410001062000E2402FFFF92220008304200408A
67104+:104420001440000A2402FFFF8E23000C8CA20074AB
67105+:10443000006218233C0208000062102414400002AD
67106+:10444000000028210060282100051043AC820018DC
67107+:104450008F820024000020219443001E3C02C00CE7
67108+:10446000006218258F8200200E000DB8AC43001C9E
67109+:104470003C038008346201008C4200008F850020DC
67110+:10448000346300808FBF0018ACA20000ACA0000411
67111+:104490008C6400488F8200248FB10014ACA4000803
67112+:1044A000ACA0000CACA00010906300059446001E68
67113+:1044B0003C02400D00031E0000C23025ACA30014D6
67114+:1044C0008FB00010ACA0001824040001ACA6001CA2
67115+:1044D0000A000DB827BD00208FBF00188FB100144F
67116+:1044E0008FB0001003E0000827BD00203C028000D0
67117+:1044F0009443007C3C02800834460100308400FF75
67118+:104500003065FFFF2402000524A34650A0C4000C20
67119+:104510005482000C3065FFFF90C2000D2C42000752
67120+:104520001040000724A30A0090C3000D24020014C9
67121+:104530000062100400A210210A00111F3045FFFF85
67122+:104540003065FFFF3C0280083442008003E0000831
67123+:10455000A44500143C03800834680080AD05003891
67124+:10456000346701008CE2001C308400FF00A210239D
67125+:104570001840000330C600FF24A2FFFCACE2001C80
67126+:1045800030820001504000083C0380088D02003C4E
67127+:1045900000A2102304410012240400058C620004D0
67128+:1045A00010A2000F3C0380088C62000414A2001EBD
67129+:1045B000000000003C0208008C4200D8304200207D
67130+:1045C000104000093C0280083462008090630008BB
67131+:1045D0009042004C144300043C0280082404000470
67132+:1045E0000A00110900000000344300803442010039
67133+:1045F000A040000C24020001A462001410C0000AB4
67134+:104600003C0280008C4401003C0380008C6201F875
67135+:104610000440FFFE24020002AC6401C0A06201C499
67136+:104620003C021000AC6201F803E00008000000004A
67137+:1046300027BDFFE800A61823AFBF00101860008058
67138+:10464000308800FF3C02800834470080A0E000244E
67139+:1046500034440100A0E000278C82001C00A210233B
67140+:1046600004400056000000008CE2003C94E3005C33
67141+:104670008CE4002C004530233063FFFF00C3182179
67142+:104680000083202B1080000400E018218CE2002C15
67143+:104690000A00117800A2102194E2005C3042FFFF72
67144+:1046A00000C2102100A21021AC62001C3C02800854
67145+:1046B000344400809482005C8C83001C3042FFFFF5
67146+:1046C0000002104000A210210043102B10400004F3
67147+:1046D000000000008C82001C0A00118B3C06800840
67148+:1046E0009482005C3042FFFF0002104000A21021C3
67149+:1046F0003C06800834C3010034C70080AC82001C33
67150+:10470000A060000CACE500388C62001C00A21023F5
67151+:104710001840000224A2FFFCAC62001C3102000120
67152+:10472000104000083C0380088CE2003C00A21023EB
67153+:1047300004410012240400058CC2000410A20010E1
67154+:104740008FBF00108C62000414A2004F8FBF0010B6
67155+:104750003C0208008C4200D8304200201040000A81
67156+:104760003C02800834620080906300089042004C54
67157+:10477000144300053C028008240400048FBF00108D
67158+:104780000A00110927BD001834430080344201009B
67159+:10479000A040000C24020001A46200143C0280002E
67160+:1047A0008C4401003C0380008C6201F80440FFFE51
67161+:1047B000240200020A0011D8000000008CE2001C54
67162+:1047C000004610230043102B54400001ACE5001CB0
67163+:1047D00094E2005C3042FFFF0062102B144000079F
67164+:1047E0002402000294E2005C8CE3001C3042FFFFD4
67165+:1047F00000621821ACE3001C24020002ACE5003882
67166+:104800000E000F5EA082000C1040001F8FBF001032
67167+:104810003C0280008C4401003C0380008C6201F863
67168+:104820000440FFFE24020002AC6401C0A06201C487
67169+:104830003C021000AC6201F80A0011F08FBF0010BA
67170+:1048400031020010104000108FBF00103C028008A1
67171+:10485000344500808CA3001C94A2005C00661823E1
67172+:104860003042FFFF006218213C023FFF3444FFFF4B
67173+:104870000083102B544000010080182100C3102138
67174+:10488000ACA2001C8FBF001003E0000827BD001879
67175+:1048900027BDFFE800C0402100A63023AFBF0010B5
67176+:1048A00018C00026308A00FF3C028008344900808E
67177+:1048B0008D24001C8D23002C008820230064182BDD
67178+:1048C0001060000F344701008CE2002000461021E8
67179+:1048D000ACE200208CE200200044102B1440000BBE
67180+:1048E0003C023FFF8CE2002000441023ACE2002099
67181+:1048F0009522005C3042FFFF0A0012100082202146
67182+:10490000ACE00020008620213C023FFF3443FFFF43
67183+:104910000064102B54400001006020213C028008FC
67184+:104920003442008000851821AC43001CA0400024C4
67185+:10493000A04000270A0012623C03800831420010A8
67186+:10494000104000433C0380083C06800834C40080CB
67187+:104950008C82003C004810235840003E34660080A2
67188+:104960009082002424420001A0820024908200242E
67189+:104970003C0308008C630024304200FF0043102BEE
67190+:10498000144000688FBF001034C201008C42001C2C
67191+:1049900000A2102318400063000000008CC3000434
67192+:1049A0009482005C006818233042FFFF0003184324
67193+:1049B000000210400043102A1040000500000000D3
67194+:1049C0008CC20004004810230A0012450002104364
67195+:1049D0009482005C3042FFFF000210403C068008D9
67196+:1049E000AC82002C34C5008094A2005C8CA4002C06
67197+:1049F00094A3005C3042FFFF00021040008220219F
67198+:104A00003063FFFF0083202101041021ACA2001CB1
67199+:104A10008CC2000434C60100ACC2001C2402000297
67200+:104A20000E000F5EA0C2000C1040003E8FBF0010B1
67201+:104A30003C0280008C4401003C0380008C6201F841
67202+:104A40000440FFFE240200020A001292000000004F
67203+:104A500034660080ACC50038346401008C82001CD0
67204+:104A600000A210231840000224A2FFFCAC82001C0C
67205+:104A7000314200015040000A3C0380088CC2003CD7
67206+:104A800000A2102304430014240400058C620004D7
67207+:104A900014A200033C0380080A00128424040005C9
67208+:104AA0008C62000414A2001F8FBF00103C0208009B
67209+:104AB0008C4200D8304200201040000A3C0280089E
67210+:104AC00034620080906300089042004C144300055B
67211+:104AD0003C028008240400048FBF00100A00110962
67212+:104AE00027BD00183443008034420100A040000C70
67213+:104AF00024020001A46200143C0280008C440100E6
67214+:104B00003C0380008C6201F80440FFFE2402000296
67215+:104B1000AC6401C0A06201C43C021000AC6201F8A8
67216+:104B20008FBF001003E0000827BD001827BDFFE875
67217+:104B30003C0A8008AFBF0010354900808D22003C40
67218+:104B400000C04021308400FF004610231840009D23
67219+:104B500030E700FF354701002402000100A63023A2
67220+:104B6000A0E0000CA0E0000DA522001418C0002455
67221+:104B7000308200108D23001C8D22002C0068182329
67222+:104B80000043102B1040000F000000008CE20020BA
67223+:104B900000461021ACE200208CE200200043102BE4
67224+:104BA0001440000B3C023FFF8CE200200043102326
67225+:104BB000ACE200209522005C3042FFFF0A0012C1E7
67226+:104BC00000621821ACE00020006618213C023FFF83
67227+:104BD0003446FFFF00C3102B5440000100C01821D1
67228+:104BE0003C0280083442008000651821AC43001C60
67229+:104BF000A0400024A04000270A00130F3C038008B7
67230+:104C0000104000403C0380088D22003C00481023E7
67231+:104C10005840003D34670080912200242442000166
67232+:104C2000A1220024912200243C0308008C6300246C
67233+:104C3000304200FF0043102B1440009A8FBF001039
67234+:104C40008CE2001C00A21023184000960000000017
67235+:104C50008D4300049522005C006818233042FFFF5A
67236+:104C600000031843000210400043102A10400005C2
67237+:104C7000012020218D420004004810230A0012F276
67238+:104C8000000210439522005C3042FFFF00021040FA
67239+:104C90003C068008AC82002C34C5008094A2005CE5
67240+:104CA0008CA4002C94A3005C3042FFFF0002104053
67241+:104CB000008220213063FFFF0083182101031021AF
67242+:104CC000ACA2001C8CC2000434C60100ACC2001CA3
67243+:104CD000240200020E000F5EA0C2000C1040007102
67244+:104CE0008FBF00103C0280008C4401003C03800018
67245+:104CF0008C6201F80440FFFE240200020A0013390E
67246+:104D00000000000034670080ACE500383466010024
67247+:104D10008CC2001C00A210231840000224A2FFFC39
67248+:104D2000ACC2001C30820001504000083C038008E7
67249+:104D30008CE2003C00A2102304430051240400052F
67250+:104D40008C62000410A2003E3C0380088C620004C8
67251+:104D500054A200548FBF00103C0208008C4200D8BF
67252+:104D600030420020104000063C028008346200807F
67253+:104D7000906300089042004C104300403C028008C1
67254+:104D80003443008034420100A040000C24020001A2
67255+:104D9000A46200143C0280008C4401003C038000AB
67256+:104DA0008C6201F80440FFFE24020002AC6401C0E2
67257+:104DB000A06201C43C021000AC6201F80A00137743
67258+:104DC0008FBF001024020005A120002714E2000A72
67259+:104DD0003C038008354301009062000D2C42000620
67260+:104DE000504000053C0380089062000D2442000101
67261+:104DF000A062000D3C03800834670080ACE50038F9
67262+:104E0000346601008CC2001C00A21023184000026E
67263+:104E100024A2FFFCACC2001C308200015040000AFA
67264+:104E20003C0380088CE2003C00A2102304410014E3
67265+:104E3000240400058C62000414A200033C038008D3
67266+:104E40000A00136E240400058C62000414A20015ED
67267+:104E50008FBF00103C0208008C4200D83042002076
67268+:104E60001040000A3C028008346200809063000811
67269+:104E70009042004C144300053C02800824040004C6
67270+:104E80008FBF00100A00110927BD001834430080AD
67271+:104E900034420100A040000C24020001A46200146E
67272+:104EA0008FBF001003E0000827BD00183C0B8008EE
67273+:104EB00027BDFFE83C028000AFBF00103442010074
67274+:104EC000356A00809044000A356901008C45001461
67275+:104ED0008D4800389123000C308400FF0105102319
67276+:104EE0001C4000B3306700FF2CE20006504000B1C8
67277+:104EF0008FBF00102402000100E2300430C2000322
67278+:104F00005440000800A8302330C2000C144000A117
67279+:104F100030C20030144000A38FBF00100A00143BC1
67280+:104F20000000000018C00024308200108D43001CD7
67281+:104F30008D42002C006818230043102B1040000FF6
67282+:104F4000000000008D22002000461021AD2200202C
67283+:104F50008D2200200043102B1440000B3C023FFF29
67284+:104F60008D22002000431023AD2200209542005CDA
67285+:104F70003042FFFF0A0013AF00621821AD2000206D
67286+:104F8000006618213C023FFF3446FFFF00C3102B90
67287+:104F90005440000100C018213C02800834420080C7
67288+:104FA00000651821AC43001CA0400024A04000274D
67289+:104FB0000A0013FD3C038008104000403C038008B9
67290+:104FC0008D42003C004810231840003D34670080AB
67291+:104FD0009142002424420001A14200249142002475
67292+:104FE0003C0308008C630024304200FF0043102B78
67293+:104FF000144000708FBF00108D22001C00A21023EF
67294+:105000001840006C000000008D6300049542005CB5
67295+:10501000006818233042FFFF0003184300021040CD
67296+:105020000043102A10400005014020218D62000439
67297+:10503000004810230A0013E0000210439542005C70
67298+:105040003042FFFF000210403C068008AC82002C7A
67299+:1050500034C5008094A2005C8CA4002C94A3005C56
67300+:105060003042FFFF00021040008220213063FFFF2A
67301+:105070000083182101031021ACA2001C8CC2000483
67302+:1050800034C60100ACC2001C240200020E000F5EF8
67303+:10509000A0C2000C104000478FBF00103C028000EF
67304+:1050A0008C4401003C0380008C6201F80440FFFE48
67305+:1050B000240200020A00142D000000003467008062
67306+:1050C000ACE50038346601008CC2001C00A210233D
67307+:1050D0001840000224A2FFFCACC2001C3082000178
67308+:1050E0005040000A3C0380088CE2003C00A21023E0
67309+:1050F00004430014240400058C62000414A200037D
67310+:105100003C0380080A00141F240400058C6200047C
67311+:1051100014A200288FBF00103C0208008C4200D867
67312+:10512000304200201040000A3C02800834620080B7
67313+:10513000906300089042004C144300053C02800834
67314+:10514000240400048FBF00100A00110927BD0018B5
67315+:105150003443008034420100A040000C24020001CE
67316+:10516000A46200143C0280008C4401003C038000D7
67317+:105170008C6201F80440FFFE24020002AC6401C00E
67318+:10518000A06201C43C021000AC6201F80A00143BAA
67319+:105190008FBF00108FBF0010010030210A00115A8C
67320+:1051A00027BD0018010030210A00129927BD001800
67321+:1051B0008FBF001003E0000827BD00183C038008E3
67322+:1051C0003464010024020003A082000C8C620004FD
67323+:1051D00003E00008AC82001C3C05800834A300807A
67324+:1051E0009062002734A501002406004324420001F8
67325+:1051F000A0620027906300273C0208008C42004810
67326+:10520000306300FF146200043C07602194A500EAAB
67327+:105210000A00090130A5FFFF03E0000800000000BC
67328+:1052200027BDFFE8AFBF00103C0280000E00144411
67329+:105230008C4401803C02800834430100A060000CD3
67330+:105240008C4200048FBF001027BD001803E0000847
67331+:10525000AC62001C27BDFFE03C028008AFBF001815
67332+:10526000AFB10014AFB000103445008034460100E7
67333+:105270003C0880008D09014090C3000C8CA4003CC8
67334+:105280008CA200381482003B306700FF9502007C3E
67335+:1052900090A30027146000093045FFFF2402000599
67336+:1052A00054E200083C04800890C2000D2442000132
67337+:1052B000A0C2000D0A00147F3C048008A0C0000DAD
67338+:1052C0003C048008348201009042000C2403000555
67339+:1052D000304200FF1443000A24A205DC348300801E
67340+:1052E000906200272C4200075040000524A20A00CB
67341+:1052F00090630027240200140062100400A2102111
67342+:105300003C108008361000803045FFFF012020212E
67343+:105310000E001444A60500149602005C8E030038AB
67344+:105320003C1180003042FFFF000210400062182153
67345+:10533000AE03001C0E0003328E24014092020025B1
67346+:1053400034420040A20200250E00033D8E2401409D
67347+:105350008E2401403C0380008C6201F80440FFFE73
67348+:1053600024020002AC6401C0A06201C43C0210002F
67349+:10537000AC6201F88FBF00188FB100148FB000101D
67350+:1053800003E0000827BD00203C0360103C02080039
67351+:1053900024420174AC62502C8C6250003C048000AA
67352+:1053A00034420080AC6250003C0208002442547C2D
67353+:1053B0003C010800AC2256003C020800244254384C
67354+:1053C0003C010800AC2256043C020002AC840008F8
67355+:1053D000AC82000C03E000082402000100A0302190
67356+:1053E0003C1C0800279C56083C0200023C050400B7
67357+:1053F00000852826008220260004102B2CA5000101
67358+:105400002C840001000210803C0308002463560035
67359+:105410000085202500431821108000030000102182
67360+:10542000AC6600002402000103E000080000000058
67361+:105430003C1C0800279C56083C0200023C05040066
67362+:1054400000852826008220260004102B2CA50001B0
67363+:105450002C840001000210803C03080024635600E5
67364+:105460000085202500431821108000050000102130
67365+:105470003C02080024425438AC62000024020001BF
67366+:1054800003E00008000000003C0200023C030400AE
67367+:1054900000821026008318262C4200012C63000194
67368+:1054A000004310251040000B000028213C1C080080
67369+:1054B000279C56083C0380008C62000824050001EC
67370+:1054C00000431025AC6200088C62000C00441025DB
67371+:1054D000AC62000C03E0000800A010213C1C080096
67372+:1054E000279C56083C0580008CA3000C0004202754
67373+:1054F000240200010064182403E00008ACA3000C9F
67374+:105500003C020002148200063C0560008CA208D018
67375+:105510002403FFFE0043102403E00008ACA208D0DF
67376+:105520003C02040014820005000000008CA208D098
67377+:105530002403FFFD00431024ACA208D003E00008C0
67378+:10554000000000003C02601A344200108C430080CE
67379+:1055500027BDFFF88C440084AFA3000093A3000094
67380+:10556000240200041462001AAFA4000493A20001F4
67381+:105570001040000797A300023062FFFC3C0380004C
67382+:10558000004310218C4200000A001536AFA200042F
67383+:105590003062FFFC3C03800000431021AC4400005B
67384+:1055A000A3A000003C0560008CA208D02403FFFEED
67385+:1055B0003C04601A00431024ACA208D08FA300045E
67386+:1055C0008FA2000034840010AC830084AC82008081
67387+:1055D00003E0000827BD000827BDFFE8AFBF0010AB
67388+:1055E0003C1C0800279C56083C0280008C43000CA1
67389+:1055F0008C420004004318243C0200021060001496
67390+:10560000006228243C0204003C04000210A00005B3
67391+:10561000006210243C0208008C4256000A00155B10
67392+:1056200000000000104000073C0404003C02080099
67393+:105630008C4256040040F809000000000A00156082
67394+:10564000000000000000000D3C1C0800279C5608CC
67395+:105650008FBF001003E0000827BD0018800802403B
67396+:1056600080080100800800808008000000000C8095
67397+:105670000000320008000E9808000EF408000F88A1
67398+:1056800008001028080010748008010080080080BD
67399+:10569000800800000A000028000000000000000050
67400+:1056A0000000000D6370362E322E316200000000C3
67401+:1056B00006020104000000000000000000000000DD
67402+:1056C000000000000000000038003C000000000066
67403+:1056D00000000000000000000000000000000020AA
67404+:1056E00000000000000000000000000000000000BA
67405+:1056F00000000000000000000000000000000000AA
67406+:10570000000000000000000021003800000000013F
67407+:105710000000002B000000000000000400030D400A
67408+:105720000000000000000000000000000000000079
67409+:105730000000000000000000100000030000000056
67410+:105740000000000D0000000D3C020800244259AC8E
67411+:105750003C03080024635BF4AC4000000043202BB2
67412+:105760001480FFFD244200043C1D080037BD9FFC4F
67413+:1057700003A0F0213C100800261000A03C1C0800EB
67414+:10578000279C59AC0E0002F6000000000000000D3E
67415+:1057900027BDFFB4AFA10000AFA20004AFA3000873
67416+:1057A000AFA4000CAFA50010AFA60014AFA700185F
67417+:1057B000AFA8001CAFA90020AFAA0024AFAB0028FF
67418+:1057C000AFAC002CAFAD0030AFAE0034AFAF00389F
67419+:1057D000AFB8003CAFB90040AFBC0044AFBF004819
67420+:1057E0000E000820000000008FBF00488FBC00445E
67421+:1057F0008FB900408FB8003C8FAF00388FAE0034B7
67422+:105800008FAD00308FAC002C8FAB00288FAA002406
67423+:105810008FA900208FA8001C8FA700188FA6001446
67424+:105820008FA500108FA4000C8FA300088FA2000486
67425+:105830008FA1000027BD004C3C1B60188F7A5030B0
67426+:10584000377B502803400008AF7A000000A01821E1
67427+:1058500000801021008028213C0460003C0760008B
67428+:105860002406000810600006348420788C42000072
67429+:10587000ACE220088C63000003E00008ACE3200CDD
67430+:105880000A000F8100000000240300403C02600079
67431+:1058900003E00008AC4320003C0760008F86000452
67432+:1058A0008CE520740086102100A2182B14600007DC
67433+:1058B000000028218F8AFDA024050001A1440013C7
67434+:1058C0008F89000401244021AF88000403E0000810
67435+:1058D00000A010218F84FDA08F8500049086001306
67436+:1058E00030C300FF00A31023AF82000403E00008D0
67437+:1058F000A08000138F84FDA027BDFFE8AFB000108B
67438+:10590000AFBF001490890011908700112402002875
67439+:10591000312800FF3906002830E300FF2485002CE1
67440+:105920002CD00001106200162484001C0E00006EB2
67441+:10593000000000008F8FFDA03C05600024020204DF
67442+:1059400095EE003E95ED003C000E5C0031ACFFFF93
67443+:10595000016C5025ACAA2010520000012402000462
67444+:10596000ACA22000000000000000000000000000C9
67445+:105970008FBF00148FB0001003E0000827BD00188F
67446+:105980000A0000A6000028218F85FDA027BDFFD8B2
67447+:10599000AFBF0020AFB3001CAFB20018AFB100140E
67448+:1059A000AFB000100080982190A4001124B0001C1A
67449+:1059B00024B1002C308300FF386200280E000090D4
67450+:1059C0002C5200010E00009800000000020020216F
67451+:1059D0001240000202202821000028210E00006E43
67452+:1059E000000000008F8DFDA03C0880003C05600099
67453+:1059F00095AC003E95AB003C02683025000C4C0095
67454+:105A0000316AFFFF012A3825ACA7201024020202C8
67455+:105A1000ACA6201452400001240200028FBF0020D7
67456+:105A20008FB3001C8FB200188FB100148FB000101C
67457+:105A300027BD002803E00008ACA2200027BDFFE03E
67458+:105A4000AFB20018AFB10014AFB00010AFBF001C70
67459+:105A50003C1160008E2320748F82000430D0FFFF41
67460+:105A600030F2FFFF1062000C2406008F0E00006E63
67461+:105A7000000000003C06801F0010440034C5FF00F9
67462+:105A80000112382524040002AE2720100000302126
67463+:105A9000AE252014AE2420008FBF001C8FB200184A
67464+:105AA0008FB100148FB0001000C0102103E0000877
67465+:105AB00027BD002027BDFFE0AFB0001030D0FFFFB2
67466+:105AC000AFBF0018AFB100140E00006E30F1FFFF41
67467+:105AD00000102400009180253C036000AC70201071
67468+:105AE0008FBF00188FB100148FB000102402000483
67469+:105AF000AC62200027BD002003E000080000102158
67470+:105B000027BDFFE03C046018AFBF0018AFB1001420
67471+:105B1000AFB000108C8850002403FF7F34028071E6
67472+:105B20000103382434E5380C241F00313C1980006F
67473+:105B3000AC8550003C11800AAC8253BCAF3F0008DA
67474+:105B40000E00054CAF9100400E00050A3C116000AC
67475+:105B50000E00007D000000008E3008083C0F570941
67476+:105B60002418FFF00218602435EEE00035EDF00057
67477+:105B7000018E5026018D58262D4600012D69000109
67478+:105B8000AF86004C0E000D09AF8900503C06601630
67479+:105B90008CC700003C0860148D0500A03C03FFFF8B
67480+:105BA00000E320243C02535300052FC2108200550D
67481+:105BB00034D07C00960201F2A780006C10400003F4
67482+:105BC000A780007C384B1E1EA78B006C960201F844
67483+:105BD000104000048F8D0050384C1E1EA78C007C96
67484+:105BE0008F8D005011A000058F83004C240E0020E3
67485+:105BF000A78E007CA78E006C8F83004C1060000580
67486+:105C00009785007C240F0020A78F007CA78F006C55
67487+:105C10009785007C2CB8008153000001240500808A
67488+:105C20009784006C2C91040152200001240404008C
67489+:105C30001060000B3C0260008FBF00188FB1001491
67490+:105C40008FB0001027BD0020A784006CA785007CC2
67491+:105C5000A380007EA780007403E00008A780009264
67492+:105C60008C4704382419103C30FFFFFF13F9000360
67493+:105C700030A8FFFF1100004624030050A380007EDF
67494+:105C80009386007E50C00024A785007CA780007CFE
67495+:105C90009798007CA780006CA7800074A780009272
67496+:105CA0003C010800AC3800800E00078700000000AF
67497+:105CB0003C0F60008DED0808240EFFF03C0B600ED9
67498+:105CC000260C0388356A00100000482100002821B6
67499+:105CD00001AE20243C105709AF8C0010AF8A004859
67500+:105CE000AF89001810900023AF8500148FBF0018F3
67501+:105CF0008FB100148FB0001027BD002003E0000812
67502+:105D0000AF80005400055080014648218D260004D4
67503+:105D10000A00014800D180219798007CA784006C7C
67504+:105D2000A7800074A78000923C010800AC38008076
67505+:105D30000E000787000000003C0F60008DED080892
67506+:105D4000240EFFF03C0B600E260C0388356A001011
67507+:105D5000000048210000282101AE20243C105709F2
67508+:105D6000AF8C0010AF8A0048AF8900181490FFDF95
67509+:105D7000AF85001424110001AF9100548FBF0018AB
67510+:105D80008FB100148FB0001003E0000827BD002081
67511+:105D90000A00017BA383007E3083FFFF8F880040D1
67512+:105DA0008F87003C000321403C0580003C020050EE
67513+:105DB000008248253C0660003C0A010034AC040027
67514+:105DC0008CCD08E001AA58241160000500000000F5
67515+:105DD0008CCF08E024E7000101EA7025ACCE08E092
67516+:105DE0008D19001001805821ACB900388D180014AD
67517+:105DF000ACB8003CACA9003000000000000000007E
67518+:105E00000000000000000000000000000000000092
67519+:105E100000000000000000003C0380008C640000D3
67520+:105E2000308200201040FFFD3C0F60008DED08E047
67521+:105E30003C0E010001AE18241460FFE100000000D8
67522+:105E4000AF87003C03E00008AF8B00588F8500400F
67523+:105E5000240BFFF03C06800094A7001A8CA90024B4
67524+:105E600030ECFFFF000C38C000EB5024012A402129
67525+:105E7000ACC8003C8CA400248CC3003C00831023DD
67526+:105E800018400033000000008CAD002025A2000166
67527+:105E90003C0F0050ACC2003835EE00103C068000CC
67528+:105EA000ACCE003000000000000000000000000048
67529+:105EB00000000000000000000000000000000000E2
67530+:105EC000000000003C0480008C9900003338002062
67531+:105ED0001300FFFD30E20008104000173C0980006D
67532+:105EE0008C880408ACA800108C83040CACA30014AC
67533+:105EF0003C1900203C188000AF19003094AE001807
67534+:105F000094AF001C01CF3021A4A6001894AD001A54
67535+:105F100025A70001A4A7001A94AB001A94AC001E98
67536+:105F2000118B00030000000003E0000800000000E7
67537+:105F300003E00008A4A0001A8D2A0400ACAA0010F7
67538+:105F40008D240404ACA400140A0002183C1900209B
67539+:105F50008CA200200A0002003C0F00500A0001EE53
67540+:105F60000000000027BDFFE8AFBF00100E000232A6
67541+:105F7000000000008F8900408FBF00103C038000AC
67542+:105F8000A520000A9528000A9527000427BD0018BF
67543+:105F90003105FFFF30E6000F0006150000A22025A6
67544+:105FA00003E00008AC6400803C0508008CA50020DC
67545+:105FB0008F83000C27BDFFE8AFB00010AFBF001407
67546+:105FC00010A300100000802124040001020430040A
67547+:105FD00000A6202400C3102450440006261000010F
67548+:105FE000001018802787FDA41480000A006718217C
67549+:105FF000261000012E0900025520FFF38F83000CAC
67550+:10600000AF85000C8FBF00148FB0001003E00008B4
67551+:1060100027BD00188C6800003C058000ACA8002457
67552+:106020000E000234261000013C0508008CA500205B
67553+:106030000A0002592E0900022405000100851804F7
67554+:106040003C0408008C84002027BDFFC8AFBF00348B
67555+:1060500000831024AFBE0030AFB7002CAFB60028CD
67556+:10606000AFB50024AFB40020AFB3001CAFB200182E
67557+:10607000AFB1001410400051AFB000108F84004049
67558+:10608000948700069488000A00E8302330D5FFFF8B
67559+:1060900012A0004B8FBF0034948B0018948C000A20
67560+:1060A000016C50233142FFFF02A2482B1520000251
67561+:1060B00002A02021004020212C8F000515E00002C5
67562+:1060C00000809821241300040E0001C102602021E9
67563+:1060D0008F87004002609021AF80004494F4000A52
67564+:1060E000026080211260004E3291FFFF3C1670006A
67565+:1060F0003C1440003C1E20003C1760008F99005863
67566+:106100008F380000031618241074004F0283F82BF8
67567+:1061100017E0003600000000107E00478F86004424
67568+:1061200014C0003A2403000102031023022320219B
67569+:106130003050FFFF1600FFF13091FFFF8F870040C6
67570+:106140003C1100203C108000AE11003094EB000A9E
67571+:106150003C178000024B5021A4EA000A94E9000A8F
67572+:1061600094E800043123FFFF3106000F00062D00E4
67573+:106170000065F025AEFE008094F3000A94F6001846
67574+:1061800012D30036001221408CFF00148CF4001052
67575+:1061900003E468210000C02101A4782B029870213B
67576+:1061A00001CF6021ACED0014ACEC001002B238233A
67577+:1061B00030F5FFFF16A0FFB88F8400408FBF00347A
67578+:1061C0008FBE00308FB7002C8FB600288FB500240B
67579+:1061D0008FB400208FB3001C8FB200188FB1001451
67580+:1061E0008FB0001003E0000827BD00381477FFCC03
67581+:1061F0008F8600440E000EE202002021004018218C
67582+:106200008F86004410C0FFC9020310230270702360
67583+:106210008F87004001C368210A0002E431B2FFFF0A
67584+:106220008F86004414C0FFC93C1100203C10800040
67585+:106230000A0002AEAE1100300E00046602002021FA
67586+:106240000A0002DB00401821020020210E0009395B
67587+:10625000022028210A0002DB004018210E0001EE76
67588+:10626000000000000A0002C702B2382327BDFFC8A1
67589+:10627000AFB7002CAFB60028AFB50024AFB40020F4
67590+:10628000AFB3001CAFB20018AFB10014AFB0001034
67591+:10629000AFBF00300E00011B241300013C047FFF40
67592+:1062A0003C0380083C0220003C010800AC20007048
67593+:1062B0003496FFFF34770080345200033C1512C03F
67594+:1062C000241400013C1080002411FF800E000245C0
67595+:1062D000000000008F8700488F8B00188F89001402
67596+:1062E0008CEA00EC8CE800E8014B302B01092823F4
67597+:1062F00000A6102314400006014B18231440000E82
67598+:106300003C05800002A3602B1180000B0000000000
67599+:106310003C0560008CEE00EC8CED00E88CA4180CC1
67600+:10632000AF8E001804800053AF8D00148F8F0010C3
67601+:10633000ADF400003C0580008CBF00003BF900017B
67602+:10634000333800011700FFE13C0380008C6201003C
67603+:1063500024060C0010460009000000008C680100B3
67604+:106360002D043080548000103C0480008C690100B2
67605+:106370002D2331811060000C3C0480008CAA0100A8
67606+:1063800011460004000020218CA6010024C5FF81D5
67607+:1063900030A400FF8E0B01000E000269AE0B00243A
67608+:1063A0000A00034F3C0480008C8D01002DAC3300AB
67609+:1063B00011800022000000003C0708008CE70098D4
67610+:1063C00024EE00013C010800AC2E00983C04800043
67611+:1063D0008C8201001440000300000000566000148D
67612+:1063E0003C0440008C9F01008C9801000000982123
67613+:1063F00003F1C82400193940330F007F00EF7025E6
67614+:1064000001D26825AC8D08308C8C01008C85010090
67615+:10641000258B0100017130240006514030A3007F1C
67616+:106420000143482501324025AC8808303C04400037
67617+:10643000AE0401380A00030E000000008C99010030
67618+:10644000240F0020AC99002092F80000330300FFD5
67619+:10645000106F000C241F0050547FFFDD3C048000AF
67620+:106460008C8401000E00154E000000000A00034F4E
67621+:106470003C04800000963824ACA7180C0A000327BF
67622+:106480008F8F00108C8501000E0008F72404008017
67623+:106490000A00034F3C04800000A4102B24030001D9
67624+:1064A00010400009000030210005284000A4102BF6
67625+:1064B00004A00003000318405440FFFC00052840DE
67626+:1064C0005060000A0004182B0085382B54E00004AB
67627+:1064D0000003184200C33025008520230003184222
67628+:1064E0001460FFF9000528420004182B03E000089F
67629+:1064F00000C310213084FFFF30C600FF3C0780003E
67630+:106500008CE201B80440FFFE00064C000124302557
67631+:106510003C08200000C820253C031000ACE00180AE
67632+:10652000ACE50184ACE4018803E00008ACE301B809
67633+:106530003C0660008CC5201C2402FFF03083020062
67634+:10654000308601001060000E00A2282434A500014E
67635+:106550003087300010E0000530830C0034A50004C3
67636+:106560003C04600003E00008AC85201C1060FFFDC7
67637+:106570003C04600034A5000803E00008AC85201C42
67638+:1065800054C0FFF334A500020A0003B03087300086
67639+:1065900027BDFFE8AFB00010AFBF00143C0760009C
67640+:1065A000240600021080001100A080218F83005873
67641+:1065B0000E0003A78C6400188F8200580000202171
67642+:1065C000240600018C45000C0E000398000000001A
67643+:1065D0001600000224020003000010218FBF0014E7
67644+:1065E0008FB0001003E0000827BD00188CE8201CC5
67645+:1065F0002409FFF001092824ACE5201C8F870058EE
67646+:106600000A0003CD8CE5000C3C02600E00804021A6
67647+:1066100034460100240900180000000000000000BA
67648+:10662000000000003C0A00503C0380003547020097
67649+:10663000AC68003834640400AC65003CAC670030E2
67650+:106640008C6C0000318B00201160FFFD2407FFFFE0
67651+:106650002403007F8C8D00002463FFFF248400044A
67652+:10666000ACCD00001467FFFB24C60004000000004E
67653+:10667000000000000000000024A402000085282B78
67654+:106680003C0300203C0E80002529FFFF010540212E
67655+:10669000ADC300301520FFE00080282103E0000892
67656+:1066A000000000008F82005827BDFFD8AFB3001C48
67657+:1066B000AFBF0020AFB20018AFB10014AFB00010F0
67658+:1066C00094460002008098218C5200182CC300814F
67659+:1066D0008C4800048C4700088C51000C8C49001039
67660+:1066E000106000078C4A00142CC4000414800013AE
67661+:1066F00030EB000730C5000310A0001000000000C0
67662+:106700002410008B02002021022028210E00039873
67663+:10671000240600031660000224020003000010217A
67664+:106720008FBF00208FB3001C8FB200188FB10014F0
67665+:106730008FB0001003E0000827BD00281560FFF1AE
67666+:106740002410008B3C0C80003C030020241F00011F
67667+:10675000AD830030AF9F0044000000000000000047
67668+:10676000000000002419FFF024D8000F031978243A
67669+:106770003C1000D0AD88003801F0702524CD000316
67670+:106780003C08600EAD87003C35850400AD8E0030BE
67671+:10679000000D38823504003C3C0380008C6B000007
67672+:1067A000316200201040FFFD0000000010E00008F2
67673+:1067B00024E3FFFF2407FFFF8CA800002463FFFFF2
67674+:1067C00024A50004AC8800001467FFFB24840004A7
67675+:1067D0003C05600EACA60038000000000000000080
67676+:1067E000000000008F8600543C0400203C0780001D
67677+:1067F000ACE4003054C000060120202102402021DA
67678+:106800000E0003A7000080210A00041D02002021C1
67679+:106810000E0003DD01402821024020210E0003A7C5
67680+:10682000000080210A00041D0200202127BDFFE096
67681+:10683000AFB200183092FFFFAFB10014AFBF001C21
67682+:10684000AFB000101640000D000088210A0004932C
67683+:106850000220102124050003508500278CE5000C40
67684+:106860000000000D262800013111FFFF24E2002066
67685+:106870000232802B12000019AF8200588F82004430
67686+:10688000144000168F8700583C0670003C0320001F
67687+:106890008CE5000000A62024148300108F84006083
67688+:1068A000000544023C09800000A980241480FFE90F
67689+:1068B000310600FF2CCA000B5140FFEB26280001D7
67690+:1068C000000668803C0E080025CE575801AE6021B6
67691+:1068D0008D8B0000016000080000000002201021E4
67692+:1068E0008FBF001C8FB200188FB100148FB0001042
67693+:1068F00003E0000827BD00200E0003982404008454
67694+:106900001600FFD88F8700580A000474AF8000601B
67695+:10691000020028210E0003BF240400018F870058C5
67696+:106920000A000474AF820060020028210E0003BF39
67697+:10693000000020210A0004A38F8700580E000404E1
67698+:10694000020020218F8700580A000474AF82006083
67699+:1069500030AFFFFF000F19C03C0480008C9001B8DD
67700+:106960000600FFFE3C1920043C181000AC83018097
67701+:10697000AC800184AC990188AC9801B80A00047518
67702+:106980002628000190E2000390E30002000020218D
67703+:106990000002FE0000033A0000FF2825240600083C
67704+:1069A0000E000398000000001600FFDC2402000324
67705+:1069B0008F870058000010210A000474AF82006025
67706+:1069C00090E8000200002021240600090A0004C308
67707+:1069D00000082E0090E4000C240900FF308500FF21
67708+:1069E00010A900150000302190F9000290F8000372
67709+:1069F000308F00FF94EB000400196E000018740043
67710+:106A0000000F62000186202501AE5025014B28258C
67711+:106A10003084FF8B0A0004C32406000A90E30002BE
67712+:106A200090FF0004000020210003360000DF28252D
67713+:106A30000A0004C32406000B0A0004D52406008BB8
67714+:106A4000000449C23127003F000443423C02800059
67715+:106A500000082040240316802CE60020AC43002CC4
67716+:106A600024EAFFE02482000114C0000330A900FFE3
67717+:106A700000801021314700FF000260803C0D800043
67718+:106A8000240A0001018D20213C0B000E00EA28049D
67719+:106A9000008B302111200005000538278CCE000026
67720+:106AA00001C5382503E00008ACC700008CD8000001
67721+:106AB0000307782403E00008ACCF000027BDFFE007
67722+:106AC000AFB10014AFB00010AFBF00183C076000BA
67723+:106AD0008CE408083402F0003C1160003083F000C0
67724+:106AE000240501C03C04800E000030211062000625
67725+:106AF000241000018CEA08083149F0003928E00030
67726+:106B00000008382B000780403C0D0200AE2D081411
67727+:106B1000240C16803C0B80008E2744000E000F8B47
67728+:106B2000AD6C002C120000043C02169124050001FB
67729+:106B3000120500103C023D2C345800E0AE384408E9
67730+:106B40003C1108008E31007C8FBF00183C066000AD
67731+:106B500000118540360F16808FB100148FB00010E1
67732+:106B60003C0E020027BD0020ACCF442003E000080B
67733+:106B7000ACCE08103C0218DA345800E0AE384408B5
67734+:106B80003C1108008E31007C8FBF00183C0660006D
67735+:106B900000118540360F16808FB100148FB00010A1
67736+:106BA0003C0E020027BD0020ACCF442003E00008CB
67737+:106BB000ACCE08100A0004EB240500010A0004EB27
67738+:106BC0000000282124020400A7820024A780001CC2
67739+:106BD000000020213C06080024C65A582405FFFF67
67740+:106BE00024890001000440803124FFFF01061821A0
67741+:106BF0002C87002014E0FFFAAC6500002404040098
67742+:106C0000A7840026A780001E000020213C06080063
67743+:106C100024C65AD82405FFFF248D0001000460809B
67744+:106C200031A4FFFF018658212C8A00201540FFFA6D
67745+:106C3000AD650000A7800028A7800020A780002263
67746+:106C4000000020213C06080024C65B582405FFFFF5
67747+:106C5000249900010004C0803324FFFF030678213B
67748+:106C60002C8E000415C0FFFAADE500003C05600065
67749+:106C70008CA73D002403E08F00E31024344601403C
67750+:106C800003E00008ACA63D002487007F000731C266
67751+:106C900024C5FFFF000518C2246400013082FFFFF5
67752+:106CA000000238C0A78400303C010800AC27003047
67753+:106CB000AF80002C0000282100002021000030219E
67754+:106CC0002489000100A728213124FFFF2CA81701E7
67755+:106CD000110000032C8300801460FFF924C600011A
67756+:106CE00000C02821AF86002C10C0001DA786002AF6
67757+:106CF00024CAFFFF000A11423C08080025085B581F
67758+:106D00001040000A00002021004030212407FFFF2E
67759+:106D1000248E00010004688031C4FFFF01A86021B7
67760+:106D20000086582B1560FFFAAD87000030A2001FC7
67761+:106D30005040000800043080240300010043C804D0
67762+:106D400000041080004878212738FFFF03E0000886
67763+:106D5000ADF8000000C820212405FFFFAC8500002D
67764+:106D600003E000080000000030A5FFFF30C6FFFF71
67765+:106D700030A8001F0080602130E700FF0005294295
67766+:106D80000000502110C0001D24090001240B000147
67767+:106D900025180001010B2004330800FF0126782686
67768+:106DA000390E00202DED00012DC2000101A2182591
67769+:106DB0001060000D014450250005C880032C4021BF
67770+:106DC0000100182110E0000F000A20278D040000A8
67771+:106DD000008A1825AD03000024AD00010000402109
67772+:106DE0000000502131A5FFFF252E000131C9FFFF12
67773+:106DF00000C9102B1040FFE72518000103E0000830
67774+:106E0000000000008D0A0000014440240A0005D162
67775+:106E1000AC68000027BDFFE830A5FFFF30C6FFFFCC
67776+:106E2000AFB00010AFBF001430E7FFFF00005021EB
67777+:106E30003410FFFF0000602124AF001F00C0482174
67778+:106E4000241800012419002005E0001601E010219B
67779+:106E50000002F943019F682A0009702B01AE40240B
67780+:106E600011000017000C18800064102110E00005CC
67781+:106E70008C4B000000F840040008382301675824B8
67782+:106E800000003821154000410000402155600016E7
67783+:106E90003169FFFF258B0001316CFFFF05E1FFEC3D
67784+:106EA00001E0102124A2003E0002F943019F682A5C
67785+:106EB0000009702B01AE40241500FFEB000C188078
67786+:106EC000154600053402FFFF020028210E0005B51B
67787+:106ED00000003821020010218FBF00148FB0001075
67788+:106EE00003E0000827BD00181520000301601821E9
67789+:106EF000000B1C0224080010306A00FF154000053A
67790+:106F0000306E000F250D000800031A0231A800FFA3
67791+:106F1000306E000F15C00005307F000325100004FF
67792+:106F200000031902320800FF307F000317E000055C
67793+:106F3000386900012502000200031882304800FF72
67794+:106F4000386900013123000110600004310300FFA3
67795+:106F5000250A0001314800FF310300FF000C6940A1
67796+:106F600001A34021240A000110CAFFD53110FFFF00
67797+:106F7000246E000131C800FF1119FFC638C9000195
67798+:106F80002D1F002053E0001C258B0001240D000163
67799+:106F90000A000648240E002051460017258B0001E8
67800+:106FA00025090001312800FF2D0900205120001281
67801+:106FB000258B000125430001010D5004014B1024D5
67802+:106FC000250900011440FFF4306AFFFF3127FFFF5D
67803+:106FD00010EE000C2582FFFF304CFFFF0000502117
67804+:106FE0003410FFFF312800FF2D0900205520FFF24B
67805+:106FF00025430001258B0001014648260A000602B0
67806+:10700000316CFFFF00003821000050210A000654B7
67807+:107010003410FFFF27BDFFD8AFB0001030F0FFFFE6
67808+:10702000AFB10014001039423211FFE000071080A8
67809+:10703000AFB3001C00B1282330D3FFFFAFB200185C
67810+:1070400030A5FFFF00809021026030210044202104
67811+:10705000AFBF00200E0005E03207001F022288218A
67812+:107060003403FFFF0240202102002821026030216A
67813+:1070700000003821104300093231FFFF02201021A7
67814+:107080008FBF00208FB3001C8FB200188FB1001487
67815+:107090008FB0001003E0000827BD00280E0005E0B7
67816+:1070A0000000000000408821022010218FBF002036
67817+:1070B0008FB3001C8FB200188FB100148FB0001076
67818+:1070C00003E0000827BD0028000424003C03600002
67819+:1070D000AC603D0810A00002348210063482101605
67820+:1070E00003E00008AC623D0427BDFFE0AFB0001034
67821+:1070F000309000FF2E020006AFBF001810400008BD
67822+:10710000AFB10014001030803C03080024635784A2
67823+:1071100000C328218CA400000080000800000000AB
67824+:10712000000020218FBF00188FB100148FB0001015
67825+:107130000080102103E0000827BD00209791002A5D
67826+:1071400016200051000020213C020800904200332C
67827+:107150000A0006BB00000000978D002615A0003134
67828+:10716000000020210A0006BB2402000897870024A3
67829+:1071700014E0001A00001821006020212402000100
67830+:107180001080FFE98FBF0018000429C2004530219C
67831+:1071900000A6582B1160FFE43C0880003C0720004B
67832+:1071A000000569C001A76025AD0C00203C038008E4
67833+:1071B0002402001F2442FFFFAC6000000441FFFDD9
67834+:1071C0002463000424A5000100A6702B15C0FFF560
67835+:1071D000000569C00A0006A58FBF00189787001C2C
67836+:1071E0003C04080024845A58240504000E0006605C
67837+:1071F00024060001978B002424440001308AFFFFFD
67838+:107200002569FFFF2D48040000402821150000409B
67839+:10721000A789002424AC3800000C19C00A0006B964
67840+:10722000A780001C9787001E3C04080024845AD8BD
67841+:10723000240504000E00066024060001979900262C
67842+:10724000244400013098FFFF272FFFFF2F0E04007A
67843+:107250000040882115C0002CA78F0026A780001EA3
67844+:107260003A020003262401003084FFFF0E00068D41
67845+:107270002C4500010011F8C027F00100001021C0CA
67846+:107280000A0006BB240200089785002E978700227B
67847+:107290003C04080024845B580E00066024060001AC
67848+:1072A0009787002A8F89002C2445000130A8FFFF12
67849+:1072B00024E3FFFF0109302B0040802114C0001897
67850+:1072C000A783002AA7800022978500300E000F7543
67851+:1072D00002002021244A05003144FFFF0E00068DE4
67852+:1072E000240500013C05080094A500320E000F752E
67853+:1072F00002002021244521003C0208009042003376
67854+:107300000A0006BB000521C00A0006F3A784001E80
67855+:1073100024AC3800000C19C00A0006B9A784001C70
67856+:107320000A00070DA7850022308400FF27BDFFE873
67857+:107330002C820006AFBF0014AFB000101040001543
67858+:1073400000A03821000440803C0308002463579CBF
67859+:10735000010328218CA40000008000080000000028
67860+:1073600024CC007F000751C2000C59C23170FFFFCE
67861+:107370002547C40030E5FFFF2784001C02003021B0
67862+:107380000E0005B52407000197860028020620217B
67863+:10739000A78400288FBF00148FB0001003E00008FE
67864+:1073A00027BD00183C0508008CA50030000779C2F5
67865+:1073B0000E00038125E4DF003045FFFF3C04080098
67866+:1073C00024845B58240600010E0005B52407000143
67867+:1073D000978E002A8FBF00148FB0001025CD0001BA
67868+:1073E00027BD001803E00008A78D002A0007C9C2C6
67869+:1073F0002738FF00001878C231F0FFFF3C04080076
67870+:1074000024845AD802002821240600010E0005B564
67871+:1074100024070001978D0026260E0100000E84002F
67872+:1074200025AC00013C0B6000A78C0026AD603D0838
67873+:1074300036040006000030213C0760008CE23D0469
67874+:10744000305F000617E0FFFD24C9000100061B00A5
67875+:10745000312600FF006440252CC50004ACE83D0443
67876+:1074600014A0FFF68FBF00148FB0001003E00008D7
67877+:1074700027BD0018000751C22549C8002406000195
67878+:10748000240700013C04080024845A580E0005B566
67879+:107490003125FFFF978700248FBF00148FB00010A5
67880+:1074A00024E6000127BD001803E00008A786002499
67881+:1074B0003C0660183C090800252900FCACC9502C8A
67882+:1074C0008CC850003C0580003C020002350700805B
67883+:1074D000ACC750003C04080024841FE03C030800B3
67884+:1074E00024631F98ACA50008ACA2000C3C01080066
67885+:1074F000AC2459A43C010800AC2359A803E00008BF
67886+:107500002402000100A030213C1C0800279C59AC3B
67887+:107510003C0C04003C0B0002008B3826008C4026FB
67888+:107520002CE200010007502B2D050001000A4880C5
67889+:107530003C030800246359A4004520250123182199
67890+:107540001080000300001021AC660000240200013E
67891+:1075500003E00008000000003C1C0800279C59AC18
67892+:107560003C0B04003C0A0002008A3026008B3826BF
67893+:107570002CC200010006482B2CE5000100094080C8
67894+:107580003C030800246359A4004520250103182169
67895+:1075900010800005000010213C0C0800258C1F986D
67896+:1075A000AC6C00002402000103E0000800000000B1
67897+:1075B0003C0900023C080400008830260089382677
67898+:1075C0002CC30001008028212CE400010083102539
67899+:1075D0001040000B000030213C1C0800279C59ACD7
67900+:1075E0003C0A80008D4E00082406000101CA68256F
67901+:1075F000AD4D00088D4C000C01855825AD4B000C9D
67902+:1076000003E0000800C010213C1C0800279C59AC76
67903+:107610003C0580008CA6000C0004202724020001F9
67904+:1076200000C4182403E00008ACA3000C3C020002D4
67905+:107630001082000B3C0560003C070400108700032B
67906+:107640000000000003E00008000000008CA908D042
67907+:10765000240AFFFD012A402403E00008ACA808D05A
67908+:107660008CA408D02406FFFE0086182403E000083E
67909+:10767000ACA308D03C05601A34A600108CC300806F
67910+:1076800027BDFFF88CC50084AFA3000093A40000C1
67911+:107690002402001010820003AFA5000403E00008DC
67912+:1076A00027BD000893A7000114E0001497AC000266
67913+:1076B00097B800023C0F8000330EFFFC01CF682119
67914+:1076C000ADA50000A3A000003C0660008CC708D058
67915+:1076D0002408FFFE3C04601A00E82824ACC508D04A
67916+:1076E0008FA300048FA200003499001027BD00086A
67917+:1076F000AF22008003E00008AF2300843C0B800031
67918+:10770000318AFFFC014B48218D2800000A00080C3B
67919+:10771000AFA8000427BDFFE8AFBF00103C1C080065
67920+:10772000279C59AC3C0580008CA4000C8CA2000462
67921+:107730003C0300020044282410A0000A00A31824DF
67922+:107740003C0604003C0400021460000900A610245A
67923+:107750001440000F3C0404000000000D3C1C080015
67924+:10776000279C59AC8FBF001003E0000827BD00180C
67925+:107770003C0208008C4259A40040F80900000000B7
67926+:107780003C1C0800279C59AC0A0008358FBF00102C
67927+:107790003C0208008C4259A80040F8090000000093
67928+:1077A0000A00083B000000003C0880008D0201B880
67929+:1077B0000440FFFE35090180AD2400003C031000A9
67930+:1077C00024040040AD250004A1240008A1260009DE
67931+:1077D000A527000A03E00008AD0301B83084FFFFCD
67932+:1077E0000080382130A5FFFF000020210A00084555
67933+:1077F000240600803087FFFF8CA400002406003898
67934+:107800000A000845000028218F8300788F860070C9
67935+:107810001066000B008040213C07080024E75B68ED
67936+:10782000000328C000A710218C440000246300013D
67937+:10783000108800053063000F5466FFFA000328C06B
67938+:1078400003E00008000010213C07080024E75B6CFF
67939+:1078500000A7302103E000088CC200003C03900028
67940+:1078600034620001008220253C038000AC640020CB
67941+:107870008C65002004A0FFFE0000000003E000086B
67942+:10788000000000003C0280003443000100832025FA
67943+:1078900003E00008AC44002027BDFFE0AFB10014B6
67944+:1078A0003091FFFFAFB00010AFBF001812200013DF
67945+:1078B00000A080218CA20000240400022406020003
67946+:1078C0001040000F004028210E0007250000000096
67947+:1078D00000001021AE000000022038218FBF0018E8
67948+:1078E0008FB100148FB0001000402021000028212B
67949+:1078F000000030210A00084527BD00208CA20000AE
67950+:10790000022038218FBF00188FB100148FB00010F3
67951+:107910000040202100002821000030210A000845F5
67952+:1079200027BD002000A010213087FFFF8CA5000498
67953+:107930008C4400000A000845240600068F83FD9C45
67954+:1079400027BDFFE8AFBF0014AFB00010906700087C
67955+:10795000008010210080282130E600400000202116
67956+:1079600010C000088C5000000E0000BD0200202155
67957+:10797000020020218FBF00148FB000100A000548BC
67958+:1079800027BD00180E0008A4000000000E0000BD76
67959+:1079900002002021020020218FBF00148FB00010B0
67960+:1079A0000A00054827BD001827BDFFE0AFB0001052
67961+:1079B0008F90FD9CAFBF001CAFB20018AFB1001498
67962+:1079C00092060001008088210E00087230D2000467
67963+:1079D00092040005001129C2A6050000348300406E
67964+:1079E000A20300050E00087C022020210E00054A9B
67965+:1079F0000220202124020001AE02000C02202821D6
67966+:107A0000A602001024040002A602001224060200AE
67967+:107A1000A60200140E000725A60200161640000F4D
67968+:107A20008FBF001C978C00743C0B08008D6B007896
67969+:107A30002588FFFF3109FFFF256A0001012A382B45
67970+:107A400010E00006A78800743C0F6006240E0016A4
67971+:107A500035ED0010ADAE00508FBF001C8FB2001886
67972+:107A60008FB100148FB0001003E0000827BD002084
67973+:107A700027BDFFE0AFB10014AFBF0018AFB00010DA
67974+:107A80001080000400A088212402008010820007DA
67975+:107A9000000000000000000D8FBF00188FB100141F
67976+:107AA0008FB0001003E0000827BD00200E00087210
67977+:107AB00000A020218F86FD9C0220202190C500057A
67978+:107AC0000E00087C30B000FF2403003E1603FFF1D7
67979+:107AD0003C0680008CC401780480FFFE34C801405D
67980+:107AE000240900073C071000AD11000002202021EE
67981+:107AF000A10900048FBF00188FB100148FB00010CF
67982+:107B0000ACC701780A0008C527BD002027BDFFE0EB
67983+:107B1000AFB00010AFBF0018AFB100143C10800030
67984+:107B20008E110020000000000E00054AAE04002067
67985+:107B3000AE1100208FBF00188FB100148FB000105D
67986+:107B400003E0000827BD00203084FFFF00803821BB
67987+:107B50002406003500A020210A0008450000282145
67988+:107B60003084FFFF008038212406003600A0202149
67989+:107B70000A0008450000282127BDFFD0AFB500242A
67990+:107B80003095FFFFAFB60028AFB40020AFBF002C88
67991+:107B9000AFB3001CAFB20018AFB10014AFB000100B
67992+:107BA00030B6FFFF12A000270000A0218F920058DE
67993+:107BB0008E4300003C0680002402004000033E0289
67994+:107BC00000032C0230E4007F006698241482001D1C
67995+:107BD00030A500FF8F8300682C68000A1100001098
67996+:107BE0008F8D0044000358803C0C0800258C57B84A
67997+:107BF000016C50218D4900000120000800000000A8
67998+:107C000002D4302130C5FFFF0E0008522404008446
67999+:107C1000166000028F920058AF8000688F8D00447C
68000+:107C20002659002026980001032090213314FFFFDD
68001+:107C300015A00004AF9900580295202B1480FFDC9A
68002+:107C400000000000028010218FBF002C8FB600289A
68003+:107C50008FB500248FB400208FB3001C8FB20018A2
68004+:107C60008FB100148FB0001003E0000827BD003072
68005+:107C70002407003414A70149000000009247000EB9
68006+:107C80008F9FFDA08F90FD9C24181600A3E700197C
68007+:107C90009242000D3C0880003C07800CA3E20018D3
68008+:107CA000964A00123C0D60003C117FFFA60A005C62
68009+:107CB000964400103623FFFF240200053099FFFF91
68010+:107CC000AE1900548E46001CAD1800288CEF000041
68011+:107CD0008DAE444801E6482601C93021AE06003881
68012+:107CE0008E05003824CB00013C0E7F00AE05003C21
68013+:107CF0008E0C003CAFEC0004AE0B00208E13002075
68014+:107D0000AE13001CA3E0001BAE03002CA3E2001284
68015+:107D10008E4A001424130050AE0A00348E0400343E
68016+:107D2000AFE400148E590018AE1900489258000CA8
68017+:107D3000A218004E920D000835AF0020A20F0008D7
68018+:107D40008E090018012E282434AC4000AE0C001817
68019+:107D5000920B0000317200FF1253027F2403FF8058
68020+:107D60003C04080024845BE80E0008AA0000000020
68021+:107D70003C1108008E315BE80E00087202202021C1
68022+:107D80002405000424080001A2050025022020216A
68023+:107D90000E00087CA20800053C0580008CB001782C
68024+:107DA0000600FFFE8F92005834AE0140240F0002FF
68025+:107DB0003C091000ADD10000A1CF0004ACA90178AE
68026+:107DC0000A000962AF8000682CAD003751A0FF9413
68027+:107DD0008F8D0044000580803C110800263157E05B
68028+:107DE000021178218DEE000001C0000800000000A3
68029+:107DF0002411000414B1008C3C0780003C080800EA
68030+:107E00008D085BE88F86FD9CACE800208E4500085D
68031+:107E10008F99FDA0240D0050ACC500308E4C000899
68032+:107E2000ACCC00508E4B000CACCB00348E43001019
68033+:107E3000ACC300388E4A0010ACCA00548E42001405
68034+:107E4000ACC2003C8E5F0018AF3F00048E50001C97
68035+:107E5000ACD0002090C40000309800FF130D024AFF
68036+:107E6000000000008CC400348CD00030009030231F
68037+:107E700004C000F12404008C126000EE2402000310
68038+:107E80000A000962AF8200682419000514B900666F
68039+:107E90003C0580003C0808008D085BE88F86FD9C4F
68040+:107EA000ACA800208E4C00048F8AFDA0240720007F
68041+:107EB000ACCC001C924B000824120008A14B001906
68042+:107EC0008F82005890430009A14300188F85005805
68043+:107ED00090BF000A33E400FF1092001028890009C7
68044+:107EE000152000BA240E0002240D0020108D000B76
68045+:107EF000340780002898002117000008240740005C
68046+:107F000024100040109000053C0700012419008057
68047+:107F1000109900023C070002240740008CC20018A0
68048+:107F20003C03FF00004350240147F825ACDF001854
68049+:107F300090B2000BA0D200278F8300589464000CED
68050+:107F4000108001FE000000009467000C3C1F8000C0
68051+:107F50002405FFBFA4C7005C9063000E2407000443
68052+:107F6000A0C300088F820058904A000FA0CA0009E1
68053+:107F70008F8900588D3200108FE400740244C823AA
68054+:107F8000ACD900588D300014ACD0002C95380018B6
68055+:107F9000330DFFFFACCD00409531001A322FFFFFAB
68056+:107FA000ACCF00448D2E001CACCE00489128000EB2
68057+:107FB000A0C8000890CC000801855824126001B6C2
68058+:107FC000A0CB00088F9200580A000962AF870068B2
68059+:107FD0002406000614A600143C0E80003C0F080086
68060+:107FE0008DEF5BE88F85FD98ADCF00208E4900189E
68061+:107FF0008F86FD9C8F8BFDA0ACA900008CC800383B
68062+:1080000024040005ACA800048CCC003C1260008164
68063+:10801000AD6C00000A000962AF84006824110007FB
68064+:1080200010B1004B240400063C05080024A55BE8C1
68065+:108030000E000881240400818F9200580013102B39
68066+:108040000A000962AF820068241F002314BFFFF6F4
68067+:108050003C0C80003C0508008CA55BE88F8BFDA0E4
68068+:10806000AD8500208F91FD9C8E4600042564002084
68069+:1080700026450014AE260028240600030E000F81BA
68070+:10808000257000308F87005802002021240600034D
68071+:108090000E000F8124E500083C04080024845BE8FE
68072+:1080A0000E0008AA0000000092230000240A0050DD
68073+:1080B000306200FF544AFFE18F9200580E000F6CAF
68074+:1080C000000000000A000A6A8F920058240800335A
68075+:1080D00014A800323C0380003C1108008E315BE89C
68076+:1080E0008F8FFDA0AC7100208E420008240D002867
68077+:1080F0008F89FD9CADE200308E4A000C24060009F9
68078+:10810000ADEA00348E5F0010ADFF00388E440014DD
68079+:10811000ADE400208E590018ADF900248E58001CE3
68080+:10812000ADF80028A1ED00118E4E00041260003160
68081+:10813000AD2E00288F9200580A000962AF860068B1
68082+:10814000240D002214ADFFB8000000002404000735
68083+:108150003C1008008E105BE83C188000AF10002037
68084+:108160005660FEAEAF8400683C04080024845BE8DF
68085+:108170000E0008AA241300508F84FD9C90920000EA
68086+:10818000325900FF1333014B000000008F9200585A
68087+:10819000000020210A000962AF8400683C05080045
68088+:1081A00024A55BE80E000858240400810A000A6A2E
68089+:1081B0008F92005802D498213265FFFF0E000852BA
68090+:1081C000240400840A0009628F920058108EFF5325
68091+:1081D000240704002887000310E00179241100041B
68092+:1081E000240F0001548FFF4D240740000A000A228B
68093+:1081F000240701003C05080024A55BE80E0008A444
68094+:10820000240400828F920058000030210A00096285
68095+:10821000AF8600683C04080024845BE88CC2003808
68096+:108220000E0008AA8CC3003C8F9200580A000AC0B6
68097+:1082300000002021240400823C05080024A55BE8FE
68098+:108240000E0008A4000000008F92005800001021CA
68099+:108250000A000962AF8200688E5000048F91FD9C75
68100+:108260003C078000ACF00020922C00050200282181
68101+:10827000318B0002156001562404008A8F92FDA004
68102+:108280002404008D9245001B30A6002014C001502C
68103+:1082900002002821922E00092408001231C900FF93
68104+:1082A0001128014B240400810E00087202002021D5
68105+:1082B0009258001B240F000402002021370D0042B9
68106+:1082C000A24D001B0E00087CA22F00253C0580005B
68107+:1082D0008CA401780480FFFE34B90140241F000201
68108+:1082E000AF300000A33F00048F9200583C101000F4
68109+:1082F000ACB001780A000A6B0013102B8E500004FA
68110+:108300008F91FD9C3C038000AC700020922A0005F8
68111+:108310000200282131420002144000172404008A80
68112+:10832000922C00092412000402002821318B00FF46
68113+:1083300011720011240400810E0008720200202135
68114+:108340008F89FDA0240800122405FFFE912F001B39
68115+:108350000200202135EE0020A12E001BA2280009DA
68116+:108360009226000500C538240E00087CA2270005CF
68117+:1083700002002821000020210E0009330000000027
68118+:108380000A000A6A8F9200588E4C00043C07800055
68119+:108390003C10080026105BE8ACEC00203C01080013
68120+:1083A000AC2C5BE8924B0003317100041220013BBE
68121+:1083B0008F84FD9C24020006A0820009924F001BBE
68122+:1083C000240EFFC031E9003F012E4025A08800089F
68123+:1083D0009245000330A6000114C0013200000000E5
68124+:1083E0008E420008AE0200083C0208008C425BF09E
68125+:1083F000104001318F90FDA0000219C28F8DFD9CAD
68126+:10840000A603000C8E4A000C24180001240400145A
68127+:10841000AE0A002C8E420010AE02001C965F0016C1
68128+:10842000A61F003C96590014A619003EADB8000CDA
68129+:10843000A5B80010A5B80012A5B80014A5B800167C
68130+:1084400012600144A2040011925100033232000272
68131+:108450002E5300018F920058266200080A0009621C
68132+:10846000AF8200688E4400043C1980003C068008FE
68133+:10847000AF2400208E45000890D80000240D005045
68134+:10848000331100FF122D009C2407008824060009E8
68135+:108490000E000845000000000A000A6A8F9200588A
68136+:1084A0008E5000043C0980003C118008AD30002053
68137+:1084B0009228000024050050310400FF10850110AF
68138+:1084C0002407008802002021000028210E00084512
68139+:1084D0002406000E922D00002418FF80020028219F
68140+:1084E00001B8802524040004240600300E0007256E
68141+:1084F000A23000000A000A6A8F9200588E500004D1
68142+:108500008F91FDA03C028000AC500020923F001BE8
68143+:1085100033F900101320006C240700810200202191
68144+:10852000000028212406001F0E000845000000005E
68145+:108530000A000A6A8F9200588E44001C0E00085DE3
68146+:1085400000000000104000E3004048218F880058E0
68147+:1085500024070089012020218D05001C240600012C
68148+:108560000E000845000000000A000A6A8F920058B9
68149+:10857000964900023C10080026105BE831280004F0
68150+:10858000110000973C0460008E4E001C3C0F8000E0
68151+:10859000ADEE00203C010800AC2E5BE896470002DF
68152+:1085A00030E40001148000E6000000008E42000468
68153+:1085B000AE0200083C1008008E105BF0120000ECC8
68154+:1085C0003C0F80008F92FD9C241000018E4E0018FD
68155+:1085D0008F8DFDA08F9FFD9801CF4825AE490018D3
68156+:1085E000A2400005AE50000C3C0808008D085BF06E
68157+:1085F0008F840058A6500010000839C2A6500012FF
68158+:10860000A6500014A6500016A5A7000C8C8C0008DC
68159+:108610008F8B00588F8A0058ADAC002C8D63000CF6
68160+:1086200024070002ADA3001C91460010A1A6001172
68161+:108630008F82005890450011A3E500088F990058DB
68162+:1086400093380012A258004E8F910058922F0013B9
68163+:10865000A1AF00128F920058964E0014A5AE003CB8
68164+:1086600096490016A5A9003E8E480018ADA8001432
68165+:108670005660FD6AAF8700683C05080024A55BE8EA
68166+:108680000E000881000020218F9200580000382140
68167+:108690000A000962AF8700683C05080024A55BE872
68168+:1086A0000E0008A4240400828F9200580A000A4D8C
68169+:1086B000000038210E000F6C000000008F9200585F
68170+:1086C0000A000AC0000020210E00087202002021CA
68171+:1086D0009223001B02002021346A00100E00087C47
68172+:1086E000A22A001B000038210200202100002821BE
68173+:1086F0000A000BA52406001F9242000C305F000107
68174+:1087000013E0000300000000964A000EA4CA002CEB
68175+:10871000924B000C316300025060000600003821CB
68176+:108720008E470014964C0012ACC7001CA4CC001A53
68177+:10873000000038210A000B7F240600093C050800D0
68178+:1087400024A55BE80E0008A42404008B8F92005837
68179+:108750000A000A4D0013382B3C0C08008D8C5BE896
68180+:1087600024DFFFFE25930100326B007F016790211B
68181+:1087700002638824AD110028AE4600E0AE4000E45C
68182+:108780000A0009B3AE5F001CACC000543C0D0800E9
68183+:108790008DAD5BE83C18800C37090100ACED00287A
68184+:1087A0008E510014AD3100E08E4F0014AD2F00E467
68185+:1087B0008E4E001025C7FFFE0A0009F4AD27001CED
68186+:1087C0005491FDD6240740000A000A222407100015
68187+:1087D0000E00092D000000000A000A6A8F9200585E
68188+:1087E0008C83442C3C12DEAD3651BEEF3C010800B8
68189+:1087F000AC205BE810710062000000003C196C6264
68190+:1088000037387970147800082404000297850074C2
68191+:108810009782006C2404009200A2F82B13E0001948
68192+:1088200002002821240400020E00069524050200FF
68193+:108830003C068000ACC200203C010800AC225BE892
68194+:108840001040000D8F8C0058240A002824040003D7
68195+:10885000918B0010316300FF546A00012404000171
68196+:108860000E0000810000000010400004240400837A
68197+:108870000A000BC28F920058240400833C050800B4
68198+:1088800024A55BE80E000881000000008F920058CC
68199+:108890000013382B0A000962AF8700680A000B49F1
68200+:1088A000240200128E4400080E00085D0000000043
68201+:1088B0000A000B55AE0200083C05080024A55BE841
68202+:1088C0000E000858240400878F9200580A000B728B
68203+:1088D0000013102B240400040E000695240500301C
68204+:1088E0001440002A004048218F8800582407008344
68205+:1088F000012020218D05001C0A000BB32406000175
68206+:108900008F8300788F8600701066FEEE000038219D
68207+:108910003C07080024E75B6C000320C00087282187
68208+:108920008CAE000011D0005D246F000131E3000F18
68209+:108930005466FFFA000320C00A000B8C00003821A7
68210+:108940008E4400040E00085D000000000A000BC801
68211+:10895000AE0200083C05080024A55BE80E0008A450
68212+:10896000240400828F9200580A000B72000010212C
68213+:108970003C05080024A55BE80A000C7C2404008761
68214+:108980008C83442C0A000C5B3C196C628F88005865
68215+:108990003C0780083C0C8000240B0050240A000196
68216+:1089A000AD820020A0EB0000A0EA000191030004CA
68217+:1089B000A0E3001891040005A0E400199106000648
68218+:1089C0003C04080024845B6CA0E6001A91020007B6
68219+:1089D0003C06080024C65B68A0E2001B9105000865
68220+:1089E000A0E5001C911F0009A0FF001D9119000ABD
68221+:1089F000A0F9001E9118000BA0F8001F9112000CA6
68222+:108A0000A0F200209111000DA0F100219110000EA4
68223+:108A1000A0F00022910F000FA0EF0023910E001094
68224+:108A2000A0EE0024910D0011A0ED0025950C00147E
68225+:108A3000A4EC0028950B00168F8A00708F920078A6
68226+:108A4000A4EB002A95030018000A10C02545000178
68227+:108A5000A4E3002C8D1F001C0044C0210046C82147
68228+:108A600030A5000FAF3F0000AF09000010B20006B4
68229+:108A7000AF850070000038218D05001C01202021E9
68230+:108A80000A000BB32406000124AD000131A7000F3A
68231+:108A9000AF8700780A000CF9000038213C06080076
68232+:108AA00024C65B680086902100003821ACA000003D
68233+:108AB0000A000B8CAE4000003C0482013C036000C5
68234+:108AC00034820E02AC603D68AF80009803E000087D
68235+:108AD000AC623D6C27BDFFE8AFB000103090FFFFE7
68236+:108AE000001018422C620041AFBF00141440000275
68237+:108AF00024040080240300403C010800AC300060E6
68238+:108B00003C010800AC2300640E000F7500602821B2
68239+:108B1000244802BF2409FF8001092824001039805D
68240+:108B2000001030408FBF00148FB0001000A720212C
68241+:108B300000861821AF8300803C010800AC25005856
68242+:108B40003C010800AC24005C03E0000827BD0018CD
68243+:108B5000308300FF30C6FFFF30E400FF3C08800098
68244+:108B60008D0201B80440FFFE000354000144382583
68245+:108B70003C09600000E920253C031000AD050180A0
68246+:108B8000AD060184AD04018803E00008AD0301B81F
68247+:108B90008F8500583C0A6012354800108CAC0004E8
68248+:108BA0003C0D600E35A60010318B00062D690001CA
68249+:108BB000AD0900C48CA70004ACC731808CA20008AA
68250+:108BC00094A40002ACC231848CA3001C0460000396
68251+:108BD000A784009003E00008000000008CAF00189C
68252+:108BE000ACCF31D08CAE001C03E00008ACCE31D449
68253+:108BF0008F8500588F87FF288F86FF308CAE00044A
68254+:108C00003C0F601235E80010ACEE00788CAD000827
68255+:108C1000ACED007C8CAC0010ACCC004C8CAB000CF0
68256+:108C2000ACCB004894CA00543C0208008C4200447B
68257+:108C300025490001A4C9005494C400543083FFFFA7
68258+:108C400010620017000000003C0208008C42004047
68259+:108C5000A4C200528CA30018ACE300308CA2001414
68260+:108C6000ACE2002C8CB90018ACF900388CB80014B8
68261+:108C700024050001ACF800348D0600BC50C5001975
68262+:108C80008D0200B48D0200B8A4E2004894E40048CC
68263+:108C9000A4E4004A94E800EA03E000083102FFFF80
68264+:108CA0003C0208008C420024A4C00054A4C200521C
68265+:108CB0008CA30018ACE300308CA20014ACE2002CB2
68266+:108CC0008CB90018ACF900388CB8001424050001E8
68267+:108CD000ACF800348D0600BC54C5FFEB8D0200B823
68268+:108CE0008D0200B4A4E2004894E40048A4E4004AE1
68269+:108CF00094E800EA03E000083102FFFF8F86005885
68270+:108D00003C0480008CC900088CC80008000929C0F8
68271+:108D1000000839C0AC87002090C30007306200040F
68272+:108D20001040003EAF85009490CB0007316A0008E8
68273+:108D30001140003D8F87FF2C8CCD000C8CCE001491
68274+:108D400001AE602B11800036000000008CC2000CC8
68275+:108D5000ACE200708CCB00188F85FF288F88FF3025
68276+:108D6000ACEB00748CCA00102402FFF8ACAA00D847
68277+:108D70008CC9000CAD0900608CC4001CACA400D0F0
68278+:108D800090E3007C0062C824A0F9007C90D8000722
68279+:108D9000330F000811E000040000000090ED007C9B
68280+:108DA00035AC0001A0EC007C90CF000731EE000153
68281+:108DB00011C000060000000090E3007C241800347D
68282+:108DC00034790002A0F9007CACB800DC90C2000746
68283+:108DD0003046000210C000040000000090E8007C53
68284+:108DE00035040004A0E4007C90ED007D3C0B600E97
68285+:108DF000356A001031AC003FA0EC007D8D4931D4C4
68286+:108E00003127000110E00002240E0001A0AE00098D
68287+:108E100094AF00EA03E0000831E2FFFF8F87FF2CE8
68288+:108E20000A000DAF8CC200140A000DB0ACE0007057
68289+:108E30008F8C005827BDFFD8AFB3001CAFB200180D
68290+:108E4000AFB00010AFBF0020AFB10014918F00157C
68291+:108E50003C13600E3673001031EB000FA38B009CA7
68292+:108E60008D8F00048D8B0008959F0012959900103E
68293+:108E70009584001A9598001E958E001C33EDFFFF17
68294+:108E8000332AFFFF3089FFFF3308FFFF31C7FFFFA1
68295+:108E90003C010800AC2D00243C010800AC29004432
68296+:108EA0003C010800AC2A0040AE683178AE67317CE6
68297+:108EB00091850015959100163C12601236520010F3
68298+:108EC00030A200FF3230FFFFAE623188AE5000B4F6
68299+:108ED00091830014959F0018240600010066C804C1
68300+:108EE00033F8FFFFAE5900B8AE5800BC918E0014A5
68301+:108EF000AF8F00843C08600631CD00FFAE4D00C04E
68302+:108F0000918A00159584000E3C07600A314900FFE4
68303+:108F1000AF8B00883084FFFFAE4900C835110010C8
68304+:108F20000E000D1034F004103C0208008C4200606A
68305+:108F30003C0308008C6300643C0608008CC60058A3
68306+:108F40003C0508008CA5005C8F8400808FBF00204A
68307+:108F5000AE23004CAE65319CAE030054AE4500DC40
68308+:108F6000AE6231A0AE6331A4AE663198AE22004845
68309+:108F70008FB3001CAE0200508FB10014AE4200E06F
68310+:108F8000AE4300E4AE4600D88FB000108FB2001898
68311+:108F90000A00057D27BD0028978500929783007CF5
68312+:108FA00027BDFFE8AFB0001000A3102BAFBF001427
68313+:108FB000240400058F900058104000552409000239
68314+:108FC0000E0006958F850080AF8200942404000374
68315+:108FD0001040004F240900023C0680000E00008172
68316+:108FE000ACC2002024070001240820001040004DDE
68317+:108FF00024040005978E00928F8AFF2C24090050CC
68318+:1090000025C50001A7850092A14900003C0D08007C
68319+:109010008DAD0064240380008F84FF28000D66005E
68320+:10902000AD4C0018A5400006954B000A8F85FF3017
68321+:109030002402FF8001633024A546000A915F000AE4
68322+:109040000000482103E2C825A159000AA0A0000899
68323+:10905000A140004CA08000D5961800029783009094
68324+:109060003C020004A49800EA960F00022418FFBFF7
68325+:1090700025EE2401A48E00BE8E0D0004ACAD00448C
68326+:109080008E0C0008ACAC0040A4A00050A4A000547A
68327+:109090008E0B000C240C0030AC8B00288E060010C8
68328+:1090A000AC860024A480003EA487004EA487005014
68329+:1090B000A483003CAD420074AC8800D8ACA800602A
68330+:1090C000A08700FC909F00D433F9007FA09900D4C2
68331+:1090D000909000D402187824A08F00D4914E007C88
68332+:1090E00035CD0001A14D007C938B009CAD480070F4
68333+:1090F000AC8C00DCA08B00D68F8800888F87008422
68334+:10910000AC8800C4AC8700C8A5400078A540007AB0
68335+:109110008FBF00148FB000100120102103E0000861
68336+:1091200027BD00188F8500940E0007258F860080CC
68337+:109130000A000E9F2409000227BDFFE0AFB0001017
68338+:109140008F900058AFB10014AFBF00188E09000413
68339+:109150000E00054A000921C08E0800048F84FF28F4
68340+:109160008F82FF30000839C03C068000ACC7002069
68341+:10917000948500EA904300131460001C30B1FFFF97
68342+:109180008F8CFF2C918B0008316A00401540000B3A
68343+:10919000000000008E0D0004022030218FBF001857
68344+:1091A0008FB100148FB00010240400220000382179
68345+:1091B000000D29C00A000D2F27BD00200E000098C9
68346+:1091C000000000008E0D0004022030218FBF001827
68347+:1091D0008FB100148FB00010240400220000382149
68348+:1091E000000D29C00A000D2F27BD00200E000090A1
68349+:1091F000000000008E0D0004022030218FBF0018F7
68350+:109200008FB100148FB00010240400220000382118
68351+:10921000000D29C00A000D2F27BD002027BDFFE04B
68352+:10922000AFB200183092FFFFAFB00010AFBF001C0C
68353+:10923000AFB100141240001E000080218F8600583C
68354+:109240008CC500002403000600053F02000514023F
68355+:1092500030E4000714830016304500FF2CA80006F8
68356+:1092600011000040000558803C0C0800258C58BCBB
68357+:10927000016C50218D490000012000080000000011
68358+:109280008F8E0098240D000111CD005024020002A1
68359+:10929000AF820098260900013130FFFF24C800206A
68360+:1092A0000212202B010030211480FFE5AF88005806
68361+:1092B000020010218FBF001C8FB200188FB1001464
68362+:1092C0008FB0001003E0000827BD00209387007EC8
68363+:1092D00054E00034000030210E000DE700000000D3
68364+:1092E0008F8600580A000EFF240200018F87009825
68365+:1092F0002405000210E50031240400130000282199
68366+:1093000000003021240700010E000D2F0000000096
68367+:109310000A000F008F8600588F83009824020002F5
68368+:109320001462FFF6240400120E000D9A00000000E3
68369+:109330008F85009400403021240400120E000D2F70
68370+:10934000000038210A000F008F8600588F83009894
68371+:109350002411000310710029241F0002107FFFCE8A
68372+:1093600026090001240400100000282100003021FB
68373+:109370000A000F1D240700018F91009824060002A7
68374+:109380001626FFF9240400100E000E410000000014
68375+:10939000144000238F9800588F8600580A000EFF53
68376+:1093A00024020003240400140E000D2F00002821C5
68377+:1093B0008F8600580A000EFF240200020E000EA93C
68378+:1093C000000000000A000F008F8600580E000D3FBD
68379+:1093D00000000000241900022404001400002821C9
68380+:1093E0000000302100003821AF9900980E000D2FA9
68381+:1093F000000000000A000F008F8600580E000D5775
68382+:10940000000000008F8500942419000200403021E4
68383+:1094100024040010000038210A000F56AF9900986C
68384+:109420000040382124040010970F0002000028217A
68385+:109430000E000D2F31E6FFFF8F8600580A000F0047
68386+:10944000AF9100988F84FF2C3C077FFF34E6FFFF2D
68387+:109450008C8500182402000100A61824AC83001893
68388+:1094600003E00008A08200053084FFFF30A5FFFF65
68389+:109470001080000700001821308200011040000217
68390+:1094800000042042006518211480FFFB00052840DD
68391+:1094900003E000080060102110C000070000000079
68392+:1094A0008CA2000024C6FFFF24A50004AC820000AB
68393+:1094B00014C0FFFB2484000403E000080000000047
68394+:1094C00010A0000824A3FFFFAC86000000000000ED
68395+:1094D000000000002402FFFF2463FFFF1462FFFA74
68396+:1094E0002484000403E0000800000000000411C010
68397+:1094F00003E000082442024027BDFFE8AFB000109F
68398+:1095000000808021AFBF00140E000F9600A0202124
68399+:1095100000504821240AFF808FBF00148FB0001034
68400+:10952000012A30243127007F3C08800A3C042100B6
68401+:1095300000E8102100C428253C03800027BD001846
68402+:10954000AC650024AF820038AC400000AC6500245C
68403+:1095500003E00008AC4000403C0D08008DAD005811
68404+:1095600000056180240AFF8001A45821016C482174
68405+:10957000012A30243127007F3C08800C3C04210064
68406+:1095800000E8102100C428253C038000AC650028B9
68407+:10959000AF82003403E00008AC40002430A5FFFF98
68408+:1095A0003C0680008CC201B80440FFFE3C086015F8
68409+:1095B00000A838253C031000ACC40180ACC0018475
68410+:1095C000ACC7018803E00008ACC301B83C0D08003B
68411+:1095D0008DAD005800056180240AFF8001A4582148
68412+:1095E000016C4021010A4824000931403107007F05
68413+:1095F00000C728253C04200000A418253C02800058
68414+:10960000AC43083003E00008AF80003427BDFFE81A
68415+:10961000AFB0001000808021AFBF00140E000F9685
68416+:1096200000A0202100504821240BFF80012B502452
68417+:10963000000A39403128007F3C0620008FBF00140B
68418+:109640008FB0001000E8282534C2000100A21825C0
68419+:109650003C04800027BD0018AC83083003E00008FC
68420+:10966000AF8000383C0580088CA700603C0680086D
68421+:109670000087102B144000112C8340008CA8006040
68422+:109680002D0340001060000F240340008CC90060CF
68423+:109690000089282B14A00002008018218CC30060D0
68424+:1096A00000035A42000B30803C0A0800254A59202A
68425+:1096B00000CA202103E000088C8200001460FFF340
68426+:1096C0002403400000035A42000B30803C0A08008B
68427+:1096D000254A592000CA202103E000088C8200009E
68428+:1096E0003C05800890A60008938400AB24C20001CA
68429+:1096F000304200FF3043007F1064000C0002382726
68430+:10970000A0A200083C0480008C85017804A0FFFE24
68431+:109710008F8A00A0240900023C081000AC8A014096
68432+:10972000A089014403E00008AC8801780A00101BFE
68433+:1097300030E2008027BDFFD8AFB200188F9200A49E
68434+:10974000AFBF0020AFB3001CAFB00010AFB100142A
68435+:109750008F9300348E5900283C1000803C0EFFEFA0
68436+:10976000AE7900008E580024A260000A35CDFFFFBC
68437+:10977000AE7800049251002C3C0BFF9F356AFFFF2E
68438+:10978000A271000C8E6F000C3C080040A271000B0F
68439+:1097900001F06025018D4824012A382400E8302595
68440+:1097A000AE66000C8E450004AE6000183C0400FF5D
68441+:1097B000AE6500148E43002C3482FFFFA6600008C3
68442+:1097C0000062F824AE7F00108E5900088F9000A030
68443+:1097D000964E0012AE7900208E51000C31D83FFF1A
68444+:1097E00000187980AE7100248E4D001401F06021C4
68445+:1097F00031CB0001AE6D00288E4A0018000C41C22A
68446+:10980000000B4B80AE6A002C8E46001C01093821EB
68447+:10981000A667001CAE660030964500028E4400200C
68448+:10982000A665001EAE64003492430033306200042B
68449+:1098300054400006924700003C0280083443010077
68450+:109840008C7F00D0AE7F0030924700008F860038BA
68451+:10985000A0C700309245003330A4000250800007BA
68452+:10986000925100018F880038240BFF80910A00304C
68453+:10987000014B4825A1090030925100018F9000381A
68454+:10988000240CFFBF2404FFDFA21100318F8D0038AC
68455+:109890003C1880083711008091AF003C31EE007F0A
68456+:1098A000A1AE003C8F890038912B003C016C502404
68457+:1098B000A12A003C8F9F00388E68001493E6003C7C
68458+:1098C0002D0700010007114000C4282400A218251C
68459+:1098D000A3E3003C8F87003896590012A4F90032A8
68460+:1098E0008E450004922E007C30B0000300107823D7
68461+:1098F00031ED000300AD102131CC000215800002D3
68462+:1099000024460034244600303C0280083443008062
68463+:10991000907F007C00BFC824333800041700000289
68464+:1099200024C2000400C010218F98003824190002BE
68465+:10993000ACE20034A3190000924F003F8F8E003834
68466+:109940003C0C8008358B0080A1CF00018F9100383E
68467+:10995000924D003F8E440004A62D0002956A005CE3
68468+:109960000E000FF43150FFFF00024B800209382532
68469+:109970003C08420000E82825AE2500048E4400384B
68470+:109980008F850038ACA400188E460034ACA6001CAD
68471+:10999000ACA0000CACA00010A4A00014A4A0001661
68472+:1099A000A4A00020A4A00022ACA000248E62001479
68473+:1099B00050400001240200018FBF00208FB3001C23
68474+:1099C0008FB200188FB100148FB00010ACA2000845
68475+:1099D0000A00101327BD002827BDFFC83C058008DA
68476+:1099E00034A40080AFBF0034AFBE0030AFB7002C4E
68477+:1099F000AFB60028AFB50024AFB40020AFB3001C51
68478+:109A0000AFB20018AFB10014AFB00010948300786B
68479+:109A10009482007A104300512405FFFF0080F0215A
68480+:109A20000A0011230080B821108B004D8FBF003435
68481+:109A30008F8600A03C1808008F18005C2411FF805E
68482+:109A40003C1680000306782101F18024AED0002C62
68483+:109A500096EE007A31EC007F3C0D800E31CB7FFF1B
68484+:109A6000018D5021000B4840012AA82196A4000036
68485+:109A70003C0808008D0800582405FF8030953FFF02
68486+:109A800001061821001539800067C8210325F82434
68487+:109A90003C02010003E290253338007F3C11800C2A
68488+:109AA000AED20028031190219250000D320F000415
68489+:109AB00011E0003702E0982196E3007A96E8007AF8
68490+:109AC00096E5007A2404800031077FFF24E300013B
68491+:109AD00030627FFF00A4F82403E2C825A6F9007ACB
68492+:109AE00096E6007A3C1408008E94006030D67FFF22
68493+:109AF00012D400C1000000008E5800188F8400A00E
68494+:109B000002A028212713FFFF0E000FCEAE53002C1A
68495+:109B100097D5007897D4007A12950010000028217C
68496+:109B20003C098008352401003C0A8008914800085F
68497+:109B3000908700D53114007F30E400FF0284302B81
68498+:109B400014C0FFB9268B0001938E00AB268C000158
68499+:109B5000008E682115ACFFB78F8600A08FBF003440
68500+:109B60008FBE00308FB7002C8FB600288FB5002431
68501+:109B70008FB400208FB3001C8FB200188FB1001477
68502+:109B80008FB0001000A0102103E0000827BD0038AE
68503+:109B900000C020210E000F99028028218E4B00105A
68504+:109BA0008E4C00308F84003824090002016C502351
68505+:109BB000AE4A0010A089000096E3005C8E4400309D
68506+:109BC0008F9100380E000FF43070FFFF00024380C9
68507+:109BD000020838253C02420000E22825AE25000498
68508+:109BE0008E5F00048F8A00388E590000240B000815
68509+:109BF000AD5F001CAD590018AD40000CAD40001029
68510+:109C00009246000A240400052408C00030D000FF5A
68511+:109C1000A550001496580008A55800169251000A45
68512+:109C20003C188008322F00FFA54F0020964E0008F8
68513+:109C300037110100A54E0022AD400024924D000BCB
68514+:109C400031AC00FFA54C0002A14B00018E49003051
68515+:109C50008F830038240BFFBFAC690008A06400307C
68516+:109C60008F9000382403FFDF9607003200E8282495
68517+:109C700000B51025A6020032921F003233F9003FD2
68518+:109C800037260040A20600328F8C0038AD800034A9
68519+:109C90008E2F00D0AD8F0038918E003C3C0F7FFF9F
68520+:109CA00031CD007FA18D003C8F84003835EEFFFF61
68521+:109CB000908A003C014B4824A089003C8F850038E5
68522+:109CC00090A8003C01033824A0A7003C8E42003439
68523+:109CD0008F9100383C038008AE2200408E59002C42
68524+:109CE0008E5F0030033F3023AE26004492300048A0
68525+:109CF0003218007FA23800488F8800388E4D00301F
68526+:109D00008D0C004801AE582401965024014B482583
68527+:109D1000AD0900489244000AA104004C964700088F
68528+:109D20008F850038A4A7004E8E5000308E4400303E
68529+:109D30000E0003818C65006092F9007C0002F940FE
68530+:109D4000004028210002110003E2302133360002D6
68531+:109D500012C00003020680210005B0800216802197
68532+:109D6000926D007C31B30004126000020005708027
68533+:109D7000020E80218E4B00308F8800382405800031
68534+:109D8000316A0003000A4823312400030204182129
68535+:109D9000AD03003496E4007A96F0007A96F1007AEA
68536+:109DA00032027FFF2447000130FF7FFF0225C824D5
68537+:109DB000033F3025A6E6007A96F8007A3C120800A8
68538+:109DC0008E520060330F7FFF11F200180000000078
68539+:109DD0008F8400A00E000FCE02A028218F8400A047
68540+:109DE0000E000FDE028028210E001013000000007C
68541+:109DF0000A00111F0000000096F1007A022480245E
68542+:109E0000A6F0007A92EF007A92EB007A31EE00FF32
68543+:109E1000000E69C2000D6027000C51C03169007F3F
68544+:109E2000012A20250A001119A2E4007A96E6007A98
68545+:109E300000C5C024A6F8007A92EF007A92F3007A67
68546+:109E400031F200FF001271C2000E6827000DB1C090
68547+:109E5000326C007F01962825A2E5007A0A0011D015
68548+:109E60008F8400A03C0380003084FFFF30A5FFFFFB
68549+:109E7000AC640018AC65001C03E000088C620014A0
68550+:109E800027BDFFA03C068008AFBF005CAFBE0058F6
68551+:109E9000AFB70054AFB60050AFB5004CAFB40048F8
68552+:109EA000AFB30044AFB20040AFB1003CAFB0003838
68553+:109EB00034C80100910500D590C700083084FFFF29
68554+:109EC00030A500FF30E2007F0045182AAFA4001043
68555+:109ED000A7A00018A7A0002610600055AFA000148E
68556+:109EE00090CA00083149007F00A9302324D3FFFF26
68557+:109EF0000013802B8FB400100014902B02128824C2
68558+:109F0000522000888FB300143C03800894790052DB
68559+:109F1000947E00508FB60010033EC0230018BC0092
68560+:109F2000001714030016FC0002C2A82A16A00002A3
68561+:109F3000001F2C030040282100133C0000072403CD
68562+:109F400000A4102A5440000100A020212885000907
68563+:109F500014A000020080A021241400083C0C8008FA
68564+:109F60008D860048001459808D88004C3C03800089
68565+:109F70003169FFFF3C0A0010012A202534710400DA
68566+:109F8000AC660038AF9100A4AC68003CAC64003013
68567+:109F900000000000000000000000000000000000C1
68568+:109FA00000000000000000000000000000000000B1
68569+:109FB0008C6E000031CD002011A0FFFD0014782A26
68570+:109FC00001F01024104000390000A8213C16800840
68571+:109FD00092D700083C1280008E44010032F6007FC8
68572+:109FE0000E000F9902C028218E3900108E44010006
68573+:109FF0000000902133373FFF0E000FB102E028210F
68574+:10A00000923800003302003F2C500008520000102C
68575+:10A0100000008821000210803C030800246358E4FB
68576+:10A020000043F8218FFE000003C00008000000007C
68577+:10A0300090CF0008938C00AB31EE007F00AE682318
68578+:10A04000018D58210A0012172573FFFF0000882197
68579+:10A050003C1E80008FC401000E000FCE02E02821BC
68580+:10A060008FC401000E000FDE02C028211220000F55
68581+:10A070000013802B8F8B00A426A400010004AC00E9
68582+:10A08000027298230015AC032578004002B4B02A70
68583+:10A090000013802B241700010300882102D0102414
68584+:10A0A000AF9800A41440FFC9AFB700143C07800864
68585+:10A0B00094E200508FAE00103C05800002A288217F
68586+:10A0C0003C060020A4F10050ACA6003094F40050EF
68587+:10A0D00094EF005201D51823306CFFFF11F4001EDD
68588+:10A0E000AFAC00108CEF004C001561808CF500487F
68589+:10A0F00001EC28210000202100AC582B02A4C02133
68590+:10A10000030BB021ACE5004CACF600488FB4001056
68591+:10A110000014902B021288241620FF7C3C03800838
68592+:10A120008FB300148FBF005C8FBE00583A620001ED
68593+:10A130008FB700548FB600508FB5004C8FB40048D5
68594+:10A140008FB300448FB200408FB1003C8FB0003815
68595+:10A1500003E0000827BD006094FE00548CF2004428
68596+:10A1600033C9FFFE0009C8C00259F821ACBF003C4A
68597+:10A170008CE800448CAD003C010D50231940003B9D
68598+:10A18000000000008CF7004026E20001ACA200387D
68599+:10A190003C05005034A700103C038000AC67003041
68600+:10A1A00000000000000000000000000000000000AF
68601+:10A1B000000000000000000000000000000000009F
68602+:10A1C0008C7800003316002012C0FFFD3C1180087F
68603+:10A1D000962200543C1580003C068008304E000159
68604+:10A1E000000E18C0007578218DEC04003C070800B3
68605+:10A1F0008CE700443C040020ACCC00488DF40404FF
68606+:10A20000240B0001ACD4004C10EB0260AEA4003073
68607+:10A21000963900523C0508008CA5004000B99021F9
68608+:10A22000A6320052963F005427ED0001A62D00549F
68609+:10A230009626005430C4FFFF5487FF2F8FB40010C0
68610+:10A2400030A5FFFF0E0011F4A62000543C070800C3
68611+:10A250008CE70024963E00520047B82303D74823DA
68612+:10A26000A62900520A0012198FB400108CE2004097
68613+:10A270000A0012BE00000000922400012407000121
68614+:10A280003085007F14A7001C97AD00268E2B00148C
68615+:10A29000240CC000316A3FFF01AC48243C06080092
68616+:10A2A0008CC60060012A402531043FFF0086882BC0
68617+:10A2B00012200011A7A800263C0508008CA5005814
68618+:10A2C0008F9100A0000439802402FF8000B1182182
68619+:10A2D0000067F82103E2F02433F8007F3C1280008D
68620+:10A2E0003C19800EAE5E002C0319702191D0000D38
68621+:10A2F000360F0004A1CF000D0E001028241200011B
68622+:10A30000241100013C1E80008FC401000E000FCEFE
68623+:10A3100002E028218FC401000E000FDE02C02821B8
68624+:10A320001620FF558F8B00A40A0012860013802B85
68625+:10A330008F8600A490C80001310400201080019194
68626+:10A34000241000013C048008348B0080916A007C5A
68627+:10A350008F9E0034AFA0002C314900011120000F66
68628+:10A36000AFB000288CCD00148C8E006001AE602B45
68629+:10A370001580000201A038218C8700603C188008FD
68630+:10A38000370300808C70007000F0782B15E000021D
68631+:10A3900000E020218C640070AFA4002C3C028008F7
68632+:10A3A000344500808CD200148CBF0070025FC82B33
68633+:10A3B00017200002024020218CA400708FA7002CDF
68634+:10A3C0000087182310600003AFA3003024050002AB
68635+:10A3D000AFA500288FA400280264882B162000BA9D
68636+:10A3E000000018218CD000388FCE000C3C0F00806C
68637+:10A3F000AFD000008CCD00343C0CFF9F01CF58251E
68638+:10A40000AFCD000490CA003F3586FFFF01662024CF
68639+:10A410003C0900203C08FFEFA3CA000B0089382547
68640+:10A420003511FFFF00F118243C0500088F8700A4B8
68641+:10A430000065C825AFD9000C8CE20014AFC000182D
68642+:10A440008FA60030AFC200148CF800188FB0002C1B
68643+:10A450003C1FFFFBAFD8001C8CEF000837F2FFFF5A
68644+:10A4600003326824AFCF00248CEC000C020670216C
68645+:10A47000AFCD000CA7C00038A7C0003AAFCE002C6B
68646+:10A48000AFCC0020AFC000288CEA00148FAB002CAA
68647+:10A49000014B48230126402311000011AFC80010D2
68648+:10A4A00090EB003D8FC900048FC80000000B5100E5
68649+:10A4B000012A28210000102100AA882B010218215E
68650+:10A4C0000071F821AFC50004AFDF000090F2003D3D
68651+:10A4D000A3D2000A8F9900A497380006A7D80008D5
68652+:10A4E0008F910038240800023C038008A228000055
68653+:10A4F0003465008094BF005C8FA4002C33F0FFFF14
68654+:10A500000E000FF48F9200380002CB808F8500A4DC
68655+:10A51000021978253C18420001F87025AE4E00045F
68656+:10A520008F8400388CAD0038AC8D00188CAC0034B2
68657+:10A53000AC8C001CAC80000CAC800010A48000141B
68658+:10A54000A4800016A4800020A4800022AC800024F7
68659+:10A5500090A6003F8FA7002CA486000250E0019235
68660+:10A56000240700018FA200305040000290A2003D5D
68661+:10A5700090A2003E244A0001A08A00018F84003886
68662+:10A580008FA9002CAC8900083C128008364D008051
68663+:10A5900091AC007C3186000214C000022407003414
68664+:10A5A000240700308F8500A43C198008373F0080C5
68665+:10A5B00090B0000093F9007C240E0004A0900030BD
68666+:10A5C0008F8F00A48FB8002C8F8D003891F200017E
68667+:10A5D0003304000301C46023A1B200318F8E003820
68668+:10A5E0008F8600A42402C00095CA003294C90012CC
68669+:10A5F0008FAB002C0142402431233FFF010388250B
68670+:10A60000A5D1003291D000323185000300EBF82152
68671+:10A610003218003F370F0040A1CF00328FA4002C2A
68672+:10A6200003E5382133280004108000028F850038AC
68673+:10A6300000E838213C0A8008ACA700343549010005
68674+:10A640008D2800D08FA3002C2419FFBFACA80038A0
68675+:10A6500090B1003C2C640001240FFFDF3227007F03
68676+:10A66000A0A7003C8F98003800049140931F003C45
68677+:10A6700003F98024A310003C8F8C0038918E003C9D
68678+:10A6800001CF682401B23025A186003C8F8900A447
68679+:10A690008F8800388D2B0020AD0B00408D220024C8
68680+:10A6A000AD0200448D2A0028AD0A00488D23002CFD
68681+:10A6B0000E001013AD03004C8FB1002824070002D8
68682+:10A6C000122700118FA300280003282B00058023E8
68683+:10A6D0000270982400608021006090210A00126FAF
68684+:10A6E0000010882B962900128F8400A00000902172
68685+:10A6F0003125FFFFA7A900180E000FC22411000189
68686+:10A700000A00131D3C1E80003C0B80003C12800898
68687+:10A710008D640100924900088F92FF340E000F995A
68688+:10A720003125007F8F9900388FA700288FA4003033
68689+:10A73000A3270000965F005C33F0FFFF0E000FF4CC
68690+:10A740008F91003800026B80020D80253C0842008A
68691+:10A750008F8D00A402085025AE2A00048DA5003874
68692+:10A760008F8A003800007821000F1100AD450018D5
68693+:10A770008DB800343C047FFF3488FFFFAD58001CC7
68694+:10A7800091A6003E8D4C001C8D4900180006190052
68695+:10A79000000677020183C821004E58250323882B29
68696+:10A7A000012B382100F1F821AD59001CAD5F0018D4
68697+:10A7B000AD40000CAD40001091B0003E8FA40030C1
68698+:10A7C00024090005A550001495A500042419C00013
68699+:10A7D00000884024A545001691B8003EA5580020E9
68700+:10A7E00095AF0004A54F0022AD40002491AE003F7C
68701+:10A7F000A54E000291A6003E91AC003D01861023BB
68702+:10A80000244B0001A14B00018F9100388FA3003031
68703+:10A810003C028008344B0100AE230008A22900301E
68704+:10A820008F8C00388F8700A4959F003294F000121F
68705+:10A830002407FFBF033FC02432053FFF03057825EF
68706+:10A84000A58F0032918E00322418FFDF31CD003FFA
68707+:10A8500035A60040A18600328F910038240DFFFFFD
68708+:10A86000240CFF80AE2000348D6A00D0AE2A003860
68709+:10A870009223003C3069007FA229003C8F90003871
68710+:10A880003C0380009219003C0327F824A21F003CDF
68711+:10A890008F8E003891C5003C00B87824A1CF003CD1
68712+:10A8A0008F8A00383C0E8008AD4D00408FA6002CEA
68713+:10A8B000AD46004491420048004C5825A14B004849
68714+:10A8C0008F9000388F9900A48E09004801238824B6
68715+:10A8D00002283825AE070048933F003EA21F004CD7
68716+:10A8E0008F9800A48F8F003897050004A5E5004ECF
68717+:10A8F0000E0003818DC500609246007C8FAC003055
68718+:10A9000000026940000291000040282130CB000283
68719+:10A9100001B21021156000AA018230213C0E80088E
68720+:10A9200035C20080904C007C31830004106000032D
68721+:10A930008FB900300005788000CF3021241F00043B
68722+:10A940008F910038332D000303ED8023320800037C
68723+:10A9500000C85021AE2A00343C188000A7C500383A
68724+:10A960003C0680088F04010090DE00080E000FDE18
68725+:10A9700033C5007F0E001013000000000A00140D04
68726+:10A980008FA300288F9800348CC90038241F00033F
68727+:10A99000A7000008AF0900008CC50034A300000A1E
68728+:10A9A0008F9900A4AF0500043C080080932D003F60
68729+:10A9B000A31F000C8F0A000C3C02FF9FA30D000B8D
68730+:10A9C0000148F0253451FFFF3C12FFEF8F9900A49E
68731+:10A9D00003D170243646FFFF01C61824AF03000CD4
68732+:10A9E0008F2C0014972900128F8400A0AF0C001048
68733+:10A9F0008F2F0014AF000018AF000020AF0F00141D
68734+:10AA0000AF0000248F270018312F3FFF000F59801F
68735+:10AA1000AF0700288F2500080164F821312D0001BF
68736+:10AA2000AF0500308F31000C8F920038001F51C2EB
68737+:10AA3000000D438001481021241E00023C068008BE
68738+:10AA4000A702001CA7000034AF11002CA25E00007A
68739+:10AA500034D20080964E005C8F9900383C0342004F
68740+:10AA600031CCFFFF01833825AF2700048F8B00A472
68741+:10AA7000240500012402C0008D640038240700343E
68742+:10AA8000AF2400188D690034AF29001CAF20000CE2
68743+:10AA9000AF200010A7200014A7200016A720002038
68744+:10AAA000A7200022AF200024A7300002A325000128
68745+:10AAB0008F8800388F9F00A4AD10000893ED000030
68746+:10AAC000A10D00308F8A00A48F98003891510001A9
68747+:10AAD000A31100318F8B0038957E003203C27024A1
68748+:10AAE00001CF6025A56C0032916300323064003FD5
68749+:10AAF000A16400329249007C3125000214A00002BA
68750+:10AB00008F840038240700303C198008AC8700345B
68751+:10AB1000373201008E5F00D0240AFFBF020090216F
68752+:10AB2000AC9F0038908D003C31A8007FA088003C8D
68753+:10AB30008F9E003893C2003C004A8824A3D1003C79
68754+:10AB40008F8300380010882B9066003C34CE0020A4
68755+:10AB5000A06E003C8F8400A48F9800388C8C00205D
68756+:10AB6000AF0C00408C8F0024AF0F00448C8700286E
68757+:10AB7000AF0700488C8B002CAF0B004C0E0010135D
68758+:10AB80003C1E80000A0012700000000094C80052B1
68759+:10AB90003C0A08008D4A002401488821A4D10052B3
68760+:10ABA0000A0012198FB40010A08700018F840038AA
68761+:10ABB000240B0001AC8B00080A0013BE3C12800875
68762+:10ABC000000520800A0014A200C4302127BDFFE048
68763+:10ABD0003C0D8008AFB20018AFB00010AFBF001C32
68764+:10ABE000AFB1001435B200808E4C001835A80100BA
68765+:10ABF000964B000695A70050910900FC000C5602E8
68766+:10AC0000016728233143007F312600FF240200031F
68767+:10AC1000AF8300A8AF8400A010C2001B30B0FFFFBC
68768+:10AC2000910600FC2412000530C200FF10520033D0
68769+:10AC300000000000160000098FBF001C8FB2001832
68770+:10AC40008FB100148FB00010240D0C003C0C80005C
68771+:10AC500027BD002003E00008AD8D00240E0011FB8D
68772+:10AC6000020020218FBF001C8FB200188FB100148A
68773+:10AC70008FB00010240D0C003C0C800027BD00207C
68774+:10AC800003E00008AD8D0024965800789651007AB4
68775+:10AC9000924E007D0238782631E8FFFF31C400C0B3
68776+:10ACA000148000092D11000116000037000000007B
68777+:10ACB0005620FFE28FBF001C0E0010D100000000E4
68778+:10ACC0000A00156A8FBF001C1620FFDA0000000082
68779+:10ACD0000E0010D1000000001440FFD88FBF001CF0
68780+:10ACE0001600002200000000925F007D33E2003F6A
68781+:10ACF000A242007D0A00156A8FBF001C950900EA78
68782+:10AD00008F86008000802821240400050E0007257E
68783+:10AD10003130FFFF978300923C0480002465FFFFE1
68784+:10AD2000A78500928C8A01B80540FFFE0000000054
68785+:10AD3000AC8001808FBF001CAC9001848FB20018E2
68786+:10AD40008FB100148FB000103C0760133C0B100053
68787+:10AD5000240D0C003C0C800027BD0020AC8701882E
68788+:10AD6000AC8B01B803E00008AD8D00240E0011FB90
68789+:10AD7000020020215040FFB18FBF001C925F007D78
68790+:10AD80000A00159733E2003F0E0011FB020020215C
68791+:10AD90001440FFAA8FBF001C122000070000000013
68792+:10ADA0009259007D3330003F36020040A242007DC0
68793+:10ADB0000A00156A8FBF001C0E0010D100000000B1
68794+:10ADC0005040FF9E8FBF001C9259007D3330003FE2
68795+:10ADD0000A0015C636020040000000000000001BFB
68796+:10ADE0000000000F0000000A00000008000000063C
68797+:10ADF0000000000500000005000000040000000441
68798+:10AE00000000000300000003000000030000000336
68799+:10AE10000000000300000002000000020000000229
68800+:10AE2000000000020000000200000002000000021A
68801+:10AE3000000000020000000200000002000000020A
68802+:10AE400000000002000000020000000200000002FA
68803+:10AE50000000000100000001000000018008010066
68804+:10AE6000800800808008000000000C000000308096
68805+:10AE7000080011D00800127C08001294080012A8E3
68806+:10AE8000080012BC080011D0080011D0080012F010
68807+:10AE90000800132C080013400800138808001A8CBF
68808+:10AEA00008001A8C08001AC408001AC408001AD82E
68809+:10AEB00008001AA808001D0008001CCC08001D5836
68810+:10AEC00008001D5808001DE008001D108008024001
68811+:10AED000080027340800256C0800275C080027F4C8
68812+:10AEE0000800293C0800298808002AAC080029B479
68813+:10AEF00008002A38080025DC08002EDC08002EA4F3
68814+:10AF000008002588080025880800258808002B20CF
68815+:10AF100008002B20080025880800258808002DD06F
68816+:10AF2000080025880800258808002588080025884D
68817+:10AF300008002E0C080025880800258808002588B0
68818+:10AF4000080025880800258808002588080025882D
68819+:10AF5000080025880800258808002588080025881D
68820+:10AF6000080025880800258808002588080029A8E9
68821+:10AF7000080025880800258808002E680800258814
68822+:10AF800008002588080025880800258808002588ED
68823+:10AF900008002588080025880800258808002588DD
68824+:10AFA00008002588080025880800258808002588CD
68825+:10AFB00008002588080025880800258808002588BD
68826+:10AFC00008002CF4080025880800258808002C6853
68827+:10AFD00008002BC408003CE408003CB808003C848E
68828+:10AFE00008003C5808003C3808003BEC8008010091
68829+:10AFF00080080080800800008008008008004C6401
68830+:10B0000008004C9C08004BE408004C6408004C64A9
68831+:10B01000080049B808004C64080050500A000C842D
68832+:10B0200000000000000000000000000D7278703683
68833+:10B030002E322E31620000000602010300000000E3
68834+:10B0400000000001000000000000000000000000FF
68835+:10B0500000000000000000000000000000000000F0
68836+:10B0600000000000000000000000000000000000E0
68837+:10B0700000000000000000000000000000000000D0
68838+:10B0800000000000000000000000000000000000C0
68839+:10B0900000000000000000000000000000000000B0
68840+:10B0A00000000000000000000000000000000000A0
68841+:10B0B0000000000000000000000000000000000090
68842+:10B0C0000000000000000000000000000000000080
68843+:10B0D0000000000000000000000000000000000070
68844+:10B0E0000000000000000000000000000000000060
68845+:10B0F0000000000000000000000000000000000050
68846+:10B10000000000000000000000000000000000003F
68847+:10B11000000000000000000000000000000000002F
68848+:10B12000000000000000000000000000000000001F
68849+:10B13000000000000000000000000000000000000F
68850+:10B1400000000000000000000000000000000000FF
68851+:10B1500000000000000000000000000000000000EF
68852+:10B1600000000000000000000000000000000000DF
68853+:10B1700000000000000000000000000000000000CF
68854+:10B1800000000000000000000000000000000000BF
68855+:10B1900000000000000000000000000000000000AF
68856+:10B1A000000000000000000000000000000000009F
68857+:10B1B000000000000000000000000000000000008F
68858+:10B1C000000000000000000000000000000000007F
68859+:10B1D000000000000000000000000000000000006F
68860+:10B1E000000000000000000000000000000000005F
68861+:10B1F000000000000000000000000000000000004F
68862+:10B20000000000000000000000000000000000003E
68863+:10B21000000000000000000000000000000000002E
68864+:10B22000000000000000000000000000000000001E
68865+:10B23000000000000000000000000000000000000E
68866+:10B2400000000000000000000000000000000000FE
68867+:10B2500000000000000000000000000000000000EE
68868+:10B2600000000000000000000000000000000000DE
68869+:10B2700000000000000000000000000000000000CE
68870+:10B2800000000000000000000000000000000000BE
68871+:10B2900000000000000000000000000000000000AE
68872+:10B2A000000000000000000000000000000000009E
68873+:10B2B000000000000000000000000000000000008E
68874+:10B2C000000000000000000000000000000000007E
68875+:10B2D000000000000000000000000000000000006E
68876+:10B2E000000000000000000000000000000000005E
68877+:10B2F000000000000000000000000000000000004E
68878+:10B30000000000000000000000000000000000003D
68879+:10B31000000000000000000000000000000000002D
68880+:10B32000000000000000000000000000000000001D
68881+:10B33000000000000000000000000000000000000D
68882+:10B3400000000000000000000000000000000000FD
68883+:10B3500000000000000000000000000000000000ED
68884+:10B3600000000000000000000000000000000000DD
68885+:10B3700000000000000000000000000000000000CD
68886+:10B3800000000000000000000000000000000000BD
68887+:10B3900000000000000000000000000000000000AD
68888+:10B3A000000000000000000000000000000000009D
68889+:10B3B000000000000000000000000000000000008D
68890+:10B3C000000000000000000000000000000000007D
68891+:10B3D000000000000000000000000000000000006D
68892+:10B3E000000000000000000000000000000000005D
68893+:10B3F000000000000000000000000000000000004D
68894+:10B40000000000000000000000000000000000003C
68895+:10B41000000000000000000000000000000000002C
68896+:10B42000000000000000000000000000000000001C
68897+:10B43000000000000000000000000000000000000C
68898+:10B4400000000000000000000000000000000000FC
68899+:10B4500000000000000000000000000000000000EC
68900+:10B4600000000000000000000000000000000000DC
68901+:10B4700000000000000000000000000000000000CC
68902+:10B4800000000000000000000000000000000000BC
68903+:10B4900000000000000000000000000000000000AC
68904+:10B4A000000000000000000000000000000000009C
68905+:10B4B000000000000000000000000000000000008C
68906+:10B4C000000000000000000000000000000000007C
68907+:10B4D000000000000000000000000000000000006C
68908+:10B4E000000000000000000000000000000000005C
68909+:10B4F000000000000000000000000000000000004C
68910+:10B50000000000000000000000000000000000003B
68911+:10B51000000000000000000000000000000000002B
68912+:10B52000000000000000000000000000000000001B
68913+:10B53000000000000000000000000000000000000B
68914+:10B5400000000000000000000000000000000000FB
68915+:10B5500000000000000000000000000000000000EB
68916+:10B5600000000000000000000000000000000000DB
68917+:10B5700000000000000000000000000000000000CB
68918+:10B5800000000000000000000000000000000000BB
68919+:10B5900000000000000000000000000000000000AB
68920+:10B5A000000000000000000000000000000000009B
68921+:10B5B000000000000000000000000000000000008B
68922+:10B5C000000000000000000000000000000000007B
68923+:10B5D000000000000000000000000000000000006B
68924+:10B5E000000000000000000000000000000000005B
68925+:10B5F000000000000000000000000000000000004B
68926+:10B60000000000000000000000000000000000003A
68927+:10B61000000000000000000000000000000000002A
68928+:10B62000000000000000000000000000000000001A
68929+:10B63000000000000000000000000000000000000A
68930+:10B6400000000000000000000000000000000000FA
68931+:10B6500000000000000000000000000000000000EA
68932+:10B6600000000000000000000000000000000000DA
68933+:10B6700000000000000000000000000000000000CA
68934+:10B6800000000000000000000000000000000000BA
68935+:10B6900000000000000000000000000000000000AA
68936+:10B6A000000000000000000000000000000000009A
68937+:10B6B000000000000000000000000000000000008A
68938+:10B6C000000000000000000000000000000000007A
68939+:10B6D000000000000000000000000000000000006A
68940+:10B6E000000000000000000000000000000000005A
68941+:10B6F000000000000000000000000000000000004A
68942+:10B700000000000000000000000000000000000039
68943+:10B710000000000000000000000000000000000029
68944+:10B720000000000000000000000000000000000019
68945+:10B730000000000000000000000000000000000009
68946+:10B7400000000000000000000000000000000000F9
68947+:10B7500000000000000000000000000000000000E9
68948+:10B7600000000000000000000000000000000000D9
68949+:10B7700000000000000000000000000000000000C9
68950+:10B7800000000000000000000000000000000000B9
68951+:10B7900000000000000000000000000000000000A9
68952+:10B7A0000000000000000000000000000000000099
68953+:10B7B0000000000000000000000000000000000089
68954+:10B7C0000000000000000000000000000000000079
68955+:10B7D0000000000000000000000000000000000069
68956+:10B7E0000000000000000000000000000000000059
68957+:10B7F0000000000000000000000000000000000049
68958+:10B800000000000000000000000000000000000038
68959+:10B810000000000000000000000000000000000028
68960+:10B820000000000000000000000000000000000018
68961+:10B830000000000000000000000000000000000008
68962+:10B8400000000000000000000000000000000000F8
68963+:10B8500000000000000000000000000000000000E8
68964+:10B8600000000000000000000000000000000000D8
68965+:10B8700000000000000000000000000000000000C8
68966+:10B8800000000000000000000000000000000000B8
68967+:10B8900000000000000000000000000000000000A8
68968+:10B8A0000000000000000000000000000000000098
68969+:10B8B0000000000000000000000000000000000088
68970+:10B8C0000000000000000000000000000000000078
68971+:10B8D0000000000000000000000000000000000068
68972+:10B8E0000000000000000000000000000000000058
68973+:10B8F0000000000000000000000000000000000048
68974+:10B900000000000000000000000000000000000037
68975+:10B910000000000000000000000000000000000027
68976+:10B920000000000000000000000000000000000017
68977+:10B930000000000000000000000000000000000007
68978+:10B9400000000000000000000000000000000000F7
68979+:10B9500000000000000000000000000000000000E7
68980+:10B9600000000000000000000000000000000000D7
68981+:10B9700000000000000000000000000000000000C7
68982+:10B9800000000000000000000000000000000000B7
68983+:10B9900000000000000000000000000000000000A7
68984+:10B9A0000000000000000000000000000000000097
68985+:10B9B0000000000000000000000000000000000087
68986+:10B9C0000000000000000000000000000000000077
68987+:10B9D0000000000000000000000000000000000067
68988+:10B9E0000000000000000000000000000000000057
68989+:10B9F0000000000000000000000000000000000047
68990+:10BA00000000000000000000000000000000000036
68991+:10BA10000000000000000000000000000000000026
68992+:10BA20000000000000000000000000000000000016
68993+:10BA30000000000000000000000000000000000006
68994+:10BA400000000000000000000000000000000000F6
68995+:10BA500000000000000000000000000000000000E6
68996+:10BA600000000000000000000000000000000000D6
68997+:10BA700000000000000000000000000000000000C6
68998+:10BA800000000000000000000000000000000000B6
68999+:10BA900000000000000000000000000000000000A6
69000+:10BAA0000000000000000000000000000000000096
69001+:10BAB0000000000000000000000000000000000086
69002+:10BAC0000000000000000000000000000000000076
69003+:10BAD0000000000000000000000000000000000066
69004+:10BAE0000000000000000000000000000000000056
69005+:10BAF0000000000000000000000000000000000046
69006+:10BB00000000000000000000000000000000000035
69007+:10BB10000000000000000000000000000000000025
69008+:10BB20000000000000000000000000000000000015
69009+:10BB30000000000000000000000000000000000005
69010+:10BB400000000000000000000000000000000000F5
69011+:10BB500000000000000000000000000000000000E5
69012+:10BB600000000000000000000000000000000000D5
69013+:10BB700000000000000000000000000000000000C5
69014+:10BB800000000000000000000000000000000000B5
69015+:10BB900000000000000000000000000000000000A5
69016+:10BBA0000000000000000000000000000000000095
69017+:10BBB0000000000000000000000000000000000085
69018+:10BBC0000000000000000000000000000000000075
69019+:10BBD0000000000000000000000000000000000065
69020+:10BBE0000000000000000000000000000000000055
69021+:10BBF0000000000000000000000000000000000045
69022+:10BC00000000000000000000000000000000000034
69023+:10BC10000000000000000000000000000000000024
69024+:10BC20000000000000000000000000000000000014
69025+:10BC30000000000000000000000000000000000004
69026+:10BC400000000000000000000000000000000000F4
69027+:10BC500000000000000000000000000000000000E4
69028+:10BC600000000000000000000000000000000000D4
69029+:10BC700000000000000000000000000000000000C4
69030+:10BC800000000000000000000000000000000000B4
69031+:10BC900000000000000000000000000000000000A4
69032+:10BCA0000000000000000000000000000000000094
69033+:10BCB0000000000000000000000000000000000084
69034+:10BCC0000000000000000000000000000000000074
69035+:10BCD0000000000000000000000000000000000064
69036+:10BCE0000000000000000000000000000000000054
69037+:10BCF0000000000000000000000000000000000044
69038+:10BD00000000000000000000000000000000000033
69039+:10BD10000000000000000000000000000000000023
69040+:10BD20000000000000000000000000000000000013
69041+:10BD30000000000000000000000000000000000003
69042+:10BD400000000000000000000000000000000000F3
69043+:10BD500000000000000000000000000000000000E3
69044+:10BD600000000000000000000000000000000000D3
69045+:10BD700000000000000000000000000000000000C3
69046+:10BD800000000000000000000000000000000000B3
69047+:10BD900000000000000000000000000000000000A3
69048+:10BDA0000000000000000000000000000000000093
69049+:10BDB0000000000000000000000000000000000083
69050+:10BDC0000000000000000000000000000000000073
69051+:10BDD0000000000000000000000000000000000063
69052+:10BDE0000000000000000000000000000000000053
69053+:10BDF0000000000000000000000000000000000043
69054+:10BE00000000000000000000000000000000000032
69055+:10BE10000000000000000000000000000000000022
69056+:10BE20000000000000000000000000000000000012
69057+:10BE30000000000000000000000000000000000002
69058+:10BE400000000000000000000000000000000000F2
69059+:10BE500000000000000000000000000000000000E2
69060+:10BE600000000000000000000000000000000000D2
69061+:10BE700000000000000000000000000000000000C2
69062+:10BE800000000000000000000000000000000000B2
69063+:10BE900000000000000000000000000000000000A2
69064+:10BEA0000000000000000000000000000000000092
69065+:10BEB0000000000000000000000000000000000082
69066+:10BEC0000000000000000000000000000000000072
69067+:10BED0000000000000000000000000000000000062
69068+:10BEE0000000000000000000000000000000000052
69069+:10BEF0000000000000000000000000000000000042
69070+:10BF00000000000000000000000000000000000031
69071+:10BF10000000000000000000000000000000000021
69072+:10BF20000000000000000000000000000000000011
69073+:10BF30000000000000000000000000000000000001
69074+:10BF400000000000000000000000000000000000F1
69075+:10BF500000000000000000000000000000000000E1
69076+:10BF600000000000000000000000000000000000D1
69077+:10BF700000000000000000000000000000000000C1
69078+:10BF800000000000000000000000000000000000B1
69079+:10BF900000000000000000000000000000000000A1
69080+:10BFA0000000000000000000000000000000000091
69081+:10BFB0000000000000000000000000000000000081
69082+:10BFC0000000000000000000000000000000000071
69083+:10BFD0000000000000000000000000000000000061
69084+:10BFE0000000000000000000000000000000000051
69085+:10BFF0000000000000000000000000000000000041
69086+:10C000000000000000000000000000000000000030
69087+:10C010000000000000000000000000000000000020
69088+:10C020000000000000000000000000000000000010
69089+:10C030000000000000000000000000000000000000
69090+:10C0400000000000000000000000000000000000F0
69091+:10C0500000000000000000000000000000000000E0
69092+:10C0600000000000000000000000000000000000D0
69093+:10C0700000000000000000000000000000000000C0
69094+:10C0800000000000000000000000000000000000B0
69095+:10C0900000000000000000000000000000000000A0
69096+:10C0A0000000000000000000000000000000000090
69097+:10C0B0000000000000000000000000000000000080
69098+:10C0C0000000000000000000000000000000000070
69099+:10C0D0000000000000000000000000000000000060
69100+:10C0E0000000000000000000000000000000000050
69101+:10C0F0000000000000000000000000000000000040
69102+:10C10000000000000000000000000000000000002F
69103+:10C11000000000000000000000000000000000001F
69104+:10C12000000000000000000000000000000000000F
69105+:10C1300000000000000000000000000000000000FF
69106+:10C1400000000000000000000000000000000000EF
69107+:10C1500000000000000000000000000000000000DF
69108+:10C1600000000000000000000000000000000000CF
69109+:10C1700000000000000000000000000000000000BF
69110+:10C1800000000000000000000000000000000000AF
69111+:10C19000000000000000000000000000000000009F
69112+:10C1A000000000000000000000000000000000008F
69113+:10C1B000000000000000000000000000000000007F
69114+:10C1C000000000000000000000000000000000006F
69115+:10C1D000000000000000000000000000000000005F
69116+:10C1E000000000000000000000000000000000004F
69117+:10C1F000000000000000000000000000000000003F
69118+:10C20000000000000000000000000000000000002E
69119+:10C21000000000000000000000000000000000001E
69120+:10C22000000000000000000000000000000000000E
69121+:10C2300000000000000000000000000000000000FE
69122+:10C2400000000000000000000000000000000000EE
69123+:10C2500000000000000000000000000000000000DE
69124+:10C2600000000000000000000000000000000000CE
69125+:10C2700000000000000000000000000000000000BE
69126+:10C2800000000000000000000000000000000000AE
69127+:10C29000000000000000000000000000000000009E
69128+:10C2A000000000000000000000000000000000008E
69129+:10C2B000000000000000000000000000000000007E
69130+:10C2C000000000000000000000000000000000006E
69131+:10C2D000000000000000000000000000000000005E
69132+:10C2E000000000000000000000000000000000004E
69133+:10C2F000000000000000000000000000000000003E
69134+:10C30000000000000000000000000000000000002D
69135+:10C31000000000000000000000000000000000001D
69136+:10C32000000000000000000000000000000000000D
69137+:10C3300000000000000000000000000000000000FD
69138+:10C3400000000000000000000000000000000000ED
69139+:10C3500000000000000000000000000000000000DD
69140+:10C3600000000000000000000000000000000000CD
69141+:10C3700000000000000000000000000000000000BD
69142+:10C3800000000000000000000000000000000000AD
69143+:10C39000000000000000000000000000000000009D
69144+:10C3A000000000000000000000000000000000008D
69145+:10C3B000000000000000000000000000000000007D
69146+:10C3C000000000000000000000000000000000006D
69147+:10C3D000000000000000000000000000000000005D
69148+:10C3E000000000000000000000000000000000004D
69149+:10C3F000000000000000000000000000000000003D
69150+:10C40000000000000000000000000000000000002C
69151+:10C41000000000000000000000000000000000001C
69152+:10C42000000000000000000000000000000000000C
69153+:10C4300000000000000000000000000000000000FC
69154+:10C4400000000000000000000000000000000000EC
69155+:10C4500000000000000000000000000000000000DC
69156+:10C4600000000000000000000000000000000000CC
69157+:10C4700000000000000000000000000000000000BC
69158+:10C4800000000000000000000000000000000000AC
69159+:10C49000000000000000000000000000000000009C
69160+:10C4A000000000000000000000000000000000008C
69161+:10C4B000000000000000000000000000000000007C
69162+:10C4C000000000000000000000000000000000006C
69163+:10C4D000000000000000000000000000000000005C
69164+:10C4E000000000000000000000000000000000004C
69165+:10C4F000000000000000000000000000000000003C
69166+:10C50000000000000000000000000000000000002B
69167+:10C51000000000000000000000000000000000001B
69168+:10C52000000000000000000000000000000000000B
69169+:10C5300000000000000000000000000000000000FB
69170+:10C5400000000000000000000000000000000000EB
69171+:10C5500000000000000000000000000000000000DB
69172+:10C5600000000000000000000000000000000000CB
69173+:10C5700000000000000000000000000000000000BB
69174+:10C5800000000000000000000000000000000000AB
69175+:10C59000000000000000000000000000000000009B
69176+:10C5A000000000000000000000000000000000008B
69177+:10C5B000000000000000000000000000000000007B
69178+:10C5C000000000000000000000000000000000006B
69179+:10C5D000000000000000000000000000000000005B
69180+:10C5E000000000000000000000000000000000004B
69181+:10C5F000000000000000000000000000000000003B
69182+:10C60000000000000000000000000000000000002A
69183+:10C61000000000000000000000000000000000001A
69184+:10C62000000000000000000000000000000000000A
69185+:10C6300000000000000000000000000000000000FA
69186+:10C6400000000000000000000000000000000000EA
69187+:10C6500000000000000000000000000000000000DA
69188+:10C6600000000000000000000000000000000000CA
69189+:10C6700000000000000000000000000000000000BA
69190+:10C6800000000000000000000000000000000000AA
69191+:10C69000000000000000000000000000000000009A
69192+:10C6A000000000000000000000000000000000008A
69193+:10C6B000000000000000000000000000000000007A
69194+:10C6C000000000000000000000000000000000006A
69195+:10C6D000000000000000000000000000000000005A
69196+:10C6E000000000000000000000000000000000004A
69197+:10C6F000000000000000000000000000000000003A
69198+:10C700000000000000000000000000000000000029
69199+:10C710000000000000000000000000000000000019
69200+:10C720000000000000000000000000000000000009
69201+:10C7300000000000000000000000000000000000F9
69202+:10C7400000000000000000000000000000000000E9
69203+:10C7500000000000000000000000000000000000D9
69204+:10C7600000000000000000000000000000000000C9
69205+:10C7700000000000000000000000000000000000B9
69206+:10C7800000000000000000000000000000000000A9
69207+:10C790000000000000000000000000000000000099
69208+:10C7A0000000000000000000000000000000000089
69209+:10C7B0000000000000000000000000000000000079
69210+:10C7C0000000000000000000000000000000000069
69211+:10C7D0000000000000000000000000000000000059
69212+:10C7E0000000000000000000000000000000000049
69213+:10C7F0000000000000000000000000000000000039
69214+:10C800000000000000000000000000000000000028
69215+:10C810000000000000000000000000000000000018
69216+:10C820000000000000000000000000000000000008
69217+:10C8300000000000000000000000000000000000F8
69218+:10C8400000000000000000000000000000000000E8
69219+:10C8500000000000000000000000000000000000D8
69220+:10C8600000000000000000000000000000000000C8
69221+:10C8700000000000000000000000000000000000B8
69222+:10C8800000000000000000000000000000000000A8
69223+:10C890000000000000000000000000000000000098
69224+:10C8A0000000000000000000000000000000000088
69225+:10C8B0000000000000000000000000000000000078
69226+:10C8C0000000000000000000000000000000000068
69227+:10C8D0000000000000000000000000000000000058
69228+:10C8E0000000000000000000000000000000000048
69229+:10C8F0000000000000000000000000000000000038
69230+:10C900000000000000000000000000000000000027
69231+:10C910000000000000000000000000000000000017
69232+:10C920000000000000000000000000000000000007
69233+:10C9300000000000000000000000000000000000F7
69234+:10C9400000000000000000000000000000000000E7
69235+:10C9500000000000000000000000000000000000D7
69236+:10C9600000000000000000000000000000000000C7
69237+:10C9700000000000000000000000000000000000B7
69238+:10C9800000000000000000000000000000000000A7
69239+:10C990000000000000000000000000000000000097
69240+:10C9A0000000000000000000000000000000000087
69241+:10C9B0000000000000000000000000000000000077
69242+:10C9C0000000000000000000000000000000000067
69243+:10C9D0000000000000000000000000000000000057
69244+:10C9E0000000000000000000000000000000000047
69245+:10C9F0000000000000000000000000000000000037
69246+:10CA00000000000000000000000000000000000026
69247+:10CA10000000000000000000000000000000000016
69248+:10CA20000000000000000000000000000000000006
69249+:10CA300000000000000000000000000000000000F6
69250+:10CA400000000000000000000000000000000000E6
69251+:10CA500000000000000000000000000000000000D6
69252+:10CA600000000000000000000000000000000000C6
69253+:10CA700000000000000000000000000000000000B6
69254+:10CA800000000000000000000000000000000000A6
69255+:10CA90000000000000000000000000000000000096
69256+:10CAA0000000000000000000000000000000000086
69257+:10CAB0000000000000000000000000000000000076
69258+:10CAC0000000000000000000000000000000000066
69259+:10CAD0000000000000000000000000000000000056
69260+:10CAE0000000000000000000000000000000000046
69261+:10CAF0000000000000000000000000000000000036
69262+:10CB00000000000000000000000000000000000025
69263+:10CB10000000000000000000000000000000000015
69264+:10CB20000000000000000000000000000000000005
69265+:10CB300000000000000000000000000000000000F5
69266+:10CB400000000000000000000000000000000000E5
69267+:10CB500000000000000000000000000000000000D5
69268+:10CB600000000000000000000000000000000000C5
69269+:10CB700000000000000000000000000000000000B5
69270+:10CB800000000000000000000000000000000000A5
69271+:10CB90000000000000000000000000000000000095
69272+:10CBA0000000000000000000000000000000000085
69273+:10CBB0000000000000000000000000000000000075
69274+:10CBC0000000000000000000000000000000000065
69275+:10CBD0000000000000000000000000000000000055
69276+:10CBE0000000000000000000000000000000000045
69277+:10CBF0000000000000000000000000000000000035
69278+:10CC00000000000000000000000000000000000024
69279+:10CC10000000000000000000000000000000000014
69280+:10CC20000000000000000000000000000000000004
69281+:10CC300000000000000000000000000000000000F4
69282+:10CC400000000000000000000000000000000000E4
69283+:10CC500000000000000000000000000000000000D4
69284+:10CC600000000000000000000000000000000000C4
69285+:10CC700000000000000000000000000000000000B4
69286+:10CC800000000000000000000000000000000000A4
69287+:10CC90000000000000000000000000000000000094
69288+:10CCA0000000000000000000000000000000000084
69289+:10CCB0000000000000000000000000000000000074
69290+:10CCC0000000000000000000000000000000000064
69291+:10CCD0000000000000000000000000000000000054
69292+:10CCE0000000000000000000000000000000000044
69293+:10CCF0000000000000000000000000000000000034
69294+:10CD00000000000000000000000000000000000023
69295+:10CD10000000000000000000000000000000000013
69296+:10CD20000000000000000000000000000000000003
69297+:10CD300000000000000000000000000000000000F3
69298+:10CD400000000000000000000000000000000000E3
69299+:10CD500000000000000000000000000000000000D3
69300+:10CD600000000000000000000000000000000000C3
69301+:10CD700000000000000000000000000000000000B3
69302+:10CD800000000000000000000000000000000000A3
69303+:10CD90000000000000000000000000000000000093
69304+:10CDA0000000000000000000000000000000000083
69305+:10CDB0000000000000000000000000000000000073
69306+:10CDC0000000000000000000000000000000000063
69307+:10CDD0000000000000000000000000000000000053
69308+:10CDE0000000000000000000000000000000000043
69309+:10CDF0000000000000000000000000000000000033
69310+:10CE00000000000000000000000000000000000022
69311+:10CE10000000000000000000000000000000000012
69312+:10CE20000000000000000000000000000000000002
69313+:10CE300000000000000000000000000000000000F2
69314+:10CE400000000000000000000000000000000000E2
69315+:10CE500000000000000000000000000000000000D2
69316+:10CE600000000000000000000000000000000000C2
69317+:10CE700000000000000000000000000000000000B2
69318+:10CE800000000000000000000000000000000000A2
69319+:10CE90000000000000000000000000000000000092
69320+:10CEA0000000000000000000000000000000000082
69321+:10CEB0000000000000000000000000000000000072
69322+:10CEC0000000000000000000000000000000000062
69323+:10CED0000000000000000000000000000000000052
69324+:10CEE0000000000000000000000000000000000042
69325+:10CEF0000000000000000000000000000000000032
69326+:10CF00000000000000000000000000000000000021
69327+:10CF10000000000000000000000000000000000011
69328+:10CF20000000000000000000000000000000000001
69329+:10CF300000000000000000000000000000000000F1
69330+:10CF400000000000000000000000000000000000E1
69331+:10CF500000000000000000000000000000000000D1
69332+:10CF600000000000000000000000000000000000C1
69333+:10CF700000000000000000000000000000000000B1
69334+:10CF800000000000000000000000000000000000A1
69335+:10CF90000000000000000000000000000000000091
69336+:10CFA0000000000000000000000000000000000081
69337+:10CFB0000000000000000000000000000000000071
69338+:10CFC0000000000000000000000000000000000061
69339+:10CFD0000000000000000000000000000000000051
69340+:10CFE0000000000000000000000000000000000041
69341+:10CFF0000000000000000000000000000000000031
69342+:10D000000000000000000000000000000000000020
69343+:10D010000000000000000000000000000000000010
69344+:10D020000000000000000000000000000000000000
69345+:10D0300000000000000000000000000000000000F0
69346+:10D0400000000000000000000000000000000000E0
69347+:10D0500000000000000000000000000000000000D0
69348+:10D0600000000000000000000000000000000000C0
69349+:10D0700000000000000000000000000000000000B0
69350+:10D0800000000000000000000000000000000000A0
69351+:10D090000000000000000000000000000000000090
69352+:10D0A0000000000000000000000000000000000080
69353+:10D0B0000000000000000000000000000000000070
69354+:10D0C0000000000000000000000000000000000060
69355+:10D0D0000000000000000000000000000000000050
69356+:10D0E0000000000000000000000000000000000040
69357+:10D0F0000000000000000000000000000000000030
69358+:10D10000000000000000000000000000000000001F
69359+:10D11000000000000000000000000000000000000F
69360+:10D1200000000000000000000000000000000000FF
69361+:10D1300000000000000000000000000000000000EF
69362+:10D1400000000000000000000000000000000000DF
69363+:10D1500000000000000000000000000000000000CF
69364+:10D1600000000000000000000000000000000000BF
69365+:10D1700000000000000000000000000000000000AF
69366+:10D18000000000000000000000000000000000009F
69367+:10D19000000000000000000000000000000000008F
69368+:10D1A000000000000000000000000000000000007F
69369+:10D1B000000000000000000000000000000000006F
69370+:10D1C000000000000000000000000000000000005F
69371+:10D1D000000000000000000000000000000000004F
69372+:10D1E000000000000000000000000000000000003F
69373+:10D1F000000000000000000000000000000000002F
69374+:10D20000000000000000000000000000000000001E
69375+:10D21000000000000000000000000000000000000E
69376+:10D2200000000000000000000000000000000000FE
69377+:10D2300000000000000000000000000000000000EE
69378+:10D2400000000000000000000000000000000000DE
69379+:10D2500000000000000000000000000000000000CE
69380+:10D2600000000000000000000000000000000000BE
69381+:10D2700000000000000000000000000000000000AE
69382+:10D28000000000000000000000000000000000009E
69383+:10D29000000000000000000000000000000000008E
69384+:10D2A000000000000000000000000000000000007E
69385+:10D2B000000000000000000000000000000000006E
69386+:10D2C000000000000000000000000000000000005E
69387+:10D2D000000000000000000000000000000000004E
69388+:10D2E000000000000000000000000000000000003E
69389+:10D2F000000000000000000000000000000000002E
69390+:10D30000000000000000000000000000000000001D
69391+:10D31000000000000000000000000000000000000D
69392+:10D3200000000000000000000000000000000000FD
69393+:10D3300000000000000000000000000000000000ED
69394+:10D3400000000000000000000000000000000000DD
69395+:10D3500000000000000000000000000000000000CD
69396+:10D3600000000000000000000000000000000000BD
69397+:10D3700000000000000000000000000000000000AD
69398+:10D38000000000000000000000000000000000009D
69399+:10D39000000000000000000000000000000000008D
69400+:10D3A000000000000000000000000000000000007D
69401+:10D3B000000000000000000000000000000000006D
69402+:10D3C000000000000000000000000000000000005D
69403+:10D3D000000000000000000000000000000000004D
69404+:10D3E000000000000000000000000000000000003D
69405+:10D3F000000000000000000000000000000000002D
69406+:10D40000000000000000000000000000000000001C
69407+:10D41000000000000000000000000000000000000C
69408+:10D4200000000000000000000000000000000000FC
69409+:10D4300000000000000000000000000000000000EC
69410+:10D4400000000000000000000000000000000000DC
69411+:10D4500000000000000000000000000000000000CC
69412+:10D4600000000000000000000000000000000000BC
69413+:10D4700000000000000000000000000000000000AC
69414+:10D48000000000000000000000000000000000009C
69415+:10D49000000000000000000000000000000000008C
69416+:10D4A000000000000000000000000000000000007C
69417+:10D4B000000000000000000000000000000000006C
69418+:10D4C000000000000000000000000000000000005C
69419+:10D4D000000000000000000000000000000000004C
69420+:10D4E000000000000000000000000000000000003C
69421+:10D4F000000000000000000000000000000000002C
69422+:10D50000000000000000000000000000000000001B
69423+:10D51000000000000000000000000000000000000B
69424+:10D5200000000000000000000000000000000000FB
69425+:10D5300000000000000000000000000000000000EB
69426+:10D5400000000000000000000000000000000000DB
69427+:10D5500000000000000000000000000000000000CB
69428+:10D5600000000000000000000000000000000000BB
69429+:10D5700000000000000000000000000000000000AB
69430+:10D58000000000000000000000000000000000009B
69431+:10D59000000000000000000000000000000000008B
69432+:10D5A000000000000000000000000000000000007B
69433+:10D5B000000000000000000000000000000000006B
69434+:10D5C000000000000000000000000000000000005B
69435+:10D5D000000000000000000000000000000000004B
69436+:10D5E000000000000000000000000000000000003B
69437+:10D5F000000000000000000000000000000000002B
69438+:10D60000000000000000000000000000000000001A
69439+:10D61000000000000000000000000000000000000A
69440+:10D6200000000000000000000000000000000000FA
69441+:10D6300000000000000000000000000000000000EA
69442+:10D6400000000000000000000000000000000000DA
69443+:10D6500000000000000000000000000000000000CA
69444+:10D6600000000000000000000000000000000000BA
69445+:10D6700000000000000000000000000000000000AA
69446+:10D68000000000000000000000000000000000009A
69447+:10D69000000000000000000000000000000000008A
69448+:10D6A000000000000000000000000000000000007A
69449+:10D6B000000000000000000000000000000000006A
69450+:10D6C000000000000000000000000000000000005A
69451+:10D6D000000000000000000000000000000000004A
69452+:10D6E000000000000000000000000000000000003A
69453+:10D6F000000000000000000000000000000000002A
69454+:10D700000000000000000000000000000000000019
69455+:10D710000000000000000000000000000000000009
69456+:10D7200000000000000000000000000000000000F9
69457+:10D7300000000000000000000000000000000000E9
69458+:10D7400000000000000000000000000000000000D9
69459+:10D7500000000000000000000000000000000000C9
69460+:10D7600000000000000000000000000000000000B9
69461+:10D7700000000000000000000000000000000000A9
69462+:10D780000000000000000000000000000000000099
69463+:10D790000000000000000000000000000000000089
69464+:10D7A0000000000000000000000000000000000079
69465+:10D7B0000000000000000000000000000000000069
69466+:10D7C0000000000000000000000000000000000059
69467+:10D7D0000000000000000000000000000000000049
69468+:10D7E0000000000000000000000000000000000039
69469+:10D7F0000000000000000000000000000000000029
69470+:10D800000000000000000000000000000000000018
69471+:10D810000000000000000000000000000000000008
69472+:10D8200000000000000000000000000000000000F8
69473+:10D8300000000000000000000000000000000000E8
69474+:10D8400000000000000000000000000000000000D8
69475+:10D8500000000000000000000000000000000000C8
69476+:10D8600000000000000000000000000000000000B8
69477+:10D8700000000000000000000000000000000000A8
69478+:10D880000000000000000000000000000000000098
69479+:10D890000000000000000000000000000000000088
69480+:10D8A0000000000000000000000000000000000078
69481+:10D8B0000000000000000000000000000000000068
69482+:10D8C0000000000000000000000000000000000058
69483+:10D8D0000000000000000000000000000000000048
69484+:10D8E0000000000000000000000000000000000038
69485+:10D8F0000000000000000000000000000000000028
69486+:10D900000000000000000000000000000000000017
69487+:10D910000000000000000000000000000000000007
69488+:10D9200000000000000000000000000000000000F7
69489+:10D9300000000000000000000000000000000000E7
69490+:10D9400000000000000000000000000000000000D7
69491+:10D9500000000000000000000000000000000000C7
69492+:10D9600000000000000000000000000000000000B7
69493+:10D9700000000000000000000000000000000000A7
69494+:10D980000000000000000000000000000000000097
69495+:10D990000000000000000000000000000000000087
69496+:10D9A0000000000000000000000000000000000077
69497+:10D9B0000000000000000000000000000000000067
69498+:10D9C0000000000000000000000000000000000057
69499+:10D9D0000000000000000000000000000000000047
69500+:10D9E0000000000000000000000000000000000037
69501+:10D9F0000000000000000000000000000000000027
69502+:10DA00000000000000000000000000000000000016
69503+:10DA10000000000000000000000000000000000006
69504+:10DA200000000000000000000000000000000000F6
69505+:10DA300000000000000000000000000000000000E6
69506+:10DA400000000000000000000000000000000000D6
69507+:10DA500000000000000000000000000000000000C6
69508+:10DA600000000000000000000000000000000000B6
69509+:10DA700000000000000000000000000000000000A6
69510+:10DA80000000000000000000000000000000000096
69511+:10DA90000000000000000000000000000000000086
69512+:10DAA0000000000000000000000000000000000076
69513+:10DAB0000000000000000000000000000000000066
69514+:10DAC0000000000000000000000000000000000056
69515+:10DAD0000000000000000000000000000000000046
69516+:10DAE0000000000000000000000000000000000036
69517+:10DAF0000000000000000000000000000000000026
69518+:10DB00000000000000000000000000000000000015
69519+:10DB10000000000000000000000000000000000005
69520+:10DB200000000000000000000000000000000000F5
69521+:10DB300000000000000000000000000000000000E5
69522+:10DB400000000000000000000000000000000000D5
69523+:10DB500000000000000000000000000000000000C5
69524+:10DB600000000000000000000000000000000000B5
69525+:10DB700000000000000000000000000000000000A5
69526+:10DB80000000000000000000000000000000000095
69527+:10DB90000000000000000000000000000000000085
69528+:10DBA0000000000000000000000000000000000075
69529+:10DBB0000000000000000000000000000000000065
69530+:10DBC0000000000000000000000000000000000055
69531+:10DBD0000000000000000000000000000000000045
69532+:10DBE0000000000000000000000000000000000035
69533+:10DBF0000000000000000000000000000000000025
69534+:10DC00000000000000000000000000000000000014
69535+:10DC10000000000000000000000000000000000004
69536+:10DC200000000000000000000000000000000000F4
69537+:10DC300000000000000000000000000000000000E4
69538+:10DC400000000000000000000000000000000000D4
69539+:10DC500000000000000000000000000000000000C4
69540+:10DC600000000000000000000000000000000000B4
69541+:10DC700000000000000000000000000000000000A4
69542+:10DC80000000000000000000000000000000000094
69543+:10DC90000000000000000000000000000000000084
69544+:10DCA0000000000000000000000000000000000074
69545+:10DCB0000000000000000000000000000000000064
69546+:10DCC0000000000000000000000000000000000054
69547+:10DCD0000000000000000000000000000000000044
69548+:10DCE0000000000000000000000000000000000034
69549+:10DCF0000000000000000000000000000000000024
69550+:10DD00000000000000000000000000000000000013
69551+:10DD10000000000000000000000000000000000003
69552+:10DD200000000000000000000000000000000000F3
69553+:10DD300000000000000000000000000000000000E3
69554+:10DD400000000000000000000000000000000000D3
69555+:10DD500000000000000000000000000000000000C3
69556+:10DD600000000000000000000000000000000000B3
69557+:10DD700000000000000000000000000000000000A3
69558+:10DD80000000000000000000000000000000000093
69559+:10DD90000000000000000000000000000000000083
69560+:10DDA0000000000000000000000000000000000073
69561+:10DDB0000000000000000000000000000000000063
69562+:10DDC0000000000000000000000000000000000053
69563+:10DDD0000000000000000000000000000000000043
69564+:10DDE0000000000000000000000000000000000033
69565+:10DDF0000000000000000000000000000000000023
69566+:10DE00000000000000000000000000000000000012
69567+:10DE10000000000000000000000000000000000002
69568+:10DE200000000000000000000000000000000000F2
69569+:10DE300000000000000000000000000000000000E2
69570+:10DE400000000000000000000000000000000000D2
69571+:10DE500000000000000000000000000000000000C2
69572+:10DE600000000000000000000000000000000000B2
69573+:10DE700000000000000000000000000000000000A2
69574+:10DE80000000000000000000000000000000000092
69575+:10DE90000000000000000000000000000000000082
69576+:10DEA0000000000000000000000000000000000072
69577+:10DEB0000000000000000000000000000000000062
69578+:10DEC0000000000000000000000000000000000052
69579+:10DED0000000000000000000000000000000000042
69580+:10DEE0000000000000000000000000000000000032
69581+:10DEF0000000000000000000000000000000000022
69582+:10DF00000000000000000000000000000000000011
69583+:10DF10000000000000000000000000000000000001
69584+:10DF200000000000000000000000000000000000F1
69585+:10DF300000000000000000000000000000000000E1
69586+:10DF400000000000000000000000000000000000D1
69587+:10DF500000000000000000000000000000000000C1
69588+:10DF600000000000000000000000000000000000B1
69589+:10DF700000000000000000000000000000000000A1
69590+:10DF80000000000000000000000000000000000091
69591+:10DF90000000000000000000000000000000000081
69592+:10DFA0000000000000000000000000000000000071
69593+:10DFB0000000000000000000000000000000000061
69594+:10DFC0000000000000000000000000000000000051
69595+:10DFD0000000000000000000000000000000000041
69596+:10DFE0000000000000000000000000000000000031
69597+:10DFF0000000000000000000000000000000000021
69598+:10E000000000000000000000000000000000000010
69599+:10E010000000000000000000000000000000000000
69600+:10E0200000000000000000000000000000000000F0
69601+:10E0300000000000000000000000000000000000E0
69602+:10E0400000000000000000000000000000000000D0
69603+:10E0500000000000000000000000000000000000C0
69604+:10E0600000000000000000000000000000000000B0
69605+:10E0700000000000000000000000000000000000A0
69606+:10E080000000000000000000000000000000000090
69607+:10E090000000000000000000000000000000000080
69608+:10E0A0000000000000000000000000000000000070
69609+:10E0B0000000000000000000000000000000000060
69610+:10E0C0000000000000000000000000000000000050
69611+:10E0D0000000000000000000000000000000000040
69612+:10E0E0000000000000000000000000000000000030
69613+:10E0F0000000000000000000000000000000000020
69614+:10E10000000000000000000000000000000000000F
69615+:10E1100000000000000000000000000000000000FF
69616+:10E1200000000000000000000000000000000000EF
69617+:10E1300000000000000000000000000000000000DF
69618+:10E1400000000000000000000000000000000000CF
69619+:10E1500000000000000000000000000000000000BF
69620+:10E1600000000000000000000000000000000000AF
69621+:10E17000000000000000000000000000000000009F
69622+:10E18000000000000000000000000000000000008F
69623+:10E19000000000000000000000000000000000007F
69624+:10E1A000000000000000000000000000000000006F
69625+:10E1B000000000000000000000000000000000005F
69626+:10E1C000000000000000000000000000000000004F
69627+:10E1D000000000000000000000000000000000003F
69628+:10E1E000000000000000000000000000000000002F
69629+:10E1F000000000000000000000000000000000809F
69630+:10E20000000000000000000000000000000000000E
69631+:10E2100000000000000000000000000000000000FE
69632+:10E220000000000A000000000000000000000000E4
69633+:10E2300010000003000000000000000D0000000DB1
69634+:10E240003C020801244295C03C030801246397FC6A
69635+:10E25000AC4000000043202B1480FFFD244200044A
69636+:10E260003C1D080037BD9FFC03A0F0213C100800B6
69637+:10E27000261032103C1C0801279C95C00E0012BECF
69638+:10E28000000000000000000D3C02800030A5FFFFF0
69639+:10E2900030C600FF344301803C0880008D0901B87E
69640+:10E2A0000520FFFE00000000AC6400002404000212
69641+:10E2B000A4650008A066000AA064000BAC67001803
69642+:10E2C0003C03100003E00008AD0301B83C0560000A
69643+:10E2D0008CA24FF80440FFFE00000000ACA44FC029
69644+:10E2E0003C0310003C040200ACA44FC403E000084F
69645+:10E2F000ACA34FF89486000C00A050212488001491
69646+:10E3000000062B0200051080004448210109182B4B
69647+:10E310001060001100000000910300002C6400094F
69648+:10E320005080000991190001000360803C0D080134
69649+:10E3300025AD9258018D58218D67000000E000083E
69650+:10E340000000000091190001011940210109302B42
69651+:10E3500054C0FFF29103000003E000080000102108
69652+:10E360000A000CCC25080001910F0001240E000AC0
69653+:10E3700015EE00400128C8232F38000A1700003D81
69654+:10E38000250D00028D580000250F0006370E0100F4
69655+:10E39000AD4E0000910C000291AB000191A400026F
69656+:10E3A00091A60003000C2E00000B3C0000A71025D6
69657+:10E3B00000041A000043C8250326C025AD580004F8
69658+:10E3C000910E000691ED000191E7000291E5000336
69659+:10E3D000000E5E00000D6400016C30250007220075
69660+:10E3E00000C41025004518252508000A0A000CCC99
69661+:10E3F000AD430008910F000125040002240800022B
69662+:10E4000055E80001012020210A000CCC00804021A9
69663+:10E41000910C0001240B0003158B00160000000076
69664+:10E420008D580000910E000225080003370D0008EA
69665+:10E43000A14E00100A000CCCAD4D00009119000156
69666+:10E44000240F0004172F000B0000000091070002AA
69667+:10E45000910400038D43000000072A0000A410254A
69668+:10E460003466000425080004AD42000C0A000CCC00
69669+:10E47000AD46000003E000082402000127BDFFE8CC
69670+:10E48000AFBF0014AFB000100E00164E0080802108
69671+:10E490003C0480083485008090A600052403FFFE1C
69672+:10E4A0000200202100C310248FBF00148FB0001081
69673+:10E4B000A0A200050A00165827BD001827BDFFE8D6
69674+:10E4C000AFB00010AFBF00140E000FD40080802149
69675+:10E4D0003C06800834C5008090A40000240200504F
69676+:10E4E000308300FF106200073C09800002002021F9
69677+:10E4F0008FBF00148FB00010AD2001800A00108F74
69678+:10E5000027BD0018240801003C07800002002021DC
69679+:10E510008FBF00148FB00010ACE801800A00108F8C
69680+:10E5200027BD001827BDFF783C058008AFBE0080DE
69681+:10E53000AFB7007CAFB3006CAFB10064AFBF008475
69682+:10E54000AFB60078AFB50074AFB40070AFB200687A
69683+:10E55000AFB0006034A600803C0580008CB201287A
69684+:10E5600090C400098CA701043C020001309100FF17
69685+:10E5700000E218240000B8210000F021106000071C
69686+:10E58000000098213C0908008D2931F02413000176
69687+:10E59000252800013C010800AC2831F0ACA0008423
69688+:10E5A00090CC0005000C5827316A0001154000721C
69689+:10E5B000AFA0005090CD00002406002031A400FF41
69690+:10E5C00010860018240E0050108E009300000000EA
69691+:10E5D0003C1008008E1000DC260F00013C010800F2
69692+:10E5E000AC2F00DC0E0016C7000000000040182110
69693+:10E5F0008FBF00848FBE00808FB7007C8FB60078FD
69694+:10E600008FB500748FB400708FB3006C8FB2006848
69695+:10E610008FB100648FB000600060102103E000083B
69696+:10E6200027BD00880000000D3C1F8000AFA0003017
69697+:10E6300097E501168FE201043C04002030B9FFFF8A
69698+:10E64000004438240007182B00033140AFA60030E7
69699+:10E650008FF5010437F80C003C1600400338802188
69700+:10E6600002B6A02434C40040128000479215000D69
69701+:10E6700032A800201500000234860080008030217E
69702+:10E6800014C0009FAFA600303C0D800835A6008066
69703+:10E6900090CC0008318B0040516000063C06800899
69704+:10E6A000240E0004122E00A8240F0012122F003294
69705+:10E6B0003C06800834C401003C0280009447011AE3
69706+:10E6C0009619000E909F00088E18000830E3FFFF97
69707+:10E6D00003F9B00432B40004AFB6005CAFA3005835
69708+:10E6E0008E1600041280002EAFB8005434C3008090
69709+:10E6F000906800083105004014A0002500000000CB
69710+:10E700008C70005002D090230640000500000000ED
69711+:10E710008C71003402D1A82306A201678EE20008A2
69712+:10E72000126000063C1280003C1508008EB531F4E2
69713+:10E7300026B600013C010800AC3631F4AE4000447E
69714+:10E74000240300018FBF00848FBE00808FB7007C40
69715+:10E750008FB600788FB500748FB400708FB3006CE3
69716+:10E760008FB200688FB100648FB00060006010212C
69717+:10E7700003E0000827BD00880E000D2800002021BE
69718+:10E780000A000D75004018210A000D9500C02021D7
69719+:10E790000E00171702C020211440FFE10000000006
69720+:10E7A0003C0B8008356400808C8A003402CA482300
69721+:10E7B0000520001D000000003C1E08008FDE310017
69722+:10E7C00027D700013C010800AC3731001260000679
69723+:10E7D000024020213C1408008E9431F42690000160
69724+:10E7E0003C010800AC3031F40E00164E3C1E80088F
69725+:10E7F00037CD008091B700250240202136EE00047D
69726+:10E800000E001658A1AE00250E000CAC02402021CF
69727+:10E810000A000DCA240300013C17080126F796C020
69728+:10E820000A000D843C1F80008C86003002C66023E5
69729+:10E830001980000C2419000C908F004F3C14080024
69730+:10E840008E94310032B500FC35ED0001268E0001BA
69731+:10E850003C010800AC2E3100A08D004FAFA0005845
69732+:10E860002419000CAFB900308C9800300316A02397
69733+:10E870001A80010B8FA300580074F82A17E0FFD309
69734+:10E88000000000001074002A8FA5005802D4B021A7
69735+:10E8900000B410233044FFFFAFA4005832A8000298
69736+:10E8A0001100002E32AB00103C15800836B00080FD
69737+:10E8B0009216000832D30040526000FB8EE200083E
69738+:10E8C0000E00164E02402021240A0018A20A000958
69739+:10E8D000921100052409FFFE024020210229902404
69740+:10E8E0000E001658A2120005240400390000282149
69741+:10E8F0000E0016F2240600180A000DCA24030001B7
69742+:10E9000092FE000C3C0A800835490080001EBB00C6
69743+:10E910008D27003836F10081024020213225F08118
69744+:10E920000E000C9B30C600FF0A000DC10000000065
69745+:10E930003AA7000130E300011460FFA402D4B02123
69746+:10E940000A000E1D00000000024020210E001734B6
69747+:10E95000020028210A000D75004018211160FF7087
69748+:10E960003C0F80083C0D800835EE00808DC40038D7
69749+:10E970008FA300548DA60004006660231D80FF68ED
69750+:10E98000000000000064C02307020001AFA400548F
69751+:10E990003C1F08008FFF31E433F9000113200015FC
69752+:10E9A0008FAC00583C07800094E3011A10600012FD
69753+:10E9B0003C0680080E00216A024020213C03080129
69754+:10E9C000906396F13064000214800145000000005D
69755+:10E9D000306C0004118000078FAC0058306600FBDB
69756+:10E9E0003C010801A02696F132B500FCAFA000580A
69757+:10E9F0008FAC00583C06800834D30080AFB40018B8
69758+:10EA0000AFB60010AFAC00143C088000950B01209D
69759+:10EA10008E6F0030966A005C8FA3005C8FBF003061
69760+:10EA20003169FFFF3144FFFF8FAE005401341021E4
69761+:10EA3000350540000064382B0045C82103E7C02598
69762+:10EA4000AFB90020AFAF0028AFB80030AFAF00249F
69763+:10EA5000AFA0002CAFAE0034926D000831B40008B6
69764+:10EA6000168000BB020020218EE200040040F8095D
69765+:10EA700027A400108FAF003031F300025660000170
69766+:10EA800032B500FE3C048008349F008093F90008F2
69767+:10EA900033380040530000138FA400248C850004F9
69768+:10EAA0008FA7005410A700D52404001432B0000131
69769+:10EAB0001200000C8FA400242414000C1234011A3C
69770+:10EAC0002A2D000D11A001022413000E240E000AAD
69771+:10EAD000522E0001241E00088FAF002425E40001FF
69772+:10EAE000AFA400248FAA00143C0B80083565008079
69773+:10EAF000008A48218CB10030ACA9003090A4004EAF
69774+:10EB00008CA700303408FFFF0088180400E3F821C8
69775+:10EB1000ACBF00348FA600308FB900548FB8005CB2
69776+:10EB200030C200081040000B033898218CAC002044
69777+:10EB3000119300D330C600FF92EE000C8FA7003473
69778+:10EB400002402021000E6B0035B400800E000C9BAB
69779+:10EB50003285F0803C028008345000808E0F0030F7
69780+:10EB600001F1302318C00097264800803C070800B8
69781+:10EB70008CE731E42404FF80010418243118007F5D
69782+:10EB80003C1F80003C19800430F10001AFE300908D
69783+:10EB900012200006031928213C030801906396F116
69784+:10EBA00030690008152000C6306A00F73C10800864
69785+:10EBB00036040080908C004F318B000115600042BC
69786+:10EBC000000000003C0608008CC6319830CE0010D2
69787+:10EBD00051C0004230F9000190AF006B55E0003F9A
69788+:10EBE00030F9000124180001A0B8006B3C1180002E
69789+:10EBF0009622007A24470064A48700123C0D800806
69790+:10EC000035A5008090B40008329000401600000442
69791+:10EC10003C03800832AE000115C0008B00000000EC
69792+:10EC2000346400808C86002010D3000A3463010015
69793+:10EC30008C67000002C7782319E000978FBF00544B
69794+:10EC4000AC93002024130001AC760000AFB3005059
69795+:10EC5000AC7F000417C0004E000000008FA90050D8
69796+:10EC60001520000B000000003C030801906396F1A2
69797+:10EC7000306A00011140002E8FAB0058306400FE56
69798+:10EC80003C010801A02496F10A000D75000018212E
69799+:10EC90000E000CAC024020210A000F1300000000FF
69800+:10ECA0000A000E200000A0210040F80924040017EB
69801+:10ECB0000A000DCA240300010040F80924040016CC
69802+:10ECC0000A000DCA240300019094004F240DFFFE9A
69803+:10ECD000028D2824A085004F30F900011320000682
69804+:10ECE0003C0480083C030801906396F1307F0010DB
69805+:10ECF00017E00051306800EF34900080240A0001D2
69806+:10ED0000024020210E00164EA60A00129203002592
69807+:10ED100024090001AFA90050346200010240202103
69808+:10ED20000E001658A20200250A000EF93C0D8008BC
69809+:10ED30001160FE83000018218FA5003030AC000464
69810+:10ED40001180FE2C8FBF00840A000DCB240300012C
69811+:10ED500027A500380E000CB6AFA000385440FF4382
69812+:10ED60008EE200048FB40038329001005200FF3F61
69813+:10ED70008EE200048FA3003C8E6E0058006E682364
69814+:10ED800005A3FF39AE6300580A000E948EE200041A
69815+:10ED90000E00164E024020213C038008346800809B
69816+:10EDA000024020210E001658A11E000903C0302188
69817+:10EDB000240400370E0016F2000028210A000F116B
69818+:10EDC0008FA900508FAB00185960FF8D3C0D800853
69819+:10EDD0000E00164E02402021920C00252405000151
69820+:10EDE000AFA5005035820004024020210E001658C5
69821+:10EDF000A20200250A000EF93C0D800812240059D9
69822+:10EE00002A2300151060004D240900162408000C68
69823+:10EE10005628FF2732B000013C0A8008914C001BA5
69824+:10EE20002406FFBD241E000E01865824A14B001BA2
69825+:10EE30000A000EA532B000013C010801A02896F19D
69826+:10EE40000A000EF93C0D80088CB500308EFE0008DB
69827+:10EE50002404001826B6000103C0F809ACB600303F
69828+:10EE60003C030801906396F13077000116E0FF81C2
69829+:10EE7000306A00018FB200300A000D753243000481
69830+:10EE80003C1080009605011A50A0FF2B34C60010DC
69831+:10EE90000A000EC892EE000C8C6200001456FF6D42
69832+:10EEA000000000008C7800048FB9005403388823D8
69833+:10EEB0000621FF638FBF00540A000F0E0000000000
69834+:10EEC0003C010801A02A96F10A000F3030F9000138
69835+:10EED0001633FF028FAF00240A000EB0241E00106C
69836+:10EEE0000E00164E024020213C0B80083568008041
69837+:10EEF00091090025240A0001AFAA0050353300040F
69838+:10EF0000024020210E001658A11300253C050801DF
69839+:10EF100090A596F130A200FD3C010801A02296F1D7
69840+:10EF20000A000E6D004018212411000E53D1FEEA94
69841+:10EF3000241E00100A000EAF241E00165629FEDC07
69842+:10EF400032B000013C0A8008914C001B2406FFBD32
69843+:10EF5000241E001001865824A14B001B0A000EA598
69844+:10EF600032B000010A000EA4241E00123C038000EF
69845+:10EF70008C6201B80440FFFE24040800AC6401B8B0
69846+:10EF800003E000080000000030A5FFFF30C6FFFFCF
69847+:10EF90003C0780008CE201B80440FFFE34EA0180A7
69848+:10EFA000AD440000ACE400203C0480089483004899
69849+:10EFB0003068FFFF11000016AF88000824AB001274
69850+:10EFC000010B482B512000133C04800034EF01005A
69851+:10EFD00095EE00208F890000240D001A31CCFFFF30
69852+:10EFE00031274000A14D000B10E000362583FFFEC5
69853+:10EFF0000103C02B170000348F9900048F88000490
69854+:10F00000A5430014350700010A001003AF87000470
69855+:10F010003C04800024030003348201808F890000B7
69856+:10F020008F870004A043000B3C088000350C018052
69857+:10F03000A585000EA585001A8F85000C30EB800099
69858+:10F04000A5890010AD850028A58600081160000F75
69859+:10F050008F85001435190100972A00163158FFFCDE
69860+:10F06000270F000401E870218DCD400031A6FFFF7D
69861+:10F0700014C000072403BFFF3C02FFFF34487FFF9A
69862+:10F0800000E83824AF8700048F8500142403BFFFF5
69863+:10F090003C04800000E3582434830180A46B0026E4
69864+:10F0A000AC69002C10A0000300054C02A465001000
69865+:10F0B000A46900263C071000AC8701B803E00008F3
69866+:10F0C000000000008F990004240AFFFE032A382460
69867+:10F0D0000A001003AF87000427BDFFE88FA20028B5
69868+:10F0E00030A5FFFF30C6FFFFAFBF0010AF87000C99
69869+:10F0F000AF820014AF8000040E000FDBAF80000071
69870+:10F100008FBF001027BD001803E00008AF80001477
69871+:10F110003C06800034C4007034C701008C8A0000B3
69872+:10F1200090E500128F84000027BDFFF030A300FFA0
69873+:10F13000000318823082400010400037246500032D
69874+:10F140000005C8800326C0218F0E4000246F0004F4
69875+:10F15000000F6880AFAE000001A660218D8B4000DB
69876+:10F16000AFAB000494E900163128FFFC01063821FA
69877+:10F170008CE64000AFA600088FA9000800003021EF
69878+:10F18000000028213C07080024E701000A0010675E
69879+:10F19000240800089059000024A500012CAC000CA4
69880+:10F1A0000079C0210018788001E770218DCD000022
69881+:10F1B0001180000600CD302603A5102114A8FFF50C
69882+:10F1C00000051A005520FFF4905900003C0480000F
69883+:10F1D000348700703C0508008CA531048CE30000E6
69884+:10F1E0002CA2002010400009006A38230005488046
69885+:10F1F0003C0B0800256B3108012B402124AA00019B
69886+:10F20000AD0700003C010800AC2A310400C0102109
69887+:10F2100003E0000827BD0010308220001040000BE2
69888+:10F2200000055880016648218D24400024680004B0
69889+:10F2300000083880AFA4000000E618218C6540006B
69890+:10F24000AFA000080A001057AFA500040000000D91
69891+:10F250000A0010588FA9000827BDFFE03C07800076
69892+:10F2600034E60100AFBF001CAFB20018AFB100140C
69893+:10F27000AFB0001094C5000E8F87000030A4FFFFD0
69894+:10F280002483000430E2400010400010AF830028C7
69895+:10F290003C09002000E940241100000D30EC800002
69896+:10F2A0008F8A0004240BBFFF00EB38243543100085
69897+:10F2B000AF87000030F220001640000B3C1900041C
69898+:10F2C000241FFFBF0A0010B7007F102430EC80001D
69899+:10F2D000158000423C0E002030F220001240FFF862
69900+:10F2E0008F8300043C19000400F9C0241300FFF5CB
69901+:10F2F000241FFFBF34620040AF82000430E20100EF
69902+:10F300001040001130F010008F83002C10600006B8
69903+:10F310003C0F80003C05002000E52024148000C044
69904+:10F320003C0800043C0F800035EE010095CD001E26
69905+:10F3300095CC001C31AAFFFF000C5C00014B482556
69906+:10F34000AF89000C30F010001200000824110001F9
69907+:10F3500030F100201620008B3C18100000F890249B
69908+:10F36000164000823C040C002411000130E801002A
69909+:10F370001500000B3C0900018F85000430A94000F6
69910+:10F38000152000073C0900013C0C1F0100EC58242B
69911+:10F390003C0A1000116A01183C1080003C09000171
69912+:10F3A00000E9302410C000173C0B10003C18080086
69913+:10F3B0008F1800243307000214E0014024030001E9
69914+:10F3C0008FBF001C8FB200188FB100148FB00010D7
69915+:10F3D0000060102103E0000827BD002000EE682433
69916+:10F3E00011A0FFBE30F220008F8F00043C11FFFF00
69917+:10F3F00036307FFF00F0382435E380000A0010A685
69918+:10F40000AF87000000EB102450400065AF8000245F
69919+:10F410008F8C002C3C0D0F0000ED18241580008807
69920+:10F42000AF83001030E8010011000086938F0010B8
69921+:10F430003C0A0200106A00833C1280003650010032
69922+:10F44000920500139789002A3626000230AF00FF8C
69923+:10F4500025EE0004000E19C03C0480008C9801B811
69924+:10F460000700FFFE34880180AD0300003C198008CE
69925+:10F47000AC830020973100483225FFFF10A0015CCB
69926+:10F48000AF8500082523001200A3F82B53E0015993
69927+:10F490008F850004348D010095AC00202402001AF1
69928+:10F4A00030E44000318BFFFFA102000B108001927D
69929+:10F4B0002563FFFE00A3502B154001908F8F0004A1
69930+:10F4C000A50300148F88000435050001AF850004F2
69931+:10F4D0003C08800035190180A729000EA729001AD1
69932+:10F4E0008F89000C30B18000A7270010AF290028B9
69933+:10F4F000A72600081220000E3C04800035020100FF
69934+:10F50000944C0016318BFFFC256400040088182100
69935+:10F510008C7F400033E6FFFF14C000053C048000F0
69936+:10F520003C0AFFFF354D7FFF00AD2824AF85000466
69937+:10F53000240EBFFF00AE402434850180A4A800261D
69938+:10F54000ACA7002C3C071000AC8701B800001821C4
69939+:10F550008FBF001C8FB200188FB100148FB0001045
69940+:10F560000060102103E0000827BD00203C020BFFD3
69941+:10F5700000E41824345FFFFF03E3C82B5320FF7B14
69942+:10F58000241100013C0608008CC6002C24C5000193
69943+:10F590003C010800AC25002C0A0010D42411000501
69944+:10F5A0008F85002410A0002FAF80001090A30000D2
69945+:10F5B000146000792419000310A0002A30E601002D
69946+:10F5C00010C000CC8F860010241F000210DF00C97D
69947+:10F5D0008F8B000C3C0708008CE7003824E4FFFF09
69948+:10F5E00014E0000201641824000018213C0D0800FA
69949+:10F5F00025AD0038006D1021904C00048F85002847
69950+:10F6000025830004000321C030A5FFFF3626000239
69951+:10F610000E000FDB000000000A00114D0000182151
69952+:10F6200000E8302414C0FF403C0F80000E00103D65
69953+:10F63000000000008F8700000A0010CAAF82000C93
69954+:10F64000938F00103C18080127189640000F90C0B7
69955+:10F6500002588021AF9000248F85002414A0FFD38E
69956+:10F66000AF8F00103C0480008C86400030C5010044
69957+:10F6700010A000BC322300043C0C08008D8C002438
69958+:10F6800024120004106000C23190000D3C04800080
69959+:10F690008C8D40003402FFFF11A201003231FFFBCC
69960+:10F6A0008C884000310A01005540000124110010EF
69961+:10F6B00030EE080011C000BE2419FFFB8F9800280F
69962+:10F6C0002F0F03EF51E000010219802430E90100FF
69963+:10F6D00011200014320800018F87002C14E000FB79
69964+:10F6E0008F8C000C3C05800034AB0100917F00132F
69965+:10F6F00033E300FF246A00042403FFFE0203802496
69966+:10F70000000A21C012000002023230253226FFFF1B
69967+:10F710000E000FDB9785002A1200FF290000182138
69968+:10F72000320800011100000D32180004240E0001FF
69969+:10F73000120E0002023230253226FFFF9785002A82
69970+:10F740000E000FDB00002021240FFFFE020F80249B
69971+:10F750001200FF1B00001821321800045300FF188C
69972+:10F760002403000102323025241200045612000145
69973+:10F770003226FFFF9785002A0E000FDB24040100CC
69974+:10F780002419FFFB021988241220FF0D0000182104
69975+:10F790000A0010E9240300011079009C00003021C8
69976+:10F7A00090AD00012402000211A200BE30EA004028
69977+:10F7B00090B90001241800011338007F30E900409F
69978+:10F7C0008CA600049785002A00C020210E000FDBC4
69979+:10F7D0003626000200004021010018218FBF001CC6
69980+:10F7E0008FB200188FB100148FB00010006010218C
69981+:10F7F00003E0000827BD0020360F010095EE000C45
69982+:10F8000031CD020015A0FEE63C0900013C1880083D
69983+:10F81000971200489789002A362600023248FFFFD7
69984+:10F82000AF8800083C0380008C7101B80620FFFE01
69985+:10F83000346A0180AD4000001100008E3C0F800052
69986+:10F84000253F0012011FC82B1320008B240E00033C
69987+:10F85000346C0100958B00202402001A30E4400033
69988+:10F860003163FFFFA142000B108000A72463FFFE5D
69989+:10F870000103682B15A000A52408FFFE34A5000194
69990+:10F88000A5430014AF8500043C0480002412BFFF90
69991+:10F8900000B2802434850180A4A9000EA4A9001A16
69992+:10F8A000A4A60008A4B00026A4A700103C071000DE
69993+:10F8B000AC8701B80A00114D000018213C038000FC
69994+:10F8C00034640100949F000E3C1908008F3900D861
69995+:10F8D0002404008033E5FFFF273100013C010800CC
69996+:10F8E000AC3100D80E000FDB240600030A00114DD6
69997+:10F8F00000001821240A000210CA00598F85002830
69998+:10F900003C0308008C6300D0240E0001106E005EE2
69999+:10F910002CCF000C24D2FFFC2E5000041600002136
70000+:10F9200000002021241800021078001B2CD9000CA4
70001+:10F9300024DFFFF82FE900041520FF330000202109
70002+:10F9400030EB020051600004000621C054C00022C8
70003+:10F9500030A5FFFF000621C030A5FFFF0A00117D82
70004+:10F96000362600023C0908008D29002431300001B0
70005+:10F970005200FEF7000018219785002A3626000263
70006+:10F980000E000FDB000020210A00114D000018219D
70007+:10F990000A00119C241200021320FFE624DFFFF866
70008+:10F9A0000000202130A5FFFF0A00117D362600024D
70009+:10F9B0000A0011AC021980245120FF828CA6000499
70010+:10F9C0003C05080190A5964110A0FF7E2408000187
70011+:10F9D0000A0011F0010018210E000FDB3226000191
70012+:10F9E0008F8600108F8500280A00124F000621C064
70013+:10F9F0008F8500043C18800024120003371001801A
70014+:10FA0000A212000B0A00112E3C08800090A30001F6
70015+:10FA1000241100011071FF70240800012409000264
70016+:10FA20005069000430E60040240800010A0011F08B
70017+:10FA30000100182150C0FFFD240800013C0C80008B
70018+:10FA4000358B01009563001094A40002307FFFFF06
70019+:10FA5000509FFF62010018210A001284240800014F
70020+:10FA60002CA803EF1100FE56240300010A001239EE
70021+:10FA700000000000240E000335EA0180A14E000BB7
70022+:10FA80000A00121C3C04800011E0FFA2000621C005
70023+:10FA900030A5FFFF0A00117D362600020A0011A5DD
70024+:10FAA000241100201140FFC63C1280003650010096
70025+:10FAB000960F001094AE000231E80FFF15C8FFC08A
70026+:10FAC000000000000A0011E690B900013C060800A1
70027+:10FAD0008CC6003824C4FFFF14C00002018418241F
70028+:10FAE000000018213C0D080025AD0038006D1021E4
70029+:10FAF0000A0011B6904300048F8F0004240EFFFE0D
70030+:10FB00000A00112C01EE28242408FFFE0A00121A14
70031+:10FB100000A8282427BDFFC8AFB00010AFBF003435
70032+:10FB20003C10600CAFBE0030AFB7002CAFB6002861
70033+:10FB3000AFB50024AFB40020AFB3001CAFB20018C3
70034+:10FB4000AFB100148E0E5000240FFF7F3C068000E2
70035+:10FB500001CF682435AC380C240B0003AE0C5000E8
70036+:10FB6000ACCB00083C010800AC2000200E001819A6
70037+:10FB7000000000003C0A0010354980513C06601628
70038+:10FB8000AE09537C8CC700003C0860148D0500A0B2
70039+:10FB90003C03FFFF00E320243C02535300051FC237
70040+:10FBA0001482000634C57C000003A08002869821E0
70041+:10FBB0008E7200043C116000025128218CBF007C31
70042+:10FBC0008CA200783C1E600037C420203C05080150
70043+:10FBD00024A59288AF820018AF9F001C0E0016DD8E
70044+:10FBE0002406000A3C190001273996403C01080010
70045+:10FBF000AC3931DC0E0020DDAF8000148FD708084F
70046+:10FC00002418FFF03C15570902F8B02412D502F56C
70047+:10FC100024040001AF80002C3C1480003697018042
70048+:10FC20003C1E080127DE9644369301008E900000AA
70049+:10FC30003205000310A0FFFD3207000110E000882C
70050+:10FC4000320600028E7100283C048000AE91002034
70051+:10FC50008E6500048E66000000A0382100C040219F
70052+:10FC60008C8301B80460FFFE3C0B0010240A0800DE
70053+:10FC700000AB4824AC8A01B8552000E0240BBFFF3C
70054+:10FC80009675000E3C1208008E52002030AC4000E9
70055+:10FC900032AFFFFF264E000125ED00043C010800B5
70056+:10FCA000AC2E0020118000E8AF8D00283C18002009
70057+:10FCB00000B8B02412C000E530B980002408BFFFAE
70058+:10FCC00000A8382434C81000AF87000030E62000B8
70059+:10FCD00010C000E92409FFBF3C03000400E328240E
70060+:10FCE00010A00002010910243502004030EA010092
70061+:10FCF00011400010AF8200048F8B002C11600007B0
70062+:10FD00003C0D002000ED6024118000043C0F000435
70063+:10FD100000EF702411C00239000000009668001E38
70064+:10FD20009678001C3115FFFF0018B40002B690252C
70065+:10FD3000AF92000C30F910001320001324150001BD
70066+:10FD400030FF002017E0000A3C04100000E41024FB
70067+:10FD50001040000D3C0A0C003C090BFF00EA18247F
70068+:10FD60003525FFFF00A3302B10C0000830ED010047
70069+:10FD70003C0C08008D8C002C24150005258B0001FF
70070+:10FD80003C010800AC2B002C30ED010015A0000B4D
70071+:10FD90003C0500018F85000430AE400055C00007CF
70072+:10FDA0003C0500013C161F0100F690243C0F10009A
70073+:10FDB000124F01CE000000003C05000100E5302498
70074+:10FDC00010C000AF3C0C10003C1F08008FFF002447
70075+:10FDD00033E90002152000712403000100601021A6
70076+:10FDE000104000083C0680003C08800035180100E7
70077+:10FDF0008F0F00243C056020ACAF00140000000011
70078+:10FE00003C0680003C194000ACD9013800000000DD
70079+:10FE10005220001332060002262B0140262C0080BF
70080+:10FE2000240EFF80016E2024018E6824000D1940ED
70081+:10FE3000318A007F0004A9403172007F3C16200007
70082+:10FE400036C20002006A482502B2382500E2882541
70083+:10FE50000122F825ACDF0830ACD1083032060002B0
70084+:10FE600010C0FF723C188000370501408CA80000CC
70085+:10FE700024100040AF08002090AF000831E300706C
70086+:10FE8000107000D428790041532000082405006038
70087+:10FE9000241100201071000E3C0A40003C09800033
70088+:10FEA000AD2A01780A001304000000001465FFFB6E
70089+:10FEB0003C0A40000E001FFA000000003C0A40000F
70090+:10FEC0003C098000AD2A01780A00130400000000FC
70091+:10FED00090A90009241F00048CA70000312800FF0E
70092+:10FEE000111F01B22503FFFA2C7200061240001404
70093+:10FEF0003C0680008CA9000494A4000A310500FF90
70094+:10FF000000095E022D6A00083086FFFF15400002DE
70095+:10FF10002567000424070003240C000910AC01FA33
70096+:10FF200028AD000A11A001DE2410000A240E0008EA
70097+:10FF300010AE0028000731C000C038213C06800008
70098+:10FF40008CD501B806A0FFFE34D20180AE47000078
70099+:10FF500034CB0140916E0008240300023C0A4000AB
70100+:10FF600031C400FF00046A0001A86025A64C000807
70101+:10FF7000A243000B9562000A3C0810003C09800077
70102+:10FF8000A64200108D670004AE470024ACC801B83B
70103+:10FF9000AD2A01780A001304000000003C0A80002A
70104+:10FFA000354401009483000E3C0208008C4200D8C6
70105+:10FFB000240400803065FFFF245500013C01080047
70106+:10FFC000AC3500D80E000FDB240600030A001370C6
70107+:10FFD000000018210009320230D900FF2418000166
70108+:10FFE0001738FFD5000731C08F910020262200016D
70109+:10FFF000AF8200200A0013C800C0382100CB2024A3
70110+:020000021000EC
70111+:10000000AF85000010800008AF860004240D87FF34
70112+:1000100000CD6024158000083C0E006000AE302446
70113+:1000200010C00005000000000E000D42000000009E
70114+:100030000A001371000000000E0016050000000009
70115+:100040000A0013710000000030B980005320FF1F28
70116+:10005000AF8500003C02002000A2F82453E0FF1B03
70117+:10006000AF8500003C07FFFF34E47FFF00A4382485
70118+:100070000A00132B34C880000A001334010910242D
70119+:1000800000EC58245160005AAF8000248F8D002C62
70120+:100090003C0E0F0000EE182415A00075AF83001071
70121+:1000A00030EF010011E00073939800103C12020041
70122+:1000B000107200703C06800034D9010093280013B0
70123+:1000C0009789002A36A60002311800FF271600047F
70124+:1000D000001619C03C0480008C8501B804A0FFFE06
70125+:1000E00034880180AD0300003C158008AC830020FB
70126+:1000F00096BF004833E5FFFF10A001BCAF850008A4
70127+:100100002523001200A3102B504001B98F85000455
70128+:10011000348D010095AC0020240B001A30E440001F
70129+:10012000318AFFFFA10B000B108001BA2543FFFEAF
70130+:1001300000A3702B15C001B88F9600048F8F0004A8
70131+:10014000A503001435E50001AF8500043C088000DC
70132+:1001500035150180A6A9000EA6A9001A8F89000CEA
70133+:1001600030BF8000A6A70010AEA90028A6A60008F0
70134+:1001700013E0000F3C0F8000350C0100958B00163A
70135+:10018000316AFFFC25440004008818218C6240007D
70136+:100190003046FFFF14C000072416BFFF3C0EFFFFD0
70137+:1001A00035CD7FFF00AD2824AF8500043C0F8000D3
70138+:1001B0002416BFFF00B6902435E50180A4B20026C6
70139+:1001C000ACA7002C3C071000ADE701B80A00137083
70140+:1001D000000018210E00165D000000003C0A4000DF
70141+:1001E0003C098000AD2A01780A00130400000000D9
70142+:1001F0008F85002410A00027AF80001090A300007E
70143+:10020000106000742409000310690101000030210E
70144+:1002100090AE0001240D000211CD014230EF0040EC
70145+:1002200090A90001241F0001113F000930E20040A5
70146+:100230008CA600049785002A00C020210E000FDB49
70147+:1002400036A60002000040210A00137001001821A8
70148+:100250005040FFF88CA600043C07080190E7964147
70149+:1002600010E0FFF4240800010A00137001001821B7
70150+:10027000939800103C1F080127FF96400018C8C043
70151+:10028000033F4021AF8800248F85002414A0FFDBAA
70152+:10029000AF9800103C0480008C86400030C50100FF
70153+:1002A00010A0008732AB00043C0C08008D8C0024A9
70154+:1002B00024160004156000033192000D241600027C
70155+:1002C0003C0480008C8E4000340DFFFF11CD0113E3
70156+:1002D00032B5FFFB8C984000330F010055E0000160
70157+:1002E0002415001030E80800110000382409FFFB35
70158+:1002F0008F9F00282FF903EF53200001024990241B
70159+:1003000030E2010010400014325F00018F87002CA2
70160+:1003100014E0010E8F8C000C3C0480003486010038
70161+:1003200090C5001330AA00FF25430004000321C03C
70162+:100330002419FFFE025990241240000202B6302513
70163+:1003400032A6FFFF0E000FDB9785002A1240FEA3A6
70164+:1003500000001821325F000113E0000D3247000455
70165+:10036000240900011249000202B6302532A6FFFF1F
70166+:100370009785002A0E000FDB000020212402FFFEDB
70167+:10038000024290241240FE950000182132470004DA
70168+:1003900050E0FE922403000102B63025241600042A
70169+:1003A0005656000132A6FFFF9785002A0E000FDB8C
70170+:1003B000240401002403FFFB0243A82412A0FE87AB
70171+:1003C000000018210A001370240300010A0014B968
70172+:1003D0000249902410A0FFAF30E5010010A00017E3
70173+:1003E0008F8600102403000210C300148F84000CB9
70174+:1003F0003C0608008CC6003824CAFFFF14C0000267
70175+:10040000008A1024000010213C0E080025CE003880
70176+:10041000004E682191AC00048F850028258B0004D4
70177+:10042000000B21C030A5FFFF36A600020E000FDB37
70178+:10043000000000000A00137000001821240F0002C1
70179+:1004400010CF0088241600013C0308008C6300D004
70180+:100450001076008D8F85002824D9FFFC2F280004FA
70181+:100460001500006300002021241F0002107F005DA2
70182+:100470002CC9000C24C3FFF82C6200041440FFE9CF
70183+:100480000000202130EA020051400004000621C093
70184+:1004900054C0000530A5FFFF000621C030A5FFFFB6
70185+:1004A0000A00150436A600020E000FDB32A600017A
70186+:1004B0008F8600108F8500280A001520000621C0B5
70187+:1004C0003C0A08008D4A0024315200015240FE438C
70188+:1004D000000018219785002A36A600020E000FDBC7
70189+:1004E000000020210A001370000018219668000CFB
70190+:1004F000311802005700FE313C0500013C1F800806
70191+:1005000097F900489789002A36A600023328FFFF92
70192+:10051000AF8800083C0380008C7501B806A0FFFE80
70193+:100520003C04800034820180AC400000110000B621
70194+:1005300024180003252A0012010A182B106000B2AB
70195+:1005400000000000966F00203C0E8000240D001A71
70196+:1005500031ECFFFF35CA018030EB4000A14D000BAC
70197+:10056000116000B02583FFFE0103902B164000AE02
70198+:100570002416FFFE34A50001A5430014AF85000436
70199+:100580002419BFFF00B94024A6E9000EA6E9001A0D
70200+:10059000A6E60008A6E80026A6E700103C07100023
70201+:1005A000AE8701B80A001370000018213C048000D7
70202+:1005B0008C8201B80440FFFE349601802415001C93
70203+:1005C000AEC70000A2D5000B3C071000AC8701B8F5
70204+:1005D0003C0A40003C098000AD2A01780A0013045F
70205+:1005E000000000005120FFA424C3FFF800002021D8
70206+:1005F00030A5FFFF0A00150436A600020E00103DCC
70207+:10060000000000008F8700000A001346AF82000C34
70208+:1006100090A30001241500011075FF0B24080001B0
70209+:10062000240600021066000430E2004024080001A5
70210+:100630000A001370010018215040FFFD240800013A
70211+:100640003C0C8000358B0100956A001094A40002D8
70212+:100650003143FFFF5083FDE1010018210A00158599
70213+:10066000240800018F8500282CB203EF1240FDDB27
70214+:10067000240300013C0308008C6300D02416000111
70215+:100680001476FF7624D9FFFC2CD8000C1300FF72DF
70216+:10069000000621C030A5FFFF0A00150436A600029F
70217+:1006A00010B00037240F000B14AFFE23000731C039
70218+:1006B000312600FF00065600000A4E0305220047BF
70219+:1006C00030C6007F0006F8C03C16080126D69640CA
70220+:1006D00003F68021A2000001A20000003C0F600090
70221+:1006E0008DF918202405000100C588040011302769
70222+:1006F0000326C024000731C000C03821ADF81820FF
70223+:100700000A0013C8A60000028F850020000731C030
70224+:1007100024A2FFFF0A0013F6AF8200200A0014B2E1
70225+:100720002415002011E0FECC3C1980003728010080
70226+:100730009518001094B6000233120FFF16D2FEC6B1
70227+:10074000000000000A00148290A900013C0B080080
70228+:100750008D6B0038256DFFFF15600002018D1024A0
70229+:10076000000010213C080800250800380048C0217E
70230+:10077000930F000425EE00040A0014C5000E21C0EA
70231+:1007800000065202241F00FF115FFDEB000731C07D
70232+:10079000000A20C03C0E080125CE9640008EA821FC
70233+:1007A000009E602100095C02240D00013C076000EE
70234+:1007B000A2AD0000AD860000A2AB00018CF21820B3
70235+:1007C00024030001014310040242B025ACF61820B6
70236+:1007D00000C038210A0013C8A6A900020A0015AA01
70237+:1007E000AF8000200A0012FFAF84002C8F85000428
70238+:1007F0003C1980002408000337380180A308000B4F
70239+:100800000A00144D3C088000A2F8000B0A00155A9B
70240+:100810002419BFFF8F9600042412FFFE0A00144B18
70241+:1008200002D228242416FFFE0A00155800B62824F8
70242+:100830003C038000346401008C85000030A2003E3F
70243+:100840001440000800000000AC6000488C870000E5
70244+:1008500030E607C010C0000500000000AC60004C8E
70245+:10086000AC60005003E0000824020001AC600054BA
70246+:10087000AC6000408C880000310438001080FFF923
70247+:10088000000000002402000103E00008AC60004406
70248+:100890003C0380008C6201B80440FFFE3467018095
70249+:1008A000ACE4000024080001ACE00004A4E500086A
70250+:1008B00024050002A0E8000A34640140A0E5000B12
70251+:1008C0009483000A14C00008A4E30010ACE00024E4
70252+:1008D0003C07800034E901803C041000AD20002872
70253+:1008E00003E00008ACE401B88C8600043C0410006E
70254+:1008F000ACE600243C07800034E90180AD200028EC
70255+:1009000003E00008ACE401B83C0680008CC201B8EA
70256+:100910000440FFFE34C7018024090002ACE400005B
70257+:10092000ACE40004A4E50008A0E9000A34C50140D5
70258+:10093000A0E9000B94A8000A3C041000A4E80010F1
70259+:10094000ACE000248CA30004ACE3002803E0000822
70260+:10095000ACC401B83C039000346200010082202541
70261+:100960003C038000AC6400208C65002004A0FFFEE6
70262+:100970000000000003E00008000000003C028000CE
70263+:10098000344300010083202503E00008AC4400202C
70264+:1009900027BDFFE03C098000AFBF0018AFB10014D5
70265+:1009A000AFB00010352801408D10000091040009FF
70266+:1009B0009107000891050008308400FF30E600FF31
70267+:1009C00000061A002C820081008330251040002A86
70268+:1009D00030A50080000460803C0D080125AD92B078
70269+:1009E000018D58218D6A00000140000800000000C0
70270+:1009F0003C038000346201409445000A14A0001EAC
70271+:100A00008F91FCC09227000530E6000414C0001A44
70272+:100A1000000000000E00164E02002021922A000560
70273+:100A200002002021354900040E001658A2290005B5
70274+:100A30009228000531040004148000020000000028
70275+:100A40000000000D922D0000240B002031AC00FFAF
70276+:100A5000158B00093C0580008CAE01B805C0FFFE77
70277+:100A600034B10180AE3000003C0F100024100005AE
70278+:100A7000A230000BACAF01B80000000D8FBF001812
70279+:100A80008FB100148FB0001003E0000827BD0020D4
70280+:100A90000200202100C028218FBF00188FB1001450
70281+:100AA0008FB00010240600010A00161D27BD00208B
70282+:100AB0000000000D0200202100C028218FBF001877
70283+:100AC0008FB100148FB00010000030210A00161DF5
70284+:100AD00027BD002014A0FFE8000000000200202134
70285+:100AE0008FBF00188FB100148FB0001000C02821F4
70286+:100AF0000A00163B27BD00203C0780008CEE01B8A1
70287+:100B000005C0FFFE34F00180241F0002A21F000B6D
70288+:100B100034F80140A60600089719000A3C0F10009F
70289+:100B2000A61900108F110004A6110012ACEF01B835
70290+:100B30000A0016998FBF001827BDFFE8AFBF00104D
70291+:100B40000E000FD4000000003C0280008FBF001098
70292+:100B500000002021AC4001800A00108F27BD001842
70293+:100B60003084FFFF30A5FFFF108000070000182130
70294+:100B7000308200011040000200042042006518216C
70295+:100B80001480FFFB0005284003E0000800601021EE
70296+:100B900010C00007000000008CA2000024C6FFFF68
70297+:100BA00024A50004AC82000014C0FFFB24840004D0
70298+:100BB00003E000080000000010A0000824A3FFFFCD
70299+:100BC000AC86000000000000000000002402FFFFCF
70300+:100BD0002463FFFF1462FFFA2484000403E000088A
70301+:100BE000000000003C03800027BDFFF83462018054
70302+:100BF000AFA20000308C00FF30AD00FF30CE00FF10
70303+:100C00003C0B80008D6401B80480FFFE00000000F2
70304+:100C10008FA900008D6801288FAA00008FA700000F
70305+:100C20008FA400002405000124020002A085000A10
70306+:100C30008FA30000359940003C051000A062000B16
70307+:100C40008FB800008FAC00008FA600008FAF0000AF
70308+:100C500027BD0008AD280000AD400004AD80002491
70309+:100C6000ACC00028A4F90008A70D0010A5EE0012E2
70310+:100C700003E00008AD6501B83C06800827BDFFE829
70311+:100C800034C50080AFBF001090A7000924020012F5
70312+:100C900030E300FF1062000B008030218CA8005070
70313+:100CA00000882023048000088FBF00108CAA003425
70314+:100CB000240400390000282100CA4823052000052B
70315+:100CC000240600128FBF00102402000103E0000878
70316+:100CD00027BD00180E0016F2000000008FBF0010A4
70317+:100CE0002402000103E0000827BD001827BDFFC84B
70318+:100CF000AFB20030AFB00028AFBF0034AFB1002CAE
70319+:100D000000A0802190A5000D30A6001010C000109A
70320+:100D1000008090213C0280088C4400048E0300086F
70321+:100D20001064000C30A7000530A6000510C0009329
70322+:100D3000240400018FBF00348FB200308FB1002C2B
70323+:100D40008FB000280080102103E0000827BD003884
70324+:100D500030A7000510E0000F30AB001210C00006F5
70325+:100D6000240400013C0980088E0800088D25000439
70326+:100D70005105009C240400388FBF00348FB200302E
70327+:100D80008FB1002C8FB000280080102103E00008F4
70328+:100D900027BD0038240A0012156AFFE6240400016A
70329+:100DA0000200202127A500100E000CB6AFA00010F5
70330+:100DB0001440007C3C19800837240080909800087B
70331+:100DC000331100081220000A8FA7001030FF010025
70332+:100DD00013E000A48FA300148C8600580066102333
70333+:100DE000044000043C0A8008AC8300588FA7001020
70334+:100DF0003C0A800835480080910900083124000829
70335+:100E00001480000224080003000040213C1F8008D9
70336+:100E100093F1001193F9001237E600808CCC005456
70337+:100E2000333800FF03087821322D00FF000F708057
70338+:100E300001AE282100AC582B1160006F00000000AB
70339+:100E400094CA005C8CC900543144FFFF0125102373
70340+:100E50000082182B14600068000000008CCB005446
70341+:100E60000165182330EC00041180006C000830800C
70342+:100E70008FA8001C0068102B1040006230ED0004A9
70343+:100E8000006610232C46008010C00002004088211C
70344+:100E9000241100800E00164E024020213C0D8008D7
70345+:100EA00035A6008024070001ACC7000C90C80008DC
70346+:100EB0000011484035A70100310C007FA0CC00088C
70347+:100EC0008E05000424AB0001ACCB0030A4D1005C43
70348+:100ED0008CCA003C9602000E01422021ACC40020C6
70349+:100EE0008CC3003C0069F821ACDF001C8E190004A3
70350+:100EF000ACF900008E180008ACF800048FB10010A7
70351+:100F0000322F000855E0004793A60020A0C0004EF5
70352+:100F100090D8004E2411FFDFA0F8000890CF000801
70353+:100F200001F17024A0CE00088E0500083C0B80085B
70354+:100F300035690080AD2500388D6A00148D2200309F
70355+:100F40002419005001422021AD24003491230000D7
70356+:100F5000307F00FF13F90036264F01000E001658AF
70357+:100F60000240202124040038000028210E0016F23F
70358+:100F70002406000A0A001757240400010E000D2859
70359+:100F8000000020218FBF00348FB200308FB1002CC1
70360+:100F90008FB00028004020210080102103E00008CD
70361+:100FA00027BD00388E0E00083C0F800835F0008009
70362+:100FB000AE0E005402402021AE0000300E00164E4E
70363+:100FC00000000000920D00250240202135AC0020D9
70364+:100FD0000E001658A20C00250E000CAC0240202179
70365+:100FE000240400382405008D0E0016F22406001299
70366+:100FF0000A0017572404000194C5005C0A001792E8
70367+:1010000030A3FFFF2407021811A0FF9E00E6102363
70368+:101010008FAE001C0A00179A01C610230A0017970A
70369+:101020002C620218A0E600080A0017C48E0500080A
70370+:101030002406FF8001E6C0243C118000AE38002861
70371+:101040008E0D000831E7007F3C0E800C00EE602121
70372+:10105000AD8D00E08E080008AF8C00380A0017D074
70373+:10106000AD8800E4AC800058908500082403FFF7A9
70374+:1010700000A33824A08700080A0017758FA7001066
70375+:101080003C05080024A560A83C04080024846FF4F3
70376+:101090003C020800244260B0240300063C01080121
70377+:1010A000AC2596C03C010801AC2496C43C01080163
70378+:1010B000AC2296C83C010801A02396CC03E00008AE
70379+:1010C0000000000003E00008240200013C02800050
70380+:1010D000308800FF344701803C0680008CC301B893
70381+:1010E0000460FFFE000000008CC501282418FF806A
70382+:1010F0003C0D800A24AF010001F8702431EC007F20
70383+:10110000ACCE0024018D2021ACE50000948B00EAD8
70384+:101110003509600024080002316AFFFFACEA0004D0
70385+:1011200024020001A4E90008A0E8000BACE00024C0
70386+:101130003C071000ACC701B8AF84003803E00008DA
70387+:10114000AF85006C938800488F8900608F820038DB
70388+:1011500030C600FF0109382330E900FF01221821C1
70389+:1011600030A500FF2468008810C000020124382147
70390+:101170000080382130E400031480000330AA00030B
70391+:101180001140000D312B000310A0000900001021B8
70392+:1011900090ED0000244E000131C200FF0045602B9D
70393+:1011A000A10D000024E700011580FFF925080001CA
70394+:1011B00003E00008000000001560FFF300000000DD
70395+:1011C00010A0FFFB000010218CF80000245900043F
70396+:1011D000332200FF0045782BAD18000024E70004FF
70397+:1011E00015E0FFF92508000403E0000800000000F6
70398+:1011F00093850048938800588F8700600004320070
70399+:101200003103007F00E5102B30C47F001040000F39
70400+:10121000006428258F8400383C0980008C8A00EC0B
70401+:10122000AD2A00A43C03800000A35825AC6B00A0AD
70402+:101230008C6C00A00580FFFE000000008C6D00ACEF
70403+:10124000AC8D00EC03E000088C6200A80A00188254
70404+:101250008F840038938800593C0280000080502120
70405+:10126000310300FEA383005930ABFFFF30CC00FFF9
70406+:1012700030E7FFFF344801803C0980008D2401B82D
70407+:101280000480FFFE8F8D006C24180016AD0D000049
70408+:101290008D2201248F8D0038AD0200048D5900206D
70409+:1012A000A5070008240201C4A119000AA118000B17
70410+:1012B000952F01208D4E00088D4700049783005C18
70411+:1012C0008D59002401CF302100C7282100A32023FD
70412+:1012D0002418FFFFA504000CA50B000EA5020010AA
70413+:1012E000A50C0012AD190018AD18002495AF00E848
70414+:1012F0003C0B10002407FFF731EEFFFFAD0E002876
70415+:101300008DAC0084AD0C002CAD2B01B88D460020B7
70416+:1013100000C7282403E00008AD4500208F8800386E
70417+:101320000080582130E7FFFF910900D63C02800081
70418+:1013300030A5FFFF312400FF00041A00006750258C
70419+:1013400030C600FF344701803C0980008D2C01B875
70420+:101350000580FFFE8F82006C240F0017ACE20000B6
70421+:101360008D390124ACF900048D780020A4EA00082E
70422+:10137000241901C4A0F8000AA0EF000B9523012056
70423+:101380008D6E00088D6D00049784005C01C35021B0
70424+:10139000014D602101841023A4E2000CA4E5000E9D
70425+:1013A000A4F90010A4E60012ACE000148D7800242B
70426+:1013B000240DFFFFACF800188D0F007CACEF001C73
70427+:1013C0008D0E00783C0F1000ACEE0020ACED002438
70428+:1013D000950A00BE240DFFF73146FFFFACE600285A
70429+:1013E000950C00809504008231837FFF0003CA00C2
70430+:1013F0003082FFFF0322C021ACF8002CAD2F01B8D2
70431+:10140000950E00828D6A002000AE3021014D282407
70432+:10141000A506008203E00008AD6500203C028000C4
70433+:10142000344501803C0480008C8301B80460FFFED9
70434+:101430008F8A0044240600199549001C3128FFFFBB
70435+:10144000000839C0ACA70000A0A6000B3C051000A6
70436+:1014500003E00008AC8501B88F87004C0080402174
70437+:1014600030C400FF3C0680008CC201B80440FFFE7F
70438+:101470008F89006C9383006834996000ACA90000E8
70439+:10148000A0A300058CE20010240F00022403FFF744
70440+:10149000A4A20006A4B900088D180020A0B8000A74
70441+:1014A000A0AF000B8CEE0000ACAE00108CED000481
70442+:1014B000ACAD00148CEC001CACAC00248CEB002018
70443+:1014C000ACAB00288CEA002C3C071000ACAA002C26
70444+:1014D0008D090024ACA90018ACC701B88D05002007
70445+:1014E00000A3202403E00008AD0400208F8600380C
70446+:1014F00027BDFFE0AFB10014AFBF0018AFB00010C0
70447+:1015000090C300D430A500FF3062002010400008D6
70448+:10151000008088218CCB00D02409FFDF256A0001E0
70449+:10152000ACCA00D090C800D401093824A0C700D4A8
70450+:1015300014A000403C0C80008F840038908700D4B9
70451+:101540002418FFBF2406FFEF30E3007FA08300D400
70452+:10155000979F005C8F8200608F8D003803E2C82364
70453+:10156000A799005CA5A000BC91AF00D401F870243D
70454+:10157000A1AE00D48F8C0038A18000D78F8A0038AC
70455+:10158000A5400082AD4000EC914500D400A658244F
70456+:10159000A14B00D48F9000348F8400609786005C4C
70457+:1015A0000204282110C0000FAF850034A38000582A
70458+:1015B0003C0780008E2C000894ED01208E2B000447
70459+:1015C000018D5021014B8021020620233086FFFF30
70460+:1015D00030C8000F3909000131310001162000091F
70461+:1015E000A3880058938600488FBF00188FB100145D
70462+:1015F0008FB0001027BD0020AF85006403E0000815
70463+:10160000AF86006000C870238FBF00189386004823
70464+:101610008FB100148FB0001034EF0C00010F28219F
70465+:1016200027BD0020ACEE0084AF85006403E0000815
70466+:10163000AF86006035900180020028210E00190F4E
70467+:10164000240600828F840038908600D430C5004084
70468+:1016500050A0FFBAA38000688F85004C3C06800034
70469+:101660008CCD01B805A0FFFE8F89006C2408608234
70470+:1016700024070002AE090000A6080008A207000B1C
70471+:101680008CA300083C0E1000AE0300108CA2000CCE
70472+:10169000AE0200148CBF0014AE1F00188CB90018E5
70473+:1016A000AE1900248CB80024AE1800288CAF002896
70474+:1016B000AE0F002CACCE01B80A001948A380006818
70475+:1016C0008F8A003827BDFFE0AFB10014AFB0001023
70476+:1016D0008F880060AFBF00189389003C954200BC22
70477+:1016E00030D100FF0109182B0080802130AC00FFB1
70478+:1016F0003047FFFF0000582114600003310600FF4F
70479+:1017000001203021010958239783005C0068202BB9
70480+:101710001480002700000000106800562419000102
70481+:101720001199006334E708803165FFFF0E0018C08F
70482+:10173000020020218F83006C3C07800034E601808A
70483+:101740003C0580008CAB01B80560FFFE240A001840
70484+:101750008F840038ACC30000A0CA000B948900BE7F
70485+:101760003C081000A4C90010ACC00030ACA801B8FF
70486+:101770009482008024430001A4830080949F008011
70487+:101780003C0608008CC6318833EC7FFF1186005E72
70488+:101790000000000002002021022028218FBF001835
70489+:1017A0008FB100148FB000100A00193427BD00203B
70490+:1017B000914400D42403FF8000838825A15100D4E4
70491+:1017C0009784005C3088FFFF51000023938C003C1D
70492+:1017D0008F8500382402EFFF008B782394AE00BC85
70493+:1017E0000168502B31E900FF01C26824A4AD00BCA0
70494+:1017F00051400039010058213C1F800037E60100AC
70495+:101800008CD800043C190001031940245500000144
70496+:1018100034E740008E0A00202403FFFB241100015E
70497+:1018200001432024AE0400201191002D34E78000F4
70498+:1018300002002021012030210E0018C03165FFFF79
70499+:101840009787005C8F890060A780005C0127802358
70500+:10185000AF900060938C003C8F8B00388FBF0018D6
70501+:101860008FB100148FB0001027BD002003E00008E6
70502+:10187000A16C00D73C0D800035AA01008D48000402
70503+:101880003C0900010109282454A0000134E740006C
70504+:101890008E0F00202418FFFB34E7800001F870242D
70505+:1018A00024190001AE0E00201599FF9F34E708802F
70506+:1018B000020020210E00188E3165FFFF020020215A
70507+:1018C000022028218FBF00188FB100148FB00010A4
70508+:1018D0000A00193427BD00200A0019F7000048212A
70509+:1018E00002002021012030210E00188E3165FFFFFB
70510+:1018F0009787005C8F890060A780005C01278023A8
70511+:101900000A001A0EAF900060948C0080241F8000A3
70512+:10191000019F3024A4860080908B0080908F0080EF
70513+:10192000316700FF0007C9C20019C027001871C045
70514+:1019300031ED007F01AE2825A08500800A0019DF67
70515+:1019400002002021938500682403000127BDFFE8E1
70516+:1019500000A330042CA20020AFB00010AFBF0014D1
70517+:1019600000C01821104000132410FFFE3C0708009F
70518+:101970008CE7319000E610243C088000350501809A
70519+:1019800014400005240600848F890038240A0004CE
70520+:101990002410FFFFA12A00FC0E00190F0000000018
70521+:1019A000020010218FBF00148FB0001003E0000868
70522+:1019B00027BD00183C0608008CC631940A001A574F
70523+:1019C00000C310248F87004427BDFFE0AFB200188A
70524+:1019D000AFB10014AFB00010AFBF001C30D000FF9B
70525+:1019E00090E6000D00A088210080902130C5007F86
70526+:1019F000A0E5000D8F8500388E2300188CA200D042
70527+:101A00001062002E240A000E0E001A4AA38A0068F3
70528+:101A10002409FFFF104900222404FFFF5200002088
70529+:101A2000000020218E2600003C0C001000CC582421
70530+:101A3000156000393C0E000800CE682455A0003F18
70531+:101A4000024020213C18000200D880241200001F10
70532+:101A50003C0A00048F8700448CE200148CE30010E1
70533+:101A60008CE500140043F82303E5C82B1320000580
70534+:101A7000024020218E24002C8CF1001010910031A6
70535+:101A80000240202124020012A38200680E001A4A9C
70536+:101A90002412FFFF105200022404FFFF0000202147
70537+:101AA0008FBF001C8FB200188FB100148FB00010D0
70538+:101AB0000080102103E0000827BD002090A800D47A
70539+:101AC000350400200A001A80A0A400D400CA4824CB
70540+:101AD0001520000B8F8B00448F8D00448DAC0010BF
70541+:101AE0001580000B024020218E2E002C51C0FFECEF
70542+:101AF00000002021024020210A001A9B2402001726
70543+:101B00008D66001050C0FFE6000020210240202119
70544+:101B10000A001A9B24020011024020212402001511
70545+:101B20000E001A4AA3820068240FFFFF104FFFDC4B
70546+:101B30002404FFFF0A001A8A8E2600000A001AC138
70547+:101B4000240200143C08000400C8382450E0FFD4EC
70548+:101B500000002021024020210A001A9B24020013C9
70549+:101B60008F85003827BDFFD8AFB3001CAFB2001877
70550+:101B7000AFB10014AFB00010AFBF002090A700D4E9
70551+:101B80008F90004C2412FFFF34E2004092060000C8
70552+:101B9000A0A200D48E0300100080982110720006CD
70553+:101BA00030D1003F2408000D0E001A4AA3880068B7
70554+:101BB000105200252404FFFF8F8A00388E09001878
70555+:101BC0008D4400D01124000702602021240C000E57
70556+:101BD0000E001A4AA38C0068240BFFFF104B001A5A
70557+:101BE0002404FFFF24040020122400048F8D0038F9
70558+:101BF00091AF00D435EE0020A1AE00D48F85005403
70559+:101C000010A00019000000001224004A8F9800382C
70560+:101C10008F92FCC0971000809651000A5230004805
70561+:101C20008F9300403C1F08008FFF318C03E5C82BC9
70562+:101C30001720001E02602021000028210E0019A993
70563+:101C400024060001000020218FBF00208FB3001C5C
70564+:101C50008FB200188FB100148FB0001000801021D7
70565+:101C600003E0000827BD00285224002A8E05001436
70566+:101C70008F840038948A008025490001A48900805F
70567+:101C8000948800803C0208008C42318831077FFF35
70568+:101C900010E2000E00000000026020210E00193446
70569+:101CA000240500010A001B0B000020212402002D46
70570+:101CB0000E001A4AA38200682403FFFF1443FFE1C9
70571+:101CC0002404FFFF0A001B0C8FBF002094990080A2
70572+:101CD000241F800024050001033FC024A498008035
70573+:101CE00090920080908E0080325100FF001181C2DE
70574+:101CF00000107827000F69C031CC007F018D582576
70575+:101D0000A08B00800E001934026020210A001B0BFA
70576+:101D1000000020212406FFFF54A6FFD68F84003840
70577+:101D2000026020210E001934240500010A001B0B5B
70578+:101D300000002021026020210A001B252402000A45
70579+:101D40002404FFFD0A001B0BAF9300608F8800384E
70580+:101D500027BDFFE8AFB00010AFBF0014910A00D458
70581+:101D60008F87004C00808021354900408CE60010B0
70582+:101D7000A10900D43C0208008C4231B030C53FFFBD
70583+:101D800000A2182B106000078F850050240DFF80E3
70584+:101D900090AE000D01AE6024318B00FF156000088D
70585+:101DA0000006C382020020212403000D8FBF00140F
70586+:101DB0008FB0001027BD00180A001A4AA3830068DC
70587+:101DC00033060003240F000254CFFFF70200202146
70588+:101DD00094A2001C8F85003824190023A4A200E8D7
70589+:101DE0008CE8000000081E02307F003F13F9003528
70590+:101DF0003C0A00838CE800188CA600D0110600086D
70591+:101E0000000000002405000E0E001A4AA385006899
70592+:101E10002407FFFF104700182404FFFF8F850038B8
70593+:101E200090A900D435240020A0A400D48F8C0044B5
70594+:101E3000918E000D31CD007FA18D000D8F83005458
70595+:101E40001060001C020020218F8400508C9800102C
70596+:101E50000303782B11E0000D241900180200202143
70597+:101E6000A39900680E001A4A2410FFFF10500002C8
70598+:101E70002404FFFF000020218FBF00148FB000104A
70599+:101E80000080102103E0000827BD00188C86001098
70600+:101E90008F9F00440200202100C31023AFE20010F6
70601+:101EA000240500010E0019A9240600010A001B9751
70602+:101EB000000020210E001934240500010A001B97A0
70603+:101EC00000002021010A5824156AFFD98F8C004494
70604+:101ED000A0A600FC0A001B84A386005A30A500FFC0
70605+:101EE0002406000124A9000100C9102B1040000C99
70606+:101EF00000004021240A000100A61823308B0001B5
70607+:101F000024C60001006A3804000420421160000267
70608+:101F100000C9182B010740251460FFF800A61823FC
70609+:101F200003E000080100102127BDFFD8AFB0001862
70610+:101F30008F90004CAFB1001CAFBF00202403FFFF07
70611+:101F40002411002FAFA30010920600002405000802
70612+:101F500026100001006620260E001BB0308400FF12
70613+:101F600000021E003C021EDC34466F410A001BD8F2
70614+:101F70000000102110A00009008018212445000154
70615+:101F800030A2FFFF2C4500080461FFFA0003204047
70616+:101F90000086202614A0FFF9008018210E001BB037
70617+:101FA000240500208FA300102629FFFF313100FFF8
70618+:101FB00000034202240700FF1627FFE20102182651
70619+:101FC00000035027AFAA0014AFAA00100000302170
70620+:101FD00027A8001027A7001400E6782391ED00033E
70621+:101FE00024CE000100C8602131C600FF2CCB0004C4
70622+:101FF0001560FFF9A18D00008FA200108FBF002097
70623+:102000008FB1001C8FB0001803E0000827BD002826
70624+:1020100027BDFFD0AFB3001CAFB00010AFBF00288A
70625+:10202000AFB50024AFB40020AFB20018AFB10014B8
70626+:102030003C0C80008D880128240FFF803C06800A1C
70627+:1020400025100100250B0080020F68243205007F57
70628+:10205000016F7024AD8E009000A62821AD8D002464
70629+:1020600090A600FC3169007F3C0A8004012A1821F7
70630+:10207000A386005A9067007C00809821AF830030CF
70631+:1020800030E20002AF88006CAF85003800A0182154
70632+:10209000144000022404003424040030A3840048C7
70633+:1020A0008C7200DC30D100FF24040004AF92006089
70634+:1020B00012240004A38000688E7400041680001EA1
70635+:1020C0003C0880009386005930C7000110E0000FE3
70636+:1020D0008F9300608CB000848CA800842404FF805F
70637+:1020E000020410240002F940310A007F03EA482567
70638+:1020F0003C0C2000012C902530CD00FE3C038000DC
70639+:10210000AC720830A38D00598F9300608FBF0028F8
70640+:102110008FB50024ACB300DC8FB400208FB3001C5B
70641+:102120008FB200188FB100148FB00010240200018C
70642+:1021300003E0000827BD00308E7F000895020120D3
70643+:102140008E67001003E2C8213326FFFF30D8000F4E
70644+:1021500033150001AF87003416A00058A39800582B
70645+:1021600035090C000309382100D81823AD03008479
70646+:10217000AF8700648E6A00043148FFFF1100007EC3
70647+:10218000A78A005C90AC00D42407FF8000EC3024C8
70648+:1021900030CB00FF1560004B9786005C938E005A91
70649+:1021A000240D000230D5FFFF11CD02A20000A021B6
70650+:1021B0008F85006002A5802B160000BC9388004824
70651+:1021C0003C11800096240120310400FF1485008812
70652+:1021D0008F8400648F9800343312000356400085CA
70653+:1021E00030A500FF8F900064310C00FF24060034FE
70654+:1021F00011860095AF90004C9204000414800118E1
70655+:102200008F8E0038A380003C8E0D00048DC800D84E
70656+:102210003C0600FF34CCFFFF01AC30240106182B34
70657+:1022200014600120AF8600548F8700609798005C8F
70658+:10223000AF8700400307402310C000C7A788005C99
70659+:102240008F91003030C3000300035823922A007C92
70660+:102250003171000302261021000A20823092000111
70661+:102260000012488000492821311FFFFF03E5C82BD9
70662+:10227000132001208F8800388F8500348F880064F8
70663+:102280001105025A3C0E3F018E0600003C0C250051
70664+:1022900000CE682411AC01638F84004C30E500FF50
70665+:1022A0000E00184A000030218F8800388F870060A8
70666+:1022B0008F8500340A001DB78F8600540A001C5613
70667+:1022C000AF87006490A400D400E48024320200FFB1
70668+:1022D000104000169386005990A6008890AE00D753
70669+:1022E00024A8008830D4003F2686FFE02CD10020AF
70670+:1022F000A38E003C1220000CAF88004C240B000180
70671+:1023000000CB20043095001916A0012B3C0680005C
70672+:1023100034CF0002008FC0241700022E3099002015
70673+:1023200017200234000000009386005930CB0001D2
70674+:102330001160000F9788005C8CBF00848CA900841A
70675+:10234000240AFF8003EA6024000C19403132007F28
70676+:10235000007238253C0D200000EDC82530D800FE65
70677+:102360003C0F8000ADF90830A39800599788005CB5
70678+:102370001500FF84000000008E630020306200041E
70679+:102380001040FF51938600592404FFFB0064802411
70680+:102390003C038000AE700020346601808C7301B86D
70681+:1023A0000660FFFE8F98006C347501003C1400013C
70682+:1023B000ACD800008C6B012424076085ACCB0004F2
70683+:1023C0008EAE000401D488245220000124076083CB
70684+:1023D00024190002A4C700083C0F1000A0D9000B6C
70685+:1023E0003C068000ACCF01B80A001C2B9386005934
70686+:1023F00030A500FF0E00184A240600018F88006CEB
70687+:102400003C05800034A90900250201889388004812
70688+:10241000304A0007304B00783C0340802407FF809F
70689+:102420000163C825014980210047F824310C00FFD1
70690+:1024300024060034ACBF0800AF90004CACB90810C3
70691+:102440005586FF6E920400048F8400388E11003090
70692+:10245000908E00D431CD001015A000108F83006045
70693+:102460002C6F000515E000E400000000909800D4F7
70694+:102470002465FFFC331200101640000830A400FF52
70695+:102480008F9F00648F99003413F90004388700018E
70696+:1024900030E20001144001C8000000000E001BC320
70697+:1024A000000000000A001DF8000000008F84006496
70698+:1024B00030C500FF0E00184A24060001939800481A
70699+:1024C000240B0034130B00A08F8500388F8600602A
70700+:1024D0009783005C306EFFFF00CE8823AF910060D1
70701+:1024E000A780005C1280FF90028018212414FFFD59
70702+:1024F0005474FFA28E6300208E6A00042403FFBF81
70703+:102500002408FFEF0155F823AE7F000490AC00D4FF
70704+:102510003189007FA0A900D48E7200208F8F0038EF
70705+:10252000A780005C364D0002AE6D0020A5E000BC27
70706+:1025300091E500D400A3C824A1F900D48F950038F8
70707+:10254000AEA000EC92B800D403085824A2AB00D48B
70708+:102550000A001CD78F8500388F910034AF8000604F
70709+:1025600002275821AF8B0034000020212403FFFFF5
70710+:10257000108301B48F8500388E0C00103C0D0800CC
70711+:102580008DAD31B09208000031843FFF008D802B6B
70712+:1025900012000023310D003F3C1908008F3931A88B
70713+:1025A0008F9F006C000479802408FF80033F202166
70714+:1025B000008FC821938500590328F8243C06008029
70715+:1025C0003C0F800034D80001001F91403331007F60
70716+:1025D0008F8600380251502535EE0940332B0078A4
70717+:1025E000333000073C0310003C02800C017890253A
70718+:1025F000020E48210143C0250222382134AE0001D9
70719+:10260000ADFF0804AF890050ADF20814AF87004455
70720+:10261000ADFF0028ACD90084ADF80830A38E005976
70721+:102620009383005A24070003106700272407000142
70722+:102630001467FFAC8F8500382411002311B1008589
70723+:1026400000000000240E000B026020210E001A4A38
70724+:10265000A38E00680040A0210A001D328F8500383B
70725+:1026600002602021240B000C0E001A4AA38B006884
70726+:10267000240AFFFF104AFFBD2404FFFF8F8E00389D
70727+:10268000A380003C8E0D00048DC800D83C0600FFDE
70728+:1026900034CCFFFF01AC30240106182B1060FEE2A1
70729+:1026A000AF86005402602021241200190E001A4A3D
70730+:1026B000A3920068240FFFFF104FFFAC2404FFFF1C
70731+:1026C0000A001C838F86005425A3FFE02C74002091
70732+:1026D0001280FFDD240E000B000328803C1108014E
70733+:1026E000263194B400B148218D2D000001A00008CE
70734+:1026F000000000008F85003400A710219385003C66
70735+:10270000AF82003402251821A383003C951F00BC32
70736+:102710000226282137F91000A51900BC5240FF926B
70737+:10272000AF850060246A0004A38A003C950900BCC0
70738+:1027300024A40004AF84006035322000A51200BC40
70739+:102740000A001D54000020218F8600602CC800055F
70740+:102750001500FF609783005C3065FFFF00C5C8234C
70741+:102760002F2F000511E00003306400FF24CDFFFC93
70742+:1027700031A400FF8F8900648F920034113200046D
70743+:10278000389F000133EC0001158001380000000083
70744+:102790008F840038908700D434E60010A08600D4DF
70745+:1027A0008F8500388F8600609783005CACA000ECBA
70746+:1027B0000A001D2F306EFFFF8CB500848CB400849E
70747+:1027C0003C04100002A7302400068940328E007FAE
70748+:1027D000022E8025020410253C08800024050001FB
70749+:1027E00002602021240600010E0019A9AD02083064
70750+:1027F0000A001CC38F8500388C8200EC1222FE7EFA
70751+:102800000260202124090005A38900680E001A4AED
70752+:102810002411FFFF1451FE782404FFFF0A001D5508
70753+:102820002403FFFF8F8F004C8F8800388DF8000045
70754+:10283000AD1800888DE70010AD0700988F87006005
70755+:102840000A001DB78F8600542406FFFF118600057D
70756+:10285000000000000E001B4C026020210A001D8FAA
70757+:102860000040A0210E001AD1026020210A001D8F15
70758+:102870000040A0218F90004C3C0208008C4231B0F7
70759+:102880008E110010322C3FFF0182282B10A0000C6B
70760+:10289000240BFF808F85005090A3000D01637024EE
70761+:1028A00031CA00FF1140000702602021001143825D
70762+:1028B000310600032418000110D8010600000000B2
70763+:1028C000026020212403000D0E001A4AA383006831
70764+:1028D000004020218F8500380A001D320080A02191
70765+:1028E0008F90004C3C0A08008D4A31B08F85005013
70766+:1028F0008E0400100000A0218CB1001430823FFF34
70767+:10290000004A602B8CB200205180FFEE0260202133
70768+:1029100090B8000D240BFF800178702431C300FFB4
70769+:102920005060FFE80260202100044382310600036A
70770+:1029300014C0FFE40260202194BF001C8F9900386E
70771+:102940008E060028A73F00E88CAF0010022F20233E
70772+:1029500014C4013A026020218F83005400C368210F
70773+:10296000022D382B14E00136240200188F8A00440F
70774+:102970008F820030024390218D4B00100163702341
70775+:10298000AD4E0010AD5200208C4C00740192282BEB
70776+:1029900014A0015F026020218F8400508E08002463
70777+:1029A0008C86002411060007026020212419001CD7
70778+:1029B0000E001A4AA3990068240FFFFF104FFFC5AD
70779+:1029C0002404FFFF8F8400448C87002424FF00012F
70780+:1029D000AC9F00241251012F8F8D00308DB10074F7
70781+:1029E0001232012C3C0B00808E0E000001CB5024D3
70782+:1029F00015400075000000008E0300142411FFFF35
70783+:102A0000107100073C0808003C0608008CC6319095
70784+:102A100000C8C0241300015202602021A380006876
70785+:102A20008E0300003C19000100792024108000135F
70786+:102A30003C1F0080007FA02416800009020028218E
70787+:102A4000026020212411001A0E001A4AA391006886
70788+:102A50002407FFFF1047FF9F2404FFFF02002821E7
70789+:102A6000026020210E001A6A240600012410FFFFD4
70790+:102A70001050FF982404FFFF241400018F8D0044A0
70791+:102A8000026020210280302195A900342405000134
70792+:102A9000253200010E0019A9A5B200340000202142
70793+:102AA0008F8500380A001D320080A0218F90004CD5
70794+:102AB0003C1408008E9431B08E07001030E53FFFC3
70795+:102AC00000B4C82B132000618F8600502412FF80B1
70796+:102AD00090C9000D0249682431A400FF5080005CB9
70797+:102AE000026020218F8C00541180000700078B8228
70798+:102AF0008F8500388F82FCC094BF0080944A000A02
70799+:102B0000515F00F78F8600403227000314E0006415
70800+:102B100000000000920E000211C000D8000000006A
70801+:102B20008E0B0024156000D902602021920400035E
70802+:102B300024190002308500FF14B90005308900FF18
70803+:102B40008F940054128000EA240D002C308900FF7D
70804+:102B5000392C00102D8400012D3200010244302553
70805+:102B6000020028210E001A6A026020212410FFFFB3
70806+:102B7000105000BF8F8500388F830054106000D341
70807+:102B8000240500013C0A08008D4A318C0143F82BD2
70808+:102B900017E000B22402002D02602021000028214D
70809+:102BA0000E0019A9240600018F85003800001821A5
70810+:102BB0000A001D320060A0210E0018750000000000
70811+:102BC0000A001DF800000000AC8000200A001E78FA
70812+:102BD0008E03001400002821026020210E0019A994
70813+:102BE000240600010A001CC38F8500380A001DB7A7
70814+:102BF0008F8800388CAA00848CAC00843C031000C1
70815+:102C00000147F824001F91403189007F024968255F
70816+:102C100001A32825ACC50830910700012405000157
70817+:102C2000026020210E0019A930E600010A001CC331
70818+:102C30008F850038938F00482403FFFD0A001D3460
70819+:102C4000AF8F00600A001D342403FFFF02602021C3
70820+:102C50002410000D0E001A4AA390006800401821AD
70821+:102C60008F8500380A001D320060A0210E00187503
70822+:102C7000000000009783005C8F86006000402021E8
70823+:102C80003070FFFF00D010232C4A00051140FE11C8
70824+:102C90008F850038ACA400EC0A001D2F306EFFFFBA
70825+:102CA00090CF000D31E300085460FFA192040003AF
70826+:102CB00002602021240200100E001A4AA38200683C
70827+:102CC0002403FFFF5443FF9A920400030A001F12DB
70828+:102CD0008F85003890A4000D308F000811E000951A
70829+:102CE0008F990054572000A6026020218E1F000CEF
70830+:102CF0008CB4002057F40005026020218E0D0008DE
70831+:102D00008CA7002411A7003A026020212402002091
70832+:102D1000A38200680E001A4A2412FFFF1052FEED33
70833+:102D20002404FFFF8F9F00442402FFF73C14800E11
70834+:102D300093EA000D2419FF803C03800001423824EF
70835+:102D4000A3E7000D8F9F00303C0908008D2931ACAE
70836+:102D50008F8C006C97F200788F870044012C302113
70837+:102D6000324D7FFF000D204000C4782131E5007F07
70838+:102D700000B4C02101F94024AC68002CA711000068
70839+:102D80008CEB0028256E0001ACEE00288CEA002CAC
70840+:102D90008E02002C01426021ACEC002C8E09002C2C
70841+:102DA000ACE900308E120014ACF2003494ED003A1D
70842+:102DB00025A40001A4E4003A97E600783C1108003D
70843+:102DC0008E3131B024C3000130707FFF1211005CDE
70844+:102DD000006030218F8F0030026020212405000127
70845+:102DE0000E001934A5E600780A001EA1000020217B
70846+:102DF0008E0900142412FFFF1132006B8F8A0038F5
70847+:102E00008E0200188D4C00D0144C00650260202109
70848+:102E10008E0B00248CAE0028116E005B2402002172
70849+:102E20000E001A4AA38200681452FFBE2404FFFF5A
70850+:102E30008F8500380A001D320080A0212402001F67
70851+:102E40000E001A4AA38200682409FFFF1049FEA160
70852+:102E50002404FFFF0A001E548F83005402602021C7
70853+:102E60000E001A4AA38200681450FF508F85003864
70854+:102E70002403FFFF0A001D320060A0218CD800242B
70855+:102E80008E0800241118FF29026020210A001F2744
70856+:102E90002402000F8E0900003C05008001259024CB
70857+:102EA0001640FF492402001A026020210E001A4A2F
70858+:102EB000A3820068240CFFFF144CFECF2404FFFF04
70859+:102EC0008F8500380A001D320080A0210E001934C1
70860+:102ED000026020218F8500380A001EE500001821BD
70861+:102EE0002403FFFD0060A0210A001D32AF860060B0
70862+:102EF000026020210E001A4AA38D00682403FFFF00
70863+:102F00001043FF588F8500380A001ECC920400033E
70864+:102F10002418001D0E001A4AA39800682403FFFF1E
70865+:102F20001443FE9D2404FFFF8F8500380A001D32E4
70866+:102F30000080A021026020210A001F3D24020024FD
70867+:102F4000240880000068C024330BFFFF000B73C20D
70868+:102F500031D000FF001088270A001F6E001133C017
70869+:102F6000240F001B0E001A4AA38F00681451FEACF8
70870+:102F70002404FFFF8F8500380A001D320080A02145
70871+:102F80000A001F3D240200278E0600288CA3002C77
70872+:102F900010C30008026020210A001F812402001FC4
70873+:102FA0000A001F812402000E026020210A001F81F6
70874+:102FB000240200258E04002C1080000D8F8F00301D
70875+:102FC0008DE800740104C02B5700000C0260202122
70876+:102FD0008CB900140086A0210334282B10A0FF52C6
70877+:102FE0008F9F0044026020210A001F8124020022DA
70878+:102FF000026020210A001F81240200230A001F8191
70879+:103000002402002627BDFFD8AFB3001CAFB10014C7
70880+:10301000AFBF0020AFB20018AFB000103C0280007C
70881+:103020008C5201408C4B01483C048000000B8C0208
70882+:10303000322300FF317300FF8C8501B804A0FFFE2E
70883+:1030400034900180AE1200008C8701442464FFF0AC
70884+:10305000240600022C830013AE070004A61100080A
70885+:10306000A206000BAE1300241060004F8FBF00209B
70886+:10307000000448803C0A0801254A9534012A402171
70887+:103080008D04000000800008000000003C030800E0
70888+:103090008C6331A831693FFF00099980007280215B
70889+:1030A000021370212405FF80264D0100264C00806C
70890+:1030B0003C02800031B1007F3198007F31CA007F2F
70891+:1030C0003C1F800A3C1980043C0F800C01C5202461
70892+:1030D00001A5302401853824014F1821AC46002475
70893+:1030E000023F402103194821AC470090AC4400281E
70894+:1030F000AF830044AF880038AF8900300E0019005C
70895+:10310000016080213C0380008C6B01B80560FFFEEC
70896+:103110008F8700448F8600383465018090E8000D69
70897+:10312000ACB20000A4B0000600082600000416039C
70898+:1031300000029027001227C21080008124C200885C
70899+:10314000241F6082A4BF0008A0A000052402000282
70900+:10315000A0A2000B8F8B0030000424003C08270045
70901+:1031600000889025ACB20010ACA00014ACA00024E4
70902+:10317000ACA00028ACA0002C8D6900382413FF807F
70903+:10318000ACA9001890E3000D02638024320500FF13
70904+:1031900010A000058FBF002090ED000D31AC007F26
70905+:1031A000A0EC000D8FBF00208FB3001C8FB2001861
70906+:1031B0008FB100148FB000103C0A10003C0E80004C
70907+:1031C00027BD002803E00008ADCA01B8265F010052
70908+:1031D0002405FF8033F8007F3C06800003E5782457
70909+:1031E0003C19800A03192021ACCF0024908E00D412
70910+:1031F00000AE682431AC00FF11800024AF84003899
70911+:10320000248E008895CD00123C0C08008D8C31A8CE
70912+:1032100031AB3FFF01924821000B5180012A402130
70913+:1032200001052024ACC400283107007F3C06800C37
70914+:1032300000E620219083000D00A31024304500FFFC
70915+:1032400010A0FFD8AF8400449098000D330F0010F9
70916+:1032500015E0FFD58FBF00200E0019000000000010
70917+:103260003C0380008C7901B80720FFFE00000000BD
70918+:10327000AE1200008C7F0144AE1F0004A6110008AE
70919+:1032800024110002A211000BAE1300243C1308010C
70920+:10329000927396F0327000015200FFC38FBF00207E
70921+:1032A0000E002146024020210A0020638FBF00202B
70922+:1032B0003C1260008E452C083C03F0033462FFFF93
70923+:1032C00000A2F824AE5F2C088E582C083C1901C0CF
70924+:1032D00003199825AE532C080A0020638FBF0020E5
70925+:1032E000264D010031AF007F3C10800A240EFF8084
70926+:1032F00001F0282101AE60243C0B8000AD6C00245D
70927+:103300001660FFA8AF85003824110003A0B100FCAF
70928+:103310000A0020638FBF002026480100310A007F89
70929+:103320003C0B800A2409FF80014B30210109202435
70930+:103330003C078000ACE400240A002062AF8600381D
70931+:10334000944E0012320C3FFF31CD3FFF15ACFF7D94
70932+:10335000241F608290D900D42418FF800319782498
70933+:1033600031EA00FF1140FF7700000000240700044D
70934+:10337000A0C700FC8F870044241160842406000D40
70935+:10338000A4B10008A0A600050A00204D24020002F6
70936+:103390003C040001248496DC24030014240200FE73
70937+:1033A0003C010800AC2431EC3C010800AC2331E8BE
70938+:1033B0003C010801A42296F83C040801248496F8F4
70939+:1033C0000000182100643021A0C300042463000120
70940+:1033D0002C6500FF54A0FFFC006430213C0708006E
70941+:1033E00024E7010003E00008AF87007800A058211F
70942+:1033F000008048210000102114A00012000050217C
70943+:103400000A002142000000003C010801A42096F8B7
70944+:103410003C05080194A596F88F8200783C0C0801C1
70945+:10342000258C96F800E2182100AC2021014B302BAE
70946+:10343000A089000400001021A460000810C0003919
70947+:10344000010048218F8600780009384000E94021BA
70948+:103450000008388000E6282190A8000B90B9000AE7
70949+:103460000008204000881021000218800066C0215A
70950+:10347000A319000A8F85007800E5782191EE000AF3
70951+:1034800091E6000B000E684001AE6021000C208028
70952+:1034900000851021A046000B3C030801906396F2C2
70953+:1034A000106000222462FFFF8F8300383C01080176
70954+:1034B000A02296F2906C00FF118000040000000032
70955+:1034C000906E00FF25CDFFFFA06D00FF3C190801A5
70956+:1034D000973996F8272300013078FFFF2F0F00FF60
70957+:1034E00011E0FFC9254A00013C010801A42396F818
70958+:1034F0003C05080194A596F88F8200783C0C0801E1
70959+:10350000258C96F800E2182100AC2021014B302BCD
70960+:10351000A089000400001021A460000814C0FFC9A5
70961+:103520000100482103E000080000000003E000085B
70962+:103530002402000227BDFFE0248501002407FF804C
70963+:10354000AFB00010AFBF0018AFB1001400A718242F
70964+:103550003C10800030A4007F3C06800A00862821B1
70965+:103560008E110024AE03002490A200FF1440000836
70966+:10357000AF850038A0A000098FBF0018AE1100244D
70967+:103580008FB100148FB0001003E0000827BD0020A9
70968+:1035900090A900FD90A800FF312400FF0E0020F448
70969+:1035A000310500FF8F8500388FBF0018A0A00009EB
70970+:1035B000AE1100248FB100148FB0001003E000089A
70971+:1035C00027BD002027BDFFD0AFB20020AFB1001C47
70972+:1035D000AFB00018AFBF002CAFB40028AFB30024C9
70973+:1035E0003C0980009533011635320C00952F011AE5
70974+:1035F0003271FFFF023280218E08000431EEFFFF9E
70975+:10360000248B0100010E6821240CFF8025A5FFFFFB
70976+:10361000016C50243166007F3C07800AAD2A0024EB
70977+:1036200000C73021AF850074AF8800703C010801ED
70978+:10363000A02096F190C300090200D02100809821BB
70979+:10364000306300FF2862000510400048AF86003854
70980+:10365000286400021480008E24140001240D00054B
70981+:103660003C010801A02D96D590CC00FD3C0108013D
70982+:10367000A02096D63C010801A02096D790CB000A46
70983+:10368000240AFF80318500FF014B4824312700FFC9
70984+:1036900010E0000C000058213C12800836510080D8
70985+:1036A0008E2F00308CD0005C01F0702305C0018E9D
70986+:1036B0008F87007090D4000A3284007FA0C4000A73
70987+:1036C0008F8600383C118008363000808E0F003025
70988+:1036D0008F87007000EF702319C000EE000000001B
70989+:1036E00090D4000924120002328400FF1092024795
70990+:1036F000000000008CC2005800E2F82327F9FFFF09
70991+:103700001B2001300000000090C5000924080004BF
70992+:1037100030A300FF10680057240A00013C01080193
70993+:10372000A02A96D590C900FF252700013C01080179
70994+:10373000A02796D43C030801906396D52406000583
70995+:103740001066006A2C780005130000C40000902168
70996+:103750000003F8803C0408012484958003E4C82118
70997+:103760008F25000000A0000800000000241800FFC2
70998+:103770001078005C0000000090CC000A90CA00099C
70999+:103780003C080801910896F13187008000EA48253D
71000+:103790003C010801A02996DC90C500FD3C140801FD
71001+:1037A000929496F2311100013C010801A02596DDAA
71002+:1037B00090DF00FE3C010801A03F96DE90D200FFA2
71003+:1037C0003C010801A03296DF8CD900543C0108016D
71004+:1037D000AC3996E08CD000583C010801AC3096E43E
71005+:1037E0008CC3005C3C010801AC3496EC3C01080140
71006+:1037F000AC2396E8162000088FBF002C8FB4002859
71007+:103800008FB300248FB200208FB1001C8FB000183E
71008+:1038100003E0000827BD00303C1180009624010E13
71009+:103820000E000FD43094FFFF3C0B08018D6B96F413
71010+:103830000260382102802821AE2B01803C13080150
71011+:103840008E7396D401602021240600830E00102F71
71012+:10385000AFB300108FBF002C8FB400288FB30024AB
71013+:103860008FB200208FB1001C8FB0001803E0000859
71014+:1038700027BD00303C1808008F1831FC270F0001CD
71015+:103880003C010800AC2F31FC0A0021D700000000E9
71016+:103890001474FFB900000000A0C000FF3C05080040
71017+:1038A0008CA531E43C0308008C6331E03C02080045
71018+:1038B0008C4232048F99003834A80001241F000282
71019+:1038C0003C010801AC2396F43C010801A02896F0C5
71020+:1038D0003C010801A02296F3A33F00090A002190B1
71021+:1038E0008F8600380E002146000000000A0021D714
71022+:1038F0008F8600383C1F080193FF96D424190001DD
71023+:1039000013F902298F8700703C100801921096D895
71024+:103910003C06080190C696D610C000050200A02102
71025+:103920003C040801908496D9109001E48F870078B8
71026+:10393000001088408F9F0078023048210009C8801D
71027+:10394000033F702195D80008270F0001A5CF00087C
71028+:103950003C040801908496D93C05080190A596D6B0
71029+:103960000E0020F4000000008F8700780230202134
71030+:103970000004308000C720218C8500048F820074F1
71031+:1039800000A2402305020006AC8200048C8A0000DD
71032+:103990008F830070014310235C400001AC83000062
71033+:1039A0008F86003890CB00FF2D6C00025580002DD3
71034+:1039B000241400010230F821001F40800107282153
71035+:1039C00090B9000B8CAE00040019C0400319782197
71036+:1039D000000F1880006710218C4D000001AE882375
71037+:1039E0002630FFFF5E00001F241400018C440004F9
71038+:1039F0008CAA0000008A482319200019240E000414
71039+:103A00003C010801A02E96D590AD000B8CAB0004B4
71040+:103A1000000D8840022D80210010108000471021E9
71041+:103A20008C44000401646023058202009443000872
71042+:103A300090DF00FE90B9000B33E500FF54B900049D
71043+:103A40000107A021A0D400FE8F8700780107A021E4
71044+:103A50009284000B0E0020F4240500018F860038AC
71045+:103A600024140001125400962E500001160000424A
71046+:103A70003C08FFFF241900021659FF3F0000000018
71047+:103A8000A0C000FF8F860038A0D200090A0021D70D
71048+:103A90008F86003890C700092404000230E300FF3D
71049+:103AA0001064016F24090004106901528F880074AA
71050+:103AB0008CCE0054010E682325B10001062001754B
71051+:103AC000241800043C010801A03896D53C010801E7
71052+:103AD000A02096D490D400FD90D200FF2E4F00027B
71053+:103AE00015E0FF14328400FF000438408F8900780D
71054+:103AF00090DF00FF00E41021000220800089C8212F
71055+:103B00002FE500029324000B14A0FF0A24070002F3
71056+:103B100000041840006480210010588001692821A9
71057+:103B20008CAC0004010C50230540FF020000000093
71058+:103B30003C030801906396D614600005246F0001D1
71059+:103B40003C010801A02496D93C010801A02796D782
71060+:103B50003C010801A02F96D690CE00FF24E700017B
71061+:103B600031CD00FF01A7882B1220FFE990A4000BA4
71062+:103B70000A0021C6000000003C0508018CA596D46F
71063+:103B80003C12000400A8F82413F2000624020005E9
71064+:103B90003C090801912996D5152000022402000352
71065+:103BA000240200053C010801A02296F190C700FF05
71066+:103BB00014E0012024020002A0C200090A0021D75B
71067+:103BC0008F86003890CC00FF1180FEDA240A0001B5
71068+:103BD0008F8C00748F890078240F00030180682186
71069+:103BE0001160001E240E0002000540400105A021C6
71070+:103BF00000142080008990218E51000401918023BF
71071+:103C00000600FECC000000003C020801904296D65F
71072+:103C100014400005245800013C010801A02A96D751
71073+:103C20003C010801A02596D93C010801A03896D690
71074+:103C300090DF00FF010510210002C88033E500FF7E
71075+:103C4000254A00010329202100AA402B1500FEB9B6
71076+:103C50009085000B1560FFE50005404000054040E1
71077+:103C600001051821000310803C010801A02A96D408
71078+:103C70003C010801A02596D8004918218C64000455
71079+:103C800000E4F82327F9FFFF1F20FFE900000000F0
71080+:103C90008C63000000E358230560013A01A38823E8
71081+:103CA00010E301170184C0231B00FEA200000000E6
71082+:103CB0003C010801A02E96D50A002305240B000123
71083+:103CC000240E0004A0CE00093C0D08008DAD31F893
71084+:103CD0008F86003825A200013C010800AC2231F893
71085+:103CE0000A0021D7000000008CD9005C00F9C02335
71086+:103CF0001F00FE7B000000008CDF005C10FFFF65F2
71087+:103D00008F8400748CC3005C008340232502000173
71088+:103D10001C40FF60000000008CC9005C248700018B
71089+:103D200000E9282B10A0FE943C0D80008DAB01040F
71090+:103D30003C0C0001016C50241140FE8F2402001045
71091+:103D40003C010801A02296F10A0021D700000000E2
71092+:103D50008F9100748F86003826220001ACC2005C6F
71093+:103D60000A002292241400018F8700382404FF8067
71094+:103D70000000882190E9000A241400010124302564
71095+:103D8000A0E6000A3C05080190A596D63C0408016F
71096+:103D9000908496D90E0020F4000000008F86003831
71097+:103DA0008F85007890C800FD310700FF0007404074
71098+:103DB0000107F821001FC0800305C8219323000BD1
71099+:103DC000A0C300FD8F8500788F8600380305602131
71100+:103DD000918F000B000F704001CF6821000D808093
71101+:103DE000020510218C4B0000ACCB00548D840004E4
71102+:103DF0008F83007400645023194000022482000164
71103+:103E00002462000101074821ACC2005C0009308037
71104+:103E100000C5402100E02021240500010E0020F40F
71105+:103E20009110000B8F86003890C500FF10A0FF0C8A
71106+:103E3000001070408F85007801D06821000D10803F
71107+:103E4000004558218D6400008F8C0074018450233C
71108+:103E50002547000104E0FF02263100013C03080170
71109+:103E6000906396D62E2F0002247800013C010801B1
71110+:103E7000A03896D63C010801A03496D711E0FEF890
71111+:103E8000020038210A002365000740408F84003873
71112+:103E90008F8300748C85005800A340230502FE9A8E
71113+:103EA000AC8300580A00223B000000003C070801D8
71114+:103EB00090E796F2240200FF10E200BE8F860038E1
71115+:103EC0003C110801963196FA3C030801246396F8E8
71116+:103ED000262500013230FFFF30ABFFFF02036021D7
71117+:103EE0002D6A00FF1540008D918700043C010801F8
71118+:103EF000A42096FA8F88003800074840012728211F
71119+:103F0000911800FF000530802405000127140001EE
71120+:103F1000A11400FF3C120801925296F28F8800789B
71121+:103F20008F8E0070264F000100C820213C0108013F
71122+:103F3000A02F96F2AC8E00008F8D0074A48500082F
71123+:103F4000AC8D00043C030801906396D414600077A4
71124+:103F5000000090213C010801A02596D4A087000B09
71125+:103F60008F8C007800CC5021A147000A8F82003846
71126+:103F7000A04700FD8F840038A08700FE8F860038A0
71127+:103F80008F9F0070ACDF00548F990074ACD900583B
71128+:103F90008F8D00780127C02100185880016DA02165
71129+:103FA000928F000A000F704001CF18210003888013
71130+:103FB000022D8021A207000B8F8600780166602108
71131+:103FC000918A000B000A1040004A2021000428803A
71132+:103FD00000A64021A107000A3C07800834E90080C0
71133+:103FE0008D2200308F860038ACC2005C0A0022921D
71134+:103FF0002414000190CA00FF1540FEAD8F880074A4
71135+:10400000A0C400090A0021D78F860038A0C000FD97
71136+:104010008F98003824060001A30000FE3C0108012F
71137+:10402000A02696D53C010801A02096D40A0021C6FE
71138+:104030000000000090CB00FF3C040801908496F340
71139+:10404000316C00FF0184502B1540000F2402000347
71140+:1040500024020004A0C200090A0021D78F8600387C
71141+:1040600090C3000A2410FF8002035824316C00FF23
71142+:104070001180FDC1000000003C010801A02096D580
71143+:104080000A0021C600000000A0C200090A0021D7D2
71144+:104090008F86003890D4000A2412FF8002544824EE
71145+:1040A000312800FF1500FFF4240200083C0108013C
71146+:1040B000A02296F10A0021D70000000000108840DD
71147+:1040C0008F8B0070023018210003688001A7202127
71148+:1040D000AC8B00008F8A0074240C0001A48C0008B3
71149+:1040E000AC8A00043C05080190A596D62402000184
71150+:1040F00010A2FE1E24A5FFFF0A0022519084000B8F
71151+:104100000184A0231A80FD8B000000003C010801FF
71152+:10411000A02E96D50A002305240B00013C010801BE
71153+:10412000A42596FA0A0023B78F880038240B0001D3
71154+:10413000106B00228F9800388F85003890BF00FFE9
71155+:1041400033F900FF1079002B000000003C1F08012C
71156+:1041500093FF96D8001FC840033FC0210018A080DD
71157+:104160000288782191EE000AA08E000A8F8D0078D7
71158+:104170003C030801906396D800CD88210A0023DD16
71159+:10418000A223000B263000010600003101A4902379
71160+:104190000640002B240200033C010801A02F96D505
71161+:1041A0000A002305240B00018F8900380A00223BF6
71162+:1041B000AD2700540A00229124120001931400FD3F
71163+:1041C000A094000B8F8800388F8F0078910E00FE2E
71164+:1041D00000CF6821A1AE000A8F910038A22700FD10
71165+:1041E0008F8300708F900038AE0300540A0023DEE6
71166+:1041F0008F8D007890B000FEA090000A8F8B003861
71167+:104200008F8C0078916A00FD00CC1021A04A000B31
71168+:104210008F840038A08700FE8F8600748F85003859
71169+:10422000ACA600580A0023DE8F8D007894B80008F1
71170+:10423000ACA40004030378210A002285A4AF00087F
71171+:104240003C010801A02296D50A0021C6000000000A
71172+:1042500090CF0009240D000431EE00FF11CDFD8543
71173+:10426000240200013C010801A02296D50A0021C6C3
71174+:1042700000000000080033440800334408003420E4
71175+:10428000080033F4080033D8080033280800332826
71176+:10429000080033280800334C8008010080080080A3
71177+:1042A000800800005F865437E4AC62CC50103A4579
71178+:1042B00036621985BF14C0E81BC27A1E84F4B55655
71179+:1042C000094EA6FE7DDA01E7C04D748108005A74DC
71180+:1042D00008005AB808005A5C08005A5C08005A5C8A
71181+:1042E00008005A5C08005A7408005A5C08005A5CBE
71182+:1042F00008005AC008005A5C080059D408005A5CEB
71183+:1043000008005A5C08005AC008005A5C08005A5C51
71184+:1043100008005A5C08005A5C08005A5C08005A5CA5
71185+:1043200008005A5C08005A5C08005A5C08005A5C95
71186+:1043300008005A9408005A5C08005A9408005A5C15
71187+:1043400008005A5C08005A5C08005A9808005A9401
71188+:1043500008005A5C08005A5C08005A5C08005A5C65
71189+:1043600008005A5C08005A5C08005A5C08005A5C55
71190+:1043700008005A5C08005A5C08005A5C08005A5C45
71191+:1043800008005A5C08005A5C08005A5C08005A5C35
71192+:1043900008005A5C08005A5C08005A5C08005A5C25
71193+:1043A00008005A9808005A9808005A5C08005A9861
71194+:1043B00008005A5C08005A5C08005A5C08005A5C05
71195+:1043C00008005A5C08005A5C08005A5C08005A5CF5
71196+:1043D00008005A5C08005A5C08005A5C08005A5CE5
71197+:1043E00008005A5C08005A5C08005A5C08005A5CD5
71198+:1043F00008005A5C08005A5C08005A5C08005A5CC5
71199+:1044000008005A5C08005A5C08005A5C08005A5CB4
71200+:1044100008005A5C08005A5C08005A5C08005A5CA4
71201+:1044200008005A5C08005A5C08005A5C08005A5C94
71202+:1044300008005A5C08005A5C08005A5C08005A5C84
71203+:1044400008005A5C08005A5C08005A5C08005A5C74
71204+:1044500008005A5C08005A5C08005A5C08005A5C64
71205+:1044600008005A5C08005A5C08005A5C08005A5C54
71206+:1044700008005A5C08005A5C08005A5C08005A5C44
71207+:1044800008005A5C08005A5C08005A5C08005A5C34
71208+:1044900008005A5C08005A5C08005A5C08005A5C24
71209+:1044A00008005A5C08005A5C08005A5C08005A5C14
71210+:1044B00008005A5C08005A5C08005A5C08005A5C04
71211+:1044C00008005A5C08005A5C08005A5C08005ADC74
71212+:1044D0000800782C08007A900800783808007628C0
71213+:1044E00008007838080078C4080078380800762872
71214+:1044F0000800762808007628080076280800762824
71215+:104500000800762808007628080076280800762813
71216+:1045100008007628080078580800784808007628AF
71217+:1045200008007628080076280800762808007628F3
71218+:1045300008007628080076280800762808007628E3
71219+:1045400008007628080076280800762808007848B1
71220+:10455000080082FC08008188080082C40800818865
71221+:104560000800829408008070080081880800818813
71222+:1045700008008188080081880800818808008188F7
71223+:1045800008008188080081880800818808008188E7
71224+:104590000800818808008188080081B008008D34F7
71225+:1045A00008008E9008008E70080088D808008D4C96
71226+:1045B0000A00012400000000000000000000000DBF
71227+:1045C000747061362E322E31620000000602010145
71228+:1045D00000000000000000000000000000000000DB
71229+:1045E00000000000000000000000000000000000CB
71230+:1045F00000000000000000000000000000000000BB
71231+:1046000000000000000000000000000000000000AA
71232+:10461000000000000000000000000000000000009A
71233+:10462000000000000000000000000000000000008A
71234+:10463000000000000000000000000000000000007A
71235+:104640000000000010000003000000000000000D4A
71236+:104650000000000D3C020800244217203C03080023
71237+:1046600024632A10AC4000000043202B1480FFFD7F
71238+:10467000244200043C1D080037BD2FFC03A0F0219C
71239+:104680003C100800261004903C1C0800279C1720B2
71240+:104690000E000262000000000000000D2402FF80F6
71241+:1046A00027BDFFE000821024AFB00010AF42002011
71242+:1046B000AFBF0018AFB10014936500043084007FD1
71243+:1046C000034418213C0200080062182130A5002094
71244+:1046D000036080213C080111277B000814A0000220
71245+:1046E0002466005C2466005892020004974301048B
71246+:1046F000920400043047000F3063FFFF3084004015
71247+:10470000006728231080000900004821920200055C
71248+:1047100030420004104000050000000010A000031B
71249+:104720000000000024A5FFFC2409000492020005FB
71250+:1047300030420004104000120000000010A00010E1
71251+:10474000000000009602000200A72021010440257D
71252+:104750002442FFFEA7421016920300042402FF80A9
71253+:1047600000431024304200FF104000033C020400CC
71254+:104770000A000174010240258CC20000AF421018EB
71255+:104780008F4201780440FFFE2402000AA742014044
71256+:1047900096020002240400093042000700021023A0
71257+:1047A00030420007A7420142960200022442FFFE67
71258+:1047B000A7420144A740014697420104A74201488D
71259+:1047C0008F420108304200205040000124040001C3
71260+:1047D00092020004304200101440000234830010A2
71261+:1047E00000801821A743014A0000000000000000DB
71262+:1047F0000000000000000000AF48100000000000B2
71263+:104800000000000000000000000000008F421000C7
71264+:104810000441FFFE3102FFFF1040000700000000CE
71265+:1048200092020004304200401440000300000000E7
71266+:104830008F421018ACC20000960200063042FFFF03
71267+:10484000244200020002104300021040036288214B
71268+:10485000962200001120000D3044FFFF00A7102118
71269+:104860008F8300388F45101C0002108200021080D8
71270+:1048700000431021AC45000030A6FFFF0E00058D5F
71271+:1048800000052C0200402021A62200009203000413
71272+:104890002402FF8000431024304200FF1040001F1C
71273+:1048A0000000000092020005304200021040001B90
71274+:1048B000000000009742100C2442FFFEA742101691
71275+:1048C000000000003C02040034420030AF421000FF
71276+:1048D00000000000000000000000000000000000D8
71277+:1048E0008F4210000441FFFE000000009742100CB0
71278+:1048F0008F45101C3042FFFF24420030000210821E
71279+:1049000000021080005B1021AC45000030A6FFFFC4
71280+:104910000E00058D00052C02A62200009604000260
71281+:10492000248400080E0001E93084FFFF974401044D
71282+:104930000E0001F73084FFFF8FBF00188FB1001405
71283+:104940008FB000103C02100027BD002003E00008DB
71284+:10495000AF4201783084FFFF308200078F8500244A
71285+:1049600010400002248300073064FFF800A41021E7
71286+:1049700030421FFF03421821247B4000AF850028EE
71287+:10498000AF82002403E00008AF4200843084FFFFC0
71288+:104990003082000F8F85002C8F860034104000027B
71289+:1049A0002483000F3064FFF000A410210046182B70
71290+:1049B000AF8500300046202314600002AF82002C37
71291+:1049C000AF84002C8F82002C340480000342182115
71292+:1049D00000641821AF83003803E00008AF42008074
71293+:1049E0008F820014104000088F8200048F82FFDC49
71294+:1049F000144000058F8200043C02FFBF3442FFFFD9
71295+:104A0000008220248F82000430430006240200022A
71296+:104A10001062000F3C0201012C62000350400005AF
71297+:104A2000240200041060000F3C0200010A00023062
71298+:104A30000000000010620005240200061462000C51
71299+:104A40003C0201110A000229008210253C020011DB
71300+:104A500000821025AF421000240200010A0002303B
71301+:104A6000AF82000C00821025AF421000AF80000C16
71302+:104A700000000000000000000000000003E000084B
71303+:104A8000000000008F82000C1040000400000000B5
71304+:104A90008F4210000441FFFE0000000003E0000808
71305+:104AA000000000008F8200102443F800000231C291
71306+:104AB00024C2FFF02C6303011060000300021042C7
71307+:104AC0000A000257AC8200008F85001800C5102B29
71308+:104AD0001440000B0000182100C5102324470001DA
71309+:104AE0008F82001C00A210212442FFFF0046102BE1
71310+:104AF000544000042402FFFF0A000257AC87000064
71311+:104B00002402FFFF0A000260AC8200008C820000D9
71312+:104B10000002194000621821000318800062182169
71313+:104B2000000318803C0208002442175C0062182130
71314+:104B300003E000080060102127BDFFD8AFBF0020B0
71315+:104B4000AFB1001CAFB000183C0460088C8250006C
71316+:104B50002403FF7F3C066000004310243442380CDD
71317+:104B6000AC8250008CC24C1C3C1A80000002160221
71318+:104B70003042000F10400007AF82001C8CC34C1C59
71319+:104B80003C02001F3442FC0000621824000319C2DA
71320+:104B9000AF8300188F420008275B400034420001B9
71321+:104BA000AF420008AF8000243C02601CAF40008090
71322+:104BB000AF4000848C4500088CC308083402800094
71323+:104BC000034220212402FFF0006218243C020080EE
71324+:104BD0003C010800AC2204203C025709AF84003895
71325+:104BE00014620004AF850034240200010A0002921E
71326+:104BF000AF820014AF8000148F42000038420001E1
71327+:104C0000304200011440FFFC8F8200141040001657
71328+:104C10000000000097420104104000058F8300004F
71329+:104C2000146000072462FFFF0A0002A72C62000A3A
71330+:104C30002C620010504000048F83000024620001A9
71331+:104C4000AF8200008F8300002C62000A1440000332
71332+:104C50002C6200070A0002AEAF80FFDC10400002A9
71333+:104C600024020001AF82FFDC8F4301088F44010062
71334+:104C700030622000AF83000410400008AF840010B1
71335+:104C80003C0208008C42042C244200013C01080034
71336+:104C9000AC22042C0A00058A3C0240003065020068
71337+:104CA00014A0000324020F001482026024020D00ED
71338+:104CB00097420104104002C83C02400030624000AC
71339+:104CC000144000AD8F8200388C4400088F42017878
71340+:104CD0000440FFFE24020800AF42017824020008CD
71341+:104CE000A7420140A7400142974201048F8400047B
71342+:104CF0003051FFFF30820001104000070220802168
71343+:104D00002623FFFE240200023070FFFFA742014667
71344+:104D10000A0002DBA7430148A74001463C02080005
71345+:104D20008C42043C1440000D8F8300103082002020
71346+:104D30001440000224030009240300010060202124
71347+:104D40008F830010240209005062000134840004A3
71348+:104D5000A744014A0A0002F60000000024020F00E6
71349+:104D60001462000530820020144000062403000D68
71350+:104D70000A0002F524030005144000022403000980
71351+:104D800024030001A743014A3C0208008C4204208E
71352+:104D90003C0400480E00020C004420250E000235A1
71353+:104DA000000000008F82000C1040003E0000000058
71354+:104DB0008F4210003C0300200043102410400039B3
71355+:104DC0008F820004304200021040003600000000D4
71356+:104DD000974210141440003300000000974210085E
71357+:104DE0008F8800383042FFFF2442000600021882FC
71358+:104DF0000003388000E83021304300018CC40000FB
71359+:104E000010600004304200030000000D0A00033768
71360+:104E100000E81021544000103084FFFF3C05FFFFE4
71361+:104E200000852024008518260003182B0004102B71
71362+:104E300000431024104000050000000000000000A6
71363+:104E40000000000D00000000240002228CC20000BF
71364+:104E50000A000336004520253883FFFF0003182B86
71365+:104E60000004102B00431024104000050000000037
71366+:104E7000000000000000000D000000002400022BD4
71367+:104E80008CC200003444FFFF00E81021AC44000055
71368+:104E90003C0208008C420430244200013C0108001E
71369+:104EA000AC2204308F6200008F840038AF8200088B
71370+:104EB0008C8300003402FFFF1462000F00001021F9
71371+:104EC0003C0508008CA504543C0408008C84045064
71372+:104ED00000B0282100B0302B008220210086202144
71373+:104EE0003C010800AC2504543C010800AC240450EB
71374+:104EF0000A000580240400088C8200003042010072
71375+:104F00001040000F000010213C0508008CA5044C47
71376+:104F10003C0408008C84044800B0282100B0302BE9
71377+:104F200000822021008620213C010800AC25044C91
71378+:104F30003C010800AC2404480A0005802404000851
71379+:104F40003C0508008CA504443C0408008C84044003
71380+:104F500000B0282100B0302B0082202100862021C3
71381+:104F60003C010800AC2504443C010800AC2404408A
71382+:104F70000A000580240400088F6200088F62000088
71383+:104F800000021602304300F02402003010620005D7
71384+:104F900024020040106200E08F8200200A00058891
71385+:104FA0002442000114A000050000000000000000E1
71386+:104FB0000000000D00000000240002568F4201781E
71387+:104FC0000440FFFE000000000E00023D27A4001078
71388+:104FD0001440000500408021000000000000000D8A
71389+:104FE000000000002400025D8E0200001040000559
71390+:104FF00000000000000000000000000D00000000A4
71391+:10500000240002608F62000C0443000324020001AC
71392+:105010000A00042EAE000000AE0200008F820038AD
71393+:105020008C480008A20000078F65000C8F64000404
71394+:1050300030A3FFFF0004240200852023308200FFFC
71395+:105040000043102124420005000230832CC200815D
71396+:10505000A605000A14400005A20400040000000098
71397+:105060000000000D00000000240002788F85003849
71398+:105070000E0005AB260400148F6200048F43010864
71399+:10508000A60200083C02100000621824106000080C
71400+:105090000000000097420104920300072442FFEC45
71401+:1050A000346300023045FFFF0A0003C3A203000778
71402+:1050B000974201042442FFF03045FFFF96060008A6
71403+:1050C0002CC200135440000592030007920200070F
71404+:1050D00034420001A20200079203000724020001EB
71405+:1050E00010620005240200031062000B8F8200385A
71406+:1050F0000A0003E030C6FFFF8F8200383C04FFFF48
71407+:105100008C43000C0064182400651825AC43000C87
71408+:105110000A0003E030C6FFFF3C04FFFF8C43001091
71409+:105120000064182400651825AC43001030C6FFFF4A
71410+:1051300024C2000200021083A20200058F830038FF
71411+:10514000304200FF00021080004328218CA800009C
71412+:105150008CA2000024030004000217021443001272
71413+:1051600000000000974201043C03FFFF01031824E4
71414+:105170003042FFFF004610232442FFFE006240251C
71415+:10518000ACA8000092030005306200FF000210800E
71416+:1051900000501021904200143042000F00431021B3
71417+:1051A0000A000415A20200068CA400049742010420
71418+:1051B0009603000A3088FFFF3042FFFF00461023AD
71419+:1051C0002442FFD60002140001024025ACA80004CE
71420+:1051D000920200079204000524630028000318834C
71421+:1051E0000064182134420004A2030006A202000752
71422+:1051F0008F8200042403FFFB34420002004310248A
71423+:10520000AF820004920300068F87003800031880E5
71424+:10521000007010218C4400203C02FFF63442FFFF56
71425+:105220000082402400671821AE04000CAC68000C1A
71426+:10523000920500063C03FF7F8E02000C00052880CB
71427+:1052400000B020213463FFFF01033024948800263E
71428+:1052500000A7282100431024AE02000CAC860020D9
71429+:10526000AC880024ACA8001024020010A742014022
71430+:1052700024020002A7400142A7400144A742014680
71431+:10528000974201043C0400082442FFFEA742014863
71432+:10529000240200010E00020CA742014A9603000AF4
71433+:1052A0009202000400431021244200023042000711
71434+:1052B00000021023304200070E000235AE0200103B
71435+:1052C0008F6200003C0308008C6304442404001037
71436+:1052D000AF820008974201043042FFFF2442FFFEE4
71437+:1052E00000403821000237C33C0208008C420440D1
71438+:1052F000006718210067282B004610210045102167
71439+:105300003C010800AC2304443C010800AC220440EA
71440+:105310000A0005150000000014A0000500000000B0
71441+:10532000000000000000000D000000002400030A3F
71442+:105330008F4201780440FFFE000000000E00023D95
71443+:1053400027A4001414400005004080210000000044
71444+:105350000000000D00000000240003118E02000078
71445+:105360005440000692020007000000000000000DFB
71446+:10537000000000002400031C9202000730420004D9
71447+:10538000104000058F8200042403FFFB344200021A
71448+:1053900000431024AF8200048F620004044300081D
71449+:1053A00092020007920200068E03000CAE0000007D
71450+:1053B0000002108000501021AC4300209202000730
71451+:1053C00030420004544000099602000A920200058F
71452+:1053D0003C03000100021080005010218C46001890
71453+:1053E00000C33021AC4600189602000A9206000461
71454+:1053F000277100080220202100C2302124C60005A8
71455+:10540000260500140E0005AB00063082920400064B
71456+:105410008F6500043C027FFF000420800091202162
71457+:105420008C8300043442FFFF00A228240065182169
71458+:10543000AC8300049202000792040005920300046A
71459+:10544000304200041040001496070008308400FF2A
71460+:1054500000042080009120218C86000497420104E2
71461+:105460009605000A306300FF3042FFFF0043102121
71462+:105470000045102130E3FFFF004310232442FFD8F2
71463+:1054800030C6FFFF0002140000C23025AC860004C5
71464+:105490000A0004C992030007308500FF0005288038
71465+:1054A00000B128218CA4000097420104306300FF62
71466+:1054B0003042FFFF00431021004710233C03FFFF51
71467+:1054C000008320243042FFFF00822025ACA400008E
71468+:1054D0009203000724020001106200060000000091
71469+:1054E0002402000310620011000000000A0004EC16
71470+:1054F0008E03001097420104920300049605000AEF
71471+:105500008E24000C00431021004510212442FFF29C
71472+:105510003C03FFFF008320243042FFFF0082202550
71473+:10552000AE24000C0A0004EC8E0300109742010424
71474+:10553000920300049605000A8E24001000431021F7
71475+:10554000004510212442FFEE3C03FFFF008320248E
71476+:105550003042FFFF00822025AE2400108E03001091
71477+:105560002402000AA7420140A74301429603000A11
71478+:10557000920200043C04004000431021A742014471
71479+:10558000A740014697420104A742014824020001B6
71480+:105590000E00020CA742014A0E0002350000000076
71481+:1055A0008F6200009203000400002021AF820008F7
71482+:1055B000974201049606000A3042FFFF006218215C
71483+:1055C000006028213C0308008C6304443C0208006E
71484+:1055D0008C42044000651821004410210065382BDE
71485+:1055E000004710213C010800AC2304443C010800A2
71486+:1055F000AC22044092040004008620212484000A86
71487+:105600003084FFFF0E0001E9000000009744010410
71488+:105610003084FFFF0E0001F7000000003C02100084
71489+:10562000AF4201780A0005878F820020148200278C
71490+:105630003062000697420104104000673C024000BF
71491+:105640003062400010400005000000000000000033
71492+:105650000000000D00000000240004208F420178AB
71493+:105660000440FFFE24020800AF4201782402000833
71494+:10567000A7420140A74001428F82000497430104E2
71495+:1056800030420001104000073070FFFF2603FFFE8C
71496+:1056900024020002A7420146A74301480A00053F31
71497+:1056A0002402000DA74001462402000DA742014A32
71498+:1056B0008F62000024040008AF8200080E0001E998
71499+:1056C000000000000A0005190200202110400042DD
71500+:1056D0003C02400093620000304300F024020010BE
71501+:1056E0001062000524020070106200358F820020D5
71502+:1056F0000A000588244200018F62000097430104DC
71503+:105700003050FFFF3071FFFF8F4201780440FFFEF1
71504+:105710003202000700021023304200072403000A6F
71505+:105720002604FFFEA7430140A7420142A7440144CB
71506+:10573000A7400146A75101488F420108304200208E
71507+:10574000144000022403000924030001A743014A76
71508+:105750000E00020C3C0400400E0002350000000068
71509+:105760003C0708008CE70444021110212442FFFE8C
71510+:105770003C0608008CC604400040182100E3382194
71511+:10578000000010218F65000000E3402B00C2302193
71512+:105790002604000800C830213084FFFFAF850008D0
71513+:1057A0003C010800AC2704443C010800AC2604403E
71514+:1057B0000E0001E9000000000A0005190220202166
71515+:1057C0000E00013B000000008F82002024420001F7
71516+:1057D000AF8200203C024000AF4201380A00029232
71517+:1057E000000000003084FFFF30C6FFFF00052C00E2
71518+:1057F00000A628253882FFFF004510210045282BF0
71519+:105800000045102100021C023042FFFF004310211E
71520+:1058100000021C023042FFFF004310213842FFFF0C
71521+:1058200003E000083042FFFF3084FFFF30A5FFFF98
71522+:1058300000001821108000070000000030820001E5
71523+:105840001040000200042042006518210A0005A152
71524+:105850000005284003E000080060102110C0000689
71525+:1058600024C6FFFF8CA2000024A50004AC82000027
71526+:105870000A0005AB2484000403E0000800000000D7
71527+:1058800010A0000824A3FFFFAC8600000000000069
71528+:10589000000000002402FFFF2463FFFF1462FFFAF0
71529+:1058A0002484000403E00008000000000000000160
71530+:1058B0000A00002A00000000000000000000000DA7
71531+:1058C000747870362E322E3162000000060201001C
71532+:1058D00000000000000001360000EA600000000047
71533+:1058E00000000000000000000000000000000000B8
71534+:1058F00000000000000000000000000000000000A8
71535+:105900000000000000000000000000000000000097
71536+:105910000000001600000000000000000000000071
71537+:105920000000000000000000000000000000000077
71538+:105930000000000000000000000000000000000067
71539+:1059400000000000000000000000138800000000BC
71540+:10595000000005DC00000000000000001000000353
71541+:10596000000000000000000D0000000D3C020800D7
71542+:1059700024423D683C0308002463401CAC40000006
71543+:105980000043202B1480FFFD244200043C1D08002E
71544+:1059900037BD7FFC03A0F0213C100800261000A8B2
71545+:1059A0003C1C0800279C3D680E00044E00000000CF
71546+:1059B0000000000D27BDFFB4AFA10000AFA200049E
71547+:1059C000AFA30008AFA4000CAFA50010AFA6001451
71548+:1059D000AFA70018AFA8001CAFA90020AFAA0024F1
71549+:1059E000AFAB0028AFAC002CAFAD0030AFAE003491
71550+:1059F000AFAF0038AFB8003CAFB90040AFBC004417
71551+:105A0000AFBF00480E000591000000008FBF0048A6
71552+:105A10008FBC00448FB900408FB8003C8FAF003876
71553+:105A20008FAE00348FAD00308FAC002C8FAB0028D0
71554+:105A30008FAA00248FA900208FA8001C8FA7001810
71555+:105A40008FA600148FA500108FA4000C8FA3000850
71556+:105A50008FA200048FA1000027BD004C3C1B6004F6
71557+:105A60008F7A5030377B502803400008AF7A00000F
71558+:105A70008F86003C3C0390003C0280000086282575
71559+:105A800000A32025AC4400203C0380008C6700204C
71560+:105A900004E0FFFE0000000003E00008000000003A
71561+:105AA0000A000070240400018F85003C3C04800043
71562+:105AB0003483000100A3102503E00008AC8200201D
71563+:105AC00003E00008000010213084FFFF30A5FFFF35
71564+:105AD00010800007000018213082000110400002F1
71565+:105AE00000042042006518211480FFFB00052840B7
71566+:105AF00003E000080060102110C000070000000053
71567+:105B00008CA2000024C6FFFF24A50004AC82000084
71568+:105B100014C0FFFB2484000403E000080000000020
71569+:105B200010A0000824A3FFFFAC86000000000000C6
71570+:105B3000000000002402FFFF2463FFFF1462FFFA4D
71571+:105B40002484000403E000080000000090AA003153
71572+:105B50008FAB00108CAC00403C0300FF8D6800044C
71573+:105B6000AD6C00208CAD004400E060213462FFFF8A
71574+:105B7000AD6D00248CA700483C09FF000109C0243A
71575+:105B8000AD6700288CAE004C0182C824031978252B
71576+:105B9000AD6F0004AD6E002C8CAD0038314A00FFB3
71577+:105BA000AD6D001C94A900323128FFFFAD680010D4
71578+:105BB00090A70030A5600002A1600004A16700006A
71579+:105BC00090A30032306200FF0002198210600005CD
71580+:105BD000240500011065000E0000000003E000082D
71581+:105BE000A16A00018CD80028354A0080AD780018E1
71582+:105BF0008CCF0014AD6F00148CCE0030AD6E000859
71583+:105C00008CC4002CA16A000103E00008AD64000C04
71584+:105C10008CCD001CAD6D00188CC90014AD6900144A
71585+:105C20008CC80024AD6800088CC70020AD67000C4C
71586+:105C30008CC200148C8300700043C82B1320000713
71587+:105C4000000000008CC20014144CFFE400000000AF
71588+:105C5000354A008003E00008A16A00018C820070D0
71589+:105C60000A0000E6000000009089003027BDFFF820
71590+:105C70008FA8001CA3A900008FA300003C0DFF808B
71591+:105C800035A2FFFF8CAC002C00625824AFAB0000A3
71592+:105C9000A100000400C05821A7A000028D06000446
71593+:105CA00000A048210167C8218FA500000080502175
71594+:105CB0003C18FF7F032C20263C0E00FF2C8C00019B
71595+:105CC000370FFFFF35CDFFFF3C02FF0000AFC824B8
71596+:105CD00000EDC02400C27824000C1DC003236825F9
71597+:105CE00001F87025AD0D0000AD0E00048D240024D8
71598+:105CF000AFAD0000AD0400088D2C00202404FFFF90
71599+:105D0000AD0C000C9547003230E6FFFFAD060010E9
71600+:105D10009145004830A200FF000219C25060000106
71601+:105D20008D240034AD0400148D4700388FAA00186C
71602+:105D300027BD0008AD0B0028AD0A0024AD07001CEC
71603+:105D4000AD00002CAD00001803E00008AD000020FD
71604+:105D500027BDFFE0AFB20018AFB10014AFB0001024
71605+:105D6000AFBF001C9098003000C088213C0D00FFA0
71606+:105D7000330F007FA0CF0000908E003135ACFFFFC5
71607+:105D80003C0AFF00A0CE000194A6001EA220000441
71608+:105D90008CAB00148E29000400A08021016C282403
71609+:105DA000012A40240080902101052025A62600021A
71610+:105DB000AE24000426050020262400080E000092D0
71611+:105DC00024060002924700302605002826240014ED
71612+:105DD00000071E000003160324060004044000030D
71613+:105DE0002403FFFF965900323323FFFF0E00009279
71614+:105DF000AE230010262400248FBF001C8FB2001891
71615+:105E00008FB100148FB00010240500030000302172
71616+:105E10000A00009C27BD002027BDFFD8AFB1001CA1
71617+:105E2000AFB00018AFBF002090A9003024020001DD
71618+:105E300000E050213123003F00A040218FB00040FE
71619+:105E40000080882100C04821106200148FA700380C
71620+:105E5000240B000500A0202100C02821106B001396
71621+:105E6000020030210E000128000000009225007C75
71622+:105E700030A400021080000326030030AE00003082
71623+:105E8000260300348FBF00208FB1001C8FB0001894
71624+:105E90000060102103E0000827BD00280E0000A7C5
71625+:105EA000AFB000100A00016F000000008FA3003C9B
71626+:105EB000010020210120282101403021AFA3001042
71627+:105EC0000E0000EEAFB000140A00016F00000000E9
71628+:105ED0003C06800034C20E008C4400108F850044C4
71629+:105EE000ACA400208C43001803E00008ACA30024FD
71630+:105EF0003C06800034C20E008C4400148F850044A0
71631+:105F0000ACA400208C43001C03E00008ACA30024D8
71632+:105F10009382000C1040001B2483000F2404FFF028
71633+:105F20000064382410E00019978B00109784000E4D
71634+:105F30009389000D3C0A601C0A0001AC01644023F7
71635+:105F400001037021006428231126000231C2FFFFE3
71636+:105F500030A2FFFF0047302B50C0000E00E4482164
71637+:105F60008D4D000C31A3FFFF00036400000C2C03D7
71638+:105F700004A1FFF30000302130637FFF0A0001A479
71639+:105F80002406000103E00008000000009784000ED2
71640+:105F900000E448213123FFFF3168FFFF0068382B00
71641+:105FA00054E0FFF8A783000E938A000D114000050E
71642+:105FB000240F0001006BC023A380000D03E0000844
71643+:105FC000A798000E006BC023A38F000D03E000080C
71644+:105FD000A798000E03E000080000000027BDFFE8BE
71645+:105FE000AFB000103C10800036030140308BFFFF43
71646+:105FF00093AA002BAFBF0014A46B000436040E005C
71647+:106000009488001630C600FF8FA90030A4680006EF
71648+:10601000AC650008A0660012A46A001AAC670020F4
71649+:106020008FA5002CA4690018012020210E000198E2
71650+:10603000AC6500143C021000AE0201788FBF001462
71651+:106040008FB0001003E0000827BD00188F85000006
71652+:106050002484000727BDFFF83084FFF83C06800049
71653+:1060600094CB008A316AFFFFAFAA00008FA900001D
71654+:10607000012540232507FFFF30E31FFF0064102B9D
71655+:106080001440FFF700056882000D288034CC4000E2
71656+:1060900000AC102103E0000827BD00088F8200003B
71657+:1060A0002486000730C5FFF800A2182130641FFFC6
71658+:1060B00003E00008AF8400008F87003C8F84004419
71659+:1060C00027BDFFB0AFB70044AFB40038AFB1002C6C
71660+:1060D000AFBF0048AFB60040AFB5003CAFB300342F
71661+:1060E000AFB20030AFB000283C0B80008C8600249B
71662+:1060F000AD6700808C8A002035670E00356901008D
71663+:10610000ACEA00108C8800248D2500040000B82122
71664+:10611000ACE800188CE3001000A688230000A02142
71665+:10612000ACE300148CE20018ACE2001C122000FE6C
71666+:1061300000E0B021936C0008118000F40000000022
71667+:10614000976F001031EEFFFF022E682B15A000EFB5
71668+:1061500000000000977200103250FFFFAED0000028
71669+:106160003C0380008C740000329300081260FFFD35
71670+:106170000000000096D800088EC700043305FFFF1A
71671+:1061800030B5000112A000E4000000000000000D86
71672+:1061900030BFA0402419004013F9011B30B4A00007
71673+:1061A000128000DF000000009373000812600008F6
71674+:1061B00000000000976D001031ACFFFF00EC202BB9
71675+:1061C0001080000330AE004011C000D50000000078
71676+:1061D000A7850040AF87003893630008022028217C
71677+:1061E000AFB10020146000F527B40020AF60000CB0
71678+:1061F000978F004031F14000162000022403001662
71679+:106200002403000E24054007A363000AAF650014B1
71680+:10621000938A00428F70001431550001001512401E
71681+:1062200002024825AF690014979F00408F78001440
71682+:1062300033F9001003194025AF680014979200400D
71683+:106240003247000810E0016E000000008F67001464
71684+:106250003C1210003C11800000F27825AF6F001452
71685+:1062600036230E00946E000A3C0D81002406000EB9
71686+:1062700031CCFFFF018D2025AF640004A36600022E
71687+:106280009373000A3406FFFC266B0004A36B000A1C
71688+:1062900097980040330820001100015F00000000C3
71689+:1062A0003C05800034A90E00979900409538000CF9
71690+:1062B00097870040001940423312C00031030003A9
71691+:1062C00000127B0330F11000006F6825001172038B
71692+:1062D00001AE6025000C20C0A76400129793004017
71693+:1062E000936A000A001359823175003C02AA1021FA
71694+:1062F0002450003CA3700009953F000C33F93FFF88
71695+:10630000A779001097700012936900090130F821F5
71696+:1063100027E5000230B900070019C0233308000741
71697+:10632000A368000B9371000997720012976F001019
71698+:10633000322700FF8F910038978D004000F218211E
71699+:10634000006F702101C6602131A6004010C0000519
71700+:106350003185FFFF00B1102B3C1280001040001768
71701+:10636000000098210225A82B56A0013E8FA50020F1
71702+:106370003C048000348A0E008D5300143C068000DB
71703+:10638000AD5300108D4B001CAD4B0018AD45000007
71704+:106390008CCD000031AC00081180FFFD34CE0E0022
71705+:1063A00095C3000800A0882100009021A783004029
71706+:1063B0008DC6000424130001AF860038976F0010CB
71707+:1063C00031F5FFFF8E9F000003F1282310A0011F6D
71708+:1063D000AE85000093620008144000DD000000005C
71709+:1063E0000E0001E7240400108F900048004028218F
71710+:1063F0003C023200320600FF000654000142F8253C
71711+:1064000026090001AF890048ACBF0000937900095C
71712+:1064100097780012936F000A332800FF3303FFFFC1
71713+:106420000103382100076C0031EE00FF01AE60254A
71714+:10643000ACAC00048F840048978B0040316A200088
71715+:106440001140010AACA4000897640012308BFFFFD2
71716+:1064500006400108ACAB000C978E004031C5000827
71717+:1064600014A0000226280006262800023C1F8000F7
71718+:1064700037E70E0094F900148CE5001C8F670004C8
71719+:10648000937800023324FFFF330300FFAFA3001013
71720+:106490008F6F0014AFA800180E0001CBAFAF00142F
71721+:1064A000240400100E0001FB000000008E9200008A
71722+:1064B00016400005000000008F7800142403FFBF81
71723+:1064C0000303A024AF7400148F67000C00F5C821EB
71724+:1064D000AF79000C9375000816A0000800000000BA
71725+:1064E00012600006000000008F6800143C0AEFFFF5
71726+:1064F0003549FFFE0109F824AF7F0014A37300089B
71727+:106500008FA500200A00034F02202021AED10000F9
71728+:106510000A00022D3C03800014E0FF1E30BFA040A3
71729+:106520000E0001900000A0212E9100010237B0253D
71730+:1065300012C000188FBF00488F87003C24170F003F
71731+:1065400010F700D43C0680008CD901780720FFFEAC
71732+:10655000241F0F0010FF00F634CA0E008D560014E1
71733+:1065600034C7014024080240ACF600048D49001CE9
71734+:106570003C141000ACE90008A0E00012A4E0001AEE
71735+:10658000ACE00020A4E00018ACE80014ACD4017822
71736+:106590008FBF00488FB700448FB600408FB5003CD6
71737+:1065A0008FB400388FB300348FB200308FB1002C1D
71738+:1065B0008FB0002803E0000827BD00508F910038FD
71739+:1065C000978800403C1280000220A821310700403B
71740+:1065D00014E0FF7C00009821977900108F9200381A
71741+:1065E0003338FFFF131200A8000020210080A021F3
71742+:1065F000108000F300A088211620FECE00000000CD
71743+:106600000A00031F2E9100013C0380008C62017878
71744+:106610000440FFFE240808008F860000AC68017863
71745+:106620003C038000946D008A31ACFFFF0186582343
71746+:10663000256AFFFF31441FFF2C8900081520FFF950
71747+:10664000000000008F8F0048347040008F83003CB2
71748+:1066500000E0A021240E0F0025E70001AF870048CD
71749+:1066600000D03021023488233C08800031F500FF3F
71750+:10667000106E0005240700019398004233130001B7
71751+:106680000013924036470001001524003C0A010027
71752+:10669000008A4825ACC900008F82004830BF003610
71753+:1066A00030B90008ACC200041320009900FF9825FF
71754+:1066B00035120E009650000A8F8700003C0F8100B3
71755+:1066C0003203FFFF24ED000835060140006F60250E
71756+:1066D0003C0E100031AB1FFF269200062405000E71
71757+:1066E000ACCC0020026E9825A4C5001AAF8B000028
71758+:1066F000A4D20018162000083C1080008F89003CAE
71759+:1067000024020F00512200022417000136730040BA
71760+:106710000E0001883C10800036060E008CCB001461
71761+:10672000360A014002402021AD4B00048CC5001CFC
71762+:10673000AD450008A1550012AD5300140E0001989C
71763+:106740003C151000AE1501780A000352000000004D
71764+:10675000936F0009976E0012936D000B31E500FFF7
71765+:1067600000AE202131AC00FF008C80212602000AFF
71766+:106770003050FFFF0E0001E7020020218F86004805
71767+:106780003C0341003C05800024CB0001AF8B004856
71768+:10679000936A00099769001230C600FF315F00FF5D
71769+:1067A0003128FFFF03E8382124F900020006C40065
71770+:1067B0000319782501E37025AC4E00008F6D000CA5
71771+:1067C00034A40E00948B001401B26025AC4C00047C
71772+:1067D0008C85001C8F670004936A00023164FFFF00
71773+:1067E000314900FFAFA900108F680014AFB1001845
71774+:1067F0000E0001CBAFA800140A0002FD0200202108
71775+:10680000AF600004A36000029798004033082000A6
71776+:106810001500FEA300003021A760001297840040FD
71777+:10682000936B000A3C10800030931F0000135183CB
71778+:10683000014BA82126A20028A362000936090E00F8
71779+:10684000953F000C0A000295A77F00108F7000147E
71780+:10685000360900400E000188AF6900140A0002C921
71781+:10686000000000000A00034F000020210641FEFA4C
71782+:10687000ACA0000C8CAC000C3C0D8000018D902570
71783+:106880000A0002EAACB2000C000090210A0002C526
71784+:1068900024130001128000073C028000344B0E00DC
71785+:1068A0009566000830D300401260004900000000E7
71786+:1068B0003C0680008CD001780600FFFE34C50E0037
71787+:1068C00094B500103C03050034CC014032B8FFFF02
71788+:1068D00003039025AD92000C8CAF0014240D200012
71789+:1068E0003C041000AD8F00048CAE001CAD8E00087F
71790+:1068F000A1800012A580001AAD800020A58000189C
71791+:10690000AD8D0014ACC401780A0003263C0680005B
71792+:106910008F9F0000351801402692000227F90008D9
71793+:1069200033281FFFA71200180A000391AF88000048
71794+:106930003C02800034450140ACA0000C1280001BDA
71795+:1069400034530E0034510E008E370010ACB70004E3
71796+:106950008E2400183C0B8000ACA400083570014068
71797+:1069600024040040A20000128FBF0048A600001AB5
71798+:106970008FB70044AE0000208FB60040A60000187C
71799+:106980008FB5003CAE0400148FB400388FB30034D0
71800+:106990008FB200308FB1002C8FB000283C02100065
71801+:1069A00027BD005003E00008AD6201788E66001438
71802+:1069B000ACA600048E64001C0A00042A3C0B800074
71803+:1069C0000E0001902E9100010A0003200237B0252D
71804+:1069D000000000000000000D00000000240003691A
71805+:1069E0000A0004013C06800027BDFFD8AFBF00208D
71806+:1069F0003C0980003C1F20FFAFB200183C0760003C
71807+:106A000035320E002402001037F9FFFDACE23008E9
71808+:106A1000AFB3001CAFB10014AFB00010AE5900000E
71809+:106A20000000000000000000000000000000000066
71810+:106A3000000000003C1800FF3713FFFDAE530000BC
71811+:106A40003C0B60048D7050002411FF7F3C0E00024F
71812+:106A50000211782435EC380C35CD0109ACED4C1819
71813+:106A6000240A0009AD6C50008CE80438AD2A0008F7
71814+:106A7000AD2000148CE54C1C3106FFFF38C42F718B
71815+:106A800000051E023062000F2486C0B310400007CC
71816+:106A9000AF8200088CE54C1C3C09001F3528FC0027
71817+:106AA00000A81824000321C2AF8400048CF1080858
71818+:106AB0003C0F57092412F0000232702435F0001008
71819+:106AC00001D0602601CF68262DAA00012D8B000180
71820+:106AD000014B382550E00009A380000C3C1F601CCE
71821+:106AE0008FF8000824190001A399000C33137C00CF
71822+:106AF000A7930010A780000EA380000DAF80004870
71823+:106B000014C00003AF8000003C066000ACC0442C01
71824+:106B10000E0005B93C1080000E000F1A361101005E
71825+:106B20003C12080026523DD03C13080026733E500C
71826+:106B30008E03000038640001308200011440FFFC25
71827+:106B40003C0B800A8E2600002407FF8024C90240E7
71828+:106B5000312A007F014B402101272824AE06002066
71829+:106B6000AF880044AE0500243C048000AF86003CA2
71830+:106B70008C8C01780580FFFE24180800922F0008F5
71831+:106B8000AC980178A38F0042938E004231CD000172
71832+:106B900011A0000F24050D0024DFF8002FF90301D8
71833+:106BA0001320001C000629C224A4FFF00004104298
71834+:106BB000000231400E00020200D2D8213C02400007
71835+:106BC0003C068000ACC201380A0004A000000000AE
71836+:106BD00010C50023240D0F0010CD00273C1F800896
71837+:106BE00037F9008093380000240E0050330F00FF67
71838+:106BF00015EEFFF33C0240000E000A3600000000D4
71839+:106C00003C0240003C068000ACC201380A0004A0EF
71840+:106C1000000000008F83000400A3402B1500000B30
71841+:106C20008F8B0008006B50212547FFFF00E5482BA4
71842+:106C30001520000600A36023000C19400E0002027C
71843+:106C40000073D8210A0004C43C0240000000000D7B
71844+:106C50000E000202000000000A0004C43C024000D2
71845+:106C60003C1B0800277B3F500E0002020000000082
71846+:106C70000A0004C43C0240003C1B0800277B3F7014
71847+:106C80000E000202000000000A0004C43C024000A2
71848+:106C90003C0660043C09080025290104ACC9502CBD
71849+:106CA0008CC850003C0580003C0200023507008083
71850+:106CB000ACC750003C040800248415A43C03080021
71851+:106CC0002463155CACA50008ACA2000C3C010800D4
71852+:106CD000AC243D603C010800AC233D6403E00008A7
71853+:106CE0002402000100A030213C1C0800279C3D68C4
71854+:106CF0003C0C04003C0B0002008B3826008C402624
71855+:106D00002CE200010007502B2D050001000A4880ED
71856+:106D10003C03080024633D60004520250123182121
71857+:106D20001080000300001021AC6600002402000166
71858+:106D300003E00008000000003C1C0800279C3D68A0
71859+:106D40003C0B04003C0A0002008A3026008B3826E7
71860+:106D50002CC200010006482B2CE5000100094080F0
71861+:106D60003C03080024633D600045202501031821F1
71862+:106D700010800005000010213C0C0800258C155CDB
71863+:106D8000AC6C00002402000103E0000800000000D9
71864+:106D90003C0900023C08040000883026008938269F
71865+:106DA0002CC30001008028212CE400010083102561
71866+:106DB0001040000B000030213C1C0800279C3D685F
71867+:106DC0003C0A80008D4E00082406000101CA682597
71868+:106DD000AD4D00088D4C000C01855825AD4B000CC5
71869+:106DE00003E0000800C010213C1C0800279C3D68FF
71870+:106DF0003C0580008CA6000C000420272402000122
71871+:106E000000C4182403E00008ACA3000C3C020002FC
71872+:106E10001082000B3C0560003C0704001087000353
71873+:106E20000000000003E00008000000008CA908D06A
71874+:106E3000240AFFFD012A402403E00008ACA808D082
71875+:106E40008CA408D02406FFFE0086182403E0000866
71876+:106E5000ACA308D03C05601A34A600108CC3008097
71877+:106E600027BDFFF88CC50084AFA3000093A40000E9
71878+:106E70002402000110820003AFA5000403E0000813
71879+:106E800027BD000893A7000114E0001497AC00028E
71880+:106E900097B800023C0F8000330EFFFC01CF682141
71881+:106EA000ADA50000A3A000003C0660008CC708D080
71882+:106EB0002408FFFE3C04601A00E82824ACC508D072
71883+:106EC0008FA300048FA200003499001027BD000892
71884+:106ED000AF22008003E00008AF2300843C0B800059
71885+:106EE000318AFFFC014B48218D2800000A00057DF6
71886+:106EF000AFA8000427BDFFE8AFBF00103C1C08008E
71887+:106F0000279C3D683C0580008CA4000C8CA20004EA
71888+:106F10003C0300020044282410A0000A00A3182407
71889+:106F20003C0604003C0400021460000900A6102482
71890+:106F30001440000F3C0404000000000D3C1C08003D
71891+:106F4000279C3D688FBF001003E0000827BD001894
71892+:106F50003C0208008C423D600040F809000000003F
71893+:106F60003C1C0800279C3D680A0005A68FBF001046
71894+:106F70003C0208008C423D640040F809000000001B
71895+:106F80000A0005AC00000000000411C003E0000886
71896+:106F9000244202403C04080024843FB42405001A23
71897+:106FA0000A00009C0000302127BDFFE0AFB00010B8
71898+:106FB0003C108000AFBF0018AFB1001436110100C3
71899+:106FC000922200090E0005B63044007F8E3F00007B
71900+:106FD0008F89003C3C0F008003E26021258800403F
71901+:106FE0000049F821240DFF80310E00783198007897
71902+:106FF00035F9000135F100020319382501D1482582
71903+:10700000010D302403ED5824018D2824240A00406A
71904+:1070100024040080240300C0AE0B0024AE0008103E
71905+:10702000AE0A0814AE040818AE03081CAE05080426
71906+:10703000AE070820AE060808AE0908243609090084
71907+:107040009539000C3605098033ED007F3338FFFF9A
71908+:10705000001889C0AE110800AE0F0828952C000C4E
71909+:107060008FBF00188FB10014318BFFFF000B51C090
71910+:10707000AE0A002C8CA400508FB000108CA3003CF2
71911+:107080008D2700048CA8001C8CA600383C0E800ABA
71912+:1070900001AE102127BD0020AF820044AF84005014
71913+:1070A000AF830054AF87004CAF88005C03E000085A
71914+:1070B000AF8600603C09080091293FD924A800024E
71915+:1070C0003C05110000093C0000E8302500C51825EA
71916+:1070D00024820008AC83000003E00008AC800004B8
71917+:1070E0003C098000352309009128010B906A0011AA
71918+:1070F0002402002800804821314700FF00A07021B1
71919+:1071000000C068213108004010E20002340C86DD26
71920+:10711000240C08003C0A800035420A9A944700007B
71921+:10712000354B0A9C35460AA030F9FFFFAD39000007
71922+:107130008D780000354B0A8024040001AD3800042E
71923+:107140008CCF0000AD2F00089165001930A300031B
71924+:107150001064009028640002148000AF240500022F
71925+:107160001065009E240F0003106F00B435450AA47B
71926+:10717000240A0800118A0048000000005100003D68
71927+:107180003C0B80003C0480003483090090670012AF
71928+:1071900030E200FF004D7821000FC8802724000155
71929+:1071A0003C0A8000354F090091E50019354C0980F3
71930+:1071B0008D87002830A300FF0003150000475825E5
71931+:1071C0000004C4003C19600001793025370806FF2F
71932+:1071D000AD260000AD2800048DEA002C25280028EB
71933+:1071E000AD2A00088DEC0030AD2C000C8DE500348C
71934+:1071F000AD2500108DE400383C05800034AC093C1E
71935+:10720000AD2400148DE3001CAD2300188DE7002091
71936+:10721000AD27001C8DE20024AD2200208DF900284E
71937+:1072200034A20100AD3900248D830000AD0E0004AE
71938+:1072300034B90900AD0300008C47000C250200148E
71939+:10724000AD070008932B00123C04080090843FD83F
71940+:10725000AD000010317800FF030D302100064F0013
71941+:1072600000047C00012F702535CDFFFC03E00008F1
71942+:10727000AD0D000C35780900930600123C0508009E
71943+:1072800094A53FC830C800FF010D5021000A60805E
71944+:107290000A00063C018520211500005B000000006B
71945+:1072A0003C08080095083FCE3C06080094C63FC83D
71946+:1072B000010610213C0B800035790900933800113C
71947+:1072C000932A001935660A80330800FF94CF002AFC
71948+:1072D00000086082314500FF978A0058000C1E00AC
71949+:1072E000000524003047FFFF006410250047C0253B
71950+:1072F00001EA30213C0B4000030B402500066400EE
71951+:10730000AD280000AD2C0004932500183C030006B6
71952+:107310002528001400053E0000E31025AD220008DA
71953+:107320008F24002C3C05800034AC093CAD24000CBB
71954+:107330008F38001C34A20100254F0001AD38001029
71955+:107340008D830000AD0E000431EB7FFFAD03000024
71956+:107350008C47000C34B90900A78B0058AD07000812
71957+:10736000932B00123C04080090843FD8250200149F
71958+:10737000317800FF030D302100064F0000047C002F
71959+:10738000012F702535CDFFFCAD00001003E0000893
71960+:10739000AD0D000C3C02080094423FD23C050800B1
71961+:1073A00094A53FC835440AA43C07080094E73FC4AD
71962+:1073B000948B00000045C8210327C023000B1C004C
71963+:1073C0002706FFF200665025AD2A000CAD20001004
71964+:1073D000AD2C00140A00063025290018354F0AA4E8
71965+:1073E00095E50000956400280005140000043C00A9
71966+:1073F0003459810000EC5825AD39000CAD2B00103C
71967+:107400000A000630252900143C0C0800958C3FCE5C
71968+:107410000A000681258200015460FF56240A0800F4
71969+:1074200035580AA49706000000061C00006C502581
71970+:10743000AD2A000C0A000630252900103C03080084
71971+:1074400094633FD23C07080094E73FC83C0F080014
71972+:1074500095EF3FC494A4000095790028006710219F
71973+:10746000004F582300041C00001934002578FFEE5B
71974+:1074700000D87825346A8100AD2A000CAD2F0010A9
71975+:10748000AD200014AD2C00180A0006302529001C80
71976+:1074900003E00008240207D027BDFFE0AFB20018C8
71977+:1074A000AFB10014AFB00010AFBF001C0E00007CE5
71978+:1074B000008088218F8800548F87004C3C0580080D
71979+:1074C00034B20080011128213C1080002402008089
71980+:1074D000240300C000A72023AE0208183C06800841
71981+:1074E000AE03081C18800004AF850054ACC500042E
71982+:1074F0008CC90004AF89004C1220000936040980B1
71983+:107500000E0006F800000000924C00278E0B00745D
71984+:1075100001825004014B3021AE46000C3604098034
71985+:107520008C8E001C8F8F005C01CF682319A0000493
71986+:107530008FBF001C8C90001CAF90005C8FBF001CA4
71987+:107540008FB200188FB100148FB000100A00007EB7
71988+:1075500027BD00208F8600508F8300548F82004CFF
71989+:107560003C05800834A40080AC860050AC83003C0D
71990+:1075700003E00008ACA200043C0308008C63005444
71991+:1075800027BDFFF8308400FF2462000130A500FF12
71992+:107590003C010800AC22005430C600FF3C078000CC
71993+:1075A0008CE801780500FFFE3C0C7FFFA3A40003DC
71994+:1075B0008FAA0000358BFFFF014B4824000627C02F
71995+:1075C00001244025AFA8000034E201009043000AE6
71996+:1075D000A3A000023C1980FFA3A300018FAF00000D
71997+:1075E00030AE007F3738FFFF01F86024000E6E00D8
71998+:1075F0003C0A002034E50140018D58253549200022
71999+:107600002406FF803C04100027BD0008ACAB000C32
72000+:10761000ACA90014A4A00018A0A6001203E0000862
72001+:10762000ACE40178308800FF30A700FF3C03800005
72002+:107630008C6201780440FFFE3C0C8000358A0A0011
72003+:107640008D4B00203584014035850980AC8B0004CA
72004+:107650008D4900240007302B00061540AC89000836
72005+:10766000A088001090A3004CA083002D03E0000828
72006+:10767000A480001827BDFFE8308400FFAFBF0010D2
72007+:107680000E00075D30A500FF8F8300548FBF0010F0
72008+:107690003C06800034C50140344700402404FF907C
72009+:1076A0003C02100027BD0018ACA3000CA0A40012DF
72010+:1076B000ACA7001403E00008ACC2017827BDFFE0CE
72011+:1076C0003C088008AFBF001CAFB20018AFB1001477
72012+:1076D000AFB00010351000808E0600183C07800007
72013+:1076E000309200FF00C72025AE0400180E00007C79
72014+:1076F00030B100FF92030005346200080E00007EE6
72015+:10770000A2020005024020210E000771022028215C
72016+:10771000024020218FBF001C8FB200188FB10014CF
72017+:107720008FB0001024050005240600010A0007326E
72018+:1077300027BD00203C05800034A309809066000826
72019+:1077400030C200081040000F3C0A01013549080A08
72020+:10775000AC8900008CA80074AC8800043C070800C9
72021+:1077600090E73FD830E5001050A00008AC8000083A
72022+:107770003C0D800835AC00808D8B0058AC8B000828
72023+:107780002484000C03E00008008010210A0007B5E3
72024+:107790002484000C27BDFFE83C098000AFB0001036
72025+:1077A000AFBF00143526098090C8000924020006E6
72026+:1077B00000A05821310300FF3527090000808021F7
72027+:1077C000240500041062007B2408000294CF005CB2
72028+:1077D0003C0E020431EDFFFF01AE6025AE0C00004F
72029+:1077E00090CA00083144002010800008000000000A
72030+:1077F00090C2004E3C1F010337F90300305800FFD0
72031+:107800000319302524050008AE06000490F9001184
72032+:1078100090E6001290E40011333800FF00187082E7
72033+:1078200030CF00FF01CF5021014B6821308900FF8C
72034+:1078300031AAFFFF39230028000A60801460002C61
72035+:10784000020C482390E400123C198000372F0100FD
72036+:10785000308C00FF018B1821000310800045F821B7
72037+:10786000001F8400360706FFAD270004373F0900DC
72038+:1078700093EC001193EE0012372609800005C082B8
72039+:107880008DE4000C8CC5003431CD00FF01AB10211C
72040+:107890000058182100A4F8230008840000033F00CA
72041+:1078A00000F0302533F9FFFF318F00FC00D970253F
72042+:1078B0000158202101E9682100045080ADAE000C80
72043+:1078C0000E00007C012A80213C088008240B000463
72044+:1078D000350500800E00007EA0AB000902001021DB
72045+:1078E0008FBF00148FB0001003E0000827BD001800
72046+:1078F00090EC001190E300193C18080097183FCE57
72047+:10790000318200FF0002F882307000FF001FCE00BD
72048+:1079100000103C000327302500D870253C0F4000A4
72049+:1079200001CF68253C198000AD2D0000373F0900CC
72050+:1079300093EC001193EE0012372F010037260980D7
72051+:107940000005C0828DE4000C8CC5003431CD00FFF1
72052+:1079500001AB10210058182100A4F823000884006E
72053+:1079600000033F0000F0302533F9FFFF318F00FCAA
72054+:1079700000D970250158202101E9682100045080B8
72055+:10798000ADAE000C0E00007C012A80213C0880086E
72056+:10799000240B0004350500800E00007EA0AB00091A
72057+:1079A000020010218FBF00148FB0001003E0000808
72058+:1079B00027BD00180A0007C72408001227BDFFD002
72059+:1079C0003C038000AFB60028AFB50024AFB4002060
72060+:1079D000AFB10014AFBF002CAFB3001CAFB20018A2
72061+:1079E000AFB000103467010090E6000B309400FF48
72062+:1079F00030B500FF30C200300000B02110400099C7
72063+:107A000000008821346409809088000800082E0056
72064+:107A100000051E03046000C0240400048F86005487
72065+:107A20003C010800A0243FD83C0C8000AD800048F9
72066+:107A30003C048000348E010091CD000B31A5002064
72067+:107A400010A000073C078000349309809272000860
72068+:107A50000012860000107E0305E000C43C1F800871
72069+:107A600034EC0100918A000B34EB09809169000825
72070+:107A7000314400400004402B3123000800C8982303
72071+:107A80001460000224120003000090213C108000CA
72072+:107A900036180A8036040900970E002C90830011D6
72073+:107AA0009089001293050018307F00FF312800FFF5
72074+:107AB000024810210002C880930D0018033F78216E
72075+:107AC00001F1302130B100FF00D11821A78E0058FC
72076+:107AD0003C010800A4263FCE3C010800A4233FD06F
72077+:107AE00015A00002000000000000000D920B010B29
72078+:107AF0003065FFFF3C010800A4233FD2316A0040FB
72079+:107B00003C010800A4203FC83C010800A4203FC459
72080+:107B10001140000224A4000A24A4000B3091FFFFAE
72081+:107B20000E0001E7022020219206010B3C0C080008
72082+:107B3000958C3FD2004020210006698231A70001C8
72083+:107B40000E00060101872821004020210260282123
72084+:107B50000E00060C024030210E0007A1004020213B
72085+:107B600016C00069004020219212010B32560040DD
72086+:107B700012C000053C0500FF8C93000034AEFFFFEF
72087+:107B8000026E8024AC9000000E0001FB0220202138
72088+:107B90003C0F080091EF3FD831F10003122000168E
72089+:107BA0003C1380088F8200543C09800835280080EF
72090+:107BB000245F0001AD1F003C3C0580088CB9000427
72091+:107BC00003E02021033FC0231B000002AF9F0054AD
72092+:107BD0008CA400040E0006F8ACA400043C0780004E
72093+:107BE0008CEB00743C04800834830080004B5021EF
72094+:107BF000AC6A000C3C1380083670008002802021A3
72095+:107C000002A02821A200006B0E00075D3C1480003A
72096+:107C10008F920054368C0140AD92000C8F86004844
72097+:107C20003C151000344D000624D60001AF960048E4
72098+:107C30008FBF002CA18600128FB60028AD8D0014D6
72099+:107C40008FB3001CAE9501788FB200188FB5002459
72100+:107C50008FB400208FB100148FB0001003E0000833
72101+:107C600027BD003034640980908F0008000F760033
72102+:107C7000000E6E0305A00033347F090093F8001B4B
72103+:107C8000241900103C010800A0393FD8331300022A
72104+:107C90001260FF678F8600548F8200601446FF6574
72105+:107CA0003C0480000E00007C000000003C048008C2
72106+:107CB0003485008090A8000924060016310300FFD7
72107+:107CC0001066000D0000000090AB00093C070800A2
72108+:107CD00090E73FD824090008316400FF34EA00012E
72109+:107CE0003C010800A02A3FD81089002F240C000A6C
72110+:107CF000108C00282402000C0E00007E0000000002
72111+:107D00000A0008608F8600540E0007B9024028213F
72112+:107D10000A0008AE004020213C0B8008356A008034
72113+:107D20008D4600548CE9000C1120FF3DAF860054B5
72114+:107D3000240700143C010800A0273FD80A00085F70
72115+:107D40003C0C800090910008241200023C010800C5
72116+:107D5000A0323FD8323000201200000B2416000160
72117+:107D60008F8600540A0008602411000837F800804C
72118+:107D70008F020038AFE200048FF90004AF19003C15
72119+:107D80000A00086C3C0780008F8600540A000860D7
72120+:107D900024110004A0A200090E00007E00000000D3
72121+:107DA0000A0008608F860054240200140A00093A71
72122+:107DB000A0A2000927BDFFE8AFB000103C10800072
72123+:107DC000AFBF001436020100904400090E00075DA9
72124+:107DD000240500013C0480089099000E3483008043
72125+:107DE000909F000F906F00269089000A33F800FFE3
72126+:107DF00000196E000018740031EC00FF01AE502530
72127+:107E0000000C5A00014B3825312800FF3603014091
72128+:107E10003445600000E830252402FF813C04100056
72129+:107E2000AC66000C8FBF0014AC650014A062001299
72130+:107E3000AE0401788FB0001003E0000827BD0018E1
72131+:107E400027BDFFE8308400FFAFBF00100E00075DC4
72132+:107E500030A500FF3C05800034A4014034470040B9
72133+:107E60002406FF92AC870014A08600128F83005472
72134+:107E70008FBF00103C02100027BD0018AC83000C1F
72135+:107E800003E00008ACA2017827BDFFD8AFB0001016
72136+:107E9000308400FF30B000FF3C058000AFB100141B
72137+:107EA000AFBF0020AFB3001CAFB20018000410C277
72138+:107EB00034A60100320300023051000114600007B3
72139+:107EC00090D200093C098008353300809268000593
72140+:107ED0003107000810E0000C308A00100240202119
72141+:107EE0000E00078302202821240200018FBF0020FA
72142+:107EF0008FB3001C8FB200188FB100148FB0001028
72143+:107F000003E0000827BD00281540003434A50A000E
72144+:107F10008CB800248CAF0008130F004B00003821F0
72145+:107F20003C0D800835B30080926C00682406000286
72146+:107F3000318B00FF116600843C06800034C20100D2
72147+:107F40009263004C90590009307F00FF53F9000400
72148+:107F50003213007C10E00069000000003213007C46
72149+:107F60005660005C0240202116200009320D0001FD
72150+:107F70003C0C800035840100358B0A008D6500249F
72151+:107F80008C86000414A6FFD900001021320D0001D8
72152+:107F900011A0000E024020213C1880003710010083
72153+:107FA0008E0F000C8F8E005011EE000800000000B4
72154+:107FB0000E000843022028218E19000C3C1F800867
72155+:107FC00037F00080AE190050024020210E000771EA
72156+:107FD000022028210A00098F240200013C05080024
72157+:107FE0008CA5006424A400013C010800AC240064BA
72158+:107FF0001600000D00000000022028210E0007716D
72159+:1080000002402021926E0068240C000231CD00FF56
72160+:1080100011AC0022024020210E00094100000000A6
72161+:108020000A00098F240200010E00007024040001E0
72162+:10803000926B0025020B30250E00007EA266002503
72163+:108040000A0009D3022028218E6200188CDF000468
72164+:108050008CB9002400021E0217F9FFB13065007FC1
72165+:108060009268004C264400013093007F1265004066
72166+:10807000310300FF1464FFAB3C0D8008264700016C
72167+:1080800030F1007F30E200FF1225000B24070001D1
72168+:10809000004090210A00099C2411000124050004DD
72169+:1080A0000E000732240600010E0009410000000006
72170+:1080B0000A00098F240200012405FF8002452024C4
72171+:1080C00000859026324200FF004090210A00099C62
72172+:1080D000241100010E00084302202821320700303D
72173+:1080E00010E0FFA132100082024020210E00078321
72174+:1080F000022028210A00098F240200018E6900183D
72175+:108100000240202102202821012640250E0009647A
72176+:10811000AE6800189264004C240500032406000198
72177+:108120000E000732308400FF0E00007024040001AE
72178+:1081300092710025021150250E00007EA26A0025D2
72179+:108140000A00098F240200018E6F00183C1880007D
72180+:108150000240202101F87025022028210E0007711D
72181+:10816000AE6E00189264004C0A000A1B240500043D
72182+:10817000324A0080394900801469FF6A3C0D80084A
72183+:108180000A0009F42647000127BDFFC0AFB0001860
72184+:108190003C108000AFBF0038AFB70034AFB600303E
72185+:1081A000AFB5002CAFB40028AFB30024AFB20020AD
72186+:1081B0000E0005BEAFB1001C360201009045000B59
72187+:1081C0000E00097690440008144000E78FBF003885
72188+:1081D0003C08800835070080A0E0006B3606098067
72189+:1081E00090C50000240300503C17080026F73F907C
72190+:1081F00030A400FF3C13080026733FA01083000347
72191+:108200003C1080000000B82100009821241F0010BD
72192+:108210003611010036120A00361509808E580024E6
72193+:108220008E3400048EAF00208F8C00543C01080077
72194+:10823000A03F3FD836190A80972B002C8EF60000FD
72195+:10824000932A00180298702301EC68233C0108006F
72196+:10825000AC2E3FB43C010800AC2D3FB83C010800F7
72197+:10826000AC2C3FDCA78B005802C0F809315400FF4A
72198+:1082700030490002152000E930420001504000C49E
72199+:108280009227000992A90008312800081500000271
72200+:10829000241500030000A8213C0A80003543090092
72201+:1082A00035440A008C8D00249072001190700012E9
72202+:1082B000907F0011325900FF321100FF02B11021EE
72203+:1082C0000002C08033EF00FF0319B021028F70213C
72204+:1082D00002D4602125CB00103C010800A4363FCE1B
72205+:1082E0003C010800AC2D3FE03C010800A42C3FD02D
72206+:1082F0003C010800A42B3FCC3556010035540980C1
72207+:1083000035510E008F8700548F89005C8E850020C8
72208+:1083100024080006012730233C010800AC283FD484
72209+:1083200000A7282304C000B50000902104A000B3DA
72210+:1083300000C5502B114000B5000000003C010800B2
72211+:10834000AC263FB88E6200000040F8090000000033
72212+:108350003046000214C0007400408021304B000100
72213+:10836000556000118E6200043C0D08008DAD3FBCCD
72214+:108370003C0EC0003C04800001AE6025AE2C000025
72215+:108380008C980000330F000811E0FFFD0000000092
72216+:10839000963F000824120001A79F00408E39000478
72217+:1083A000AF9900388E6200040040F8090000000018
72218+:1083B0000202802532030002146000B300000000B6
72219+:1083C0003C09080095293FC43C06080094C63FD0EC
72220+:1083D0003C0A0800954A3FC63C0708008CE73FBCB2
72221+:1083E000012670213C0308008C633FE03C08080034
72222+:1083F00095083FDA01CA20218ED9000C00E9282116
72223+:10840000249F000200A878210067C02133E4FFFF09
72224+:10841000AF9900503C010800AC383FE03C01080037
72225+:10842000A42F3FC83C010800A42E3FD20E0001E754
72226+:10843000000000008F8D0048004020213C01080012
72227+:10844000A02D3FD98E62000825AC0001AF8C0048FA
72228+:108450000040F809000000008F85005402A0302180
72229+:108460000E00060C004020210E0007A10040202134
72230+:108470008E6B000C0160F809004020213C0A0800C6
72231+:10848000954A3FD23C06080094C63FC601464821A3
72232+:10849000252800020E0001FB3104FFFF3C05080007
72233+:1084A0008CA53FB43C0708008CE73FBC00A7202305
72234+:1084B0003C010800AC243FB414800006000000001A
72235+:1084C0003C0208008C423FD4344B00403C01080081
72236+:1084D000AC2B3FD4124000438F8E00448E2D0010F1
72237+:1084E0008F920044AE4D00208E2C0018AE4C00241C
72238+:1084F0003C04080094843FC80E0006FA0000000007
72239+:108500008F9F00548E6700103C010800AC3F3FDC99
72240+:1085100000E0F809000000003C1908008F393FB462
72241+:108520001720FF798F870054979300583C11800ED5
72242+:10853000321601000E000729A633002C16C0004594
72243+:10854000320300105460004C8EE5000432080040F5
72244+:108550005500001D8EF000088EE4000C0080F80924
72245+:10856000000000008FBF00388FB700348FB6003096
72246+:108570008FB5002C8FB400288FB300248FB2002059
72247+:108580008FB1001C8FB0001803E0000827BD004029
72248+:108590008F86003C36110E0000072E0000A6202515
72249+:1085A000AE0400808E4300208E500024AFA3001044
72250+:1085B000AE2300148FB20010AE320010AE30001C9B
72251+:1085C0000A000A75AE3000180200F8090000000029
72252+:1085D0008EE4000C0080F809000000000A000B2E59
72253+:1085E0008FBF003824180001240F0001A5C000200F
72254+:1085F000A5D800220A000B10ADCF00243C010800D2
72255+:10860000AC203FB80A000AA68E6200003C010800B8
72256+:10861000AC253FB80A000AA68E6200009224000929
72257+:108620000E000771000028218FBF00388FB700347B
72258+:108630008FB600308FB5002C8FB400288FB3002484
72259+:108640008FB200208FB1001C8FB0001803E000082B
72260+:1086500027BD00403C1480009295010900002821AC
72261+:108660000E00084332A400FF320300105060FFB830
72262+:10867000320800408EE5000400A0F8090000000068
72263+:108680000A000B28320800405240FFA89793005878
72264+:108690008E3400148F930044AE7400208E35001C7D
72265+:1086A000AE7500240A000B1F979300588F820014A8
72266+:1086B0000004218003E00008008210213C078008AC
72267+:1086C00034E200809043006900804021106000097E
72268+:1086D0003C0401003C0708008CE73FDC8F8300303E
72269+:1086E00000E32023048000089389001C14E30003A6
72270+:1086F0000100202103E00008008010213C0401005B
72271+:1087000003E00008008010211120000B00673823CF
72272+:108710003C0D800035AC0980918B007C316A0002F1
72273+:10872000114000202409003400E9702B15C0FFF12E
72274+:108730000100202100E938232403FFFC00A3C82402
72275+:1087400000E3C02400F9782B15E0FFEA030820219C
72276+:1087500030C400030004102314C000143049000387
72277+:108760000000302100A9782101E6702100EE682B7D
72278+:1087700011A0FFE03C0401002D3800010006C82BC9
72279+:10878000010548210319382414E0FFDA2524FFFCF1
72280+:108790002402FFFC00A218240068202103E0000846
72281+:1087A000008010210A000B9E240900303C0C800040
72282+:1087B0003586098090CB007C316A00041540FFE9C2
72283+:1087C000240600040A000BAD000030213C03080021
72284+:1087D0008C63005C8F82001827BDFFE0AFBF0018DC
72285+:1087E000AFB1001410620005AFB00010000329C043
72286+:1087F00024A40280AF840014AF8300183C108000D2
72287+:1088000036020A0094450032361101000E000B7F3B
72288+:1088100030A43FFF8E240000241FFF803C11008005
72289+:108820000082C021031F60243309007F000CC9406F
72290+:1088300003294025330E0078362F00033C0D10002D
72291+:10884000010D502501CF5825AE0C002836080980AF
72292+:10885000AE0C080CAE0B082CAE0A08309103006970
72293+:108860003C06800C0126382110600006AF870034DA
72294+:108870008D09003C8D03006C0123382318E0008231
72295+:10888000000000003C0B8008356A00803C1080002E
72296+:10889000A1400069360609808CC200383C06800081
72297+:1088A00034C50A0090A8003C310C00201180001A49
72298+:1088B000AF820030240D00013C0E800035D10A004B
72299+:1088C000A38D001CAF8000248E2400248F850024FB
72300+:1088D000240D0008AF800020AF8000283C01080074
72301+:1088E000A42D3FC63C010800A4203FDA0E000B83F4
72302+:1088F000000030219228003C8FBF00188FB1001477
72303+:108900008FB0001000086142AF82002C27BD00200C
72304+:1089100003E000083182000190B80032240E00010B
72305+:10892000330F00FF000F2182108E00412419000236
72306+:108930001099006434C40AC03C03800034640A0007
72307+:108940008C8F002415E0001E34660900909F0030D3
72308+:108950002418000533F9003F1338004E24030001AA
72309+:108960008F860020A383001CAF860028AF860024DA
72310+:108970003C0E800035D10A008E2400248F8500240F
72311+:10898000240D00083C010800A42D3FC63C0108004E
72312+:10899000A4203FDA0E000B83000000009228003C68
72313+:1089A0008FBF00188FB100148FB000100008614213
72314+:1089B000AF82002C27BD002003E0000831820001B7
72315+:1089C0008C8A00088C8B00248CD000643C0E8000C4
72316+:1089D00035D10A00014B2823AF900024A380001C4E
72317+:1089E000AF8500288E2400248F8600208F850024E8
72318+:1089F000240D00083C010800A42D3FC63C010800DE
72319+:108A0000A4203FDA0E000B83000000009228003CF7
72320+:108A10008FBF00188FB100148FB0001000086142A2
72321+:108A2000AF82002C27BD002003E000083182000146
72322+:108A300090A200303051003F5224002834C50AC0B3
72323+:108A40008CB000241600002234CB09008CA600480C
72324+:108A50003C0A7FFF3545FFFF00C510243C0E800017
72325+:108A6000AF82002035C509008F8800208CAD0060E2
72326+:108A7000010D602B15800002010020218CA40060F4
72327+:108A80000A000C22AF8400208D02006C0A000BFC4F
72328+:108A90003C0680008C8200488F8600203C097FFFC6
72329+:108AA0003527FFFF004788243C0480082403000189
72330+:108AB000AF910028AC80006CA383001C0A000C302E
72331+:108AC000AF8600248C9F00140A000C22AF9F002068
72332+:108AD0008D6200680A000C6C3C0E800034C4098072
72333+:108AE0008C8900708CA300140123382B10E0000443
72334+:108AF000000000008C8200700A000C6C3C0E8000AC
72335+:108B00008CA200140A000C6C3C0E80008F8500249F
72336+:108B100027BDFFE0AFBF0018AFB1001414A00008DC
72337+:108B2000AFB000103C04800034870A0090E60030AB
72338+:108B30002402000530C3003F106200B934840900EC
72339+:108B40008F91002000A080213C048000348E0A0018
72340+:108B50008DCD00043C0608008CC63FB831A73FFF0E
72341+:108B600000E6602B5580000100E03021938F001C4F
72342+:108B700011E0007800D0282B349F098093F9007C05
72343+:108B800033380002130000792403003400C3102B93
72344+:108B9000144000D90000000000C3302300D0282B6F
72345+:108BA0003C010800A4233FC414A0006E0200182159
72346+:108BB0003C0408008C843FB40064402B5500000145
72347+:108BC000006020213C05800034A90A00912A003C65
72348+:108BD0003C010800AC243FBC31430020146000037A
72349+:108BE0000000482134AB0E008D6900188F88002CDE
72350+:108BF0000128202B1080005F000000003C050800C9
72351+:108C00008CA53FBC00A96821010D602B1180005C80
72352+:108C100000B0702B0109382300E028213C01080036
72353+:108C2000AC273FBC12000003240AFFFC10B0008DEB
72354+:108C30003224000300AA18243C010800A4203FDAD3
72355+:108C40003C010800AC233FBC006028218F84002435
72356+:108C5000120400063C0B80088D6C006C0200202181
72357+:108C6000AF91002025900001AD70006C8F8D002821
72358+:108C700000858823AF91002401A52023AF8400281C
72359+:108C80001220000224070018240700103C18800856
72360+:108C90003706008090CF00683C010800A0273FD82D
72361+:108CA0002407000131EE00FF11C70047000000005B
72362+:108CB00014800018000028213C06800034D109806F
72363+:108CC00034CD010091A600098E2C001824C40001A7
72364+:108CD000000C86023205007F308B007F1165007F1B
72365+:108CE0002407FF803C19800837290080A124004C0C
72366+:108CF0003C0808008D083FD4241800023C010800FD
72367+:108D0000A0384019350F00083C010800AC2F3FD4B3
72368+:108D1000240500103C02800034440A009083003C8B
72369+:108D2000307F002013E0000500A02021240A00016C
72370+:108D30003C010800AC2A3FBC34A400018FBF0018DE
72371+:108D40008FB100148FB000100080102103E00008E4
72372+:108D500027BD00203C010800A4203FC410A0FF94C0
72373+:108D6000020018210A000CC000C018210A000CB72C
72374+:108D7000240300303C0508008CA53FBC00B0702BDC
72375+:108D800011C0FFA8000000003C19080097393FC43B
72376+:108D90000325C0210307782B11E000072CAA00044B
72377+:108DA0003C0360008C625404305F003F17E0FFE337
72378+:108DB000240400422CAA00041140FF9A240400421B
72379+:108DC0000A000D248FBF00181528FFB9000000000D
72380+:108DD0008CCA00183C1F800024020002015F182585
72381+:108DE000ACC3001837F90A00A0C200689329003C00
72382+:108DF0002404000400A01021312800203C010800B8
72383+:108E0000A0244019110000022405001024020001D2
72384+:108E10003C010800AC223FB40A000D1A3C0280005D
72385+:108E20008F8800288C8900600109282B14A000027B
72386+:108E3000010088218C9100603C048000348B0E007E
72387+:108E40008D640018240A000102202821022030210C
72388+:108E5000A38A001C0E000B83022080210A000CA6AE
72389+:108E6000AF82002C00045823122000073164000355
72390+:108E70003C0E800035C7098090ED007C31AC0004C9
72391+:108E800015800019248F00043C010800A4243FDA57
72392+:108E90003C1F080097FF3FDA03E5C82100D9C02B2B
72393+:108EA0001300FF6B8F8400242CA6000514C0FFA3C1
72394+:108EB0002404004230A200031440000200A2182340
72395+:108EC00024A3FFFC3C010800AC233FBC3C0108008C
72396+:108ED000A4203FDA0A000CE70060282100C77024B4
72397+:108EE0000A000D0D01C720263C010800A42F3FDA1F
72398+:108EF0000A000D78000000003C010800AC203FBCD7
72399+:108F00000A000D23240400428F8300283C058000C2
72400+:108F100034AA0A00146000060000102191470030B6
72401+:108F20002406000530E400FF108600030000000066
72402+:108F300003E0000800000000914B0048316900FF89
72403+:108F4000000941C21500FFFA3C0680083C040800F5
72404+:108F500094843FC43C0308008C633FDC3C19080048
72405+:108F60008F393FBC3C0F080095EF3FDA0064C02109
72406+:108F70008CCD00040319702101CF602134AB0E00A9
72407+:108F8000018D282318A0001D00000000914F004C07
72408+:108F90008F8C0034956D001031EE00FF8D89000438
72409+:108FA00001AE30238D8A000030CEFFFF000E290075
72410+:108FB0000125C82100003821014720210325182B55
72411+:108FC0000083C021AD990004AD980000918F000A84
72412+:108FD00001CF6821A18D000A956500128F8A0034A7
72413+:108FE000A5450008954B003825690001A5490038C2
72414+:108FF0009148000D35070008A147000D03E0000867
72415+:109000000000000027BDFFD8AFB000189388001CF7
72416+:109010008FB000143C0A80003C197FFF8F8700242A
72417+:109020003738FFFFAFBF0020AFB1001C355F0A002B
72418+:109030000218182493EB003C00087FC03C02BFFFDD
72419+:10904000006F60252CF000013449FFFF3C1F080031
72420+:109050008FFF3FDC8F9900303C18080097183FD2F3
72421+:1090600001897824001047803C07EFFF3C05F0FFA2
72422+:1090700001E818253C1180003169002034E2FFFF2F
72423+:1090800034ADFFFF362E098027A50010240600020C
72424+:1090900003F96023270B0002354A0E0000621824F2
72425+:1090A0000080802115200002000040218D48001C16
72426+:1090B000A7AB0012058000392407000030E800FF4C
72427+:1090C00000083F00006758253C028008AFAB001441
72428+:1090D000344F008091EA00683C08080091083FD9AD
72429+:1090E0003C09DFFF352CFFFF000AF82B3C0208008B
72430+:1090F00094423FCCA3A80011016CC024001FCF40B4
72431+:10910000031918258FA70010AFA300143C0C08000A
72432+:10911000918C3FDBA7A200168FAB001400ED482412
72433+:109120003C0F01003C0A0FFF012FC82531980003B6
72434+:10913000355FFFFF016D40243C027000033F38247F
72435+:1091400000181E0000E2482501037825AFAF001487
72436+:10915000AFA9001091CC007C0E000092A3AC0015CA
72437+:10916000362D0A0091A6003C30C400201080000675
72438+:10917000260200083C11080096313FC8262EFFFF4A
72439+:109180003C010800A42E3FC88FBF00208FB1001CF7
72440+:109190008FB0001803E0000827BD00288F8B002C3B
72441+:1091A000010B502B5540FFC5240700010A000E0497
72442+:1091B00030E800FF9383001C3C02800027BDFFD8ED
72443+:1091C00034480A0000805021AFBF002034460AC056
72444+:1091D000010028211060000E3444098091070030FE
72445+:1091E000240B00058F89002030EC003F118B000B11
72446+:1091F00000003821AFA900103C0B80088D69006C7D
72447+:10920000AFAA00180E00015AAFA90014A380001CD9
72448+:109210008FBF002003E0000827BD00288D1F0048F5
72449+:109220003C1808008F183FBC8F9900283C027FFF34
72450+:109230008D0800443443FFFFAFA900103C0B8008A9
72451+:109240008D69006C03E370240319782101CF682332
72452+:1092500001A83821AFAA00180E00015AAFA90014C6
72453+:109260000A000E58A380001C3C05800034A60A00AA
72454+:1092700090C7003C3C06080094C63FDA3C02080058
72455+:109280008C423FD430E30020000624001060001E12
72456+:10929000004438253C0880083505008090A300680C
72457+:1092A00000004821240800010000282124040001B6
72458+:1092B0003C0680008CCD017805A0FFFE34CF014034
72459+:1092C000ADE800083C0208008C423FDCA5E5000444
72460+:1092D000A5E40006ADE2000C3C04080090843FD9F0
72461+:1092E0003C03800834790080A1E40012ADE700144B
72462+:1092F000A5E900189338004C3C0E1000A1F8002D91
72463+:1093000003E00008ACCE017834A90E008D28001CC3
72464+:109310003C0C08008D8C3FBC952B0016952A001440
72465+:10932000018648213164FFFF0A000E803145FFFFAE
72466+:109330003C04800034830A009065003C30A2002089
72467+:109340001040001934870E00000040210000382131
72468+:10935000000020213C0680008CC901780520FFFE1A
72469+:1093600034CA014034CF010091EB0009AD48000838
72470+:109370003C0E08008DCE3FDC240DFF91240C0040F4
72471+:109380003C081000A5440004A5470006AD4E000CA3
72472+:10939000A14D0012AD4C0014A5400018A14B002DAA
72473+:1093A00003E00008ACC801788CE8001894E60012CD
72474+:1093B00094E4001030C7FFFF0A000EA93084FFFFBD
72475+:1093C0003C04800034830A009065003C30A20020F9
72476+:1093D0001040002727BDFFF82409000100003821B4
72477+:1093E000240800013C0680008CCA01780540FFFE7D
72478+:1093F0003C0280FF34C40100908D00093C0C080041
72479+:10940000918C4019A3AD00038FAB00003185007F24
72480+:109410003459FFFF01665025AFAA00009083000A6F
72481+:10942000A3A0000200057E00A3A300018FB80000E6
72482+:1094300034CB0140240C30000319702401CF68257F
72483+:10944000AD6D000C27BD0008AD6C0014A5600018C0
72484+:10945000AD690008A56700042409FF80A56800061F
72485+:109460003C081000A169001203E00008ACC80178B4
72486+:1094700034870E008CE9001894E6001294E4001082
72487+:1094800030C8FFFF0A000ECD3087FFFF27BDFFE089
72488+:10949000AFB100143C118000AFB00010AFBF001896
72489+:1094A00036380A00970F0032363001000E000B7F6D
72490+:1094B00031E43FFF8E0E0000240DFF803C042000AD
72491+:1094C00001C25821016D6024000C4940316A007FBF
72492+:1094D000012A4025010438253C048008AE270830C5
72493+:1094E0003486008090C500682403000230A200FF8B
72494+:1094F000104300048F9F00208F990024AC9F0068C8
72495+:10950000AC9900648FBF00188FB100148FB00010A9
72496+:1095100003E0000827BD00203C0A0800254A3A80E5
72497+:109520003C09080025293B103C08080025082F1C91
72498+:109530003C07080024E73BDC3C06080024C639044D
72499+:109540003C05080024A536583C0408002484325CFD
72500+:109550003C030800246339B83C0208002442375415
72501+:109560003C010800AC2A3F983C010800AC293F941C
72502+:109570003C010800AC283F903C010800AC273F9C10
72503+:109580003C010800AC263FAC3C010800AC253FA4E0
72504+:109590003C010800AC243FA03C010800AC233FB0D4
72505+:1095A0003C010800AC223FA803E0000800000000D6
72506+:1095B00080000940800009008008010080080080C8
72507+:1095C00080080000800E00008008008080080000F5
72508+:1095D00080000A8080000A00800009808000090065
72509+:00000001FF
72510diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
72511index 703342e..2b96b597 100644
72512--- a/fs/9p/vfs_inode.c
72513+++ b/fs/9p/vfs_inode.c
72514@@ -540,8 +540,7 @@ static struct inode *v9fs_qid_iget(struct super_block *sb,
72515 unlock_new_inode(inode);
72516 return inode;
72517 error:
72518- unlock_new_inode(inode);
72519- iput(inode);
72520+ iget_failed(inode);
72521 return ERR_PTR(retval);
72522
72523 }
72524@@ -1312,7 +1311,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
72525 void
72526 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
72527 {
72528- char *s = nd_get_link(nd);
72529+ const char *s = nd_get_link(nd);
72530
72531 p9_debug(P9_DEBUG_VFS, " %pd %s\n",
72532 dentry, IS_ERR(s) ? "<error>" : s);
72533diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
72534index 9861c7c..4d3ecfb 100644
72535--- a/fs/9p/vfs_inode_dotl.c
72536+++ b/fs/9p/vfs_inode_dotl.c
72537@@ -149,8 +149,7 @@ static struct inode *v9fs_qid_iget_dotl(struct super_block *sb,
72538 unlock_new_inode(inode);
72539 return inode;
72540 error:
72541- unlock_new_inode(inode);
72542- iput(inode);
72543+ iget_failed(inode);
72544 return ERR_PTR(retval);
72545
72546 }
72547diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
72548index 2d0cbbd..a6d6149 100644
72549--- a/fs/Kconfig.binfmt
72550+++ b/fs/Kconfig.binfmt
72551@@ -103,7 +103,7 @@ config HAVE_AOUT
72552
72553 config BINFMT_AOUT
72554 tristate "Kernel support for a.out and ECOFF binaries"
72555- depends on HAVE_AOUT
72556+ depends on HAVE_AOUT && BROKEN
72557 ---help---
72558 A.out (Assembler.OUTput) is a set of formats for libraries and
72559 executables used in the earliest versions of UNIX. Linux used
72560diff --git a/fs/afs/inode.c b/fs/afs/inode.c
72561index e06f5a2..81d07ac 100644
72562--- a/fs/afs/inode.c
72563+++ b/fs/afs/inode.c
72564@@ -141,7 +141,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
72565 struct afs_vnode *vnode;
72566 struct super_block *sb;
72567 struct inode *inode;
72568- static atomic_t afs_autocell_ino;
72569+ static atomic_unchecked_t afs_autocell_ino;
72570
72571 _enter("{%x:%u},%*.*s,",
72572 AFS_FS_I(dir)->fid.vid, AFS_FS_I(dir)->fid.vnode,
72573@@ -154,7 +154,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
72574 data.fid.unique = 0;
72575 data.fid.vnode = 0;
72576
72577- inode = iget5_locked(sb, atomic_inc_return(&afs_autocell_ino),
72578+ inode = iget5_locked(sb, atomic_inc_return_unchecked(&afs_autocell_ino),
72579 afs_iget5_autocell_test, afs_iget5_set,
72580 &data);
72581 if (!inode) {
72582diff --git a/fs/aio.c b/fs/aio.c
72583index 480440f..623fd88 100644
72584--- a/fs/aio.c
72585+++ b/fs/aio.c
72586@@ -441,7 +441,7 @@ static int aio_setup_ring(struct kioctx *ctx)
72587 size += sizeof(struct io_event) * nr_events;
72588
72589 nr_pages = PFN_UP(size);
72590- if (nr_pages < 0)
72591+ if (nr_pages <= 0)
72592 return -EINVAL;
72593
72594 file = aio_private_file(ctx, nr_pages);
72595diff --git a/fs/attr.c b/fs/attr.c
72596index 6530ced..4a827e2 100644
72597--- a/fs/attr.c
72598+++ b/fs/attr.c
72599@@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
72600 unsigned long limit;
72601
72602 limit = rlimit(RLIMIT_FSIZE);
72603+ gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
72604 if (limit != RLIM_INFINITY && offset > limit)
72605 goto out_sig;
72606 if (offset > inode->i_sb->s_maxbytes)
72607diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
72608index 35b755e..f4b9e0a 100644
72609--- a/fs/autofs4/waitq.c
72610+++ b/fs/autofs4/waitq.c
72611@@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
72612 {
72613 unsigned long sigpipe, flags;
72614 mm_segment_t fs;
72615- const char *data = (const char *)addr;
72616+ const char __user *data = (const char __force_user *)addr;
72617 ssize_t wr = 0;
72618
72619 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
72620@@ -340,6 +340,10 @@ static int validate_request(struct autofs_wait_queue **wait,
72621 return 1;
72622 }
72623
72624+#ifdef CONFIG_GRKERNSEC_HIDESYM
72625+static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
72626+#endif
72627+
72628 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
72629 enum autofs_notify notify)
72630 {
72631@@ -385,7 +389,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
72632
72633 /* If this is a direct mount request create a dummy name */
72634 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
72635+#ifdef CONFIG_GRKERNSEC_HIDESYM
72636+ /* this name does get written to userland via autofs4_write() */
72637+ qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
72638+#else
72639 qstr.len = sprintf(name, "%p", dentry);
72640+#endif
72641 else {
72642 qstr.len = autofs4_getpath(sbi, dentry, &name);
72643 if (!qstr.len) {
72644diff --git a/fs/befs/endian.h b/fs/befs/endian.h
72645index 2722387..56059b5 100644
72646--- a/fs/befs/endian.h
72647+++ b/fs/befs/endian.h
72648@@ -11,7 +11,7 @@
72649
72650 #include <asm/byteorder.h>
72651
72652-static inline u64
72653+static inline u64 __intentional_overflow(-1)
72654 fs64_to_cpu(const struct super_block *sb, fs64 n)
72655 {
72656 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
72657@@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
72658 return (__force fs64)cpu_to_be64(n);
72659 }
72660
72661-static inline u32
72662+static inline u32 __intentional_overflow(-1)
72663 fs32_to_cpu(const struct super_block *sb, fs32 n)
72664 {
72665 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
72666@@ -47,7 +47,7 @@ cpu_to_fs32(const struct super_block *sb, u32 n)
72667 return (__force fs32)cpu_to_be32(n);
72668 }
72669
72670-static inline u16
72671+static inline u16 __intentional_overflow(-1)
72672 fs16_to_cpu(const struct super_block *sb, fs16 n)
72673 {
72674 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
72675diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
72676index 4c55668..eeae150 100644
72677--- a/fs/binfmt_aout.c
72678+++ b/fs/binfmt_aout.c
72679@@ -16,6 +16,7 @@
72680 #include <linux/string.h>
72681 #include <linux/fs.h>
72682 #include <linux/file.h>
72683+#include <linux/security.h>
72684 #include <linux/stat.h>
72685 #include <linux/fcntl.h>
72686 #include <linux/ptrace.h>
72687@@ -58,6 +59,8 @@ static int aout_core_dump(struct coredump_params *cprm)
72688 #endif
72689 # define START_STACK(u) ((void __user *)u.start_stack)
72690
72691+ memset(&dump, 0, sizeof(dump));
72692+
72693 fs = get_fs();
72694 set_fs(KERNEL_DS);
72695 has_dumped = 1;
72696@@ -68,10 +71,12 @@ static int aout_core_dump(struct coredump_params *cprm)
72697
72698 /* If the size of the dump file exceeds the rlimit, then see what would happen
72699 if we wrote the stack, but not the data area. */
72700+ gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
72701 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
72702 dump.u_dsize = 0;
72703
72704 /* Make sure we have enough room to write the stack and data areas. */
72705+ gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
72706 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
72707 dump.u_ssize = 0;
72708
72709@@ -232,6 +237,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
72710 rlim = rlimit(RLIMIT_DATA);
72711 if (rlim >= RLIM_INFINITY)
72712 rlim = ~0;
72713+
72714+ gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
72715 if (ex.a_data + ex.a_bss > rlim)
72716 return -ENOMEM;
72717
72718@@ -261,6 +268,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
72719
72720 install_exec_creds(bprm);
72721
72722+#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
72723+ current->mm->pax_flags = 0UL;
72724+#endif
72725+
72726+#ifdef CONFIG_PAX_PAGEEXEC
72727+ if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
72728+ current->mm->pax_flags |= MF_PAX_PAGEEXEC;
72729+
72730+#ifdef CONFIG_PAX_EMUTRAMP
72731+ if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
72732+ current->mm->pax_flags |= MF_PAX_EMUTRAMP;
72733+#endif
72734+
72735+#ifdef CONFIG_PAX_MPROTECT
72736+ if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
72737+ current->mm->pax_flags |= MF_PAX_MPROTECT;
72738+#endif
72739+
72740+ }
72741+#endif
72742+
72743 if (N_MAGIC(ex) == OMAGIC) {
72744 unsigned long text_addr, map_size;
72745 loff_t pos;
72746@@ -312,7 +340,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
72747 return error;
72748
72749 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
72750- PROT_READ | PROT_WRITE | PROT_EXEC,
72751+ PROT_READ | PROT_WRITE,
72752 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
72753 fd_offset + ex.a_text);
72754 if (error != N_DATADDR(ex))
72755diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
72756index cd46e41..244f778 100644
72757--- a/fs/binfmt_elf.c
72758+++ b/fs/binfmt_elf.c
72759@@ -35,6 +35,7 @@
72760 #include <linux/utsname.h>
72761 #include <linux/coredump.h>
72762 #include <linux/sched.h>
72763+#include <linux/xattr.h>
72764 #include <asm/uaccess.h>
72765 #include <asm/param.h>
72766 #include <asm/page.h>
72767@@ -48,7 +49,7 @@
72768
72769 static int load_elf_binary(struct linux_binprm *bprm);
72770 static unsigned long elf_map(struct file *, unsigned long, struct elf_phdr *,
72771- int, int, unsigned long);
72772+ int, int, unsigned long) __intentional_overflow(-1);
72773
72774 #ifdef CONFIG_USELIB
72775 static int load_elf_library(struct file *);
72776@@ -66,6 +67,14 @@ static int elf_core_dump(struct coredump_params *cprm);
72777 #define elf_core_dump NULL
72778 #endif
72779
72780+#ifdef CONFIG_PAX_MPROTECT
72781+static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
72782+#endif
72783+
72784+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
72785+static void elf_handle_mmap(struct file *file);
72786+#endif
72787+
72788 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
72789 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
72790 #else
72791@@ -85,6 +94,15 @@ static struct linux_binfmt elf_format = {
72792 .load_binary = load_elf_binary,
72793 .load_shlib = load_elf_library,
72794 .core_dump = elf_core_dump,
72795+
72796+#ifdef CONFIG_PAX_MPROTECT
72797+ .handle_mprotect= elf_handle_mprotect,
72798+#endif
72799+
72800+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
72801+ .handle_mmap = elf_handle_mmap,
72802+#endif
72803+
72804 .min_coredump = ELF_EXEC_PAGESIZE,
72805 };
72806
72807@@ -92,6 +110,8 @@ static struct linux_binfmt elf_format = {
72808
72809 static int set_brk(unsigned long start, unsigned long end)
72810 {
72811+ unsigned long e = end;
72812+
72813 start = ELF_PAGEALIGN(start);
72814 end = ELF_PAGEALIGN(end);
72815 if (end > start) {
72816@@ -100,7 +120,7 @@ static int set_brk(unsigned long start, unsigned long end)
72817 if (BAD_ADDR(addr))
72818 return addr;
72819 }
72820- current->mm->start_brk = current->mm->brk = end;
72821+ current->mm->start_brk = current->mm->brk = e;
72822 return 0;
72823 }
72824
72825@@ -161,12 +181,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
72826 elf_addr_t __user *u_rand_bytes;
72827 const char *k_platform = ELF_PLATFORM;
72828 const char *k_base_platform = ELF_BASE_PLATFORM;
72829- unsigned char k_rand_bytes[16];
72830+ u32 k_rand_bytes[4];
72831 int items;
72832 elf_addr_t *elf_info;
72833 int ei_index = 0;
72834 const struct cred *cred = current_cred();
72835 struct vm_area_struct *vma;
72836+ unsigned long saved_auxv[AT_VECTOR_SIZE];
72837
72838 /*
72839 * In some cases (e.g. Hyper-Threading), we want to avoid L1
72840@@ -208,8 +229,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
72841 * Generate 16 random bytes for userspace PRNG seeding.
72842 */
72843 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
72844- u_rand_bytes = (elf_addr_t __user *)
72845- STACK_ALLOC(p, sizeof(k_rand_bytes));
72846+ prandom_seed(k_rand_bytes[0] ^ prandom_u32());
72847+ prandom_seed(k_rand_bytes[1] ^ prandom_u32());
72848+ prandom_seed(k_rand_bytes[2] ^ prandom_u32());
72849+ prandom_seed(k_rand_bytes[3] ^ prandom_u32());
72850+ p = STACK_ROUND(p, sizeof(k_rand_bytes));
72851+ u_rand_bytes = (elf_addr_t __user *) p;
72852 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
72853 return -EFAULT;
72854
72855@@ -324,9 +349,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
72856 return -EFAULT;
72857 current->mm->env_end = p;
72858
72859+ memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
72860+
72861 /* Put the elf_info on the stack in the right place. */
72862 sp = (elf_addr_t __user *)envp + 1;
72863- if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
72864+ if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
72865 return -EFAULT;
72866 return 0;
72867 }
72868@@ -515,14 +542,14 @@ static inline int arch_check_elf(struct elfhdr *ehdr, bool has_interp,
72869 an ELF header */
72870
72871 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
72872- struct file *interpreter, unsigned long *interp_map_addr,
72873+ struct file *interpreter,
72874 unsigned long no_base, struct elf_phdr *interp_elf_phdata)
72875 {
72876 struct elf_phdr *eppnt;
72877- unsigned long load_addr = 0;
72878+ unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
72879 int load_addr_set = 0;
72880 unsigned long last_bss = 0, elf_bss = 0;
72881- unsigned long error = ~0UL;
72882+ unsigned long error = -EINVAL;
72883 unsigned long total_size;
72884 int i;
72885
72886@@ -542,6 +569,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
72887 goto out;
72888 }
72889
72890+#ifdef CONFIG_PAX_SEGMEXEC
72891+ if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
72892+ pax_task_size = SEGMEXEC_TASK_SIZE;
72893+#endif
72894+
72895 eppnt = interp_elf_phdata;
72896 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
72897 if (eppnt->p_type == PT_LOAD) {
72898@@ -565,8 +597,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
72899 map_addr = elf_map(interpreter, load_addr + vaddr,
72900 eppnt, elf_prot, elf_type, total_size);
72901 total_size = 0;
72902- if (!*interp_map_addr)
72903- *interp_map_addr = map_addr;
72904 error = map_addr;
72905 if (BAD_ADDR(map_addr))
72906 goto out;
72907@@ -585,8 +615,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
72908 k = load_addr + eppnt->p_vaddr;
72909 if (BAD_ADDR(k) ||
72910 eppnt->p_filesz > eppnt->p_memsz ||
72911- eppnt->p_memsz > TASK_SIZE ||
72912- TASK_SIZE - eppnt->p_memsz < k) {
72913+ eppnt->p_memsz > pax_task_size ||
72914+ pax_task_size - eppnt->p_memsz < k) {
72915 error = -ENOMEM;
72916 goto out;
72917 }
72918@@ -625,9 +655,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
72919 elf_bss = ELF_PAGESTART(elf_bss + ELF_MIN_ALIGN - 1);
72920
72921 /* Map the last of the bss segment */
72922- error = vm_brk(elf_bss, last_bss - elf_bss);
72923- if (BAD_ADDR(error))
72924- goto out;
72925+ if (last_bss > elf_bss) {
72926+ error = vm_brk(elf_bss, last_bss - elf_bss);
72927+ if (BAD_ADDR(error))
72928+ goto out;
72929+ }
72930 }
72931
72932 error = load_addr;
72933@@ -635,6 +667,336 @@ out:
72934 return error;
72935 }
72936
72937+#ifdef CONFIG_PAX_PT_PAX_FLAGS
72938+#ifdef CONFIG_PAX_SOFTMODE
72939+static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
72940+{
72941+ unsigned long pax_flags = 0UL;
72942+
72943+#ifdef CONFIG_PAX_PAGEEXEC
72944+ if (elf_phdata->p_flags & PF_PAGEEXEC)
72945+ pax_flags |= MF_PAX_PAGEEXEC;
72946+#endif
72947+
72948+#ifdef CONFIG_PAX_SEGMEXEC
72949+ if (elf_phdata->p_flags & PF_SEGMEXEC)
72950+ pax_flags |= MF_PAX_SEGMEXEC;
72951+#endif
72952+
72953+#ifdef CONFIG_PAX_EMUTRAMP
72954+ if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
72955+ pax_flags |= MF_PAX_EMUTRAMP;
72956+#endif
72957+
72958+#ifdef CONFIG_PAX_MPROTECT
72959+ if (elf_phdata->p_flags & PF_MPROTECT)
72960+ pax_flags |= MF_PAX_MPROTECT;
72961+#endif
72962+
72963+#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
72964+ if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
72965+ pax_flags |= MF_PAX_RANDMMAP;
72966+#endif
72967+
72968+ return pax_flags;
72969+}
72970+#endif
72971+
72972+static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
72973+{
72974+ unsigned long pax_flags = 0UL;
72975+
72976+#ifdef CONFIG_PAX_PAGEEXEC
72977+ if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
72978+ pax_flags |= MF_PAX_PAGEEXEC;
72979+#endif
72980+
72981+#ifdef CONFIG_PAX_SEGMEXEC
72982+ if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
72983+ pax_flags |= MF_PAX_SEGMEXEC;
72984+#endif
72985+
72986+#ifdef CONFIG_PAX_EMUTRAMP
72987+ if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
72988+ pax_flags |= MF_PAX_EMUTRAMP;
72989+#endif
72990+
72991+#ifdef CONFIG_PAX_MPROTECT
72992+ if (!(elf_phdata->p_flags & PF_NOMPROTECT))
72993+ pax_flags |= MF_PAX_MPROTECT;
72994+#endif
72995+
72996+#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
72997+ if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
72998+ pax_flags |= MF_PAX_RANDMMAP;
72999+#endif
73000+
73001+ return pax_flags;
73002+}
73003+#endif
73004+
73005+#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
73006+#ifdef CONFIG_PAX_SOFTMODE
73007+static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
73008+{
73009+ unsigned long pax_flags = 0UL;
73010+
73011+#ifdef CONFIG_PAX_PAGEEXEC
73012+ if (pax_flags_softmode & MF_PAX_PAGEEXEC)
73013+ pax_flags |= MF_PAX_PAGEEXEC;
73014+#endif
73015+
73016+#ifdef CONFIG_PAX_SEGMEXEC
73017+ if (pax_flags_softmode & MF_PAX_SEGMEXEC)
73018+ pax_flags |= MF_PAX_SEGMEXEC;
73019+#endif
73020+
73021+#ifdef CONFIG_PAX_EMUTRAMP
73022+ if ((pax_flags_softmode & MF_PAX_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
73023+ pax_flags |= MF_PAX_EMUTRAMP;
73024+#endif
73025+
73026+#ifdef CONFIG_PAX_MPROTECT
73027+ if (pax_flags_softmode & MF_PAX_MPROTECT)
73028+ pax_flags |= MF_PAX_MPROTECT;
73029+#endif
73030+
73031+#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
73032+ if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
73033+ pax_flags |= MF_PAX_RANDMMAP;
73034+#endif
73035+
73036+ return pax_flags;
73037+}
73038+#endif
73039+
73040+static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
73041+{
73042+ unsigned long pax_flags = 0UL;
73043+
73044+#ifdef CONFIG_PAX_PAGEEXEC
73045+ if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
73046+ pax_flags |= MF_PAX_PAGEEXEC;
73047+#endif
73048+
73049+#ifdef CONFIG_PAX_SEGMEXEC
73050+ if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
73051+ pax_flags |= MF_PAX_SEGMEXEC;
73052+#endif
73053+
73054+#ifdef CONFIG_PAX_EMUTRAMP
73055+ if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
73056+ pax_flags |= MF_PAX_EMUTRAMP;
73057+#endif
73058+
73059+#ifdef CONFIG_PAX_MPROTECT
73060+ if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
73061+ pax_flags |= MF_PAX_MPROTECT;
73062+#endif
73063+
73064+#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
73065+ if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
73066+ pax_flags |= MF_PAX_RANDMMAP;
73067+#endif
73068+
73069+ return pax_flags;
73070+}
73071+#endif
73072+
73073+#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
73074+static unsigned long pax_parse_defaults(void)
73075+{
73076+ unsigned long pax_flags = 0UL;
73077+
73078+#ifdef CONFIG_PAX_SOFTMODE
73079+ if (pax_softmode)
73080+ return pax_flags;
73081+#endif
73082+
73083+#ifdef CONFIG_PAX_PAGEEXEC
73084+ pax_flags |= MF_PAX_PAGEEXEC;
73085+#endif
73086+
73087+#ifdef CONFIG_PAX_SEGMEXEC
73088+ pax_flags |= MF_PAX_SEGMEXEC;
73089+#endif
73090+
73091+#ifdef CONFIG_PAX_MPROTECT
73092+ pax_flags |= MF_PAX_MPROTECT;
73093+#endif
73094+
73095+#ifdef CONFIG_PAX_RANDMMAP
73096+ if (randomize_va_space)
73097+ pax_flags |= MF_PAX_RANDMMAP;
73098+#endif
73099+
73100+ return pax_flags;
73101+}
73102+
73103+static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
73104+{
73105+ unsigned long pax_flags = PAX_PARSE_FLAGS_FALLBACK;
73106+
73107+#ifdef CONFIG_PAX_EI_PAX
73108+
73109+#ifdef CONFIG_PAX_SOFTMODE
73110+ if (pax_softmode)
73111+ return pax_flags;
73112+#endif
73113+
73114+ pax_flags = 0UL;
73115+
73116+#ifdef CONFIG_PAX_PAGEEXEC
73117+ if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
73118+ pax_flags |= MF_PAX_PAGEEXEC;
73119+#endif
73120+
73121+#ifdef CONFIG_PAX_SEGMEXEC
73122+ if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
73123+ pax_flags |= MF_PAX_SEGMEXEC;
73124+#endif
73125+
73126+#ifdef CONFIG_PAX_EMUTRAMP
73127+ if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
73128+ pax_flags |= MF_PAX_EMUTRAMP;
73129+#endif
73130+
73131+#ifdef CONFIG_PAX_MPROTECT
73132+ if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
73133+ pax_flags |= MF_PAX_MPROTECT;
73134+#endif
73135+
73136+#ifdef CONFIG_PAX_ASLR
73137+ if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
73138+ pax_flags |= MF_PAX_RANDMMAP;
73139+#endif
73140+
73141+#endif
73142+
73143+ return pax_flags;
73144+
73145+}
73146+
73147+static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
73148+{
73149+
73150+#ifdef CONFIG_PAX_PT_PAX_FLAGS
73151+ unsigned long i;
73152+
73153+ for (i = 0UL; i < elf_ex->e_phnum; i++)
73154+ if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
73155+ if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
73156+ ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
73157+ ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
73158+ ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
73159+ ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
73160+ return PAX_PARSE_FLAGS_FALLBACK;
73161+
73162+#ifdef CONFIG_PAX_SOFTMODE
73163+ if (pax_softmode)
73164+ return pax_parse_pt_pax_softmode(&elf_phdata[i]);
73165+ else
73166+#endif
73167+
73168+ return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
73169+ break;
73170+ }
73171+#endif
73172+
73173+ return PAX_PARSE_FLAGS_FALLBACK;
73174+}
73175+
73176+static unsigned long pax_parse_xattr_pax(struct file * const file)
73177+{
73178+
73179+#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
73180+ ssize_t xattr_size, i;
73181+ unsigned char xattr_value[sizeof("pemrs") - 1];
73182+ unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
73183+
73184+ xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
73185+ if (xattr_size < 0 || xattr_size > sizeof xattr_value)
73186+ return PAX_PARSE_FLAGS_FALLBACK;
73187+
73188+ for (i = 0; i < xattr_size; i++)
73189+ switch (xattr_value[i]) {
73190+ default:
73191+ return PAX_PARSE_FLAGS_FALLBACK;
73192+
73193+#define parse_flag(option1, option2, flag) \
73194+ case option1: \
73195+ if (pax_flags_hardmode & MF_PAX_##flag) \
73196+ return PAX_PARSE_FLAGS_FALLBACK;\
73197+ pax_flags_hardmode |= MF_PAX_##flag; \
73198+ break; \
73199+ case option2: \
73200+ if (pax_flags_softmode & MF_PAX_##flag) \
73201+ return PAX_PARSE_FLAGS_FALLBACK;\
73202+ pax_flags_softmode |= MF_PAX_##flag; \
73203+ break;
73204+
73205+ parse_flag('p', 'P', PAGEEXEC);
73206+ parse_flag('e', 'E', EMUTRAMP);
73207+ parse_flag('m', 'M', MPROTECT);
73208+ parse_flag('r', 'R', RANDMMAP);
73209+ parse_flag('s', 'S', SEGMEXEC);
73210+
73211+#undef parse_flag
73212+ }
73213+
73214+ if (pax_flags_hardmode & pax_flags_softmode)
73215+ return PAX_PARSE_FLAGS_FALLBACK;
73216+
73217+#ifdef CONFIG_PAX_SOFTMODE
73218+ if (pax_softmode)
73219+ return pax_parse_xattr_pax_softmode(pax_flags_softmode);
73220+ else
73221+#endif
73222+
73223+ return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
73224+#else
73225+ return PAX_PARSE_FLAGS_FALLBACK;
73226+#endif
73227+
73228+}
73229+
73230+static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
73231+{
73232+ unsigned long pax_flags, ei_pax_flags, pt_pax_flags, xattr_pax_flags;
73233+
73234+ pax_flags = pax_parse_defaults();
73235+ ei_pax_flags = pax_parse_ei_pax(elf_ex);
73236+ pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
73237+ xattr_pax_flags = pax_parse_xattr_pax(file);
73238+
73239+ if (pt_pax_flags != PAX_PARSE_FLAGS_FALLBACK &&
73240+ xattr_pax_flags != PAX_PARSE_FLAGS_FALLBACK &&
73241+ pt_pax_flags != xattr_pax_flags)
73242+ return -EINVAL;
73243+ if (xattr_pax_flags != PAX_PARSE_FLAGS_FALLBACK)
73244+ pax_flags = xattr_pax_flags;
73245+ else if (pt_pax_flags != PAX_PARSE_FLAGS_FALLBACK)
73246+ pax_flags = pt_pax_flags;
73247+ else if (ei_pax_flags != PAX_PARSE_FLAGS_FALLBACK)
73248+ pax_flags = ei_pax_flags;
73249+
73250+#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
73251+ if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
73252+ if ((__supported_pte_mask & _PAGE_NX))
73253+ pax_flags &= ~MF_PAX_SEGMEXEC;
73254+ else
73255+ pax_flags &= ~MF_PAX_PAGEEXEC;
73256+ }
73257+#endif
73258+
73259+ if (0 > pax_check_flags(&pax_flags))
73260+ return -EINVAL;
73261+
73262+ current->mm->pax_flags = pax_flags;
73263+ return 0;
73264+}
73265+#endif
73266+
73267 /*
73268 * These are the functions used to load ELF style executables and shared
73269 * libraries. There is no binary dependent code anywhere else.
73270@@ -648,6 +1010,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
73271 {
73272 unsigned long random_variable = 0;
73273
73274+#ifdef CONFIG_PAX_RANDUSTACK
73275+ if (current->mm->pax_flags & MF_PAX_RANDMMAP)
73276+ return stack_top - current->mm->delta_stack;
73277+#endif
73278+
73279 if ((current->flags & PF_RANDOMIZE) &&
73280 !(current->personality & ADDR_NO_RANDOMIZE)) {
73281 random_variable = (unsigned long) get_random_int();
73282@@ -667,7 +1034,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
73283 unsigned long load_addr = 0, load_bias = 0;
73284 int load_addr_set = 0;
73285 char * elf_interpreter = NULL;
73286- unsigned long error;
73287+ unsigned long error = 0;
73288 struct elf_phdr *elf_ppnt, *elf_phdata, *interp_elf_phdata = NULL;
73289 unsigned long elf_bss, elf_brk;
73290 int retval, i;
73291@@ -682,6 +1049,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
73292 struct elfhdr interp_elf_ex;
73293 } *loc;
73294 struct arch_elf_state arch_state = INIT_ARCH_ELF_STATE;
73295+ unsigned long pax_task_size;
73296
73297 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
73298 if (!loc) {
73299@@ -840,6 +1208,77 @@ static int load_elf_binary(struct linux_binprm *bprm)
73300 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
73301 may depend on the personality. */
73302 SET_PERSONALITY2(loc->elf_ex, &arch_state);
73303+
73304+#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
73305+ current->mm->pax_flags = 0UL;
73306+#endif
73307+
73308+#ifdef CONFIG_PAX_DLRESOLVE
73309+ current->mm->call_dl_resolve = 0UL;
73310+#endif
73311+
73312+#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
73313+ current->mm->call_syscall = 0UL;
73314+#endif
73315+
73316+#ifdef CONFIG_PAX_ASLR
73317+ current->mm->delta_mmap = 0UL;
73318+ current->mm->delta_stack = 0UL;
73319+#endif
73320+
73321+#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
73322+ if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
73323+ send_sig(SIGKILL, current, 0);
73324+ goto out_free_dentry;
73325+ }
73326+#endif
73327+
73328+#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
73329+ pax_set_initial_flags(bprm);
73330+#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
73331+ if (pax_set_initial_flags_func)
73332+ (pax_set_initial_flags_func)(bprm);
73333+#endif
73334+
73335+#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
73336+ if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
73337+ current->mm->context.user_cs_limit = PAGE_SIZE;
73338+ current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
73339+ }
73340+#endif
73341+
73342+#ifdef CONFIG_PAX_SEGMEXEC
73343+ if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
73344+ current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
73345+ current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
73346+ pax_task_size = SEGMEXEC_TASK_SIZE;
73347+ current->mm->def_flags |= VM_NOHUGEPAGE;
73348+ } else
73349+#endif
73350+
73351+ pax_task_size = TASK_SIZE;
73352+
73353+#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
73354+ if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
73355+ set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
73356+ put_cpu();
73357+ }
73358+#endif
73359+
73360+#ifdef CONFIG_PAX_ASLR
73361+ if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
73362+ current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
73363+ current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
73364+ }
73365+#endif
73366+
73367+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
73368+ if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
73369+ executable_stack = EXSTACK_DISABLE_X;
73370+ current->personality &= ~READ_IMPLIES_EXEC;
73371+ } else
73372+#endif
73373+
73374 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
73375 current->personality |= READ_IMPLIES_EXEC;
73376
73377@@ -915,8 +1354,21 @@ static int load_elf_binary(struct linux_binprm *bprm)
73378 if (current->flags & PF_RANDOMIZE)
73379 load_bias += arch_mmap_rnd();
73380 load_bias = ELF_PAGESTART(load_bias);
73381- total_size = total_mapping_size(elf_phdata,
73382- loc->elf_ex.e_phnum);
73383+
73384+#ifdef CONFIG_PAX_RANDMMAP
73385+ /* PaX: randomize base address at the default exe base if requested */
73386+ if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
73387+#ifdef CONFIG_SPARC64
73388+ load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
73389+#else
73390+ load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
73391+#endif
73392+ load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
73393+ elf_flags |= MAP_FIXED;
73394+ }
73395+#endif
73396+
73397+ total_size = total_mapping_size(elf_phdata, loc->elf_ex.e_phnum);
73398 if (!total_size) {
73399 retval = -EINVAL;
73400 goto out_free_dentry;
73401@@ -952,9 +1404,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
73402 * allowed task size. Note that p_filesz must always be
73403 * <= p_memsz so it is only necessary to check p_memsz.
73404 */
73405- if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
73406- elf_ppnt->p_memsz > TASK_SIZE ||
73407- TASK_SIZE - elf_ppnt->p_memsz < k) {
73408+ if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
73409+ elf_ppnt->p_memsz > pax_task_size ||
73410+ pax_task_size - elf_ppnt->p_memsz < k) {
73411 /* set_brk can never work. Avoid overflows. */
73412 retval = -EINVAL;
73413 goto out_free_dentry;
73414@@ -990,16 +1442,43 @@ static int load_elf_binary(struct linux_binprm *bprm)
73415 if (retval)
73416 goto out_free_dentry;
73417 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
73418- retval = -EFAULT; /* Nobody gets to see this, but.. */
73419- goto out_free_dentry;
73420+ /*
73421+ * This bss-zeroing can fail if the ELF
73422+ * file specifies odd protections. So
73423+ * we don't check the return value
73424+ */
73425 }
73426
73427+#ifdef CONFIG_PAX_RANDMMAP
73428+ if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
73429+ unsigned long start, size, flags;
73430+ vm_flags_t vm_flags;
73431+
73432+ start = ELF_PAGEALIGN(elf_brk);
73433+ size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
73434+ flags = MAP_FIXED | MAP_PRIVATE;
73435+ vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
73436+
73437+ down_write(&current->mm->mmap_sem);
73438+ start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
73439+ retval = -ENOMEM;
73440+ if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
73441+// if (current->personality & ADDR_NO_RANDOMIZE)
73442+// vm_flags |= VM_READ | VM_MAYREAD;
73443+ start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
73444+ retval = IS_ERR_VALUE(start) ? start : 0;
73445+ }
73446+ up_write(&current->mm->mmap_sem);
73447+ if (retval == 0)
73448+ retval = set_brk(start + size, start + size + PAGE_SIZE);
73449+ if (retval < 0)
73450+ goto out_free_dentry;
73451+ }
73452+#endif
73453+
73454 if (elf_interpreter) {
73455- unsigned long interp_map_addr = 0;
73456-
73457 elf_entry = load_elf_interp(&loc->interp_elf_ex,
73458 interpreter,
73459- &interp_map_addr,
73460 load_bias, interp_elf_phdata);
73461 if (!IS_ERR((void *)elf_entry)) {
73462 /*
73463@@ -1050,6 +1529,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
73464 current->mm->end_data = end_data;
73465 current->mm->start_stack = bprm->p;
73466
73467+#ifndef CONFIG_PAX_RANDMMAP
73468 if ((current->flags & PF_RANDOMIZE) && (randomize_va_space > 1)) {
73469 current->mm->brk = current->mm->start_brk =
73470 arch_randomize_brk(current->mm);
73471@@ -1057,6 +1537,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
73472 current->brk_randomized = 1;
73473 #endif
73474 }
73475+#endif
73476
73477 if (current->personality & MMAP_PAGE_ZERO) {
73478 /* Why this, you ask??? Well SVr4 maps page 0 as read-only,
73479@@ -1225,7 +1706,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
73480 * Decide what to dump of a segment, part, all or none.
73481 */
73482 static unsigned long vma_dump_size(struct vm_area_struct *vma,
73483- unsigned long mm_flags)
73484+ unsigned long mm_flags, long signr)
73485 {
73486 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
73487
73488@@ -1263,7 +1744,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
73489 if (vma->vm_file == NULL)
73490 return 0;
73491
73492- if (FILTER(MAPPED_PRIVATE))
73493+ if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
73494 goto whole;
73495
73496 /*
73497@@ -1470,9 +1951,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
73498 {
73499 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
73500 int i = 0;
73501- do
73502+ do {
73503 i += 2;
73504- while (auxv[i - 2] != AT_NULL);
73505+ } while (auxv[i - 2] != AT_NULL);
73506 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
73507 }
73508
73509@@ -1481,7 +1962,7 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
73510 {
73511 mm_segment_t old_fs = get_fs();
73512 set_fs(KERNEL_DS);
73513- copy_siginfo_to_user((user_siginfo_t __user *) csigdata, siginfo);
73514+ copy_siginfo_to_user((user_siginfo_t __force_user *) csigdata, siginfo);
73515 set_fs(old_fs);
73516 fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
73517 }
73518@@ -2201,7 +2682,7 @@ static int elf_core_dump(struct coredump_params *cprm)
73519 vma = next_vma(vma, gate_vma)) {
73520 unsigned long dump_size;
73521
73522- dump_size = vma_dump_size(vma, cprm->mm_flags);
73523+ dump_size = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
73524 vma_filesz[i++] = dump_size;
73525 vma_data_size += dump_size;
73526 }
73527@@ -2309,6 +2790,167 @@ out:
73528
73529 #endif /* CONFIG_ELF_CORE */
73530
73531+#ifdef CONFIG_PAX_MPROTECT
73532+/* PaX: non-PIC ELF libraries need relocations on their executable segments
73533+ * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
73534+ * we'll remove VM_MAYWRITE for good on RELRO segments.
73535+ *
73536+ * The checks favour ld-linux.so behaviour which operates on a per ELF segment
73537+ * basis because we want to allow the common case and not the special ones.
73538+ */
73539+static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
73540+{
73541+ struct elfhdr elf_h;
73542+ struct elf_phdr elf_p;
73543+ unsigned long i;
73544+ unsigned long oldflags;
73545+ bool is_textrel_rw, is_textrel_rx, is_relro;
73546+
73547+ if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT) || !vma->vm_file)
73548+ return;
73549+
73550+ oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
73551+ newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
73552+
73553+#ifdef CONFIG_PAX_ELFRELOCS
73554+ /* possible TEXTREL */
73555+ is_textrel_rw = !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
73556+ is_textrel_rx = vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_WRITE | VM_READ) && newflags == (VM_EXEC | VM_READ);
73557+#else
73558+ is_textrel_rw = false;
73559+ is_textrel_rx = false;
73560+#endif
73561+
73562+ /* possible RELRO */
73563+ is_relro = vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
73564+
73565+ if (!is_textrel_rw && !is_textrel_rx && !is_relro)
73566+ return;
73567+
73568+ if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
73569+ memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
73570+
73571+#ifdef CONFIG_PAX_ETEXECRELOCS
73572+ ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
73573+#else
73574+ ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
73575+#endif
73576+
73577+ (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
73578+ !elf_check_arch(&elf_h) ||
73579+ elf_h.e_phentsize != sizeof(struct elf_phdr) ||
73580+ elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
73581+ return;
73582+
73583+ for (i = 0UL; i < elf_h.e_phnum; i++) {
73584+ if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
73585+ return;
73586+ switch (elf_p.p_type) {
73587+ case PT_DYNAMIC:
73588+ if (!is_textrel_rw && !is_textrel_rx)
73589+ continue;
73590+ i = 0UL;
73591+ while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
73592+ elf_dyn dyn;
73593+
73594+ if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
73595+ break;
73596+ if (dyn.d_tag == DT_NULL)
73597+ break;
73598+ if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
73599+ gr_log_textrel(vma);
73600+ if (is_textrel_rw)
73601+ vma->vm_flags |= VM_MAYWRITE;
73602+ else
73603+ /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
73604+ vma->vm_flags &= ~VM_MAYWRITE;
73605+ break;
73606+ }
73607+ i++;
73608+ }
73609+ is_textrel_rw = false;
73610+ is_textrel_rx = false;
73611+ continue;
73612+
73613+ case PT_GNU_RELRO:
73614+ if (!is_relro)
73615+ continue;
73616+ if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
73617+ vma->vm_flags &= ~VM_MAYWRITE;
73618+ is_relro = false;
73619+ continue;
73620+
73621+#ifdef CONFIG_PAX_PT_PAX_FLAGS
73622+ case PT_PAX_FLAGS: {
73623+ const char *msg_mprotect = "", *msg_emutramp = "";
73624+ char *buffer_lib, *buffer_exe;
73625+
73626+ if (elf_p.p_flags & PF_NOMPROTECT)
73627+ msg_mprotect = "MPROTECT disabled";
73628+
73629+#ifdef CONFIG_PAX_EMUTRAMP
73630+ if (!(vma->vm_mm->pax_flags & MF_PAX_EMUTRAMP) && !(elf_p.p_flags & PF_NOEMUTRAMP))
73631+ msg_emutramp = "EMUTRAMP enabled";
73632+#endif
73633+
73634+ if (!msg_mprotect[0] && !msg_emutramp[0])
73635+ continue;
73636+
73637+ if (!printk_ratelimit())
73638+ continue;
73639+
73640+ buffer_lib = (char *)__get_free_page(GFP_KERNEL);
73641+ buffer_exe = (char *)__get_free_page(GFP_KERNEL);
73642+ if (buffer_lib && buffer_exe) {
73643+ char *path_lib, *path_exe;
73644+
73645+ path_lib = pax_get_path(&vma->vm_file->f_path, buffer_lib, PAGE_SIZE);
73646+ path_exe = pax_get_path(&vma->vm_mm->exe_file->f_path, buffer_exe, PAGE_SIZE);
73647+
73648+ pr_info("PAX: %s wants %s%s%s on %s\n", path_lib, msg_mprotect,
73649+ (msg_mprotect[0] && msg_emutramp[0] ? " and " : ""), msg_emutramp, path_exe);
73650+
73651+ }
73652+ free_page((unsigned long)buffer_exe);
73653+ free_page((unsigned long)buffer_lib);
73654+ continue;
73655+ }
73656+#endif
73657+
73658+ }
73659+ }
73660+}
73661+#endif
73662+
73663+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
73664+
73665+extern int grsec_enable_log_rwxmaps;
73666+
73667+static void elf_handle_mmap(struct file *file)
73668+{
73669+ struct elfhdr elf_h;
73670+ struct elf_phdr elf_p;
73671+ unsigned long i;
73672+
73673+ if (!grsec_enable_log_rwxmaps)
73674+ return;
73675+
73676+ if (sizeof(elf_h) != kernel_read(file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
73677+ memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
73678+ (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC) || !elf_check_arch(&elf_h) ||
73679+ elf_h.e_phentsize != sizeof(struct elf_phdr) ||
73680+ elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
73681+ return;
73682+
73683+ for (i = 0UL; i < elf_h.e_phnum; i++) {
73684+ if (sizeof(elf_p) != kernel_read(file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
73685+ return;
73686+ if (elf_p.p_type == PT_GNU_STACK && (elf_p.p_flags & PF_X))
73687+ gr_log_ptgnustack(file);
73688+ }
73689+}
73690+#endif
73691+
73692 static int __init init_elf_binfmt(void)
73693 {
73694 register_binfmt(&elf_format);
73695diff --git a/fs/block_dev.c b/fs/block_dev.c
73696index c7e4163..6939003 100644
73697--- a/fs/block_dev.c
73698+++ b/fs/block_dev.c
73699@@ -732,7 +732,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
73700 else if (bdev->bd_contains == bdev)
73701 return true; /* is a whole device which isn't held */
73702
73703- else if (whole->bd_holder == bd_may_claim)
73704+ else if (whole->bd_holder == (void *)bd_may_claim)
73705 return true; /* is a partition of a device that is being partitioned */
73706 else if (whole->bd_holder != NULL)
73707 return false; /* is a partition of a held device */
73708diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
73709index 0f11ebc..1bf3321 100644
73710--- a/fs/btrfs/ctree.c
73711+++ b/fs/btrfs/ctree.c
73712@@ -1180,9 +1180,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
73713 free_extent_buffer(buf);
73714 add_root_to_dirty_list(root);
73715 } else {
73716- if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
73717- parent_start = parent->start;
73718- else
73719+ if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
73720+ if (parent)
73721+ parent_start = parent->start;
73722+ else
73723+ parent_start = 0;
73724+ } else
73725 parent_start = 0;
73726
73727 WARN_ON(trans->transid != btrfs_header_generation(parent));
73728diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
73729index a2ae427..53c2e98 100644
73730--- a/fs/btrfs/delayed-inode.c
73731+++ b/fs/btrfs/delayed-inode.c
73732@@ -462,7 +462,7 @@ static int __btrfs_add_delayed_deletion_item(struct btrfs_delayed_node *node,
73733
73734 static void finish_one_item(struct btrfs_delayed_root *delayed_root)
73735 {
73736- int seq = atomic_inc_return(&delayed_root->items_seq);
73737+ int seq = atomic_inc_return_unchecked(&delayed_root->items_seq);
73738 if ((atomic_dec_return(&delayed_root->items) <
73739 BTRFS_DELAYED_BACKGROUND || seq % BTRFS_DELAYED_BATCH == 0) &&
73740 waitqueue_active(&delayed_root->wait))
73741@@ -1412,7 +1412,7 @@ void btrfs_assert_delayed_root_empty(struct btrfs_root *root)
73742
73743 static int could_end_wait(struct btrfs_delayed_root *delayed_root, int seq)
73744 {
73745- int val = atomic_read(&delayed_root->items_seq);
73746+ int val = atomic_read_unchecked(&delayed_root->items_seq);
73747
73748 if (val < seq || val >= seq + BTRFS_DELAYED_BATCH)
73749 return 1;
73750@@ -1437,7 +1437,7 @@ void btrfs_balance_delayed_items(struct btrfs_root *root)
73751 int seq;
73752 int ret;
73753
73754- seq = atomic_read(&delayed_root->items_seq);
73755+ seq = atomic_read_unchecked(&delayed_root->items_seq);
73756
73757 ret = btrfs_wq_run_delayed_node(delayed_root, fs_info, 0);
73758 if (ret)
73759diff --git a/fs/btrfs/delayed-inode.h b/fs/btrfs/delayed-inode.h
73760index f70119f..ab5894d 100644
73761--- a/fs/btrfs/delayed-inode.h
73762+++ b/fs/btrfs/delayed-inode.h
73763@@ -43,7 +43,7 @@ struct btrfs_delayed_root {
73764 */
73765 struct list_head prepare_list;
73766 atomic_t items; /* for delayed items */
73767- atomic_t items_seq; /* for delayed items */
73768+ atomic_unchecked_t items_seq; /* for delayed items */
73769 int nodes; /* for delayed nodes */
73770 wait_queue_head_t wait;
73771 };
73772@@ -90,7 +90,7 @@ static inline void btrfs_init_delayed_root(
73773 struct btrfs_delayed_root *delayed_root)
73774 {
73775 atomic_set(&delayed_root->items, 0);
73776- atomic_set(&delayed_root->items_seq, 0);
73777+ atomic_set_unchecked(&delayed_root->items_seq, 0);
73778 delayed_root->nodes = 0;
73779 spin_lock_init(&delayed_root->lock);
73780 init_waitqueue_head(&delayed_root->wait);
73781diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
73782index 9e66f5e..f7caaf0 100644
73783--- a/fs/btrfs/super.c
73784+++ b/fs/btrfs/super.c
73785@@ -271,7 +271,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
73786 function, line, errstr);
73787 return;
73788 }
73789- ACCESS_ONCE(trans->transaction->aborted) = errno;
73790+ ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
73791 /* Wake up anybody who may be waiting on this transaction */
73792 wake_up(&root->fs_info->transaction_wait);
73793 wake_up(&root->fs_info->transaction_blocked_wait);
73794diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
73795index e8a4c86..f8c22ae 100644
73796--- a/fs/btrfs/sysfs.c
73797+++ b/fs/btrfs/sysfs.c
73798@@ -472,7 +472,7 @@ static int addrm_unknown_feature_attrs(struct btrfs_fs_info *fs_info, bool add)
73799 for (set = 0; set < FEAT_MAX; set++) {
73800 int i;
73801 struct attribute *attrs[2];
73802- struct attribute_group agroup = {
73803+ attribute_group_no_const agroup = {
73804 .name = "features",
73805 .attrs = attrs,
73806 };
73807diff --git a/fs/btrfs/tests/free-space-tests.c b/fs/btrfs/tests/free-space-tests.c
73808index 2299bfd..4098e72 100644
73809--- a/fs/btrfs/tests/free-space-tests.c
73810+++ b/fs/btrfs/tests/free-space-tests.c
73811@@ -463,7 +463,9 @@ test_steal_space_from_bitmap_to_extent(struct btrfs_block_group_cache *cache)
73812 * extent entry.
73813 */
73814 use_bitmap_op = cache->free_space_ctl->op->use_bitmap;
73815- cache->free_space_ctl->op->use_bitmap = test_use_bitmap;
73816+ pax_open_kernel();
73817+ *(void **)&cache->free_space_ctl->op->use_bitmap = test_use_bitmap;
73818+ pax_close_kernel();
73819
73820 /*
73821 * Extent entry covering free space range [128Mb - 256Kb, 128Mb - 128Kb[
73822@@ -870,7 +872,9 @@ test_steal_space_from_bitmap_to_extent(struct btrfs_block_group_cache *cache)
73823 if (ret)
73824 return ret;
73825
73826- cache->free_space_ctl->op->use_bitmap = use_bitmap_op;
73827+ pax_open_kernel();
73828+ *(void **)&cache->free_space_ctl->op->use_bitmap = use_bitmap_op;
73829+ pax_close_kernel();
73830 __btrfs_remove_free_space_cache(cache->free_space_ctl);
73831
73832 return 0;
73833diff --git a/fs/btrfs/tree-log.h b/fs/btrfs/tree-log.h
73834index 6916a78..4598936 100644
73835--- a/fs/btrfs/tree-log.h
73836+++ b/fs/btrfs/tree-log.h
73837@@ -45,7 +45,7 @@ static inline void btrfs_init_log_ctx(struct btrfs_log_ctx *ctx)
73838 static inline void btrfs_set_log_full_commit(struct btrfs_fs_info *fs_info,
73839 struct btrfs_trans_handle *trans)
73840 {
73841- ACCESS_ONCE(fs_info->last_trans_log_full_commit) = trans->transid;
73842+ ACCESS_ONCE_RW(fs_info->last_trans_log_full_commit) = trans->transid;
73843 }
73844
73845 static inline int btrfs_need_log_full_commit(struct btrfs_fs_info *fs_info,
73846diff --git a/fs/buffer.c b/fs/buffer.c
73847index c7a5602..18eabd1 100644
73848--- a/fs/buffer.c
73849+++ b/fs/buffer.c
73850@@ -3417,7 +3417,7 @@ void __init buffer_init(void)
73851 bh_cachep = kmem_cache_create("buffer_head",
73852 sizeof(struct buffer_head), 0,
73853 (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|
73854- SLAB_MEM_SPREAD),
73855+ SLAB_MEM_SPREAD|SLAB_NO_SANITIZE),
73856 NULL);
73857
73858 /*
73859diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
73860index 6af790f..ec4c1e6 100644
73861--- a/fs/cachefiles/bind.c
73862+++ b/fs/cachefiles/bind.c
73863@@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
73864 args);
73865
73866 /* start by checking things over */
73867- ASSERT(cache->fstop_percent >= 0 &&
73868- cache->fstop_percent < cache->fcull_percent &&
73869+ ASSERT(cache->fstop_percent < cache->fcull_percent &&
73870 cache->fcull_percent < cache->frun_percent &&
73871 cache->frun_percent < 100);
73872
73873- ASSERT(cache->bstop_percent >= 0 &&
73874- cache->bstop_percent < cache->bcull_percent &&
73875+ ASSERT(cache->bstop_percent < cache->bcull_percent &&
73876 cache->bcull_percent < cache->brun_percent &&
73877 cache->brun_percent < 100);
73878
73879diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
73880index f601def..b2cf704 100644
73881--- a/fs/cachefiles/daemon.c
73882+++ b/fs/cachefiles/daemon.c
73883@@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
73884 if (n > buflen)
73885 return -EMSGSIZE;
73886
73887- if (copy_to_user(_buffer, buffer, n) != 0)
73888+ if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
73889 return -EFAULT;
73890
73891 return n;
73892@@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
73893 if (test_bit(CACHEFILES_DEAD, &cache->flags))
73894 return -EIO;
73895
73896- if (datalen < 0 || datalen > PAGE_SIZE - 1)
73897+ if (datalen > PAGE_SIZE - 1)
73898 return -EOPNOTSUPP;
73899
73900 /* drag the command string into the kernel so we can parse it */
73901@@ -385,7 +385,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
73902 if (args[0] != '%' || args[1] != '\0')
73903 return -EINVAL;
73904
73905- if (fstop < 0 || fstop >= cache->fcull_percent)
73906+ if (fstop >= cache->fcull_percent)
73907 return cachefiles_daemon_range_error(cache, args);
73908
73909 cache->fstop_percent = fstop;
73910@@ -457,7 +457,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
73911 if (args[0] != '%' || args[1] != '\0')
73912 return -EINVAL;
73913
73914- if (bstop < 0 || bstop >= cache->bcull_percent)
73915+ if (bstop >= cache->bcull_percent)
73916 return cachefiles_daemon_range_error(cache, args);
73917
73918 cache->bstop_percent = bstop;
73919diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
73920index 8c52472..c4e3a69 100644
73921--- a/fs/cachefiles/internal.h
73922+++ b/fs/cachefiles/internal.h
73923@@ -66,7 +66,7 @@ struct cachefiles_cache {
73924 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
73925 struct rb_root active_nodes; /* active nodes (can't be culled) */
73926 rwlock_t active_lock; /* lock for active_nodes */
73927- atomic_t gravecounter; /* graveyard uniquifier */
73928+ atomic_unchecked_t gravecounter; /* graveyard uniquifier */
73929 unsigned frun_percent; /* when to stop culling (% files) */
73930 unsigned fcull_percent; /* when to start culling (% files) */
73931 unsigned fstop_percent; /* when to stop allocating (% files) */
73932@@ -178,19 +178,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
73933 * proc.c
73934 */
73935 #ifdef CONFIG_CACHEFILES_HISTOGRAM
73936-extern atomic_t cachefiles_lookup_histogram[HZ];
73937-extern atomic_t cachefiles_mkdir_histogram[HZ];
73938-extern atomic_t cachefiles_create_histogram[HZ];
73939+extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
73940+extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
73941+extern atomic_unchecked_t cachefiles_create_histogram[HZ];
73942
73943 extern int __init cachefiles_proc_init(void);
73944 extern void cachefiles_proc_cleanup(void);
73945 static inline
73946-void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
73947+void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
73948 {
73949 unsigned long jif = jiffies - start_jif;
73950 if (jif >= HZ)
73951 jif = HZ - 1;
73952- atomic_inc(&histogram[jif]);
73953+ atomic_inc_unchecked(&histogram[jif]);
73954 }
73955
73956 #else
73957diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
73958index ab857ab..ff8d593 100644
73959--- a/fs/cachefiles/namei.c
73960+++ b/fs/cachefiles/namei.c
73961@@ -309,7 +309,7 @@ try_again:
73962 /* first step is to make up a grave dentry in the graveyard */
73963 sprintf(nbuffer, "%08x%08x",
73964 (uint32_t) get_seconds(),
73965- (uint32_t) atomic_inc_return(&cache->gravecounter));
73966+ (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
73967
73968 /* do the multiway lock magic */
73969 trap = lock_rename(cache->graveyard, dir);
73970diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
73971index eccd339..4c1d995 100644
73972--- a/fs/cachefiles/proc.c
73973+++ b/fs/cachefiles/proc.c
73974@@ -14,9 +14,9 @@
73975 #include <linux/seq_file.h>
73976 #include "internal.h"
73977
73978-atomic_t cachefiles_lookup_histogram[HZ];
73979-atomic_t cachefiles_mkdir_histogram[HZ];
73980-atomic_t cachefiles_create_histogram[HZ];
73981+atomic_unchecked_t cachefiles_lookup_histogram[HZ];
73982+atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
73983+atomic_unchecked_t cachefiles_create_histogram[HZ];
73984
73985 /*
73986 * display the latency histogram
73987@@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
73988 return 0;
73989 default:
73990 index = (unsigned long) v - 3;
73991- x = atomic_read(&cachefiles_lookup_histogram[index]);
73992- y = atomic_read(&cachefiles_mkdir_histogram[index]);
73993- z = atomic_read(&cachefiles_create_histogram[index]);
73994+ x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
73995+ y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
73996+ z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
73997 if (x == 0 && y == 0 && z == 0)
73998 return 0;
73999
74000diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
74001index 4248307..f41e44e 100644
74002--- a/fs/ceph/dir.c
74003+++ b/fs/ceph/dir.c
74004@@ -127,6 +127,8 @@ static int __dcache_readdir(struct file *file, struct dir_context *ctx,
74005 struct dentry *dentry, *last;
74006 struct ceph_dentry_info *di;
74007 int err = 0;
74008+ char d_name[DNAME_INLINE_LEN];
74009+ const unsigned char *name;
74010
74011 /* claim ref on last dentry we returned */
74012 last = fi->dentry;
74013@@ -190,7 +192,12 @@ more:
74014
74015 dout(" %llu (%llu) dentry %p %pd %p\n", di->offset, ctx->pos,
74016 dentry, dentry, d_inode(dentry));
74017- if (!dir_emit(ctx, dentry->d_name.name,
74018+ name = dentry->d_name.name;
74019+ if (name == dentry->d_iname) {
74020+ memcpy(d_name, name, dentry->d_name.len);
74021+ name = d_name;
74022+ }
74023+ if (!dir_emit(ctx, name,
74024 dentry->d_name.len,
74025 ceph_translate_ino(dentry->d_sb, d_inode(dentry)->i_ino),
74026 d_inode(dentry)->i_mode >> 12)) {
74027@@ -248,7 +255,7 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
74028 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
74029 struct ceph_mds_client *mdsc = fsc->mdsc;
74030 unsigned frag = fpos_frag(ctx->pos);
74031- int off = fpos_off(ctx->pos);
74032+ unsigned int off = fpos_off(ctx->pos);
74033 int err;
74034 u32 ftype;
74035 struct ceph_mds_reply_info_parsed *rinfo;
74036diff --git a/fs/ceph/super.c b/fs/ceph/super.c
74037index 4e99053..a7e2a5f 100644
74038--- a/fs/ceph/super.c
74039+++ b/fs/ceph/super.c
74040@@ -885,7 +885,7 @@ static int ceph_compare_super(struct super_block *sb, void *data)
74041 /*
74042 * construct our own bdi so we can control readahead, etc.
74043 */
74044-static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
74045+static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
74046
74047 static int ceph_register_bdi(struct super_block *sb,
74048 struct ceph_fs_client *fsc)
74049@@ -902,7 +902,7 @@ static int ceph_register_bdi(struct super_block *sb,
74050 VM_MAX_READAHEAD * 1024 / PAGE_CACHE_SIZE;
74051
74052 err = bdi_register(&fsc->backing_dev_info, NULL, "ceph-%ld",
74053- atomic_long_inc_return(&bdi_seq));
74054+ atomic_long_inc_return_unchecked(&bdi_seq));
74055 if (!err)
74056 sb->s_bdi = &fsc->backing_dev_info;
74057 return err;
74058diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
74059index 7febcf2..62a5721 100644
74060--- a/fs/cifs/cifs_debug.c
74061+++ b/fs/cifs/cifs_debug.c
74062@@ -269,8 +269,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
74063
74064 if (strtobool(&c, &bv) == 0) {
74065 #ifdef CONFIG_CIFS_STATS2
74066- atomic_set(&totBufAllocCount, 0);
74067- atomic_set(&totSmBufAllocCount, 0);
74068+ atomic_set_unchecked(&totBufAllocCount, 0);
74069+ atomic_set_unchecked(&totSmBufAllocCount, 0);
74070 #endif /* CONFIG_CIFS_STATS2 */
74071 spin_lock(&cifs_tcp_ses_lock);
74072 list_for_each(tmp1, &cifs_tcp_ses_list) {
74073@@ -283,7 +283,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
74074 tcon = list_entry(tmp3,
74075 struct cifs_tcon,
74076 tcon_list);
74077- atomic_set(&tcon->num_smbs_sent, 0);
74078+ atomic_set_unchecked(&tcon->num_smbs_sent, 0);
74079 if (server->ops->clear_stats)
74080 server->ops->clear_stats(tcon);
74081 }
74082@@ -315,8 +315,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
74083 smBufAllocCount.counter, cifs_min_small);
74084 #ifdef CONFIG_CIFS_STATS2
74085 seq_printf(m, "Total Large %d Small %d Allocations\n",
74086- atomic_read(&totBufAllocCount),
74087- atomic_read(&totSmBufAllocCount));
74088+ atomic_read_unchecked(&totBufAllocCount),
74089+ atomic_read_unchecked(&totSmBufAllocCount));
74090 #endif /* CONFIG_CIFS_STATS2 */
74091
74092 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
74093@@ -345,7 +345,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
74094 if (tcon->need_reconnect)
74095 seq_puts(m, "\tDISCONNECTED ");
74096 seq_printf(m, "\nSMBs: %d",
74097- atomic_read(&tcon->num_smbs_sent));
74098+ atomic_read_unchecked(&tcon->num_smbs_sent));
74099 if (server->ops->print_stats)
74100 server->ops->print_stats(m, tcon);
74101 }
74102diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
74103index 0a9fb6b..9def7fa 100644
74104--- a/fs/cifs/cifsfs.c
74105+++ b/fs/cifs/cifsfs.c
74106@@ -1082,7 +1082,7 @@ cifs_init_request_bufs(void)
74107 */
74108 cifs_req_cachep = kmem_cache_create("cifs_request",
74109 CIFSMaxBufSize + max_hdr_size, 0,
74110- SLAB_HWCACHE_ALIGN, NULL);
74111+ SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
74112 if (cifs_req_cachep == NULL)
74113 return -ENOMEM;
74114
74115@@ -1109,7 +1109,7 @@ cifs_init_request_bufs(void)
74116 efficient to alloc 1 per page off the slab compared to 17K (5page)
74117 alloc of large cifs buffers even when page debugging is on */
74118 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
74119- MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
74120+ MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
74121 NULL);
74122 if (cifs_sm_req_cachep == NULL) {
74123 mempool_destroy(cifs_req_poolp);
74124@@ -1194,8 +1194,8 @@ init_cifs(void)
74125 atomic_set(&bufAllocCount, 0);
74126 atomic_set(&smBufAllocCount, 0);
74127 #ifdef CONFIG_CIFS_STATS2
74128- atomic_set(&totBufAllocCount, 0);
74129- atomic_set(&totSmBufAllocCount, 0);
74130+ atomic_set_unchecked(&totBufAllocCount, 0);
74131+ atomic_set_unchecked(&totSmBufAllocCount, 0);
74132 #endif /* CONFIG_CIFS_STATS2 */
74133
74134 atomic_set(&midCount, 0);
74135diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
74136index 22b289a..bbbba082 100644
74137--- a/fs/cifs/cifsglob.h
74138+++ b/fs/cifs/cifsglob.h
74139@@ -823,35 +823,35 @@ struct cifs_tcon {
74140 __u16 Flags; /* optional support bits */
74141 enum statusEnum tidStatus;
74142 #ifdef CONFIG_CIFS_STATS
74143- atomic_t num_smbs_sent;
74144+ atomic_unchecked_t num_smbs_sent;
74145 union {
74146 struct {
74147- atomic_t num_writes;
74148- atomic_t num_reads;
74149- atomic_t num_flushes;
74150- atomic_t num_oplock_brks;
74151- atomic_t num_opens;
74152- atomic_t num_closes;
74153- atomic_t num_deletes;
74154- atomic_t num_mkdirs;
74155- atomic_t num_posixopens;
74156- atomic_t num_posixmkdirs;
74157- atomic_t num_rmdirs;
74158- atomic_t num_renames;
74159- atomic_t num_t2renames;
74160- atomic_t num_ffirst;
74161- atomic_t num_fnext;
74162- atomic_t num_fclose;
74163- atomic_t num_hardlinks;
74164- atomic_t num_symlinks;
74165- atomic_t num_locks;
74166- atomic_t num_acl_get;
74167- atomic_t num_acl_set;
74168+ atomic_unchecked_t num_writes;
74169+ atomic_unchecked_t num_reads;
74170+ atomic_unchecked_t num_flushes;
74171+ atomic_unchecked_t num_oplock_brks;
74172+ atomic_unchecked_t num_opens;
74173+ atomic_unchecked_t num_closes;
74174+ atomic_unchecked_t num_deletes;
74175+ atomic_unchecked_t num_mkdirs;
74176+ atomic_unchecked_t num_posixopens;
74177+ atomic_unchecked_t num_posixmkdirs;
74178+ atomic_unchecked_t num_rmdirs;
74179+ atomic_unchecked_t num_renames;
74180+ atomic_unchecked_t num_t2renames;
74181+ atomic_unchecked_t num_ffirst;
74182+ atomic_unchecked_t num_fnext;
74183+ atomic_unchecked_t num_fclose;
74184+ atomic_unchecked_t num_hardlinks;
74185+ atomic_unchecked_t num_symlinks;
74186+ atomic_unchecked_t num_locks;
74187+ atomic_unchecked_t num_acl_get;
74188+ atomic_unchecked_t num_acl_set;
74189 } cifs_stats;
74190 #ifdef CONFIG_CIFS_SMB2
74191 struct {
74192- atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
74193- atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
74194+ atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
74195+ atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
74196 } smb2_stats;
74197 #endif /* CONFIG_CIFS_SMB2 */
74198 } stats;
74199@@ -1198,7 +1198,7 @@ convert_delimiter(char *path, char delim)
74200 }
74201
74202 #ifdef CONFIG_CIFS_STATS
74203-#define cifs_stats_inc atomic_inc
74204+#define cifs_stats_inc atomic_inc_unchecked
74205
74206 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
74207 unsigned int bytes)
74208@@ -1565,8 +1565,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
74209 /* Various Debug counters */
74210 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
74211 #ifdef CONFIG_CIFS_STATS2
74212-GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
74213-GLOBAL_EXTERN atomic_t totSmBufAllocCount;
74214+GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
74215+GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
74216 #endif
74217 GLOBAL_EXTERN atomic_t smBufAllocCount;
74218 GLOBAL_EXTERN atomic_t midCount;
74219diff --git a/fs/cifs/file.c b/fs/cifs/file.c
74220index 3f50cee..7741620 100644
74221--- a/fs/cifs/file.c
74222+++ b/fs/cifs/file.c
74223@@ -2054,10 +2054,14 @@ static int cifs_writepages(struct address_space *mapping,
74224 index = mapping->writeback_index; /* Start from prev offset */
74225 end = -1;
74226 } else {
74227- index = wbc->range_start >> PAGE_CACHE_SHIFT;
74228- end = wbc->range_end >> PAGE_CACHE_SHIFT;
74229- if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
74230+ if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX) {
74231 range_whole = true;
74232+ index = 0;
74233+ end = ULONG_MAX;
74234+ } else {
74235+ index = wbc->range_start >> PAGE_CACHE_SHIFT;
74236+ end = wbc->range_end >> PAGE_CACHE_SHIFT;
74237+ }
74238 scanned = true;
74239 }
74240 server = cifs_sb_master_tcon(cifs_sb)->ses->server;
74241diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
74242index 8442b8b..ea6986f 100644
74243--- a/fs/cifs/misc.c
74244+++ b/fs/cifs/misc.c
74245@@ -170,7 +170,7 @@ cifs_buf_get(void)
74246 memset(ret_buf, 0, buf_size + 3);
74247 atomic_inc(&bufAllocCount);
74248 #ifdef CONFIG_CIFS_STATS2
74249- atomic_inc(&totBufAllocCount);
74250+ atomic_inc_unchecked(&totBufAllocCount);
74251 #endif /* CONFIG_CIFS_STATS2 */
74252 }
74253
74254@@ -205,7 +205,7 @@ cifs_small_buf_get(void)
74255 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
74256 atomic_inc(&smBufAllocCount);
74257 #ifdef CONFIG_CIFS_STATS2
74258- atomic_inc(&totSmBufAllocCount);
74259+ atomic_inc_unchecked(&totSmBufAllocCount);
74260 #endif /* CONFIG_CIFS_STATS2 */
74261
74262 }
74263diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
74264index fc537c2..47d654c 100644
74265--- a/fs/cifs/smb1ops.c
74266+++ b/fs/cifs/smb1ops.c
74267@@ -622,27 +622,27 @@ static void
74268 cifs_clear_stats(struct cifs_tcon *tcon)
74269 {
74270 #ifdef CONFIG_CIFS_STATS
74271- atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
74272- atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
74273- atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
74274- atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
74275- atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
74276- atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
74277- atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
74278- atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
74279- atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
74280- atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
74281- atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
74282- atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
74283- atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
74284- atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
74285- atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
74286- atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
74287- atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
74288- atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
74289- atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
74290- atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
74291- atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
74292+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
74293+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
74294+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
74295+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
74296+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
74297+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
74298+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
74299+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
74300+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
74301+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
74302+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
74303+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
74304+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
74305+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
74306+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
74307+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
74308+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
74309+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
74310+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
74311+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
74312+ atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
74313 #endif
74314 }
74315
74316@@ -651,36 +651,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
74317 {
74318 #ifdef CONFIG_CIFS_STATS
74319 seq_printf(m, " Oplocks breaks: %d",
74320- atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
74321+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
74322 seq_printf(m, "\nReads: %d Bytes: %llu",
74323- atomic_read(&tcon->stats.cifs_stats.num_reads),
74324+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
74325 (long long)(tcon->bytes_read));
74326 seq_printf(m, "\nWrites: %d Bytes: %llu",
74327- atomic_read(&tcon->stats.cifs_stats.num_writes),
74328+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
74329 (long long)(tcon->bytes_written));
74330 seq_printf(m, "\nFlushes: %d",
74331- atomic_read(&tcon->stats.cifs_stats.num_flushes));
74332+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
74333 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
74334- atomic_read(&tcon->stats.cifs_stats.num_locks),
74335- atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
74336- atomic_read(&tcon->stats.cifs_stats.num_symlinks));
74337+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
74338+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
74339+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
74340 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
74341- atomic_read(&tcon->stats.cifs_stats.num_opens),
74342- atomic_read(&tcon->stats.cifs_stats.num_closes),
74343- atomic_read(&tcon->stats.cifs_stats.num_deletes));
74344+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
74345+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
74346+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
74347 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
74348- atomic_read(&tcon->stats.cifs_stats.num_posixopens),
74349- atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
74350+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
74351+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
74352 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
74353- atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
74354- atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
74355+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
74356+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
74357 seq_printf(m, "\nRenames: %d T2 Renames %d",
74358- atomic_read(&tcon->stats.cifs_stats.num_renames),
74359- atomic_read(&tcon->stats.cifs_stats.num_t2renames));
74360+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
74361+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
74362 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
74363- atomic_read(&tcon->stats.cifs_stats.num_ffirst),
74364- atomic_read(&tcon->stats.cifs_stats.num_fnext),
74365- atomic_read(&tcon->stats.cifs_stats.num_fclose));
74366+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
74367+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
74368+ atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
74369 #endif
74370 }
74371
74372diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
74373index 54daee5..2669fcb 100644
74374--- a/fs/cifs/smb2ops.c
74375+++ b/fs/cifs/smb2ops.c
74376@@ -418,8 +418,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
74377 #ifdef CONFIG_CIFS_STATS
74378 int i;
74379 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
74380- atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
74381- atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
74382+ atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
74383+ atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
74384 }
74385 #endif
74386 }
74387@@ -459,65 +459,65 @@ static void
74388 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
74389 {
74390 #ifdef CONFIG_CIFS_STATS
74391- atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
74392- atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
74393+ atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
74394+ atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
74395 seq_printf(m, "\nNegotiates: %d sent %d failed",
74396- atomic_read(&sent[SMB2_NEGOTIATE_HE]),
74397- atomic_read(&failed[SMB2_NEGOTIATE_HE]));
74398+ atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
74399+ atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
74400 seq_printf(m, "\nSessionSetups: %d sent %d failed",
74401- atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
74402- atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
74403+ atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
74404+ atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
74405 seq_printf(m, "\nLogoffs: %d sent %d failed",
74406- atomic_read(&sent[SMB2_LOGOFF_HE]),
74407- atomic_read(&failed[SMB2_LOGOFF_HE]));
74408+ atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
74409+ atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
74410 seq_printf(m, "\nTreeConnects: %d sent %d failed",
74411- atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
74412- atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
74413+ atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
74414+ atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
74415 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
74416- atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
74417- atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
74418+ atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
74419+ atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
74420 seq_printf(m, "\nCreates: %d sent %d failed",
74421- atomic_read(&sent[SMB2_CREATE_HE]),
74422- atomic_read(&failed[SMB2_CREATE_HE]));
74423+ atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
74424+ atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
74425 seq_printf(m, "\nCloses: %d sent %d failed",
74426- atomic_read(&sent[SMB2_CLOSE_HE]),
74427- atomic_read(&failed[SMB2_CLOSE_HE]));
74428+ atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
74429+ atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
74430 seq_printf(m, "\nFlushes: %d sent %d failed",
74431- atomic_read(&sent[SMB2_FLUSH_HE]),
74432- atomic_read(&failed[SMB2_FLUSH_HE]));
74433+ atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
74434+ atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
74435 seq_printf(m, "\nReads: %d sent %d failed",
74436- atomic_read(&sent[SMB2_READ_HE]),
74437- atomic_read(&failed[SMB2_READ_HE]));
74438+ atomic_read_unchecked(&sent[SMB2_READ_HE]),
74439+ atomic_read_unchecked(&failed[SMB2_READ_HE]));
74440 seq_printf(m, "\nWrites: %d sent %d failed",
74441- atomic_read(&sent[SMB2_WRITE_HE]),
74442- atomic_read(&failed[SMB2_WRITE_HE]));
74443+ atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
74444+ atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
74445 seq_printf(m, "\nLocks: %d sent %d failed",
74446- atomic_read(&sent[SMB2_LOCK_HE]),
74447- atomic_read(&failed[SMB2_LOCK_HE]));
74448+ atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
74449+ atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
74450 seq_printf(m, "\nIOCTLs: %d sent %d failed",
74451- atomic_read(&sent[SMB2_IOCTL_HE]),
74452- atomic_read(&failed[SMB2_IOCTL_HE]));
74453+ atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
74454+ atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
74455 seq_printf(m, "\nCancels: %d sent %d failed",
74456- atomic_read(&sent[SMB2_CANCEL_HE]),
74457- atomic_read(&failed[SMB2_CANCEL_HE]));
74458+ atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
74459+ atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
74460 seq_printf(m, "\nEchos: %d sent %d failed",
74461- atomic_read(&sent[SMB2_ECHO_HE]),
74462- atomic_read(&failed[SMB2_ECHO_HE]));
74463+ atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
74464+ atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
74465 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
74466- atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
74467- atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
74468+ atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
74469+ atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
74470 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
74471- atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
74472- atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
74473+ atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
74474+ atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
74475 seq_printf(m, "\nQueryInfos: %d sent %d failed",
74476- atomic_read(&sent[SMB2_QUERY_INFO_HE]),
74477- atomic_read(&failed[SMB2_QUERY_INFO_HE]));
74478+ atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
74479+ atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
74480 seq_printf(m, "\nSetInfos: %d sent %d failed",
74481- atomic_read(&sent[SMB2_SET_INFO_HE]),
74482- atomic_read(&failed[SMB2_SET_INFO_HE]));
74483+ atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
74484+ atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
74485 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
74486- atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
74487- atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
74488+ atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
74489+ atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
74490 #endif
74491 }
74492
74493diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
74494index 54cbe19..fcd4a1b 100644
74495--- a/fs/cifs/smb2pdu.c
74496+++ b/fs/cifs/smb2pdu.c
74497@@ -2147,8 +2147,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
74498 default:
74499 cifs_dbg(VFS, "info level %u isn't supported\n",
74500 srch_inf->info_level);
74501- rc = -EINVAL;
74502- goto qdir_exit;
74503+ return -EINVAL;
74504 }
74505
74506 req->FileIndex = cpu_to_le32(index);
74507diff --git a/fs/coda/cache.c b/fs/coda/cache.c
74508index 5bb630a..043dc70 100644
74509--- a/fs/coda/cache.c
74510+++ b/fs/coda/cache.c
74511@@ -24,7 +24,7 @@
74512 #include "coda_linux.h"
74513 #include "coda_cache.h"
74514
74515-static atomic_t permission_epoch = ATOMIC_INIT(0);
74516+static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
74517
74518 /* replace or extend an acl cache hit */
74519 void coda_cache_enter(struct inode *inode, int mask)
74520@@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
74521 struct coda_inode_info *cii = ITOC(inode);
74522
74523 spin_lock(&cii->c_lock);
74524- cii->c_cached_epoch = atomic_read(&permission_epoch);
74525+ cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
74526 if (!uid_eq(cii->c_uid, current_fsuid())) {
74527 cii->c_uid = current_fsuid();
74528 cii->c_cached_perm = mask;
74529@@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
74530 {
74531 struct coda_inode_info *cii = ITOC(inode);
74532 spin_lock(&cii->c_lock);
74533- cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
74534+ cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
74535 spin_unlock(&cii->c_lock);
74536 }
74537
74538 /* remove all acl caches */
74539 void coda_cache_clear_all(struct super_block *sb)
74540 {
74541- atomic_inc(&permission_epoch);
74542+ atomic_inc_unchecked(&permission_epoch);
74543 }
74544
74545
74546@@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
74547 spin_lock(&cii->c_lock);
74548 hit = (mask & cii->c_cached_perm) == mask &&
74549 uid_eq(cii->c_uid, current_fsuid()) &&
74550- cii->c_cached_epoch == atomic_read(&permission_epoch);
74551+ cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
74552 spin_unlock(&cii->c_lock);
74553
74554 return hit;
74555diff --git a/fs/compat.c b/fs/compat.c
74556index 6fd272d..dd34ba2 100644
74557--- a/fs/compat.c
74558+++ b/fs/compat.c
74559@@ -54,7 +54,7 @@
74560 #include <asm/ioctls.h>
74561 #include "internal.h"
74562
74563-int compat_log = 1;
74564+int compat_log = 0;
74565
74566 int compat_printk(const char *fmt, ...)
74567 {
74568@@ -512,7 +512,7 @@ COMPAT_SYSCALL_DEFINE2(io_setup, unsigned, nr_reqs, u32 __user *, ctx32p)
74569
74570 set_fs(KERNEL_DS);
74571 /* The __user pointer cast is valid because of the set_fs() */
74572- ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
74573+ ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
74574 set_fs(oldfs);
74575 /* truncating is ok because it's a user address */
74576 if (!ret)
74577@@ -562,7 +562,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
74578 goto out;
74579
74580 ret = -EINVAL;
74581- if (nr_segs > UIO_MAXIOV || nr_segs < 0)
74582+ if (nr_segs > UIO_MAXIOV)
74583 goto out;
74584 if (nr_segs > fast_segs) {
74585 ret = -ENOMEM;
74586@@ -844,6 +844,7 @@ struct compat_old_linux_dirent {
74587 struct compat_readdir_callback {
74588 struct dir_context ctx;
74589 struct compat_old_linux_dirent __user *dirent;
74590+ struct file * file;
74591 int result;
74592 };
74593
74594@@ -863,6 +864,10 @@ static int compat_fillonedir(struct dir_context *ctx, const char *name,
74595 buf->result = -EOVERFLOW;
74596 return -EOVERFLOW;
74597 }
74598+
74599+ if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
74600+ return 0;
74601+
74602 buf->result++;
74603 dirent = buf->dirent;
74604 if (!access_ok(VERIFY_WRITE, dirent,
74605@@ -894,6 +899,7 @@ COMPAT_SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
74606 if (!f.file)
74607 return -EBADF;
74608
74609+ buf.file = f.file;
74610 error = iterate_dir(f.file, &buf.ctx);
74611 if (buf.result)
74612 error = buf.result;
74613@@ -913,6 +919,7 @@ struct compat_getdents_callback {
74614 struct dir_context ctx;
74615 struct compat_linux_dirent __user *current_dir;
74616 struct compat_linux_dirent __user *previous;
74617+ struct file * file;
74618 int count;
74619 int error;
74620 };
74621@@ -935,6 +942,10 @@ static int compat_filldir(struct dir_context *ctx, const char *name, int namlen,
74622 buf->error = -EOVERFLOW;
74623 return -EOVERFLOW;
74624 }
74625+
74626+ if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
74627+ return 0;
74628+
74629 dirent = buf->previous;
74630 if (dirent) {
74631 if (__put_user(offset, &dirent->d_off))
74632@@ -980,6 +991,7 @@ COMPAT_SYSCALL_DEFINE3(getdents, unsigned int, fd,
74633 if (!f.file)
74634 return -EBADF;
74635
74636+ buf.file = f.file;
74637 error = iterate_dir(f.file, &buf.ctx);
74638 if (error >= 0)
74639 error = buf.error;
74640@@ -1000,6 +1012,7 @@ struct compat_getdents_callback64 {
74641 struct dir_context ctx;
74642 struct linux_dirent64 __user *current_dir;
74643 struct linux_dirent64 __user *previous;
74644+ struct file * file;
74645 int count;
74646 int error;
74647 };
74648@@ -1018,6 +1031,10 @@ static int compat_filldir64(struct dir_context *ctx, const char *name,
74649 buf->error = -EINVAL; /* only used if we fail.. */
74650 if (reclen > buf->count)
74651 return -EINVAL;
74652+
74653+ if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
74654+ return 0;
74655+
74656 dirent = buf->previous;
74657
74658 if (dirent) {
74659@@ -1067,6 +1084,7 @@ COMPAT_SYSCALL_DEFINE3(getdents64, unsigned int, fd,
74660 if (!f.file)
74661 return -EBADF;
74662
74663+ buf.file = f.file;
74664 error = iterate_dir(f.file, &buf.ctx);
74665 if (error >= 0)
74666 error = buf.error;
74667diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
74668index 4d24d17..4f8c09e 100644
74669--- a/fs/compat_binfmt_elf.c
74670+++ b/fs/compat_binfmt_elf.c
74671@@ -30,11 +30,13 @@
74672 #undef elf_phdr
74673 #undef elf_shdr
74674 #undef elf_note
74675+#undef elf_dyn
74676 #undef elf_addr_t
74677 #define elfhdr elf32_hdr
74678 #define elf_phdr elf32_phdr
74679 #define elf_shdr elf32_shdr
74680 #define elf_note elf32_note
74681+#define elf_dyn Elf32_Dyn
74682 #define elf_addr_t Elf32_Addr
74683
74684 /*
74685diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
74686index 6b8e2f0..9b13a5e 100644
74687--- a/fs/compat_ioctl.c
74688+++ b/fs/compat_ioctl.c
74689@@ -622,7 +622,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
74690 return -EFAULT;
74691 if (__get_user(udata, &ss32->iomem_base))
74692 return -EFAULT;
74693- ss.iomem_base = compat_ptr(udata);
74694+ ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
74695 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
74696 __get_user(ss.port_high, &ss32->port_high))
74697 return -EFAULT;
74698@@ -704,8 +704,8 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
74699 for (i = 0; i < nmsgs; i++) {
74700 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
74701 return -EFAULT;
74702- if (get_user(datap, &umsgs[i].buf) ||
74703- put_user(compat_ptr(datap), &tmsgs[i].buf))
74704+ if (get_user(datap, (compat_caddr_t __user *)&umsgs[i].buf) ||
74705+ put_user(compat_ptr(datap), (u8 __user * __user *)&tmsgs[i].buf))
74706 return -EFAULT;
74707 }
74708 return sys_ioctl(fd, cmd, (unsigned long)tdata);
74709@@ -798,7 +798,7 @@ static int compat_ioctl_preallocate(struct file *file,
74710 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
74711 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
74712 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
74713- copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
74714+ copy_in_user(p->l_pad, p32->l_pad, 4*sizeof(u32)))
74715 return -EFAULT;
74716
74717 return ioctl_preallocate(file, p);
74718@@ -1620,8 +1620,8 @@ COMPAT_SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd,
74719 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
74720 {
74721 unsigned int a, b;
74722- a = *(unsigned int *)p;
74723- b = *(unsigned int *)q;
74724+ a = *(const unsigned int *)p;
74725+ b = *(const unsigned int *)q;
74726 if (a > b)
74727 return 1;
74728 if (a < b)
74729diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
74730index c81ce7f..f3de5fd 100644
74731--- a/fs/configfs/dir.c
74732+++ b/fs/configfs/dir.c
74733@@ -1540,7 +1540,8 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
74734 }
74735 for (p = q->next; p != &parent_sd->s_children; p = p->next) {
74736 struct configfs_dirent *next;
74737- const char *name;
74738+ const unsigned char * name;
74739+ char d_name[sizeof(next->s_dentry->d_iname)];
74740 int len;
74741 struct inode *inode = NULL;
74742
74743@@ -1549,7 +1550,12 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
74744 continue;
74745
74746 name = configfs_get_name(next);
74747- len = strlen(name);
74748+ if (next->s_dentry && name == next->s_dentry->d_iname) {
74749+ len = next->s_dentry->d_name.len;
74750+ memcpy(d_name, name, len);
74751+ name = d_name;
74752+ } else
74753+ len = strlen(name);
74754
74755 /*
74756 * We'll have a dentry and an inode for
74757diff --git a/fs/configfs/item.c b/fs/configfs/item.c
74758index e65f9ff..3ed264d 100644
74759--- a/fs/configfs/item.c
74760+++ b/fs/configfs/item.c
74761@@ -116,7 +116,7 @@ void config_item_init_type_name(struct config_item *item,
74762 const char *name,
74763 struct config_item_type *type)
74764 {
74765- config_item_set_name(item, name);
74766+ config_item_set_name(item, "%s", name);
74767 item->ci_type = type;
74768 config_item_init(item);
74769 }
74770@@ -125,7 +125,7 @@ EXPORT_SYMBOL(config_item_init_type_name);
74771 void config_group_init_type_name(struct config_group *group, const char *name,
74772 struct config_item_type *type)
74773 {
74774- config_item_set_name(&group->cg_item, name);
74775+ config_item_set_name(&group->cg_item, "%s", name);
74776 group->cg_item.ci_type = type;
74777 config_group_init(group);
74778 }
74779diff --git a/fs/coredump.c b/fs/coredump.c
74780index bbbe139..b76fae5 100644
74781--- a/fs/coredump.c
74782+++ b/fs/coredump.c
74783@@ -450,8 +450,8 @@ static void wait_for_dump_helpers(struct file *file)
74784 struct pipe_inode_info *pipe = file->private_data;
74785
74786 pipe_lock(pipe);
74787- pipe->readers++;
74788- pipe->writers--;
74789+ atomic_inc(&pipe->readers);
74790+ atomic_dec(&pipe->writers);
74791 wake_up_interruptible_sync(&pipe->wait);
74792 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
74793 pipe_unlock(pipe);
74794@@ -460,11 +460,11 @@ static void wait_for_dump_helpers(struct file *file)
74795 * We actually want wait_event_freezable() but then we need
74796 * to clear TIF_SIGPENDING and improve dump_interrupted().
74797 */
74798- wait_event_interruptible(pipe->wait, pipe->readers == 1);
74799+ wait_event_interruptible(pipe->wait, atomic_read(&pipe->readers) == 1);
74800
74801 pipe_lock(pipe);
74802- pipe->readers--;
74803- pipe->writers++;
74804+ atomic_dec(&pipe->readers);
74805+ atomic_inc(&pipe->writers);
74806 pipe_unlock(pipe);
74807 }
74808
74809@@ -511,7 +511,9 @@ void do_coredump(const siginfo_t *siginfo)
74810 struct files_struct *displaced;
74811 bool need_nonrelative = false;
74812 bool core_dumped = false;
74813- static atomic_t core_dump_count = ATOMIC_INIT(0);
74814+ static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
74815+ long signr = siginfo->si_signo;
74816+ int dumpable;
74817 struct coredump_params cprm = {
74818 .siginfo = siginfo,
74819 .regs = signal_pt_regs(),
74820@@ -524,12 +526,17 @@ void do_coredump(const siginfo_t *siginfo)
74821 .mm_flags = mm->flags,
74822 };
74823
74824- audit_core_dumps(siginfo->si_signo);
74825+ audit_core_dumps(signr);
74826+
74827+ dumpable = __get_dumpable(cprm.mm_flags);
74828+
74829+ if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
74830+ gr_handle_brute_attach(dumpable);
74831
74832 binfmt = mm->binfmt;
74833 if (!binfmt || !binfmt->core_dump)
74834 goto fail;
74835- if (!__get_dumpable(cprm.mm_flags))
74836+ if (!dumpable)
74837 goto fail;
74838
74839 cred = prepare_creds();
74840@@ -548,7 +555,7 @@ void do_coredump(const siginfo_t *siginfo)
74841 need_nonrelative = true;
74842 }
74843
74844- retval = coredump_wait(siginfo->si_signo, &core_state);
74845+ retval = coredump_wait(signr, &core_state);
74846 if (retval < 0)
74847 goto fail_creds;
74848
74849@@ -591,7 +598,7 @@ void do_coredump(const siginfo_t *siginfo)
74850 }
74851 cprm.limit = RLIM_INFINITY;
74852
74853- dump_count = atomic_inc_return(&core_dump_count);
74854+ dump_count = atomic_inc_return_unchecked(&core_dump_count);
74855 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
74856 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
74857 task_tgid_vnr(current), current->comm);
74858@@ -623,6 +630,8 @@ void do_coredump(const siginfo_t *siginfo)
74859 } else {
74860 struct inode *inode;
74861
74862+ gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
74863+
74864 if (cprm.limit < binfmt->min_coredump)
74865 goto fail_unlock;
74866
74867@@ -681,7 +690,7 @@ close_fail:
74868 filp_close(cprm.file, NULL);
74869 fail_dropcount:
74870 if (ispipe)
74871- atomic_dec(&core_dump_count);
74872+ atomic_dec_unchecked(&core_dump_count);
74873 fail_unlock:
74874 kfree(cn.corename);
74875 coredump_finish(mm, core_dumped);
74876@@ -702,6 +711,8 @@ int dump_emit(struct coredump_params *cprm, const void *addr, int nr)
74877 struct file *file = cprm->file;
74878 loff_t pos = file->f_pos;
74879 ssize_t n;
74880+
74881+ gr_learn_resource(current, RLIMIT_CORE, cprm->written + nr, 1);
74882 if (cprm->written + nr > cprm->limit)
74883 return 0;
74884 while (nr) {
74885diff --git a/fs/dcache.c b/fs/dcache.c
74886index 50bb3c2..d874b57 100644
74887--- a/fs/dcache.c
74888+++ b/fs/dcache.c
74889@@ -545,7 +545,7 @@ static void __dentry_kill(struct dentry *dentry)
74890 * dentry_iput drops the locks, at which point nobody (except
74891 * transient RCU lookups) can reach this dentry.
74892 */
74893- BUG_ON(dentry->d_lockref.count > 0);
74894+ BUG_ON(__lockref_read(&dentry->d_lockref) > 0);
74895 this_cpu_dec(nr_dentry);
74896 if (dentry->d_op && dentry->d_op->d_release)
74897 dentry->d_op->d_release(dentry);
74898@@ -598,7 +598,7 @@ static inline struct dentry *lock_parent(struct dentry *dentry)
74899 struct dentry *parent = dentry->d_parent;
74900 if (IS_ROOT(dentry))
74901 return NULL;
74902- if (unlikely(dentry->d_lockref.count < 0))
74903+ if (unlikely(__lockref_read(&dentry->d_lockref) < 0))
74904 return NULL;
74905 if (likely(spin_trylock(&parent->d_lock)))
74906 return parent;
74907@@ -642,7 +642,7 @@ static inline bool fast_dput(struct dentry *dentry)
74908
74909 /*
74910 * If we have a d_op->d_delete() operation, we sould not
74911- * let the dentry count go to zero, so use "put__or_lock".
74912+ * let the dentry count go to zero, so use "put_or_lock".
74913 */
74914 if (unlikely(dentry->d_flags & DCACHE_OP_DELETE))
74915 return lockref_put_or_lock(&dentry->d_lockref);
74916@@ -660,8 +660,8 @@ static inline bool fast_dput(struct dentry *dentry)
74917 */
74918 if (unlikely(ret < 0)) {
74919 spin_lock(&dentry->d_lock);
74920- if (dentry->d_lockref.count > 1) {
74921- dentry->d_lockref.count--;
74922+ if (__lockref_read(&dentry->d_lockref) > 1) {
74923+ __lockref_dec(&dentry->d_lockref);
74924 spin_unlock(&dentry->d_lock);
74925 return 1;
74926 }
74927@@ -697,7 +697,7 @@ static inline bool fast_dput(struct dentry *dentry)
74928 */
74929 smp_rmb();
74930 d_flags = ACCESS_ONCE(dentry->d_flags);
74931- d_flags &= DCACHE_REFERENCED | DCACHE_LRU_LIST;
74932+ d_flags &= DCACHE_REFERENCED | DCACHE_LRU_LIST | DCACHE_DISCONNECTED;
74933
74934 /* Nothing to do? Dropping the reference was all we needed? */
74935 if (d_flags == (DCACHE_REFERENCED | DCACHE_LRU_LIST) && !d_unhashed(dentry))
74936@@ -716,7 +716,7 @@ static inline bool fast_dput(struct dentry *dentry)
74937 * else could have killed it and marked it dead. Either way, we
74938 * don't need to do anything else.
74939 */
74940- if (dentry->d_lockref.count) {
74941+ if (__lockref_read(&dentry->d_lockref)) {
74942 spin_unlock(&dentry->d_lock);
74943 return 1;
74944 }
74945@@ -726,7 +726,7 @@ static inline bool fast_dput(struct dentry *dentry)
74946 * lock, and we just tested that it was zero, so we can just
74947 * set it to 1.
74948 */
74949- dentry->d_lockref.count = 1;
74950+ __lockref_set(&dentry->d_lockref, 1);
74951 return 0;
74952 }
74953
74954@@ -776,6 +776,9 @@ repeat:
74955 if (unlikely(d_unhashed(dentry)))
74956 goto kill_it;
74957
74958+ if (unlikely(dentry->d_flags & DCACHE_DISCONNECTED))
74959+ goto kill_it;
74960+
74961 if (unlikely(dentry->d_flags & DCACHE_OP_DELETE)) {
74962 if (dentry->d_op->d_delete(dentry))
74963 goto kill_it;
74964@@ -785,7 +788,7 @@ repeat:
74965 dentry->d_flags |= DCACHE_REFERENCED;
74966 dentry_lru_add(dentry);
74967
74968- dentry->d_lockref.count--;
74969+ __lockref_dec(&dentry->d_lockref);
74970 spin_unlock(&dentry->d_lock);
74971 return;
74972
74973@@ -800,7 +803,7 @@ EXPORT_SYMBOL(dput);
74974 /* This must be called with d_lock held */
74975 static inline void __dget_dlock(struct dentry *dentry)
74976 {
74977- dentry->d_lockref.count++;
74978+ __lockref_inc(&dentry->d_lockref);
74979 }
74980
74981 static inline void __dget(struct dentry *dentry)
74982@@ -841,8 +844,8 @@ repeat:
74983 goto repeat;
74984 }
74985 rcu_read_unlock();
74986- BUG_ON(!ret->d_lockref.count);
74987- ret->d_lockref.count++;
74988+ BUG_ON(!__lockref_read(&ret->d_lockref));
74989+ __lockref_inc(&ret->d_lockref);
74990 spin_unlock(&ret->d_lock);
74991 return ret;
74992 }
74993@@ -920,9 +923,9 @@ restart:
74994 spin_lock(&inode->i_lock);
74995 hlist_for_each_entry(dentry, &inode->i_dentry, d_u.d_alias) {
74996 spin_lock(&dentry->d_lock);
74997- if (!dentry->d_lockref.count) {
74998+ if (!__lockref_read(&dentry->d_lockref)) {
74999 struct dentry *parent = lock_parent(dentry);
75000- if (likely(!dentry->d_lockref.count)) {
75001+ if (likely(!__lockref_read(&dentry->d_lockref))) {
75002 __dentry_kill(dentry);
75003 dput(parent);
75004 goto restart;
75005@@ -957,7 +960,7 @@ static void shrink_dentry_list(struct list_head *list)
75006 * We found an inuse dentry which was not removed from
75007 * the LRU because of laziness during lookup. Do not free it.
75008 */
75009- if (dentry->d_lockref.count > 0) {
75010+ if (__lockref_read(&dentry->d_lockref) > 0) {
75011 spin_unlock(&dentry->d_lock);
75012 if (parent)
75013 spin_unlock(&parent->d_lock);
75014@@ -995,8 +998,8 @@ static void shrink_dentry_list(struct list_head *list)
75015 dentry = parent;
75016 while (dentry && !lockref_put_or_lock(&dentry->d_lockref)) {
75017 parent = lock_parent(dentry);
75018- if (dentry->d_lockref.count != 1) {
75019- dentry->d_lockref.count--;
75020+ if (__lockref_read(&dentry->d_lockref) != 1) {
75021+ __lockref_inc(&dentry->d_lockref);
75022 spin_unlock(&dentry->d_lock);
75023 if (parent)
75024 spin_unlock(&parent->d_lock);
75025@@ -1036,7 +1039,7 @@ static enum lru_status dentry_lru_isolate(struct list_head *item,
75026 * counts, just remove them from the LRU. Otherwise give them
75027 * another pass through the LRU.
75028 */
75029- if (dentry->d_lockref.count) {
75030+ if (__lockref_read(&dentry->d_lockref)) {
75031 d_lru_isolate(lru, dentry);
75032 spin_unlock(&dentry->d_lock);
75033 return LRU_REMOVED;
75034@@ -1370,7 +1373,7 @@ static enum d_walk_ret select_collect(void *_data, struct dentry *dentry)
75035 } else {
75036 if (dentry->d_flags & DCACHE_LRU_LIST)
75037 d_lru_del(dentry);
75038- if (!dentry->d_lockref.count) {
75039+ if (!__lockref_read(&dentry->d_lockref)) {
75040 d_shrink_add(dentry, &data->dispose);
75041 data->found++;
75042 }
75043@@ -1418,7 +1421,7 @@ static enum d_walk_ret umount_check(void *_data, struct dentry *dentry)
75044 return D_WALK_CONTINUE;
75045
75046 /* root with refcount 1 is fine */
75047- if (dentry == _data && dentry->d_lockref.count == 1)
75048+ if (dentry == _data && __lockref_read(&dentry->d_lockref) == 1)
75049 return D_WALK_CONTINUE;
75050
75051 printk(KERN_ERR "BUG: Dentry %p{i=%lx,n=%pd} "
75052@@ -1427,7 +1430,7 @@ static enum d_walk_ret umount_check(void *_data, struct dentry *dentry)
75053 dentry->d_inode ?
75054 dentry->d_inode->i_ino : 0UL,
75055 dentry,
75056- dentry->d_lockref.count,
75057+ __lockref_read(&dentry->d_lockref),
75058 dentry->d_sb->s_type->name,
75059 dentry->d_sb->s_id);
75060 WARN_ON(1);
75061@@ -1568,7 +1571,7 @@ struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)
75062 dentry->d_iname[DNAME_INLINE_LEN-1] = 0;
75063 if (name->len > DNAME_INLINE_LEN-1) {
75064 size_t size = offsetof(struct external_name, name[1]);
75065- struct external_name *p = kmalloc(size + name->len, GFP_KERNEL);
75066+ struct external_name *p = kmalloc(round_up(size + name->len, sizeof(unsigned long)), GFP_KERNEL);
75067 if (!p) {
75068 kmem_cache_free(dentry_cache, dentry);
75069 return NULL;
75070@@ -1591,7 +1594,7 @@ struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)
75071 smp_wmb();
75072 dentry->d_name.name = dname;
75073
75074- dentry->d_lockref.count = 1;
75075+ __lockref_set(&dentry->d_lockref, 1);
75076 dentry->d_flags = 0;
75077 spin_lock_init(&dentry->d_lock);
75078 seqcount_init(&dentry->d_seq);
75079@@ -1600,6 +1603,9 @@ struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)
75080 dentry->d_sb = sb;
75081 dentry->d_op = NULL;
75082 dentry->d_fsdata = NULL;
75083+#ifdef CONFIG_GRKERNSEC_CHROOT_RENAME
75084+ atomic_set(&dentry->chroot_refcnt, 0);
75085+#endif
75086 INIT_HLIST_BL_NODE(&dentry->d_hash);
75087 INIT_LIST_HEAD(&dentry->d_lru);
75088 INIT_LIST_HEAD(&dentry->d_subdirs);
75089@@ -2321,7 +2327,7 @@ struct dentry *__d_lookup(const struct dentry *parent, const struct qstr *name)
75090 goto next;
75091 }
75092
75093- dentry->d_lockref.count++;
75094+ __lockref_inc(&dentry->d_lockref);
75095 found = dentry;
75096 spin_unlock(&dentry->d_lock);
75097 break;
75098@@ -2389,7 +2395,7 @@ again:
75099 spin_lock(&dentry->d_lock);
75100 inode = dentry->d_inode;
75101 isdir = S_ISDIR(inode->i_mode);
75102- if (dentry->d_lockref.count == 1) {
75103+ if (__lockref_read(&dentry->d_lockref) == 1) {
75104 if (!spin_trylock(&inode->i_lock)) {
75105 spin_unlock(&dentry->d_lock);
75106 cpu_relax();
75107@@ -3331,7 +3337,7 @@ static enum d_walk_ret d_genocide_kill(void *data, struct dentry *dentry)
75108
75109 if (!(dentry->d_flags & DCACHE_GENOCIDE)) {
75110 dentry->d_flags |= DCACHE_GENOCIDE;
75111- dentry->d_lockref.count--;
75112+ __lockref_dec(&dentry->d_lockref);
75113 }
75114 }
75115 return D_WALK_CONTINUE;
75116@@ -3447,7 +3453,8 @@ void __init vfs_caches_init(unsigned long mempages)
75117 mempages -= reserve;
75118
75119 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
75120- SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
75121+ SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY|
75122+ SLAB_NO_SANITIZE, NULL);
75123
75124 dcache_init();
75125 inode_init();
75126diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
75127index 1275604..d2ca85b 100644
75128--- a/fs/debugfs/inode.c
75129+++ b/fs/debugfs/inode.c
75130@@ -407,6 +407,10 @@ EXPORT_SYMBOL_GPL(debugfs_create_file_size);
75131 * If debugfs is not enabled in the kernel, the value -%ENODEV will be
75132 * returned.
75133 */
75134+#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
75135+extern int grsec_enable_sysfs_restrict;
75136+#endif
75137+
75138 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
75139 {
75140 struct dentry *dentry = start_creating(name, parent);
75141@@ -419,7 +423,12 @@ struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
75142 if (unlikely(!inode))
75143 return failed_creating(dentry);
75144
75145- inode->i_mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
75146+#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
75147+ if (grsec_enable_sysfs_restrict)
75148+ inode->i_mode = S_IFDIR | S_IRWXU;
75149+ else
75150+#endif
75151+ inode->i_mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
75152 inode->i_op = &simple_dir_inode_operations;
75153 inode->i_fop = &simple_dir_operations;
75154
75155diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
75156index fc850b5..1677a2a 100644
75157--- a/fs/ecryptfs/inode.c
75158+++ b/fs/ecryptfs/inode.c
75159@@ -663,7 +663,7 @@ static char *ecryptfs_readlink_lower(struct dentry *dentry, size_t *bufsiz)
75160 old_fs = get_fs();
75161 set_fs(get_ds());
75162 rc = d_inode(lower_dentry)->i_op->readlink(lower_dentry,
75163- (char __user *)lower_buf,
75164+ (char __force_user *)lower_buf,
75165 PATH_MAX);
75166 set_fs(old_fs);
75167 if (rc < 0)
75168diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
75169index e4141f2..d8263e8 100644
75170--- a/fs/ecryptfs/miscdev.c
75171+++ b/fs/ecryptfs/miscdev.c
75172@@ -304,7 +304,7 @@ check_list:
75173 goto out_unlock_msg_ctx;
75174 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
75175 if (msg_ctx->msg) {
75176- if (copy_to_user(&buf[i], packet_length, packet_length_size))
75177+ if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
75178 goto out_unlock_msg_ctx;
75179 i += packet_length_size;
75180 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
75181diff --git a/fs/exec.c b/fs/exec.c
75182index 1977c2a..40e7f8f 100644
75183--- a/fs/exec.c
75184+++ b/fs/exec.c
75185@@ -56,8 +56,20 @@
75186 #include <linux/pipe_fs_i.h>
75187 #include <linux/oom.h>
75188 #include <linux/compat.h>
75189+#include <linux/random.h>
75190+#include <linux/seq_file.h>
75191+#include <linux/coredump.h>
75192+#include <linux/mman.h>
75193+
75194+#ifdef CONFIG_PAX_REFCOUNT
75195+#include <linux/kallsyms.h>
75196+#include <linux/kdebug.h>
75197+#endif
75198+
75199+#include <trace/events/fs.h>
75200
75201 #include <asm/uaccess.h>
75202+#include <asm/sections.h>
75203 #include <asm/mmu_context.h>
75204 #include <asm/tlb.h>
75205
75206@@ -66,19 +78,34 @@
75207
75208 #include <trace/events/sched.h>
75209
75210+#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
75211+void __weak pax_set_initial_flags(struct linux_binprm *bprm)
75212+{
75213+ 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");
75214+}
75215+#endif
75216+
75217+#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
75218+void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
75219+EXPORT_SYMBOL(pax_set_initial_flags_func);
75220+#endif
75221+
75222 int suid_dumpable = 0;
75223
75224 static LIST_HEAD(formats);
75225 static DEFINE_RWLOCK(binfmt_lock);
75226
75227+extern int gr_process_kernel_exec_ban(void);
75228+extern int gr_process_suid_exec_ban(const struct linux_binprm *bprm);
75229+
75230 void __register_binfmt(struct linux_binfmt * fmt, int insert)
75231 {
75232 BUG_ON(!fmt);
75233 if (WARN_ON(!fmt->load_binary))
75234 return;
75235 write_lock(&binfmt_lock);
75236- insert ? list_add(&fmt->lh, &formats) :
75237- list_add_tail(&fmt->lh, &formats);
75238+ insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
75239+ pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
75240 write_unlock(&binfmt_lock);
75241 }
75242
75243@@ -87,7 +114,7 @@ EXPORT_SYMBOL(__register_binfmt);
75244 void unregister_binfmt(struct linux_binfmt * fmt)
75245 {
75246 write_lock(&binfmt_lock);
75247- list_del(&fmt->lh);
75248+ pax_list_del((struct list_head *)&fmt->lh);
75249 write_unlock(&binfmt_lock);
75250 }
75251
75252@@ -183,18 +210,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
75253 int write)
75254 {
75255 struct page *page;
75256- int ret;
75257
75258-#ifdef CONFIG_STACK_GROWSUP
75259- if (write) {
75260- ret = expand_downwards(bprm->vma, pos);
75261- if (ret < 0)
75262- return NULL;
75263- }
75264-#endif
75265- ret = get_user_pages(current, bprm->mm, pos,
75266- 1, write, 1, &page, NULL);
75267- if (ret <= 0)
75268+ if (0 > expand_downwards(bprm->vma, pos))
75269+ return NULL;
75270+ if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
75271 return NULL;
75272
75273 if (write) {
75274@@ -210,6 +229,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
75275 if (size <= ARG_MAX)
75276 return page;
75277
75278+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
75279+ // only allow 512KB for argv+env on suid/sgid binaries
75280+ // to prevent easy ASLR exhaustion
75281+ if (((!uid_eq(bprm->cred->euid, current_euid())) ||
75282+ (!gid_eq(bprm->cred->egid, current_egid()))) &&
75283+ (size > (512 * 1024))) {
75284+ put_page(page);
75285+ return NULL;
75286+ }
75287+#endif
75288+
75289 /*
75290 * Limit to 1/4-th the stack size for the argv+env strings.
75291 * This ensures that:
75292@@ -269,6 +299,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
75293 vma->vm_end = STACK_TOP_MAX;
75294 vma->vm_start = vma->vm_end - PAGE_SIZE;
75295 vma->vm_flags = VM_SOFTDIRTY | VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
75296+
75297+#ifdef CONFIG_PAX_SEGMEXEC
75298+ vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
75299+#endif
75300+
75301 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
75302 INIT_LIST_HEAD(&vma->anon_vma_chain);
75303
75304@@ -280,6 +315,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
75305 arch_bprm_mm_init(mm, vma);
75306 up_write(&mm->mmap_sem);
75307 bprm->p = vma->vm_end - sizeof(void *);
75308+
75309+#ifdef CONFIG_PAX_RANDUSTACK
75310+ if (randomize_va_space)
75311+ bprm->p ^= prandom_u32() & ~PAGE_MASK;
75312+#endif
75313+
75314 return 0;
75315 err:
75316 up_write(&mm->mmap_sem);
75317@@ -396,7 +437,7 @@ struct user_arg_ptr {
75318 } ptr;
75319 };
75320
75321-static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
75322+const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
75323 {
75324 const char __user *native;
75325
75326@@ -405,14 +446,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
75327 compat_uptr_t compat;
75328
75329 if (get_user(compat, argv.ptr.compat + nr))
75330- return ERR_PTR(-EFAULT);
75331+ return (const char __force_user *)ERR_PTR(-EFAULT);
75332
75333 return compat_ptr(compat);
75334 }
75335 #endif
75336
75337 if (get_user(native, argv.ptr.native + nr))
75338- return ERR_PTR(-EFAULT);
75339+ return (const char __force_user *)ERR_PTR(-EFAULT);
75340
75341 return native;
75342 }
75343@@ -431,7 +472,7 @@ static int count(struct user_arg_ptr argv, int max)
75344 if (!p)
75345 break;
75346
75347- if (IS_ERR(p))
75348+ if (IS_ERR((const char __force_kernel *)p))
75349 return -EFAULT;
75350
75351 if (i >= max)
75352@@ -466,7 +507,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
75353
75354 ret = -EFAULT;
75355 str = get_user_arg_ptr(argv, argc);
75356- if (IS_ERR(str))
75357+ if (IS_ERR((const char __force_kernel *)str))
75358 goto out;
75359
75360 len = strnlen_user(str, MAX_ARG_STRLEN);
75361@@ -548,7 +589,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
75362 int r;
75363 mm_segment_t oldfs = get_fs();
75364 struct user_arg_ptr argv = {
75365- .ptr.native = (const char __user *const __user *)__argv,
75366+ .ptr.native = (const char __user * const __force_user *)__argv,
75367 };
75368
75369 set_fs(KERNEL_DS);
75370@@ -583,7 +624,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
75371 unsigned long new_end = old_end - shift;
75372 struct mmu_gather tlb;
75373
75374- BUG_ON(new_start > new_end);
75375+ if (new_start >= new_end || new_start < mmap_min_addr)
75376+ return -ENOMEM;
75377
75378 /*
75379 * ensure there are no vmas between where we want to go
75380@@ -592,6 +634,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
75381 if (vma != find_vma(mm, new_start))
75382 return -EFAULT;
75383
75384+#ifdef CONFIG_PAX_SEGMEXEC
75385+ BUG_ON(pax_find_mirror_vma(vma));
75386+#endif
75387+
75388 /*
75389 * cover the whole range: [new_start, old_end)
75390 */
75391@@ -675,10 +721,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
75392 stack_top = arch_align_stack(stack_top);
75393 stack_top = PAGE_ALIGN(stack_top);
75394
75395- if (unlikely(stack_top < mmap_min_addr) ||
75396- unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
75397- return -ENOMEM;
75398-
75399 stack_shift = vma->vm_end - stack_top;
75400
75401 bprm->p -= stack_shift;
75402@@ -690,8 +732,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
75403 bprm->exec -= stack_shift;
75404
75405 down_write(&mm->mmap_sem);
75406+
75407+ /* Move stack pages down in memory. */
75408+ if (stack_shift) {
75409+ ret = shift_arg_pages(vma, stack_shift);
75410+ if (ret)
75411+ goto out_unlock;
75412+ }
75413+
75414 vm_flags = VM_STACK_FLAGS;
75415
75416+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
75417+ if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
75418+ vm_flags &= ~VM_EXEC;
75419+
75420+#ifdef CONFIG_PAX_MPROTECT
75421+ if (mm->pax_flags & MF_PAX_MPROTECT)
75422+ vm_flags &= ~VM_MAYEXEC;
75423+#endif
75424+
75425+ }
75426+#endif
75427+
75428 /*
75429 * Adjust stack execute permissions; explicitly enable for
75430 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
75431@@ -710,13 +772,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
75432 goto out_unlock;
75433 BUG_ON(prev != vma);
75434
75435- /* Move stack pages down in memory. */
75436- if (stack_shift) {
75437- ret = shift_arg_pages(vma, stack_shift);
75438- if (ret)
75439- goto out_unlock;
75440- }
75441-
75442 /* mprotect_fixup is overkill to remove the temporary stack flags */
75443 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
75444
75445@@ -740,6 +795,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
75446 #endif
75447 current->mm->start_stack = bprm->p;
75448 ret = expand_stack(vma, stack_base);
75449+
75450+#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
75451+ if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
75452+ unsigned long size;
75453+ vm_flags_t vm_flags;
75454+
75455+ size = STACK_TOP - vma->vm_end;
75456+ vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
75457+
75458+ ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
75459+
75460+#ifdef CONFIG_X86
75461+ if (!ret) {
75462+ size = PAGE_SIZE + mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
75463+ ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
75464+ }
75465+#endif
75466+
75467+ }
75468+#endif
75469+
75470 if (ret)
75471 ret = -EFAULT;
75472
75473@@ -784,8 +860,10 @@ static struct file *do_open_execat(int fd, struct filename *name, int flags)
75474 if (err)
75475 goto exit;
75476
75477- if (name->name[0] != '\0')
75478+ if (name->name[0] != '\0') {
75479 fsnotify_open(file);
75480+ trace_open_exec(name->name);
75481+ }
75482
75483 out:
75484 return file;
75485@@ -818,7 +896,7 @@ int kernel_read(struct file *file, loff_t offset,
75486 old_fs = get_fs();
75487 set_fs(get_ds());
75488 /* The cast to a user pointer is valid due to the set_fs() */
75489- result = vfs_read(file, (void __user *)addr, count, &pos);
75490+ result = vfs_read(file, (void __force_user *)addr, count, &pos);
75491 set_fs(old_fs);
75492 return result;
75493 }
75494@@ -863,6 +941,7 @@ static int exec_mmap(struct mm_struct *mm)
75495 tsk->mm = mm;
75496 tsk->active_mm = mm;
75497 activate_mm(active_mm, mm);
75498+ populate_stack();
75499 tsk->mm->vmacache_seqnum = 0;
75500 vmacache_flush(tsk);
75501 task_unlock(tsk);
75502@@ -1271,7 +1350,7 @@ static void check_unsafe_exec(struct linux_binprm *bprm)
75503 }
75504 rcu_read_unlock();
75505
75506- if (p->fs->users > n_fs)
75507+ if (atomic_read(&p->fs->users) > n_fs)
75508 bprm->unsafe |= LSM_UNSAFE_SHARE;
75509 else
75510 p->fs->in_exec = 1;
75511@@ -1472,6 +1551,31 @@ static int exec_binprm(struct linux_binprm *bprm)
75512 return ret;
75513 }
75514
75515+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
75516+static DEFINE_PER_CPU(u64, exec_counter);
75517+static int __init init_exec_counters(void)
75518+{
75519+ unsigned int cpu;
75520+
75521+ for_each_possible_cpu(cpu) {
75522+ per_cpu(exec_counter, cpu) = (u64)cpu;
75523+ }
75524+
75525+ return 0;
75526+}
75527+early_initcall(init_exec_counters);
75528+static inline void increment_exec_counter(void)
75529+{
75530+ BUILD_BUG_ON(NR_CPUS > (1 << 16));
75531+ current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
75532+}
75533+#else
75534+static inline void increment_exec_counter(void) {}
75535+#endif
75536+
75537+extern void gr_handle_exec_args(struct linux_binprm *bprm,
75538+ struct user_arg_ptr argv);
75539+
75540 /*
75541 * sys_execve() executes a new program.
75542 */
75543@@ -1480,6 +1584,11 @@ static int do_execveat_common(int fd, struct filename *filename,
75544 struct user_arg_ptr envp,
75545 int flags)
75546 {
75547+#ifdef CONFIG_GRKERNSEC
75548+ struct file *old_exec_file;
75549+ struct acl_subject_label *old_acl;
75550+ struct rlimit old_rlim[RLIM_NLIMITS];
75551+#endif
75552 char *pathbuf = NULL;
75553 struct linux_binprm *bprm;
75554 struct file *file;
75555@@ -1489,6 +1598,8 @@ static int do_execveat_common(int fd, struct filename *filename,
75556 if (IS_ERR(filename))
75557 return PTR_ERR(filename);
75558
75559+ gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current_user()->processes), 1);
75560+
75561 /*
75562 * We move the actual failure in case of RLIMIT_NPROC excess from
75563 * set*uid() to execve() because too many poorly written programs
75564@@ -1526,6 +1637,11 @@ static int do_execveat_common(int fd, struct filename *filename,
75565 if (IS_ERR(file))
75566 goto out_unmark;
75567
75568+ if (gr_ptrace_readexec(file, bprm->unsafe)) {
75569+ retval = -EPERM;
75570+ goto out_unmark;
75571+ }
75572+
75573 sched_exec();
75574
75575 bprm->file = file;
75576@@ -1552,6 +1668,11 @@ static int do_execveat_common(int fd, struct filename *filename,
75577 }
75578 bprm->interp = bprm->filename;
75579
75580+ if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
75581+ retval = -EACCES;
75582+ goto out_unmark;
75583+ }
75584+
75585 retval = bprm_mm_init(bprm);
75586 if (retval)
75587 goto out_unmark;
75588@@ -1568,24 +1689,70 @@ static int do_execveat_common(int fd, struct filename *filename,
75589 if (retval < 0)
75590 goto out;
75591
75592+#ifdef CONFIG_GRKERNSEC
75593+ old_acl = current->acl;
75594+ memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
75595+ old_exec_file = current->exec_file;
75596+ get_file(file);
75597+ current->exec_file = file;
75598+#endif
75599+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
75600+ /* limit suid stack to 8MB
75601+ * we saved the old limits above and will restore them if this exec fails
75602+ */
75603+ if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
75604+ (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
75605+ current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
75606+#endif
75607+
75608+ if (gr_process_kernel_exec_ban() || gr_process_suid_exec_ban(bprm)) {
75609+ retval = -EPERM;
75610+ goto out_fail;
75611+ }
75612+
75613+ if (!gr_tpe_allow(file)) {
75614+ retval = -EACCES;
75615+ goto out_fail;
75616+ }
75617+
75618+ if (gr_check_crash_exec(file)) {
75619+ retval = -EACCES;
75620+ goto out_fail;
75621+ }
75622+
75623+ retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
75624+ bprm->unsafe);
75625+ if (retval < 0)
75626+ goto out_fail;
75627+
75628 retval = copy_strings_kernel(1, &bprm->filename, bprm);
75629 if (retval < 0)
75630- goto out;
75631+ goto out_fail;
75632
75633 bprm->exec = bprm->p;
75634 retval = copy_strings(bprm->envc, envp, bprm);
75635 if (retval < 0)
75636- goto out;
75637+ goto out_fail;
75638
75639 retval = copy_strings(bprm->argc, argv, bprm);
75640 if (retval < 0)
75641- goto out;
75642+ goto out_fail;
75643+
75644+ gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
75645+
75646+ gr_handle_exec_args(bprm, argv);
75647
75648 retval = exec_binprm(bprm);
75649 if (retval < 0)
75650- goto out;
75651+ goto out_fail;
75652+#ifdef CONFIG_GRKERNSEC
75653+ if (old_exec_file)
75654+ fput(old_exec_file);
75655+#endif
75656
75657 /* execve succeeded */
75658+
75659+ increment_exec_counter();
75660 current->fs->in_exec = 0;
75661 current->in_execve = 0;
75662 acct_update_integrals(current);
75663@@ -1597,6 +1764,14 @@ static int do_execveat_common(int fd, struct filename *filename,
75664 put_files_struct(displaced);
75665 return retval;
75666
75667+out_fail:
75668+#ifdef CONFIG_GRKERNSEC
75669+ current->acl = old_acl;
75670+ memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
75671+ fput(current->exec_file);
75672+ current->exec_file = old_exec_file;
75673+#endif
75674+
75675 out:
75676 if (bprm->mm) {
75677 acct_arg_size(bprm, 0);
75678@@ -1743,3 +1918,312 @@ COMPAT_SYSCALL_DEFINE5(execveat, int, fd,
75679 argv, envp, flags);
75680 }
75681 #endif
75682+
75683+int pax_check_flags(unsigned long *flags)
75684+{
75685+ int retval = 0;
75686+
75687+#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
75688+ if (*flags & MF_PAX_SEGMEXEC)
75689+ {
75690+ *flags &= ~MF_PAX_SEGMEXEC;
75691+ retval = -EINVAL;
75692+ }
75693+#endif
75694+
75695+ if ((*flags & MF_PAX_PAGEEXEC)
75696+
75697+#ifdef CONFIG_PAX_PAGEEXEC
75698+ && (*flags & MF_PAX_SEGMEXEC)
75699+#endif
75700+
75701+ )
75702+ {
75703+ *flags &= ~MF_PAX_PAGEEXEC;
75704+ retval = -EINVAL;
75705+ }
75706+
75707+ if ((*flags & MF_PAX_MPROTECT)
75708+
75709+#ifdef CONFIG_PAX_MPROTECT
75710+ && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
75711+#endif
75712+
75713+ )
75714+ {
75715+ *flags &= ~MF_PAX_MPROTECT;
75716+ retval = -EINVAL;
75717+ }
75718+
75719+ if ((*flags & MF_PAX_EMUTRAMP)
75720+
75721+#ifdef CONFIG_PAX_EMUTRAMP
75722+ && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
75723+#endif
75724+
75725+ )
75726+ {
75727+ *flags &= ~MF_PAX_EMUTRAMP;
75728+ retval = -EINVAL;
75729+ }
75730+
75731+ return retval;
75732+}
75733+
75734+EXPORT_SYMBOL(pax_check_flags);
75735+
75736+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
75737+char *pax_get_path(const struct path *path, char *buf, int buflen)
75738+{
75739+ char *pathname = d_path(path, buf, buflen);
75740+
75741+ if (IS_ERR(pathname))
75742+ goto toolong;
75743+
75744+ pathname = mangle_path(buf, pathname, "\t\n\\");
75745+ if (!pathname)
75746+ goto toolong;
75747+
75748+ *pathname = 0;
75749+ return buf;
75750+
75751+toolong:
75752+ return "<path too long>";
75753+}
75754+EXPORT_SYMBOL(pax_get_path);
75755+
75756+void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
75757+{
75758+ struct task_struct *tsk = current;
75759+ struct mm_struct *mm = current->mm;
75760+ char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
75761+ char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
75762+ char *path_exec = NULL;
75763+ char *path_fault = NULL;
75764+ unsigned long start = 0UL, end = 0UL, offset = 0UL;
75765+ siginfo_t info = { };
75766+
75767+ if (buffer_exec && buffer_fault) {
75768+ struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
75769+
75770+ down_read(&mm->mmap_sem);
75771+ vma = mm->mmap;
75772+ while (vma && (!vma_exec || !vma_fault)) {
75773+ if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
75774+ vma_exec = vma;
75775+ if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
75776+ vma_fault = vma;
75777+ vma = vma->vm_next;
75778+ }
75779+ if (vma_exec)
75780+ path_exec = pax_get_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
75781+ if (vma_fault) {
75782+ start = vma_fault->vm_start;
75783+ end = vma_fault->vm_end;
75784+ offset = vma_fault->vm_pgoff << PAGE_SHIFT;
75785+ if (vma_fault->vm_file)
75786+ path_fault = pax_get_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
75787+ else if ((unsigned long)pc >= mm->start_brk && (unsigned long)pc < mm->brk)
75788+ path_fault = "<heap>";
75789+ else if (vma_fault->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
75790+ path_fault = "<stack>";
75791+ else
75792+ path_fault = "<anonymous mapping>";
75793+ }
75794+ up_read(&mm->mmap_sem);
75795+ }
75796+ if (tsk->signal->curr_ip)
75797+ printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
75798+ else
75799+ printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
75800+ 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),
75801+ from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
75802+ free_page((unsigned long)buffer_exec);
75803+ free_page((unsigned long)buffer_fault);
75804+ pax_report_insns(regs, pc, sp);
75805+ info.si_signo = SIGKILL;
75806+ info.si_errno = 0;
75807+ info.si_code = SI_KERNEL;
75808+ info.si_pid = 0;
75809+ info.si_uid = 0;
75810+ do_coredump(&info);
75811+}
75812+#endif
75813+
75814+#ifdef CONFIG_PAX_REFCOUNT
75815+void pax_report_refcount_overflow(struct pt_regs *regs)
75816+{
75817+ if (current->signal->curr_ip)
75818+ printk(KERN_EMERG "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
75819+ &current->signal->curr_ip, current->comm, task_pid_nr(current),
75820+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
75821+ else
75822+ printk(KERN_EMERG "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
75823+ from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
75824+ print_symbol(KERN_EMERG "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
75825+ preempt_disable();
75826+ show_regs(regs);
75827+ preempt_enable();
75828+ force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
75829+}
75830+#endif
75831+
75832+#ifdef CONFIG_PAX_USERCOPY
75833+/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
75834+static noinline int check_stack_object(const void *obj, unsigned long len)
75835+{
75836+ const void * const stack = task_stack_page(current);
75837+ const void * const stackend = stack + THREAD_SIZE;
75838+
75839+#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
75840+ const void *frame = NULL;
75841+ const void *oldframe;
75842+#endif
75843+
75844+ if (obj + len < obj)
75845+ return -1;
75846+
75847+ if (obj + len <= stack || stackend <= obj)
75848+ return 0;
75849+
75850+ if (obj < stack || stackend < obj + len)
75851+ return -1;
75852+
75853+#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
75854+ oldframe = __builtin_frame_address(1);
75855+ if (oldframe)
75856+ frame = __builtin_frame_address(2);
75857+ /*
75858+ low ----------------------------------------------> high
75859+ [saved bp][saved ip][args][local vars][saved bp][saved ip]
75860+ ^----------------^
75861+ allow copies only within here
75862+ */
75863+ while (stack <= frame && frame < stackend) {
75864+ /* if obj + len extends past the last frame, this
75865+ check won't pass and the next frame will be 0,
75866+ causing us to bail out and correctly report
75867+ the copy as invalid
75868+ */
75869+ if (obj + len <= frame)
75870+ return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
75871+ oldframe = frame;
75872+ frame = *(const void * const *)frame;
75873+ }
75874+ return -1;
75875+#else
75876+ return 1;
75877+#endif
75878+}
75879+
75880+static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
75881+{
75882+ if (current->signal->curr_ip)
75883+ printk(KERN_EMERG "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
75884+ &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
75885+ else
75886+ printk(KERN_EMERG "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
75887+ to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
75888+ dump_stack();
75889+ gr_handle_kernel_exploit();
75890+ do_group_exit(SIGKILL);
75891+}
75892+#endif
75893+
75894+#ifdef CONFIG_PAX_USERCOPY
75895+
75896+static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
75897+{
75898+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75899+ unsigned long textlow = ktla_ktva((unsigned long)_stext);
75900+#ifdef CONFIG_MODULES
75901+ unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
75902+#else
75903+ unsigned long texthigh = ktla_ktva((unsigned long)_etext);
75904+#endif
75905+
75906+#else
75907+ unsigned long textlow = (unsigned long)_stext;
75908+ unsigned long texthigh = (unsigned long)_etext;
75909+
75910+#ifdef CONFIG_X86_64
75911+ /* check against linear mapping as well */
75912+ if (high > (unsigned long)__va(__pa(textlow)) &&
75913+ low < (unsigned long)__va(__pa(texthigh)))
75914+ return true;
75915+#endif
75916+
75917+#endif
75918+
75919+ if (high <= textlow || low >= texthigh)
75920+ return false;
75921+ else
75922+ return true;
75923+}
75924+#endif
75925+
75926+void __check_object_size(const void *ptr, unsigned long n, bool to_user, bool const_size)
75927+{
75928+#ifdef CONFIG_PAX_USERCOPY
75929+ const char *type;
75930+#endif
75931+
75932+#if !defined(CONFIG_STACK_GROWSUP) && !defined(CONFIG_X86_64)
75933+ unsigned long stackstart = (unsigned long)task_stack_page(current);
75934+ unsigned long currentsp = (unsigned long)&stackstart;
75935+ if (unlikely((currentsp < stackstart + 512 ||
75936+ currentsp >= stackstart + THREAD_SIZE) && !in_interrupt()))
75937+ BUG();
75938+#endif
75939+
75940+#ifndef CONFIG_PAX_USERCOPY_DEBUG
75941+ if (const_size)
75942+ return;
75943+#endif
75944+
75945+#ifdef CONFIG_PAX_USERCOPY
75946+ if (!n)
75947+ return;
75948+
75949+ type = check_heap_object(ptr, n);
75950+ if (!type) {
75951+ int ret = check_stack_object(ptr, n);
75952+ if (ret == 1 || ret == 2)
75953+ return;
75954+ if (ret == 0) {
75955+ if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
75956+ type = "<kernel text>";
75957+ else
75958+ return;
75959+ } else
75960+ type = "<process stack>";
75961+ }
75962+
75963+ pax_report_usercopy(ptr, n, to_user, type);
75964+#endif
75965+
75966+}
75967+EXPORT_SYMBOL(__check_object_size);
75968+
75969+#ifdef CONFIG_PAX_MEMORY_STACKLEAK
75970+void __used pax_track_stack(void)
75971+{
75972+ unsigned long sp = (unsigned long)&sp;
75973+ if (sp < current_thread_info()->lowest_stack &&
75974+ sp >= (unsigned long)task_stack_page(current) + 2 * sizeof(unsigned long))
75975+ current_thread_info()->lowest_stack = sp;
75976+ if (unlikely((sp & ~(THREAD_SIZE - 1)) < (THREAD_SIZE/16)))
75977+ BUG();
75978+}
75979+EXPORT_SYMBOL(pax_track_stack);
75980+#endif
75981+
75982+#ifdef CONFIG_PAX_SIZE_OVERFLOW
75983+void __nocapture(1, 3, 4) __used report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
75984+{
75985+ printk(KERN_EMERG "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
75986+ dump_stack();
75987+ do_group_exit(SIGKILL);
75988+}
75989+EXPORT_SYMBOL(report_size_overflow);
75990+#endif
75991diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
75992index 9f9992b..8b59411 100644
75993--- a/fs/ext2/balloc.c
75994+++ b/fs/ext2/balloc.c
75995@@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
75996
75997 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
75998 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
75999- if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
76000+ if (free_blocks < root_blocks + 1 &&
76001 !uid_eq(sbi->s_resuid, current_fsuid()) &&
76002 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
76003- !in_group_p (sbi->s_resgid))) {
76004+ !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
76005 return 0;
76006 }
76007 return 1;
76008diff --git a/fs/ext2/super.c b/fs/ext2/super.c
76009index d0e746e..82e06f0 100644
76010--- a/fs/ext2/super.c
76011+++ b/fs/ext2/super.c
76012@@ -267,10 +267,8 @@ static int ext2_show_options(struct seq_file *seq, struct dentry *root)
76013 #ifdef CONFIG_EXT2_FS_XATTR
76014 if (test_opt(sb, XATTR_USER))
76015 seq_puts(seq, ",user_xattr");
76016- if (!test_opt(sb, XATTR_USER) &&
76017- (def_mount_opts & EXT2_DEFM_XATTR_USER)) {
76018+ if (!test_opt(sb, XATTR_USER))
76019 seq_puts(seq, ",nouser_xattr");
76020- }
76021 #endif
76022
76023 #ifdef CONFIG_EXT2_FS_POSIX_ACL
76024@@ -856,8 +854,8 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
76025 if (def_mount_opts & EXT2_DEFM_UID16)
76026 set_opt(sbi->s_mount_opt, NO_UID32);
76027 #ifdef CONFIG_EXT2_FS_XATTR
76028- if (def_mount_opts & EXT2_DEFM_XATTR_USER)
76029- set_opt(sbi->s_mount_opt, XATTR_USER);
76030+ /* always enable user xattrs */
76031+ set_opt(sbi->s_mount_opt, XATTR_USER);
76032 #endif
76033 #ifdef CONFIG_EXT2_FS_POSIX_ACL
76034 if (def_mount_opts & EXT2_DEFM_ACL)
76035diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
76036index 0b6bfd3..93a2964 100644
76037--- a/fs/ext2/xattr.c
76038+++ b/fs/ext2/xattr.c
76039@@ -247,7 +247,7 @@ ext2_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size)
76040 struct buffer_head *bh = NULL;
76041 struct ext2_xattr_entry *entry;
76042 char *end;
76043- size_t rest = buffer_size;
76044+ size_t rest = buffer_size, total_size = 0;
76045 int error;
76046
76047 ea_idebug(inode, "buffer=%p, buffer_size=%ld",
76048@@ -305,9 +305,10 @@ bad_block: ext2_error(inode->i_sb, "ext2_xattr_list",
76049 buffer += size;
76050 }
76051 rest -= size;
76052+ total_size += size;
76053 }
76054 }
76055- error = buffer_size - rest; /* total size */
76056+ error = total_size;
76057
76058 cleanup:
76059 brelse(bh);
76060diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
76061index 158b5d4..2432610 100644
76062--- a/fs/ext3/balloc.c
76063+++ b/fs/ext3/balloc.c
76064@@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
76065
76066 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
76067 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
76068- if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
76069+ if (free_blocks < root_blocks + 1 &&
76070 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
76071 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
76072- !in_group_p (sbi->s_resgid))) {
76073+ !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
76074 return 0;
76075 }
76076 return 1;
76077diff --git a/fs/ext3/super.c b/fs/ext3/super.c
76078index a9312f0..e3a11ec 100644
76079--- a/fs/ext3/super.c
76080+++ b/fs/ext3/super.c
76081@@ -655,10 +655,8 @@ static int ext3_show_options(struct seq_file *seq, struct dentry *root)
76082 #ifdef CONFIG_EXT3_FS_XATTR
76083 if (test_opt(sb, XATTR_USER))
76084 seq_puts(seq, ",user_xattr");
76085- if (!test_opt(sb, XATTR_USER) &&
76086- (def_mount_opts & EXT3_DEFM_XATTR_USER)) {
76087+ if (!test_opt(sb, XATTR_USER))
76088 seq_puts(seq, ",nouser_xattr");
76089- }
76090 #endif
76091 #ifdef CONFIG_EXT3_FS_POSIX_ACL
76092 if (test_opt(sb, POSIX_ACL))
76093@@ -1760,8 +1758,8 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
76094 if (def_mount_opts & EXT3_DEFM_UID16)
76095 set_opt(sbi->s_mount_opt, NO_UID32);
76096 #ifdef CONFIG_EXT3_FS_XATTR
76097- if (def_mount_opts & EXT3_DEFM_XATTR_USER)
76098- set_opt(sbi->s_mount_opt, XATTR_USER);
76099+ /* always enable user xattrs */
76100+ set_opt(sbi->s_mount_opt, XATTR_USER);
76101 #endif
76102 #ifdef CONFIG_EXT3_FS_POSIX_ACL
76103 if (def_mount_opts & EXT3_DEFM_ACL)
76104diff --git a/fs/ext3/xattr.c b/fs/ext3/xattr.c
76105index 7cf3650..e3f4a51 100644
76106--- a/fs/ext3/xattr.c
76107+++ b/fs/ext3/xattr.c
76108@@ -330,7 +330,7 @@ static int
76109 ext3_xattr_list_entries(struct dentry *dentry, struct ext3_xattr_entry *entry,
76110 char *buffer, size_t buffer_size)
76111 {
76112- size_t rest = buffer_size;
76113+ size_t rest = buffer_size, total_size = 0;
76114
76115 for (; !IS_LAST_ENTRY(entry); entry = EXT3_XATTR_NEXT(entry)) {
76116 const struct xattr_handler *handler =
76117@@ -347,9 +347,10 @@ ext3_xattr_list_entries(struct dentry *dentry, struct ext3_xattr_entry *entry,
76118 buffer += size;
76119 }
76120 rest -= size;
76121+ total_size += size;
76122 }
76123 }
76124- return buffer_size - rest;
76125+ return total_size;
76126 }
76127
76128 static int
76129diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
76130index 955bf49a..44ee359 100644
76131--- a/fs/ext4/balloc.c
76132+++ b/fs/ext4/balloc.c
76133@@ -556,8 +556,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
76134 /* Hm, nope. Are (enough) root reserved clusters available? */
76135 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
76136 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
76137- capable(CAP_SYS_RESOURCE) ||
76138- (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
76139+ (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
76140+ capable_nolog(CAP_SYS_RESOURCE)) {
76141
76142 if (free_clusters >= (nclusters + dirty_clusters +
76143 resv_clusters))
76144diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
76145index 9a83f14..1dd1b38 100644
76146--- a/fs/ext4/ext4.h
76147+++ b/fs/ext4/ext4.h
76148@@ -1310,19 +1310,19 @@ struct ext4_sb_info {
76149 unsigned long s_mb_last_start;
76150
76151 /* stats for buddy allocator */
76152- atomic_t s_bal_reqs; /* number of reqs with len > 1 */
76153- atomic_t s_bal_success; /* we found long enough chunks */
76154- atomic_t s_bal_allocated; /* in blocks */
76155- atomic_t s_bal_ex_scanned; /* total extents scanned */
76156- atomic_t s_bal_goals; /* goal hits */
76157- atomic_t s_bal_breaks; /* too long searches */
76158- atomic_t s_bal_2orders; /* 2^order hits */
76159+ atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
76160+ atomic_unchecked_t s_bal_success; /* we found long enough chunks */
76161+ atomic_unchecked_t s_bal_allocated; /* in blocks */
76162+ atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
76163+ atomic_unchecked_t s_bal_goals; /* goal hits */
76164+ atomic_unchecked_t s_bal_breaks; /* too long searches */
76165+ atomic_unchecked_t s_bal_2orders; /* 2^order hits */
76166 spinlock_t s_bal_lock;
76167 unsigned long s_mb_buddies_generated;
76168 unsigned long long s_mb_generation_time;
76169- atomic_t s_mb_lost_chunks;
76170- atomic_t s_mb_preallocated;
76171- atomic_t s_mb_discarded;
76172+ atomic_unchecked_t s_mb_lost_chunks;
76173+ atomic_unchecked_t s_mb_preallocated;
76174+ atomic_unchecked_t s_mb_discarded;
76175 atomic_t s_lock_busy;
76176
76177 /* locality groups */
76178diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
76179index 8d1e602..abf497b 100644
76180--- a/fs/ext4/mballoc.c
76181+++ b/fs/ext4/mballoc.c
76182@@ -1901,7 +1901,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
76183 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
76184
76185 if (EXT4_SB(sb)->s_mb_stats)
76186- atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
76187+ atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
76188
76189 break;
76190 }
76191@@ -2211,7 +2211,7 @@ repeat:
76192 ac->ac_status = AC_STATUS_CONTINUE;
76193 ac->ac_flags |= EXT4_MB_HINT_FIRST;
76194 cr = 3;
76195- atomic_inc(&sbi->s_mb_lost_chunks);
76196+ atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
76197 goto repeat;
76198 }
76199 }
76200@@ -2716,25 +2716,25 @@ int ext4_mb_release(struct super_block *sb)
76201 if (sbi->s_mb_stats) {
76202 ext4_msg(sb, KERN_INFO,
76203 "mballoc: %u blocks %u reqs (%u success)",
76204- atomic_read(&sbi->s_bal_allocated),
76205- atomic_read(&sbi->s_bal_reqs),
76206- atomic_read(&sbi->s_bal_success));
76207+ atomic_read_unchecked(&sbi->s_bal_allocated),
76208+ atomic_read_unchecked(&sbi->s_bal_reqs),
76209+ atomic_read_unchecked(&sbi->s_bal_success));
76210 ext4_msg(sb, KERN_INFO,
76211 "mballoc: %u extents scanned, %u goal hits, "
76212 "%u 2^N hits, %u breaks, %u lost",
76213- atomic_read(&sbi->s_bal_ex_scanned),
76214- atomic_read(&sbi->s_bal_goals),
76215- atomic_read(&sbi->s_bal_2orders),
76216- atomic_read(&sbi->s_bal_breaks),
76217- atomic_read(&sbi->s_mb_lost_chunks));
76218+ atomic_read_unchecked(&sbi->s_bal_ex_scanned),
76219+ atomic_read_unchecked(&sbi->s_bal_goals),
76220+ atomic_read_unchecked(&sbi->s_bal_2orders),
76221+ atomic_read_unchecked(&sbi->s_bal_breaks),
76222+ atomic_read_unchecked(&sbi->s_mb_lost_chunks));
76223 ext4_msg(sb, KERN_INFO,
76224 "mballoc: %lu generated and it took %Lu",
76225 sbi->s_mb_buddies_generated,
76226 sbi->s_mb_generation_time);
76227 ext4_msg(sb, KERN_INFO,
76228 "mballoc: %u preallocated, %u discarded",
76229- atomic_read(&sbi->s_mb_preallocated),
76230- atomic_read(&sbi->s_mb_discarded));
76231+ atomic_read_unchecked(&sbi->s_mb_preallocated),
76232+ atomic_read_unchecked(&sbi->s_mb_discarded));
76233 }
76234
76235 free_percpu(sbi->s_locality_groups);
76236@@ -3190,16 +3190,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
76237 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
76238
76239 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
76240- atomic_inc(&sbi->s_bal_reqs);
76241- atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
76242+ atomic_inc_unchecked(&sbi->s_bal_reqs);
76243+ atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
76244 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
76245- atomic_inc(&sbi->s_bal_success);
76246- atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
76247+ atomic_inc_unchecked(&sbi->s_bal_success);
76248+ atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
76249 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
76250 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
76251- atomic_inc(&sbi->s_bal_goals);
76252+ atomic_inc_unchecked(&sbi->s_bal_goals);
76253 if (ac->ac_found > sbi->s_mb_max_to_scan)
76254- atomic_inc(&sbi->s_bal_breaks);
76255+ atomic_inc_unchecked(&sbi->s_bal_breaks);
76256 }
76257
76258 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
76259@@ -3626,7 +3626,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
76260 trace_ext4_mb_new_inode_pa(ac, pa);
76261
76262 ext4_mb_use_inode_pa(ac, pa);
76263- atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
76264+ atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
76265
76266 ei = EXT4_I(ac->ac_inode);
76267 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
76268@@ -3686,7 +3686,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
76269 trace_ext4_mb_new_group_pa(ac, pa);
76270
76271 ext4_mb_use_group_pa(ac, pa);
76272- atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
76273+ atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
76274
76275 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
76276 lg = ac->ac_lg;
76277@@ -3775,7 +3775,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
76278 * from the bitmap and continue.
76279 */
76280 }
76281- atomic_add(free, &sbi->s_mb_discarded);
76282+ atomic_add_unchecked(free, &sbi->s_mb_discarded);
76283
76284 return err;
76285 }
76286@@ -3793,7 +3793,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
76287 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
76288 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
76289 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
76290- atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
76291+ atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
76292 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
76293
76294 return 0;
76295diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
76296index 8313ca3..8a37d08 100644
76297--- a/fs/ext4/mmp.c
76298+++ b/fs/ext4/mmp.c
76299@@ -111,7 +111,7 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
76300 void __dump_mmp_msg(struct super_block *sb, struct mmp_struct *mmp,
76301 const char *function, unsigned int line, const char *msg)
76302 {
76303- __ext4_warning(sb, function, line, msg);
76304+ __ext4_warning(sb, function, line, "%s", msg);
76305 __ext4_warning(sb, function, line,
76306 "MMP failure info: last update time: %llu, last update "
76307 "node: %s, last update device: %s\n",
76308diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
76309index cf0c472..ddf284d 100644
76310--- a/fs/ext4/resize.c
76311+++ b/fs/ext4/resize.c
76312@@ -413,7 +413,7 @@ static int set_flexbg_block_bitmap(struct super_block *sb, handle_t *handle,
76313
76314 ext4_debug("mark blocks [%llu/%u] used\n", block, count);
76315 for (count2 = count; count > 0; count -= count2, block += count2) {
76316- ext4_fsblk_t start;
76317+ ext4_fsblk_t start, diff;
76318 struct buffer_head *bh;
76319 ext4_group_t group;
76320 int err;
76321@@ -422,10 +422,6 @@ static int set_flexbg_block_bitmap(struct super_block *sb, handle_t *handle,
76322 start = ext4_group_first_block_no(sb, group);
76323 group -= flex_gd->groups[0].group;
76324
76325- count2 = EXT4_BLOCKS_PER_GROUP(sb) - (block - start);
76326- if (count2 > count)
76327- count2 = count;
76328-
76329 if (flex_gd->bg_flags[group] & EXT4_BG_BLOCK_UNINIT) {
76330 BUG_ON(flex_gd->count > 1);
76331 continue;
76332@@ -443,9 +439,15 @@ static int set_flexbg_block_bitmap(struct super_block *sb, handle_t *handle,
76333 err = ext4_journal_get_write_access(handle, bh);
76334 if (err)
76335 return err;
76336+
76337+ diff = block - start;
76338+ count2 = EXT4_BLOCKS_PER_GROUP(sb) - diff;
76339+ if (count2 > count)
76340+ count2 = count;
76341+
76342 ext4_debug("mark block bitmap %#04llx (+%llu/%u)\n", block,
76343- block - start, count2);
76344- ext4_set_bits(bh->b_data, block - start, count2);
76345+ diff, count2);
76346+ ext4_set_bits(bh->b_data, diff, count2);
76347
76348 err = ext4_handle_dirty_metadata(handle, NULL, bh);
76349 if (unlikely(err))
76350diff --git a/fs/ext4/super.c b/fs/ext4/super.c
76351index ca9d4a2..4c52f42 100644
76352--- a/fs/ext4/super.c
76353+++ b/fs/ext4/super.c
76354@@ -1232,7 +1232,7 @@ static ext4_fsblk_t get_sb_block(void **data)
76355 }
76356
76357 #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
76358-static char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
76359+static const char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
76360 "Contact linux-ext4@vger.kernel.org if you think we should keep it.\n";
76361
76362 #ifdef CONFIG_QUOTA
76363@@ -2442,7 +2442,7 @@ struct ext4_attr {
76364 int offset;
76365 int deprecated_val;
76366 } u;
76367-};
76368+} __do_const;
76369
76370 static int parse_strtoull(const char *buf,
76371 unsigned long long max, unsigned long long *value)
76372diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
76373index 16e28c0..728c282 100644
76374--- a/fs/ext4/xattr.c
76375+++ b/fs/ext4/xattr.c
76376@@ -398,7 +398,7 @@ static int
76377 ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry,
76378 char *buffer, size_t buffer_size)
76379 {
76380- size_t rest = buffer_size;
76381+ size_t rest = buffer_size, total_size = 0;
76382
76383 for (; !IS_LAST_ENTRY(entry); entry = EXT4_XATTR_NEXT(entry)) {
76384 const struct xattr_handler *handler =
76385@@ -415,9 +415,10 @@ ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry,
76386 buffer += size;
76387 }
76388 rest -= size;
76389+ total_size += size;
76390 }
76391 }
76392- return buffer_size - rest;
76393+ return total_size;
76394 }
76395
76396 static int
76397diff --git a/fs/fcntl.c b/fs/fcntl.c
76398index ee85cd4..9dd0d20 100644
76399--- a/fs/fcntl.c
76400+++ b/fs/fcntl.c
76401@@ -102,6 +102,10 @@ void __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
76402 int force)
76403 {
76404 security_file_set_fowner(filp);
76405+ if (gr_handle_chroot_fowner(pid, type))
76406+ return;
76407+ if (gr_check_protected_task_fowner(pid, type))
76408+ return;
76409 f_modown(filp, pid, type, force);
76410 }
76411 EXPORT_SYMBOL(__f_setown);
76412diff --git a/fs/fhandle.c b/fs/fhandle.c
76413index d59712d..2281df9 100644
76414--- a/fs/fhandle.c
76415+++ b/fs/fhandle.c
76416@@ -8,6 +8,7 @@
76417 #include <linux/fs_struct.h>
76418 #include <linux/fsnotify.h>
76419 #include <linux/personality.h>
76420+#include <linux/grsecurity.h>
76421 #include <asm/uaccess.h>
76422 #include "internal.h"
76423 #include "mount.h"
76424@@ -67,8 +68,7 @@ static long do_sys_name_to_handle(struct path *path,
76425 } else
76426 retval = 0;
76427 /* copy the mount id */
76428- if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
76429- sizeof(*mnt_id)) ||
76430+ if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
76431 copy_to_user(ufh, handle,
76432 sizeof(struct file_handle) + handle_bytes))
76433 retval = -EFAULT;
76434@@ -175,7 +175,7 @@ static int handle_to_path(int mountdirfd, struct file_handle __user *ufh,
76435 * the directory. Ideally we would like CAP_DAC_SEARCH.
76436 * But we don't have that
76437 */
76438- if (!capable(CAP_DAC_READ_SEARCH)) {
76439+ if (!capable(CAP_DAC_READ_SEARCH) || !gr_chroot_fhandle()) {
76440 retval = -EPERM;
76441 goto out_err;
76442 }
76443diff --git a/fs/file.c b/fs/file.c
76444index 93c5f89..ed75817 100644
76445--- a/fs/file.c
76446+++ b/fs/file.c
76447@@ -16,6 +16,7 @@
76448 #include <linux/slab.h>
76449 #include <linux/vmalloc.h>
76450 #include <linux/file.h>
76451+#include <linux/security.h>
76452 #include <linux/fdtable.h>
76453 #include <linux/bitops.h>
76454 #include <linux/interrupt.h>
76455@@ -139,7 +140,7 @@ out:
76456 * Return <0 error code on error; 1 on successful completion.
76457 * The files->file_lock should be held on entry, and will be held on exit.
76458 */
76459-static int expand_fdtable(struct files_struct *files, int nr)
76460+static int expand_fdtable(struct files_struct *files, unsigned int nr)
76461 __releases(files->file_lock)
76462 __acquires(files->file_lock)
76463 {
76464@@ -184,7 +185,7 @@ static int expand_fdtable(struct files_struct *files, int nr)
76465 * expanded and execution may have blocked.
76466 * The files->file_lock should be held on entry, and will be held on exit.
76467 */
76468-static int expand_files(struct files_struct *files, int nr)
76469+static int expand_files(struct files_struct *files, unsigned int nr)
76470 {
76471 struct fdtable *fdt;
76472
76473@@ -799,6 +800,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
76474 if (!file)
76475 return __close_fd(files, fd);
76476
76477+ gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
76478 if (fd >= rlimit(RLIMIT_NOFILE))
76479 return -EBADF;
76480
76481@@ -825,6 +827,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
76482 if (unlikely(oldfd == newfd))
76483 return -EINVAL;
76484
76485+ gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
76486 if (newfd >= rlimit(RLIMIT_NOFILE))
76487 return -EBADF;
76488
76489@@ -880,6 +883,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
76490 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
76491 {
76492 int err;
76493+ gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
76494 if (from >= rlimit(RLIMIT_NOFILE))
76495 return -EINVAL;
76496 err = alloc_fd(from, flags);
76497diff --git a/fs/filesystems.c b/fs/filesystems.c
76498index 5797d45..7d7d79a 100644
76499--- a/fs/filesystems.c
76500+++ b/fs/filesystems.c
76501@@ -275,7 +275,11 @@ struct file_system_type *get_fs_type(const char *name)
76502 int len = dot ? dot - name : strlen(name);
76503
76504 fs = __get_fs_type(name, len);
76505+#ifdef CONFIG_GRKERNSEC_MODHARDEN
76506+ if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
76507+#else
76508 if (!fs && (request_module("fs-%.*s", len, name) == 0))
76509+#endif
76510 fs = __get_fs_type(name, len);
76511
76512 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
76513diff --git a/fs/fs_struct.c b/fs/fs_struct.c
76514index 7dca743..1ff87ae 100644
76515--- a/fs/fs_struct.c
76516+++ b/fs/fs_struct.c
76517@@ -4,6 +4,7 @@
76518 #include <linux/path.h>
76519 #include <linux/slab.h>
76520 #include <linux/fs_struct.h>
76521+#include <linux/grsecurity.h>
76522 #include "internal.h"
76523
76524 /*
76525@@ -15,14 +16,18 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
76526 struct path old_root;
76527
76528 path_get(path);
76529+ gr_inc_chroot_refcnts(path->dentry, path->mnt);
76530 spin_lock(&fs->lock);
76531 write_seqcount_begin(&fs->seq);
76532 old_root = fs->root;
76533 fs->root = *path;
76534+ gr_set_chroot_entries(current, path);
76535 write_seqcount_end(&fs->seq);
76536 spin_unlock(&fs->lock);
76537- if (old_root.dentry)
76538+ if (old_root.dentry) {
76539+ gr_dec_chroot_refcnts(old_root.dentry, old_root.mnt);
76540 path_put(&old_root);
76541+ }
76542 }
76543
76544 /*
76545@@ -67,6 +72,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
76546 int hits = 0;
76547 spin_lock(&fs->lock);
76548 write_seqcount_begin(&fs->seq);
76549+ /* this root replacement is only done by pivot_root,
76550+ leave grsec's chroot tagging alone for this task
76551+ so that a pivoted root isn't treated as a chroot
76552+ */
76553 hits += replace_path(&fs->root, old_root, new_root);
76554 hits += replace_path(&fs->pwd, old_root, new_root);
76555 write_seqcount_end(&fs->seq);
76556@@ -85,6 +94,7 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
76557
76558 void free_fs_struct(struct fs_struct *fs)
76559 {
76560+ gr_dec_chroot_refcnts(fs->root.dentry, fs->root.mnt);
76561 path_put(&fs->root);
76562 path_put(&fs->pwd);
76563 kmem_cache_free(fs_cachep, fs);
76564@@ -99,7 +109,8 @@ void exit_fs(struct task_struct *tsk)
76565 task_lock(tsk);
76566 spin_lock(&fs->lock);
76567 tsk->fs = NULL;
76568- kill = !--fs->users;
76569+ gr_clear_chroot_entries(tsk);
76570+ kill = !atomic_dec_return(&fs->users);
76571 spin_unlock(&fs->lock);
76572 task_unlock(tsk);
76573 if (kill)
76574@@ -112,7 +123,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
76575 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
76576 /* We don't need to lock fs - think why ;-) */
76577 if (fs) {
76578- fs->users = 1;
76579+ atomic_set(&fs->users, 1);
76580 fs->in_exec = 0;
76581 spin_lock_init(&fs->lock);
76582 seqcount_init(&fs->seq);
76583@@ -121,9 +132,13 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
76584 spin_lock(&old->lock);
76585 fs->root = old->root;
76586 path_get(&fs->root);
76587+ /* instead of calling gr_set_chroot_entries here,
76588+ we call it from every caller of this function
76589+ */
76590 fs->pwd = old->pwd;
76591 path_get(&fs->pwd);
76592 spin_unlock(&old->lock);
76593+ gr_inc_chroot_refcnts(fs->root.dentry, fs->root.mnt);
76594 }
76595 return fs;
76596 }
76597@@ -139,8 +154,9 @@ int unshare_fs_struct(void)
76598
76599 task_lock(current);
76600 spin_lock(&fs->lock);
76601- kill = !--fs->users;
76602+ kill = !atomic_dec_return(&fs->users);
76603 current->fs = new_fs;
76604+ gr_set_chroot_entries(current, &new_fs->root);
76605 spin_unlock(&fs->lock);
76606 task_unlock(current);
76607
76608@@ -153,13 +169,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
76609
76610 int current_umask(void)
76611 {
76612- return current->fs->umask;
76613+ return current->fs->umask | gr_acl_umask();
76614 }
76615 EXPORT_SYMBOL(current_umask);
76616
76617 /* to be mentioned only in INIT_TASK */
76618 struct fs_struct init_fs = {
76619- .users = 1,
76620+ .users = ATOMIC_INIT(1),
76621 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
76622 .seq = SEQCNT_ZERO(init_fs.seq),
76623 .umask = 0022,
76624diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
76625index 89acec7..a575262 100644
76626--- a/fs/fscache/cookie.c
76627+++ b/fs/fscache/cookie.c
76628@@ -19,7 +19,7 @@
76629
76630 struct kmem_cache *fscache_cookie_jar;
76631
76632-static atomic_t fscache_object_debug_id = ATOMIC_INIT(0);
76633+static atomic_unchecked_t fscache_object_debug_id = ATOMIC_INIT(0);
76634
76635 static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie);
76636 static int fscache_alloc_object(struct fscache_cache *cache,
76637@@ -69,11 +69,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
76638 parent ? (char *) parent->def->name : "<no-parent>",
76639 def->name, netfs_data, enable);
76640
76641- fscache_stat(&fscache_n_acquires);
76642+ fscache_stat_unchecked(&fscache_n_acquires);
76643
76644 /* if there's no parent cookie, then we don't create one here either */
76645 if (!parent) {
76646- fscache_stat(&fscache_n_acquires_null);
76647+ fscache_stat_unchecked(&fscache_n_acquires_null);
76648 _leave(" [no parent]");
76649 return NULL;
76650 }
76651@@ -88,7 +88,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
76652 /* allocate and initialise a cookie */
76653 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
76654 if (!cookie) {
76655- fscache_stat(&fscache_n_acquires_oom);
76656+ fscache_stat_unchecked(&fscache_n_acquires_oom);
76657 _leave(" [ENOMEM]");
76658 return NULL;
76659 }
76660@@ -115,13 +115,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
76661
76662 switch (cookie->def->type) {
76663 case FSCACHE_COOKIE_TYPE_INDEX:
76664- fscache_stat(&fscache_n_cookie_index);
76665+ fscache_stat_unchecked(&fscache_n_cookie_index);
76666 break;
76667 case FSCACHE_COOKIE_TYPE_DATAFILE:
76668- fscache_stat(&fscache_n_cookie_data);
76669+ fscache_stat_unchecked(&fscache_n_cookie_data);
76670 break;
76671 default:
76672- fscache_stat(&fscache_n_cookie_special);
76673+ fscache_stat_unchecked(&fscache_n_cookie_special);
76674 break;
76675 }
76676
76677@@ -135,7 +135,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
76678 } else {
76679 atomic_dec(&parent->n_children);
76680 __fscache_cookie_put(cookie);
76681- fscache_stat(&fscache_n_acquires_nobufs);
76682+ fscache_stat_unchecked(&fscache_n_acquires_nobufs);
76683 _leave(" = NULL");
76684 return NULL;
76685 }
76686@@ -144,7 +144,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
76687 }
76688 }
76689
76690- fscache_stat(&fscache_n_acquires_ok);
76691+ fscache_stat_unchecked(&fscache_n_acquires_ok);
76692 _leave(" = %p", cookie);
76693 return cookie;
76694 }
76695@@ -213,7 +213,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
76696 cache = fscache_select_cache_for_object(cookie->parent);
76697 if (!cache) {
76698 up_read(&fscache_addremove_sem);
76699- fscache_stat(&fscache_n_acquires_no_cache);
76700+ fscache_stat_unchecked(&fscache_n_acquires_no_cache);
76701 _leave(" = -ENOMEDIUM [no cache]");
76702 return -ENOMEDIUM;
76703 }
76704@@ -297,14 +297,14 @@ static int fscache_alloc_object(struct fscache_cache *cache,
76705 object = cache->ops->alloc_object(cache, cookie);
76706 fscache_stat_d(&fscache_n_cop_alloc_object);
76707 if (IS_ERR(object)) {
76708- fscache_stat(&fscache_n_object_no_alloc);
76709+ fscache_stat_unchecked(&fscache_n_object_no_alloc);
76710 ret = PTR_ERR(object);
76711 goto error;
76712 }
76713
76714- fscache_stat(&fscache_n_object_alloc);
76715+ fscache_stat_unchecked(&fscache_n_object_alloc);
76716
76717- object->debug_id = atomic_inc_return(&fscache_object_debug_id);
76718+ object->debug_id = atomic_inc_return_unchecked(&fscache_object_debug_id);
76719
76720 _debug("ALLOC OBJ%x: %s {%lx}",
76721 object->debug_id, cookie->def->name, object->events);
76722@@ -418,7 +418,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
76723
76724 _enter("{%s}", cookie->def->name);
76725
76726- fscache_stat(&fscache_n_invalidates);
76727+ fscache_stat_unchecked(&fscache_n_invalidates);
76728
76729 /* Only permit invalidation of data files. Invalidating an index will
76730 * require the caller to release all its attachments to the tree rooted
76731@@ -476,10 +476,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
76732 {
76733 struct fscache_object *object;
76734
76735- fscache_stat(&fscache_n_updates);
76736+ fscache_stat_unchecked(&fscache_n_updates);
76737
76738 if (!cookie) {
76739- fscache_stat(&fscache_n_updates_null);
76740+ fscache_stat_unchecked(&fscache_n_updates_null);
76741 _leave(" [no cookie]");
76742 return;
76743 }
76744@@ -580,12 +580,12 @@ EXPORT_SYMBOL(__fscache_disable_cookie);
76745 */
76746 void __fscache_relinquish_cookie(struct fscache_cookie *cookie, bool retire)
76747 {
76748- fscache_stat(&fscache_n_relinquishes);
76749+ fscache_stat_unchecked(&fscache_n_relinquishes);
76750 if (retire)
76751- fscache_stat(&fscache_n_relinquishes_retire);
76752+ fscache_stat_unchecked(&fscache_n_relinquishes_retire);
76753
76754 if (!cookie) {
76755- fscache_stat(&fscache_n_relinquishes_null);
76756+ fscache_stat_unchecked(&fscache_n_relinquishes_null);
76757 _leave(" [no cookie]");
76758 return;
76759 }
76760@@ -686,7 +686,7 @@ int __fscache_check_consistency(struct fscache_cookie *cookie)
76761 if (test_bit(FSCACHE_IOERROR, &object->cache->flags))
76762 goto inconsistent;
76763
76764- op->debug_id = atomic_inc_return(&fscache_op_debug_id);
76765+ op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
76766
76767 __fscache_use_cookie(cookie);
76768 if (fscache_submit_op(object, op) < 0)
76769diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
76770index 7872a62..d91b19f 100644
76771--- a/fs/fscache/internal.h
76772+++ b/fs/fscache/internal.h
76773@@ -137,8 +137,8 @@ extern void fscache_operation_gc(struct work_struct *);
76774 extern int fscache_wait_for_deferred_lookup(struct fscache_cookie *);
76775 extern int fscache_wait_for_operation_activation(struct fscache_object *,
76776 struct fscache_operation *,
76777- atomic_t *,
76778- atomic_t *,
76779+ atomic_unchecked_t *,
76780+ atomic_unchecked_t *,
76781 void (*)(struct fscache_operation *));
76782 extern void fscache_invalidate_writes(struct fscache_cookie *);
76783
76784@@ -157,101 +157,101 @@ extern void fscache_proc_cleanup(void);
76785 * stats.c
76786 */
76787 #ifdef CONFIG_FSCACHE_STATS
76788-extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
76789-extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
76790+extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
76791+extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
76792
76793-extern atomic_t fscache_n_op_pend;
76794-extern atomic_t fscache_n_op_run;
76795-extern atomic_t fscache_n_op_enqueue;
76796-extern atomic_t fscache_n_op_deferred_release;
76797-extern atomic_t fscache_n_op_release;
76798-extern atomic_t fscache_n_op_gc;
76799-extern atomic_t fscache_n_op_cancelled;
76800-extern atomic_t fscache_n_op_rejected;
76801+extern atomic_unchecked_t fscache_n_op_pend;
76802+extern atomic_unchecked_t fscache_n_op_run;
76803+extern atomic_unchecked_t fscache_n_op_enqueue;
76804+extern atomic_unchecked_t fscache_n_op_deferred_release;
76805+extern atomic_unchecked_t fscache_n_op_release;
76806+extern atomic_unchecked_t fscache_n_op_gc;
76807+extern atomic_unchecked_t fscache_n_op_cancelled;
76808+extern atomic_unchecked_t fscache_n_op_rejected;
76809
76810-extern atomic_t fscache_n_attr_changed;
76811-extern atomic_t fscache_n_attr_changed_ok;
76812-extern atomic_t fscache_n_attr_changed_nobufs;
76813-extern atomic_t fscache_n_attr_changed_nomem;
76814-extern atomic_t fscache_n_attr_changed_calls;
76815+extern atomic_unchecked_t fscache_n_attr_changed;
76816+extern atomic_unchecked_t fscache_n_attr_changed_ok;
76817+extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
76818+extern atomic_unchecked_t fscache_n_attr_changed_nomem;
76819+extern atomic_unchecked_t fscache_n_attr_changed_calls;
76820
76821-extern atomic_t fscache_n_allocs;
76822-extern atomic_t fscache_n_allocs_ok;
76823-extern atomic_t fscache_n_allocs_wait;
76824-extern atomic_t fscache_n_allocs_nobufs;
76825-extern atomic_t fscache_n_allocs_intr;
76826-extern atomic_t fscache_n_allocs_object_dead;
76827-extern atomic_t fscache_n_alloc_ops;
76828-extern atomic_t fscache_n_alloc_op_waits;
76829+extern atomic_unchecked_t fscache_n_allocs;
76830+extern atomic_unchecked_t fscache_n_allocs_ok;
76831+extern atomic_unchecked_t fscache_n_allocs_wait;
76832+extern atomic_unchecked_t fscache_n_allocs_nobufs;
76833+extern atomic_unchecked_t fscache_n_allocs_intr;
76834+extern atomic_unchecked_t fscache_n_allocs_object_dead;
76835+extern atomic_unchecked_t fscache_n_alloc_ops;
76836+extern atomic_unchecked_t fscache_n_alloc_op_waits;
76837
76838-extern atomic_t fscache_n_retrievals;
76839-extern atomic_t fscache_n_retrievals_ok;
76840-extern atomic_t fscache_n_retrievals_wait;
76841-extern atomic_t fscache_n_retrievals_nodata;
76842-extern atomic_t fscache_n_retrievals_nobufs;
76843-extern atomic_t fscache_n_retrievals_intr;
76844-extern atomic_t fscache_n_retrievals_nomem;
76845-extern atomic_t fscache_n_retrievals_object_dead;
76846-extern atomic_t fscache_n_retrieval_ops;
76847-extern atomic_t fscache_n_retrieval_op_waits;
76848+extern atomic_unchecked_t fscache_n_retrievals;
76849+extern atomic_unchecked_t fscache_n_retrievals_ok;
76850+extern atomic_unchecked_t fscache_n_retrievals_wait;
76851+extern atomic_unchecked_t fscache_n_retrievals_nodata;
76852+extern atomic_unchecked_t fscache_n_retrievals_nobufs;
76853+extern atomic_unchecked_t fscache_n_retrievals_intr;
76854+extern atomic_unchecked_t fscache_n_retrievals_nomem;
76855+extern atomic_unchecked_t fscache_n_retrievals_object_dead;
76856+extern atomic_unchecked_t fscache_n_retrieval_ops;
76857+extern atomic_unchecked_t fscache_n_retrieval_op_waits;
76858
76859-extern atomic_t fscache_n_stores;
76860-extern atomic_t fscache_n_stores_ok;
76861-extern atomic_t fscache_n_stores_again;
76862-extern atomic_t fscache_n_stores_nobufs;
76863-extern atomic_t fscache_n_stores_oom;
76864-extern atomic_t fscache_n_store_ops;
76865-extern atomic_t fscache_n_store_calls;
76866-extern atomic_t fscache_n_store_pages;
76867-extern atomic_t fscache_n_store_radix_deletes;
76868-extern atomic_t fscache_n_store_pages_over_limit;
76869+extern atomic_unchecked_t fscache_n_stores;
76870+extern atomic_unchecked_t fscache_n_stores_ok;
76871+extern atomic_unchecked_t fscache_n_stores_again;
76872+extern atomic_unchecked_t fscache_n_stores_nobufs;
76873+extern atomic_unchecked_t fscache_n_stores_oom;
76874+extern atomic_unchecked_t fscache_n_store_ops;
76875+extern atomic_unchecked_t fscache_n_store_calls;
76876+extern atomic_unchecked_t fscache_n_store_pages;
76877+extern atomic_unchecked_t fscache_n_store_radix_deletes;
76878+extern atomic_unchecked_t fscache_n_store_pages_over_limit;
76879
76880-extern atomic_t fscache_n_store_vmscan_not_storing;
76881-extern atomic_t fscache_n_store_vmscan_gone;
76882-extern atomic_t fscache_n_store_vmscan_busy;
76883-extern atomic_t fscache_n_store_vmscan_cancelled;
76884-extern atomic_t fscache_n_store_vmscan_wait;
76885+extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
76886+extern atomic_unchecked_t fscache_n_store_vmscan_gone;
76887+extern atomic_unchecked_t fscache_n_store_vmscan_busy;
76888+extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
76889+extern atomic_unchecked_t fscache_n_store_vmscan_wait;
76890
76891-extern atomic_t fscache_n_marks;
76892-extern atomic_t fscache_n_uncaches;
76893+extern atomic_unchecked_t fscache_n_marks;
76894+extern atomic_unchecked_t fscache_n_uncaches;
76895
76896-extern atomic_t fscache_n_acquires;
76897-extern atomic_t fscache_n_acquires_null;
76898-extern atomic_t fscache_n_acquires_no_cache;
76899-extern atomic_t fscache_n_acquires_ok;
76900-extern atomic_t fscache_n_acquires_nobufs;
76901-extern atomic_t fscache_n_acquires_oom;
76902+extern atomic_unchecked_t fscache_n_acquires;
76903+extern atomic_unchecked_t fscache_n_acquires_null;
76904+extern atomic_unchecked_t fscache_n_acquires_no_cache;
76905+extern atomic_unchecked_t fscache_n_acquires_ok;
76906+extern atomic_unchecked_t fscache_n_acquires_nobufs;
76907+extern atomic_unchecked_t fscache_n_acquires_oom;
76908
76909-extern atomic_t fscache_n_invalidates;
76910-extern atomic_t fscache_n_invalidates_run;
76911+extern atomic_unchecked_t fscache_n_invalidates;
76912+extern atomic_unchecked_t fscache_n_invalidates_run;
76913
76914-extern atomic_t fscache_n_updates;
76915-extern atomic_t fscache_n_updates_null;
76916-extern atomic_t fscache_n_updates_run;
76917+extern atomic_unchecked_t fscache_n_updates;
76918+extern atomic_unchecked_t fscache_n_updates_null;
76919+extern atomic_unchecked_t fscache_n_updates_run;
76920
76921-extern atomic_t fscache_n_relinquishes;
76922-extern atomic_t fscache_n_relinquishes_null;
76923-extern atomic_t fscache_n_relinquishes_waitcrt;
76924-extern atomic_t fscache_n_relinquishes_retire;
76925+extern atomic_unchecked_t fscache_n_relinquishes;
76926+extern atomic_unchecked_t fscache_n_relinquishes_null;
76927+extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
76928+extern atomic_unchecked_t fscache_n_relinquishes_retire;
76929
76930-extern atomic_t fscache_n_cookie_index;
76931-extern atomic_t fscache_n_cookie_data;
76932-extern atomic_t fscache_n_cookie_special;
76933+extern atomic_unchecked_t fscache_n_cookie_index;
76934+extern atomic_unchecked_t fscache_n_cookie_data;
76935+extern atomic_unchecked_t fscache_n_cookie_special;
76936
76937-extern atomic_t fscache_n_object_alloc;
76938-extern atomic_t fscache_n_object_no_alloc;
76939-extern atomic_t fscache_n_object_lookups;
76940-extern atomic_t fscache_n_object_lookups_negative;
76941-extern atomic_t fscache_n_object_lookups_positive;
76942-extern atomic_t fscache_n_object_lookups_timed_out;
76943-extern atomic_t fscache_n_object_created;
76944-extern atomic_t fscache_n_object_avail;
76945-extern atomic_t fscache_n_object_dead;
76946+extern atomic_unchecked_t fscache_n_object_alloc;
76947+extern atomic_unchecked_t fscache_n_object_no_alloc;
76948+extern atomic_unchecked_t fscache_n_object_lookups;
76949+extern atomic_unchecked_t fscache_n_object_lookups_negative;
76950+extern atomic_unchecked_t fscache_n_object_lookups_positive;
76951+extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
76952+extern atomic_unchecked_t fscache_n_object_created;
76953+extern atomic_unchecked_t fscache_n_object_avail;
76954+extern atomic_unchecked_t fscache_n_object_dead;
76955
76956-extern atomic_t fscache_n_checkaux_none;
76957-extern atomic_t fscache_n_checkaux_okay;
76958-extern atomic_t fscache_n_checkaux_update;
76959-extern atomic_t fscache_n_checkaux_obsolete;
76960+extern atomic_unchecked_t fscache_n_checkaux_none;
76961+extern atomic_unchecked_t fscache_n_checkaux_okay;
76962+extern atomic_unchecked_t fscache_n_checkaux_update;
76963+extern atomic_unchecked_t fscache_n_checkaux_obsolete;
76964
76965 extern atomic_t fscache_n_cop_alloc_object;
76966 extern atomic_t fscache_n_cop_lookup_object;
76967@@ -276,6 +276,11 @@ static inline void fscache_stat(atomic_t *stat)
76968 atomic_inc(stat);
76969 }
76970
76971+static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
76972+{
76973+ atomic_inc_unchecked(stat);
76974+}
76975+
76976 static inline void fscache_stat_d(atomic_t *stat)
76977 {
76978 atomic_dec(stat);
76979@@ -288,6 +293,7 @@ extern const struct file_operations fscache_stats_fops;
76980
76981 #define __fscache_stat(stat) (NULL)
76982 #define fscache_stat(stat) do {} while (0)
76983+#define fscache_stat_unchecked(stat) do {} while (0)
76984 #define fscache_stat_d(stat) do {} while (0)
76985 #endif
76986
76987diff --git a/fs/fscache/object.c b/fs/fscache/object.c
76988index da032da..0076ce7 100644
76989--- a/fs/fscache/object.c
76990+++ b/fs/fscache/object.c
76991@@ -454,7 +454,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
76992 _debug("LOOKUP \"%s\" in \"%s\"",
76993 cookie->def->name, object->cache->tag->name);
76994
76995- fscache_stat(&fscache_n_object_lookups);
76996+ fscache_stat_unchecked(&fscache_n_object_lookups);
76997 fscache_stat(&fscache_n_cop_lookup_object);
76998 ret = object->cache->ops->lookup_object(object);
76999 fscache_stat_d(&fscache_n_cop_lookup_object);
77000@@ -464,7 +464,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
77001 if (ret == -ETIMEDOUT) {
77002 /* probably stuck behind another object, so move this one to
77003 * the back of the queue */
77004- fscache_stat(&fscache_n_object_lookups_timed_out);
77005+ fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
77006 _leave(" [timeout]");
77007 return NO_TRANSIT;
77008 }
77009@@ -492,7 +492,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
77010 _enter("{OBJ%x,%s}", object->debug_id, object->state->name);
77011
77012 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
77013- fscache_stat(&fscache_n_object_lookups_negative);
77014+ fscache_stat_unchecked(&fscache_n_object_lookups_negative);
77015
77016 /* Allow write requests to begin stacking up and read requests to begin
77017 * returning ENODATA.
77018@@ -527,7 +527,7 @@ void fscache_obtained_object(struct fscache_object *object)
77019 /* if we were still looking up, then we must have a positive lookup
77020 * result, in which case there may be data available */
77021 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
77022- fscache_stat(&fscache_n_object_lookups_positive);
77023+ fscache_stat_unchecked(&fscache_n_object_lookups_positive);
77024
77025 /* We do (presumably) have data */
77026 clear_bit_unlock(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
77027@@ -539,7 +539,7 @@ void fscache_obtained_object(struct fscache_object *object)
77028 clear_bit_unlock(FSCACHE_COOKIE_LOOKING_UP, &cookie->flags);
77029 wake_up_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP);
77030 } else {
77031- fscache_stat(&fscache_n_object_created);
77032+ fscache_stat_unchecked(&fscache_n_object_created);
77033 }
77034
77035 set_bit(FSCACHE_OBJECT_IS_AVAILABLE, &object->flags);
77036@@ -575,7 +575,7 @@ static const struct fscache_state *fscache_object_available(struct fscache_objec
77037 fscache_stat_d(&fscache_n_cop_lookup_complete);
77038
77039 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
77040- fscache_stat(&fscache_n_object_avail);
77041+ fscache_stat_unchecked(&fscache_n_object_avail);
77042
77043 _leave("");
77044 return transit_to(JUMPSTART_DEPS);
77045@@ -722,7 +722,7 @@ static const struct fscache_state *fscache_drop_object(struct fscache_object *ob
77046
77047 /* this just shifts the object release to the work processor */
77048 fscache_put_object(object);
77049- fscache_stat(&fscache_n_object_dead);
77050+ fscache_stat_unchecked(&fscache_n_object_dead);
77051
77052 _leave("");
77053 return transit_to(OBJECT_DEAD);
77054@@ -887,7 +887,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
77055 enum fscache_checkaux result;
77056
77057 if (!object->cookie->def->check_aux) {
77058- fscache_stat(&fscache_n_checkaux_none);
77059+ fscache_stat_unchecked(&fscache_n_checkaux_none);
77060 return FSCACHE_CHECKAUX_OKAY;
77061 }
77062
77063@@ -896,17 +896,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
77064 switch (result) {
77065 /* entry okay as is */
77066 case FSCACHE_CHECKAUX_OKAY:
77067- fscache_stat(&fscache_n_checkaux_okay);
77068+ fscache_stat_unchecked(&fscache_n_checkaux_okay);
77069 break;
77070
77071 /* entry requires update */
77072 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
77073- fscache_stat(&fscache_n_checkaux_update);
77074+ fscache_stat_unchecked(&fscache_n_checkaux_update);
77075 break;
77076
77077 /* entry requires deletion */
77078 case FSCACHE_CHECKAUX_OBSOLETE:
77079- fscache_stat(&fscache_n_checkaux_obsolete);
77080+ fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
77081 break;
77082
77083 default:
77084@@ -993,7 +993,7 @@ static const struct fscache_state *fscache_invalidate_object(struct fscache_obje
77085 {
77086 const struct fscache_state *s;
77087
77088- fscache_stat(&fscache_n_invalidates_run);
77089+ fscache_stat_unchecked(&fscache_n_invalidates_run);
77090 fscache_stat(&fscache_n_cop_invalidate_object);
77091 s = _fscache_invalidate_object(object, event);
77092 fscache_stat_d(&fscache_n_cop_invalidate_object);
77093@@ -1008,7 +1008,7 @@ static const struct fscache_state *fscache_update_object(struct fscache_object *
77094 {
77095 _enter("{OBJ%x},%d", object->debug_id, event);
77096
77097- fscache_stat(&fscache_n_updates_run);
77098+ fscache_stat_unchecked(&fscache_n_updates_run);
77099 fscache_stat(&fscache_n_cop_update_object);
77100 object->cache->ops->update_object(object);
77101 fscache_stat_d(&fscache_n_cop_update_object);
77102diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
77103index e7b87a0..a85d47a 100644
77104--- a/fs/fscache/operation.c
77105+++ b/fs/fscache/operation.c
77106@@ -17,7 +17,7 @@
77107 #include <linux/slab.h>
77108 #include "internal.h"
77109
77110-atomic_t fscache_op_debug_id;
77111+atomic_unchecked_t fscache_op_debug_id;
77112 EXPORT_SYMBOL(fscache_op_debug_id);
77113
77114 /**
77115@@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
77116 ASSERTCMP(atomic_read(&op->usage), >, 0);
77117 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
77118
77119- fscache_stat(&fscache_n_op_enqueue);
77120+ fscache_stat_unchecked(&fscache_n_op_enqueue);
77121 switch (op->flags & FSCACHE_OP_TYPE) {
77122 case FSCACHE_OP_ASYNC:
77123 _debug("queue async");
77124@@ -72,7 +72,7 @@ static void fscache_run_op(struct fscache_object *object,
77125 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
77126 if (op->processor)
77127 fscache_enqueue_operation(op);
77128- fscache_stat(&fscache_n_op_run);
77129+ fscache_stat_unchecked(&fscache_n_op_run);
77130 }
77131
77132 /*
77133@@ -104,11 +104,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
77134 if (object->n_in_progress > 0) {
77135 atomic_inc(&op->usage);
77136 list_add_tail(&op->pend_link, &object->pending_ops);
77137- fscache_stat(&fscache_n_op_pend);
77138+ fscache_stat_unchecked(&fscache_n_op_pend);
77139 } else if (!list_empty(&object->pending_ops)) {
77140 atomic_inc(&op->usage);
77141 list_add_tail(&op->pend_link, &object->pending_ops);
77142- fscache_stat(&fscache_n_op_pend);
77143+ fscache_stat_unchecked(&fscache_n_op_pend);
77144 fscache_start_operations(object);
77145 } else {
77146 ASSERTCMP(object->n_in_progress, ==, 0);
77147@@ -124,7 +124,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
77148 object->n_exclusive++; /* reads and writes must wait */
77149 atomic_inc(&op->usage);
77150 list_add_tail(&op->pend_link, &object->pending_ops);
77151- fscache_stat(&fscache_n_op_pend);
77152+ fscache_stat_unchecked(&fscache_n_op_pend);
77153 ret = 0;
77154 } else {
77155 /* If we're in any other state, there must have been an I/O
77156@@ -211,11 +211,11 @@ int fscache_submit_op(struct fscache_object *object,
77157 if (object->n_exclusive > 0) {
77158 atomic_inc(&op->usage);
77159 list_add_tail(&op->pend_link, &object->pending_ops);
77160- fscache_stat(&fscache_n_op_pend);
77161+ fscache_stat_unchecked(&fscache_n_op_pend);
77162 } else if (!list_empty(&object->pending_ops)) {
77163 atomic_inc(&op->usage);
77164 list_add_tail(&op->pend_link, &object->pending_ops);
77165- fscache_stat(&fscache_n_op_pend);
77166+ fscache_stat_unchecked(&fscache_n_op_pend);
77167 fscache_start_operations(object);
77168 } else {
77169 ASSERTCMP(object->n_exclusive, ==, 0);
77170@@ -227,10 +227,10 @@ int fscache_submit_op(struct fscache_object *object,
77171 object->n_ops++;
77172 atomic_inc(&op->usage);
77173 list_add_tail(&op->pend_link, &object->pending_ops);
77174- fscache_stat(&fscache_n_op_pend);
77175+ fscache_stat_unchecked(&fscache_n_op_pend);
77176 ret = 0;
77177 } else if (fscache_object_is_dying(object)) {
77178- fscache_stat(&fscache_n_op_rejected);
77179+ fscache_stat_unchecked(&fscache_n_op_rejected);
77180 op->state = FSCACHE_OP_ST_CANCELLED;
77181 ret = -ENOBUFS;
77182 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
77183@@ -309,7 +309,7 @@ int fscache_cancel_op(struct fscache_operation *op,
77184 ret = -EBUSY;
77185 if (op->state == FSCACHE_OP_ST_PENDING) {
77186 ASSERT(!list_empty(&op->pend_link));
77187- fscache_stat(&fscache_n_op_cancelled);
77188+ fscache_stat_unchecked(&fscache_n_op_cancelled);
77189 list_del_init(&op->pend_link);
77190 if (do_cancel)
77191 do_cancel(op);
77192@@ -341,7 +341,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
77193 while (!list_empty(&object->pending_ops)) {
77194 op = list_entry(object->pending_ops.next,
77195 struct fscache_operation, pend_link);
77196- fscache_stat(&fscache_n_op_cancelled);
77197+ fscache_stat_unchecked(&fscache_n_op_cancelled);
77198 list_del_init(&op->pend_link);
77199
77200 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
77201@@ -413,7 +413,7 @@ void fscache_put_operation(struct fscache_operation *op)
77202 op->state, ==, FSCACHE_OP_ST_CANCELLED);
77203 op->state = FSCACHE_OP_ST_DEAD;
77204
77205- fscache_stat(&fscache_n_op_release);
77206+ fscache_stat_unchecked(&fscache_n_op_release);
77207
77208 if (op->release) {
77209 op->release(op);
77210@@ -432,7 +432,7 @@ void fscache_put_operation(struct fscache_operation *op)
77211 * lock, and defer it otherwise */
77212 if (!spin_trylock(&object->lock)) {
77213 _debug("defer put");
77214- fscache_stat(&fscache_n_op_deferred_release);
77215+ fscache_stat_unchecked(&fscache_n_op_deferred_release);
77216
77217 cache = object->cache;
77218 spin_lock(&cache->op_gc_list_lock);
77219@@ -485,7 +485,7 @@ void fscache_operation_gc(struct work_struct *work)
77220
77221 _debug("GC DEFERRED REL OBJ%x OP%x",
77222 object->debug_id, op->debug_id);
77223- fscache_stat(&fscache_n_op_gc);
77224+ fscache_stat_unchecked(&fscache_n_op_gc);
77225
77226 ASSERTCMP(atomic_read(&op->usage), ==, 0);
77227 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
77228diff --git a/fs/fscache/page.c b/fs/fscache/page.c
77229index de33b3f..8be4d29 100644
77230--- a/fs/fscache/page.c
77231+++ b/fs/fscache/page.c
77232@@ -74,7 +74,7 @@ try_again:
77233 val = radix_tree_lookup(&cookie->stores, page->index);
77234 if (!val) {
77235 rcu_read_unlock();
77236- fscache_stat(&fscache_n_store_vmscan_not_storing);
77237+ fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
77238 __fscache_uncache_page(cookie, page);
77239 return true;
77240 }
77241@@ -104,11 +104,11 @@ try_again:
77242 spin_unlock(&cookie->stores_lock);
77243
77244 if (xpage) {
77245- fscache_stat(&fscache_n_store_vmscan_cancelled);
77246- fscache_stat(&fscache_n_store_radix_deletes);
77247+ fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
77248+ fscache_stat_unchecked(&fscache_n_store_radix_deletes);
77249 ASSERTCMP(xpage, ==, page);
77250 } else {
77251- fscache_stat(&fscache_n_store_vmscan_gone);
77252+ fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
77253 }
77254
77255 wake_up_bit(&cookie->flags, 0);
77256@@ -123,11 +123,11 @@ page_busy:
77257 * sleeping on memory allocation, so we may need to impose a timeout
77258 * too. */
77259 if (!(gfp & __GFP_WAIT) || !(gfp & __GFP_FS)) {
77260- fscache_stat(&fscache_n_store_vmscan_busy);
77261+ fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
77262 return false;
77263 }
77264
77265- fscache_stat(&fscache_n_store_vmscan_wait);
77266+ fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
77267 if (!release_page_wait_timeout(cookie, page))
77268 _debug("fscache writeout timeout page: %p{%lx}",
77269 page, page->index);
77270@@ -156,7 +156,7 @@ static void fscache_end_page_write(struct fscache_object *object,
77271 FSCACHE_COOKIE_STORING_TAG);
77272 if (!radix_tree_tag_get(&cookie->stores, page->index,
77273 FSCACHE_COOKIE_PENDING_TAG)) {
77274- fscache_stat(&fscache_n_store_radix_deletes);
77275+ fscache_stat_unchecked(&fscache_n_store_radix_deletes);
77276 xpage = radix_tree_delete(&cookie->stores, page->index);
77277 }
77278 spin_unlock(&cookie->stores_lock);
77279@@ -177,7 +177,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
77280
77281 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
77282
77283- fscache_stat(&fscache_n_attr_changed_calls);
77284+ fscache_stat_unchecked(&fscache_n_attr_changed_calls);
77285
77286 if (fscache_object_is_active(object)) {
77287 fscache_stat(&fscache_n_cop_attr_changed);
77288@@ -204,11 +204,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
77289
77290 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
77291
77292- fscache_stat(&fscache_n_attr_changed);
77293+ fscache_stat_unchecked(&fscache_n_attr_changed);
77294
77295 op = kzalloc(sizeof(*op), GFP_KERNEL);
77296 if (!op) {
77297- fscache_stat(&fscache_n_attr_changed_nomem);
77298+ fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
77299 _leave(" = -ENOMEM");
77300 return -ENOMEM;
77301 }
77302@@ -230,7 +230,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
77303 if (fscache_submit_exclusive_op(object, op) < 0)
77304 goto nobufs_dec;
77305 spin_unlock(&cookie->lock);
77306- fscache_stat(&fscache_n_attr_changed_ok);
77307+ fscache_stat_unchecked(&fscache_n_attr_changed_ok);
77308 fscache_put_operation(op);
77309 _leave(" = 0");
77310 return 0;
77311@@ -242,7 +242,7 @@ nobufs:
77312 kfree(op);
77313 if (wake_cookie)
77314 __fscache_wake_unused_cookie(cookie);
77315- fscache_stat(&fscache_n_attr_changed_nobufs);
77316+ fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
77317 _leave(" = %d", -ENOBUFS);
77318 return -ENOBUFS;
77319 }
77320@@ -281,7 +281,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
77321 /* allocate a retrieval operation and attempt to submit it */
77322 op = kzalloc(sizeof(*op), GFP_NOIO);
77323 if (!op) {
77324- fscache_stat(&fscache_n_retrievals_nomem);
77325+ fscache_stat_unchecked(&fscache_n_retrievals_nomem);
77326 return NULL;
77327 }
77328
77329@@ -311,12 +311,12 @@ int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
77330 return 0;
77331 }
77332
77333- fscache_stat(&fscache_n_retrievals_wait);
77334+ fscache_stat_unchecked(&fscache_n_retrievals_wait);
77335
77336 jif = jiffies;
77337 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
77338 TASK_INTERRUPTIBLE) != 0) {
77339- fscache_stat(&fscache_n_retrievals_intr);
77340+ fscache_stat_unchecked(&fscache_n_retrievals_intr);
77341 _leave(" = -ERESTARTSYS");
77342 return -ERESTARTSYS;
77343 }
77344@@ -345,8 +345,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
77345 */
77346 int fscache_wait_for_operation_activation(struct fscache_object *object,
77347 struct fscache_operation *op,
77348- atomic_t *stat_op_waits,
77349- atomic_t *stat_object_dead,
77350+ atomic_unchecked_t *stat_op_waits,
77351+ atomic_unchecked_t *stat_object_dead,
77352 void (*do_cancel)(struct fscache_operation *))
77353 {
77354 int ret;
77355@@ -356,7 +356,7 @@ int fscache_wait_for_operation_activation(struct fscache_object *object,
77356
77357 _debug(">>> WT");
77358 if (stat_op_waits)
77359- fscache_stat(stat_op_waits);
77360+ fscache_stat_unchecked(stat_op_waits);
77361 if (wait_on_bit(&op->flags, FSCACHE_OP_WAITING,
77362 TASK_INTERRUPTIBLE) != 0) {
77363 ret = fscache_cancel_op(op, do_cancel);
77364@@ -373,7 +373,7 @@ int fscache_wait_for_operation_activation(struct fscache_object *object,
77365 check_if_dead:
77366 if (op->state == FSCACHE_OP_ST_CANCELLED) {
77367 if (stat_object_dead)
77368- fscache_stat(stat_object_dead);
77369+ fscache_stat_unchecked(stat_object_dead);
77370 _leave(" = -ENOBUFS [cancelled]");
77371 return -ENOBUFS;
77372 }
77373@@ -381,7 +381,7 @@ check_if_dead:
77374 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->state);
77375 fscache_cancel_op(op, do_cancel);
77376 if (stat_object_dead)
77377- fscache_stat(stat_object_dead);
77378+ fscache_stat_unchecked(stat_object_dead);
77379 return -ENOBUFS;
77380 }
77381 return 0;
77382@@ -409,7 +409,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
77383
77384 _enter("%p,%p,,,", cookie, page);
77385
77386- fscache_stat(&fscache_n_retrievals);
77387+ fscache_stat_unchecked(&fscache_n_retrievals);
77388
77389 if (hlist_empty(&cookie->backing_objects))
77390 goto nobufs;
77391@@ -451,7 +451,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
77392 goto nobufs_unlock_dec;
77393 spin_unlock(&cookie->lock);
77394
77395- fscache_stat(&fscache_n_retrieval_ops);
77396+ fscache_stat_unchecked(&fscache_n_retrieval_ops);
77397
77398 /* pin the netfs read context in case we need to do the actual netfs
77399 * read because we've encountered a cache read failure */
77400@@ -482,15 +482,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
77401
77402 error:
77403 if (ret == -ENOMEM)
77404- fscache_stat(&fscache_n_retrievals_nomem);
77405+ fscache_stat_unchecked(&fscache_n_retrievals_nomem);
77406 else if (ret == -ERESTARTSYS)
77407- fscache_stat(&fscache_n_retrievals_intr);
77408+ fscache_stat_unchecked(&fscache_n_retrievals_intr);
77409 else if (ret == -ENODATA)
77410- fscache_stat(&fscache_n_retrievals_nodata);
77411+ fscache_stat_unchecked(&fscache_n_retrievals_nodata);
77412 else if (ret < 0)
77413- fscache_stat(&fscache_n_retrievals_nobufs);
77414+ fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
77415 else
77416- fscache_stat(&fscache_n_retrievals_ok);
77417+ fscache_stat_unchecked(&fscache_n_retrievals_ok);
77418
77419 fscache_put_retrieval(op);
77420 _leave(" = %d", ret);
77421@@ -505,7 +505,7 @@ nobufs_unlock:
77422 __fscache_wake_unused_cookie(cookie);
77423 kfree(op);
77424 nobufs:
77425- fscache_stat(&fscache_n_retrievals_nobufs);
77426+ fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
77427 _leave(" = -ENOBUFS");
77428 return -ENOBUFS;
77429 }
77430@@ -544,7 +544,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
77431
77432 _enter("%p,,%d,,,", cookie, *nr_pages);
77433
77434- fscache_stat(&fscache_n_retrievals);
77435+ fscache_stat_unchecked(&fscache_n_retrievals);
77436
77437 if (hlist_empty(&cookie->backing_objects))
77438 goto nobufs;
77439@@ -582,7 +582,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
77440 goto nobufs_unlock_dec;
77441 spin_unlock(&cookie->lock);
77442
77443- fscache_stat(&fscache_n_retrieval_ops);
77444+ fscache_stat_unchecked(&fscache_n_retrieval_ops);
77445
77446 /* pin the netfs read context in case we need to do the actual netfs
77447 * read because we've encountered a cache read failure */
77448@@ -613,15 +613,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
77449
77450 error:
77451 if (ret == -ENOMEM)
77452- fscache_stat(&fscache_n_retrievals_nomem);
77453+ fscache_stat_unchecked(&fscache_n_retrievals_nomem);
77454 else if (ret == -ERESTARTSYS)
77455- fscache_stat(&fscache_n_retrievals_intr);
77456+ fscache_stat_unchecked(&fscache_n_retrievals_intr);
77457 else if (ret == -ENODATA)
77458- fscache_stat(&fscache_n_retrievals_nodata);
77459+ fscache_stat_unchecked(&fscache_n_retrievals_nodata);
77460 else if (ret < 0)
77461- fscache_stat(&fscache_n_retrievals_nobufs);
77462+ fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
77463 else
77464- fscache_stat(&fscache_n_retrievals_ok);
77465+ fscache_stat_unchecked(&fscache_n_retrievals_ok);
77466
77467 fscache_put_retrieval(op);
77468 _leave(" = %d", ret);
77469@@ -636,7 +636,7 @@ nobufs_unlock:
77470 if (wake_cookie)
77471 __fscache_wake_unused_cookie(cookie);
77472 nobufs:
77473- fscache_stat(&fscache_n_retrievals_nobufs);
77474+ fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
77475 _leave(" = -ENOBUFS");
77476 return -ENOBUFS;
77477 }
77478@@ -661,7 +661,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
77479
77480 _enter("%p,%p,,,", cookie, page);
77481
77482- fscache_stat(&fscache_n_allocs);
77483+ fscache_stat_unchecked(&fscache_n_allocs);
77484
77485 if (hlist_empty(&cookie->backing_objects))
77486 goto nobufs;
77487@@ -695,7 +695,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
77488 goto nobufs_unlock_dec;
77489 spin_unlock(&cookie->lock);
77490
77491- fscache_stat(&fscache_n_alloc_ops);
77492+ fscache_stat_unchecked(&fscache_n_alloc_ops);
77493
77494 ret = fscache_wait_for_operation_activation(
77495 object, &op->op,
77496@@ -712,11 +712,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
77497
77498 error:
77499 if (ret == -ERESTARTSYS)
77500- fscache_stat(&fscache_n_allocs_intr);
77501+ fscache_stat_unchecked(&fscache_n_allocs_intr);
77502 else if (ret < 0)
77503- fscache_stat(&fscache_n_allocs_nobufs);
77504+ fscache_stat_unchecked(&fscache_n_allocs_nobufs);
77505 else
77506- fscache_stat(&fscache_n_allocs_ok);
77507+ fscache_stat_unchecked(&fscache_n_allocs_ok);
77508
77509 fscache_put_retrieval(op);
77510 _leave(" = %d", ret);
77511@@ -730,7 +730,7 @@ nobufs_unlock:
77512 if (wake_cookie)
77513 __fscache_wake_unused_cookie(cookie);
77514 nobufs:
77515- fscache_stat(&fscache_n_allocs_nobufs);
77516+ fscache_stat_unchecked(&fscache_n_allocs_nobufs);
77517 _leave(" = -ENOBUFS");
77518 return -ENOBUFS;
77519 }
77520@@ -806,7 +806,7 @@ static void fscache_write_op(struct fscache_operation *_op)
77521
77522 spin_lock(&cookie->stores_lock);
77523
77524- fscache_stat(&fscache_n_store_calls);
77525+ fscache_stat_unchecked(&fscache_n_store_calls);
77526
77527 /* find a page to store */
77528 page = NULL;
77529@@ -817,7 +817,7 @@ static void fscache_write_op(struct fscache_operation *_op)
77530 page = results[0];
77531 _debug("gang %d [%lx]", n, page->index);
77532 if (page->index > op->store_limit) {
77533- fscache_stat(&fscache_n_store_pages_over_limit);
77534+ fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
77535 goto superseded;
77536 }
77537
77538@@ -829,7 +829,7 @@ static void fscache_write_op(struct fscache_operation *_op)
77539 spin_unlock(&cookie->stores_lock);
77540 spin_unlock(&object->lock);
77541
77542- fscache_stat(&fscache_n_store_pages);
77543+ fscache_stat_unchecked(&fscache_n_store_pages);
77544 fscache_stat(&fscache_n_cop_write_page);
77545 ret = object->cache->ops->write_page(op, page);
77546 fscache_stat_d(&fscache_n_cop_write_page);
77547@@ -933,7 +933,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
77548 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
77549 ASSERT(PageFsCache(page));
77550
77551- fscache_stat(&fscache_n_stores);
77552+ fscache_stat_unchecked(&fscache_n_stores);
77553
77554 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
77555 _leave(" = -ENOBUFS [invalidating]");
77556@@ -992,7 +992,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
77557 spin_unlock(&cookie->stores_lock);
77558 spin_unlock(&object->lock);
77559
77560- op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
77561+ op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
77562 op->store_limit = object->store_limit;
77563
77564 __fscache_use_cookie(cookie);
77565@@ -1001,8 +1001,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
77566
77567 spin_unlock(&cookie->lock);
77568 radix_tree_preload_end();
77569- fscache_stat(&fscache_n_store_ops);
77570- fscache_stat(&fscache_n_stores_ok);
77571+ fscache_stat_unchecked(&fscache_n_store_ops);
77572+ fscache_stat_unchecked(&fscache_n_stores_ok);
77573
77574 /* the work queue now carries its own ref on the object */
77575 fscache_put_operation(&op->op);
77576@@ -1010,14 +1010,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
77577 return 0;
77578
77579 already_queued:
77580- fscache_stat(&fscache_n_stores_again);
77581+ fscache_stat_unchecked(&fscache_n_stores_again);
77582 already_pending:
77583 spin_unlock(&cookie->stores_lock);
77584 spin_unlock(&object->lock);
77585 spin_unlock(&cookie->lock);
77586 radix_tree_preload_end();
77587 kfree(op);
77588- fscache_stat(&fscache_n_stores_ok);
77589+ fscache_stat_unchecked(&fscache_n_stores_ok);
77590 _leave(" = 0");
77591 return 0;
77592
77593@@ -1039,14 +1039,14 @@ nobufs:
77594 kfree(op);
77595 if (wake_cookie)
77596 __fscache_wake_unused_cookie(cookie);
77597- fscache_stat(&fscache_n_stores_nobufs);
77598+ fscache_stat_unchecked(&fscache_n_stores_nobufs);
77599 _leave(" = -ENOBUFS");
77600 return -ENOBUFS;
77601
77602 nomem_free:
77603 kfree(op);
77604 nomem:
77605- fscache_stat(&fscache_n_stores_oom);
77606+ fscache_stat_unchecked(&fscache_n_stores_oom);
77607 _leave(" = -ENOMEM");
77608 return -ENOMEM;
77609 }
77610@@ -1064,7 +1064,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
77611 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
77612 ASSERTCMP(page, !=, NULL);
77613
77614- fscache_stat(&fscache_n_uncaches);
77615+ fscache_stat_unchecked(&fscache_n_uncaches);
77616
77617 /* cache withdrawal may beat us to it */
77618 if (!PageFsCache(page))
77619@@ -1115,7 +1115,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
77620 struct fscache_cookie *cookie = op->op.object->cookie;
77621
77622 #ifdef CONFIG_FSCACHE_STATS
77623- atomic_inc(&fscache_n_marks);
77624+ atomic_inc_unchecked(&fscache_n_marks);
77625 #endif
77626
77627 _debug("- mark %p{%lx}", page, page->index);
77628diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
77629index 40d13c7..ddf52b9 100644
77630--- a/fs/fscache/stats.c
77631+++ b/fs/fscache/stats.c
77632@@ -18,99 +18,99 @@
77633 /*
77634 * operation counters
77635 */
77636-atomic_t fscache_n_op_pend;
77637-atomic_t fscache_n_op_run;
77638-atomic_t fscache_n_op_enqueue;
77639-atomic_t fscache_n_op_requeue;
77640-atomic_t fscache_n_op_deferred_release;
77641-atomic_t fscache_n_op_release;
77642-atomic_t fscache_n_op_gc;
77643-atomic_t fscache_n_op_cancelled;
77644-atomic_t fscache_n_op_rejected;
77645+atomic_unchecked_t fscache_n_op_pend;
77646+atomic_unchecked_t fscache_n_op_run;
77647+atomic_unchecked_t fscache_n_op_enqueue;
77648+atomic_unchecked_t fscache_n_op_requeue;
77649+atomic_unchecked_t fscache_n_op_deferred_release;
77650+atomic_unchecked_t fscache_n_op_release;
77651+atomic_unchecked_t fscache_n_op_gc;
77652+atomic_unchecked_t fscache_n_op_cancelled;
77653+atomic_unchecked_t fscache_n_op_rejected;
77654
77655-atomic_t fscache_n_attr_changed;
77656-atomic_t fscache_n_attr_changed_ok;
77657-atomic_t fscache_n_attr_changed_nobufs;
77658-atomic_t fscache_n_attr_changed_nomem;
77659-atomic_t fscache_n_attr_changed_calls;
77660+atomic_unchecked_t fscache_n_attr_changed;
77661+atomic_unchecked_t fscache_n_attr_changed_ok;
77662+atomic_unchecked_t fscache_n_attr_changed_nobufs;
77663+atomic_unchecked_t fscache_n_attr_changed_nomem;
77664+atomic_unchecked_t fscache_n_attr_changed_calls;
77665
77666-atomic_t fscache_n_allocs;
77667-atomic_t fscache_n_allocs_ok;
77668-atomic_t fscache_n_allocs_wait;
77669-atomic_t fscache_n_allocs_nobufs;
77670-atomic_t fscache_n_allocs_intr;
77671-atomic_t fscache_n_allocs_object_dead;
77672-atomic_t fscache_n_alloc_ops;
77673-atomic_t fscache_n_alloc_op_waits;
77674+atomic_unchecked_t fscache_n_allocs;
77675+atomic_unchecked_t fscache_n_allocs_ok;
77676+atomic_unchecked_t fscache_n_allocs_wait;
77677+atomic_unchecked_t fscache_n_allocs_nobufs;
77678+atomic_unchecked_t fscache_n_allocs_intr;
77679+atomic_unchecked_t fscache_n_allocs_object_dead;
77680+atomic_unchecked_t fscache_n_alloc_ops;
77681+atomic_unchecked_t fscache_n_alloc_op_waits;
77682
77683-atomic_t fscache_n_retrievals;
77684-atomic_t fscache_n_retrievals_ok;
77685-atomic_t fscache_n_retrievals_wait;
77686-atomic_t fscache_n_retrievals_nodata;
77687-atomic_t fscache_n_retrievals_nobufs;
77688-atomic_t fscache_n_retrievals_intr;
77689-atomic_t fscache_n_retrievals_nomem;
77690-atomic_t fscache_n_retrievals_object_dead;
77691-atomic_t fscache_n_retrieval_ops;
77692-atomic_t fscache_n_retrieval_op_waits;
77693+atomic_unchecked_t fscache_n_retrievals;
77694+atomic_unchecked_t fscache_n_retrievals_ok;
77695+atomic_unchecked_t fscache_n_retrievals_wait;
77696+atomic_unchecked_t fscache_n_retrievals_nodata;
77697+atomic_unchecked_t fscache_n_retrievals_nobufs;
77698+atomic_unchecked_t fscache_n_retrievals_intr;
77699+atomic_unchecked_t fscache_n_retrievals_nomem;
77700+atomic_unchecked_t fscache_n_retrievals_object_dead;
77701+atomic_unchecked_t fscache_n_retrieval_ops;
77702+atomic_unchecked_t fscache_n_retrieval_op_waits;
77703
77704-atomic_t fscache_n_stores;
77705-atomic_t fscache_n_stores_ok;
77706-atomic_t fscache_n_stores_again;
77707-atomic_t fscache_n_stores_nobufs;
77708-atomic_t fscache_n_stores_oom;
77709-atomic_t fscache_n_store_ops;
77710-atomic_t fscache_n_store_calls;
77711-atomic_t fscache_n_store_pages;
77712-atomic_t fscache_n_store_radix_deletes;
77713-atomic_t fscache_n_store_pages_over_limit;
77714+atomic_unchecked_t fscache_n_stores;
77715+atomic_unchecked_t fscache_n_stores_ok;
77716+atomic_unchecked_t fscache_n_stores_again;
77717+atomic_unchecked_t fscache_n_stores_nobufs;
77718+atomic_unchecked_t fscache_n_stores_oom;
77719+atomic_unchecked_t fscache_n_store_ops;
77720+atomic_unchecked_t fscache_n_store_calls;
77721+atomic_unchecked_t fscache_n_store_pages;
77722+atomic_unchecked_t fscache_n_store_radix_deletes;
77723+atomic_unchecked_t fscache_n_store_pages_over_limit;
77724
77725-atomic_t fscache_n_store_vmscan_not_storing;
77726-atomic_t fscache_n_store_vmscan_gone;
77727-atomic_t fscache_n_store_vmscan_busy;
77728-atomic_t fscache_n_store_vmscan_cancelled;
77729-atomic_t fscache_n_store_vmscan_wait;
77730+atomic_unchecked_t fscache_n_store_vmscan_not_storing;
77731+atomic_unchecked_t fscache_n_store_vmscan_gone;
77732+atomic_unchecked_t fscache_n_store_vmscan_busy;
77733+atomic_unchecked_t fscache_n_store_vmscan_cancelled;
77734+atomic_unchecked_t fscache_n_store_vmscan_wait;
77735
77736-atomic_t fscache_n_marks;
77737-atomic_t fscache_n_uncaches;
77738+atomic_unchecked_t fscache_n_marks;
77739+atomic_unchecked_t fscache_n_uncaches;
77740
77741-atomic_t fscache_n_acquires;
77742-atomic_t fscache_n_acquires_null;
77743-atomic_t fscache_n_acquires_no_cache;
77744-atomic_t fscache_n_acquires_ok;
77745-atomic_t fscache_n_acquires_nobufs;
77746-atomic_t fscache_n_acquires_oom;
77747+atomic_unchecked_t fscache_n_acquires;
77748+atomic_unchecked_t fscache_n_acquires_null;
77749+atomic_unchecked_t fscache_n_acquires_no_cache;
77750+atomic_unchecked_t fscache_n_acquires_ok;
77751+atomic_unchecked_t fscache_n_acquires_nobufs;
77752+atomic_unchecked_t fscache_n_acquires_oom;
77753
77754-atomic_t fscache_n_invalidates;
77755-atomic_t fscache_n_invalidates_run;
77756+atomic_unchecked_t fscache_n_invalidates;
77757+atomic_unchecked_t fscache_n_invalidates_run;
77758
77759-atomic_t fscache_n_updates;
77760-atomic_t fscache_n_updates_null;
77761-atomic_t fscache_n_updates_run;
77762+atomic_unchecked_t fscache_n_updates;
77763+atomic_unchecked_t fscache_n_updates_null;
77764+atomic_unchecked_t fscache_n_updates_run;
77765
77766-atomic_t fscache_n_relinquishes;
77767-atomic_t fscache_n_relinquishes_null;
77768-atomic_t fscache_n_relinquishes_waitcrt;
77769-atomic_t fscache_n_relinquishes_retire;
77770+atomic_unchecked_t fscache_n_relinquishes;
77771+atomic_unchecked_t fscache_n_relinquishes_null;
77772+atomic_unchecked_t fscache_n_relinquishes_waitcrt;
77773+atomic_unchecked_t fscache_n_relinquishes_retire;
77774
77775-atomic_t fscache_n_cookie_index;
77776-atomic_t fscache_n_cookie_data;
77777-atomic_t fscache_n_cookie_special;
77778+atomic_unchecked_t fscache_n_cookie_index;
77779+atomic_unchecked_t fscache_n_cookie_data;
77780+atomic_unchecked_t fscache_n_cookie_special;
77781
77782-atomic_t fscache_n_object_alloc;
77783-atomic_t fscache_n_object_no_alloc;
77784-atomic_t fscache_n_object_lookups;
77785-atomic_t fscache_n_object_lookups_negative;
77786-atomic_t fscache_n_object_lookups_positive;
77787-atomic_t fscache_n_object_lookups_timed_out;
77788-atomic_t fscache_n_object_created;
77789-atomic_t fscache_n_object_avail;
77790-atomic_t fscache_n_object_dead;
77791+atomic_unchecked_t fscache_n_object_alloc;
77792+atomic_unchecked_t fscache_n_object_no_alloc;
77793+atomic_unchecked_t fscache_n_object_lookups;
77794+atomic_unchecked_t fscache_n_object_lookups_negative;
77795+atomic_unchecked_t fscache_n_object_lookups_positive;
77796+atomic_unchecked_t fscache_n_object_lookups_timed_out;
77797+atomic_unchecked_t fscache_n_object_created;
77798+atomic_unchecked_t fscache_n_object_avail;
77799+atomic_unchecked_t fscache_n_object_dead;
77800
77801-atomic_t fscache_n_checkaux_none;
77802-atomic_t fscache_n_checkaux_okay;
77803-atomic_t fscache_n_checkaux_update;
77804-atomic_t fscache_n_checkaux_obsolete;
77805+atomic_unchecked_t fscache_n_checkaux_none;
77806+atomic_unchecked_t fscache_n_checkaux_okay;
77807+atomic_unchecked_t fscache_n_checkaux_update;
77808+atomic_unchecked_t fscache_n_checkaux_obsolete;
77809
77810 atomic_t fscache_n_cop_alloc_object;
77811 atomic_t fscache_n_cop_lookup_object;
77812@@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
77813 seq_puts(m, "FS-Cache statistics\n");
77814
77815 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
77816- atomic_read(&fscache_n_cookie_index),
77817- atomic_read(&fscache_n_cookie_data),
77818- atomic_read(&fscache_n_cookie_special));
77819+ atomic_read_unchecked(&fscache_n_cookie_index),
77820+ atomic_read_unchecked(&fscache_n_cookie_data),
77821+ atomic_read_unchecked(&fscache_n_cookie_special));
77822
77823 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
77824- atomic_read(&fscache_n_object_alloc),
77825- atomic_read(&fscache_n_object_no_alloc),
77826- atomic_read(&fscache_n_object_avail),
77827- atomic_read(&fscache_n_object_dead));
77828+ atomic_read_unchecked(&fscache_n_object_alloc),
77829+ atomic_read_unchecked(&fscache_n_object_no_alloc),
77830+ atomic_read_unchecked(&fscache_n_object_avail),
77831+ atomic_read_unchecked(&fscache_n_object_dead));
77832 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
77833- atomic_read(&fscache_n_checkaux_none),
77834- atomic_read(&fscache_n_checkaux_okay),
77835- atomic_read(&fscache_n_checkaux_update),
77836- atomic_read(&fscache_n_checkaux_obsolete));
77837+ atomic_read_unchecked(&fscache_n_checkaux_none),
77838+ atomic_read_unchecked(&fscache_n_checkaux_okay),
77839+ atomic_read_unchecked(&fscache_n_checkaux_update),
77840+ atomic_read_unchecked(&fscache_n_checkaux_obsolete));
77841
77842 seq_printf(m, "Pages : mrk=%u unc=%u\n",
77843- atomic_read(&fscache_n_marks),
77844- atomic_read(&fscache_n_uncaches));
77845+ atomic_read_unchecked(&fscache_n_marks),
77846+ atomic_read_unchecked(&fscache_n_uncaches));
77847
77848 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
77849 " oom=%u\n",
77850- atomic_read(&fscache_n_acquires),
77851- atomic_read(&fscache_n_acquires_null),
77852- atomic_read(&fscache_n_acquires_no_cache),
77853- atomic_read(&fscache_n_acquires_ok),
77854- atomic_read(&fscache_n_acquires_nobufs),
77855- atomic_read(&fscache_n_acquires_oom));
77856+ atomic_read_unchecked(&fscache_n_acquires),
77857+ atomic_read_unchecked(&fscache_n_acquires_null),
77858+ atomic_read_unchecked(&fscache_n_acquires_no_cache),
77859+ atomic_read_unchecked(&fscache_n_acquires_ok),
77860+ atomic_read_unchecked(&fscache_n_acquires_nobufs),
77861+ atomic_read_unchecked(&fscache_n_acquires_oom));
77862
77863 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
77864- atomic_read(&fscache_n_object_lookups),
77865- atomic_read(&fscache_n_object_lookups_negative),
77866- atomic_read(&fscache_n_object_lookups_positive),
77867- atomic_read(&fscache_n_object_created),
77868- atomic_read(&fscache_n_object_lookups_timed_out));
77869+ atomic_read_unchecked(&fscache_n_object_lookups),
77870+ atomic_read_unchecked(&fscache_n_object_lookups_negative),
77871+ atomic_read_unchecked(&fscache_n_object_lookups_positive),
77872+ atomic_read_unchecked(&fscache_n_object_created),
77873+ atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
77874
77875 seq_printf(m, "Invals : n=%u run=%u\n",
77876- atomic_read(&fscache_n_invalidates),
77877- atomic_read(&fscache_n_invalidates_run));
77878+ atomic_read_unchecked(&fscache_n_invalidates),
77879+ atomic_read_unchecked(&fscache_n_invalidates_run));
77880
77881 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
77882- atomic_read(&fscache_n_updates),
77883- atomic_read(&fscache_n_updates_null),
77884- atomic_read(&fscache_n_updates_run));
77885+ atomic_read_unchecked(&fscache_n_updates),
77886+ atomic_read_unchecked(&fscache_n_updates_null),
77887+ atomic_read_unchecked(&fscache_n_updates_run));
77888
77889 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
77890- atomic_read(&fscache_n_relinquishes),
77891- atomic_read(&fscache_n_relinquishes_null),
77892- atomic_read(&fscache_n_relinquishes_waitcrt),
77893- atomic_read(&fscache_n_relinquishes_retire));
77894+ atomic_read_unchecked(&fscache_n_relinquishes),
77895+ atomic_read_unchecked(&fscache_n_relinquishes_null),
77896+ atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
77897+ atomic_read_unchecked(&fscache_n_relinquishes_retire));
77898
77899 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
77900- atomic_read(&fscache_n_attr_changed),
77901- atomic_read(&fscache_n_attr_changed_ok),
77902- atomic_read(&fscache_n_attr_changed_nobufs),
77903- atomic_read(&fscache_n_attr_changed_nomem),
77904- atomic_read(&fscache_n_attr_changed_calls));
77905+ atomic_read_unchecked(&fscache_n_attr_changed),
77906+ atomic_read_unchecked(&fscache_n_attr_changed_ok),
77907+ atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
77908+ atomic_read_unchecked(&fscache_n_attr_changed_nomem),
77909+ atomic_read_unchecked(&fscache_n_attr_changed_calls));
77910
77911 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
77912- atomic_read(&fscache_n_allocs),
77913- atomic_read(&fscache_n_allocs_ok),
77914- atomic_read(&fscache_n_allocs_wait),
77915- atomic_read(&fscache_n_allocs_nobufs),
77916- atomic_read(&fscache_n_allocs_intr));
77917+ atomic_read_unchecked(&fscache_n_allocs),
77918+ atomic_read_unchecked(&fscache_n_allocs_ok),
77919+ atomic_read_unchecked(&fscache_n_allocs_wait),
77920+ atomic_read_unchecked(&fscache_n_allocs_nobufs),
77921+ atomic_read_unchecked(&fscache_n_allocs_intr));
77922 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
77923- atomic_read(&fscache_n_alloc_ops),
77924- atomic_read(&fscache_n_alloc_op_waits),
77925- atomic_read(&fscache_n_allocs_object_dead));
77926+ atomic_read_unchecked(&fscache_n_alloc_ops),
77927+ atomic_read_unchecked(&fscache_n_alloc_op_waits),
77928+ atomic_read_unchecked(&fscache_n_allocs_object_dead));
77929
77930 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
77931 " int=%u oom=%u\n",
77932- atomic_read(&fscache_n_retrievals),
77933- atomic_read(&fscache_n_retrievals_ok),
77934- atomic_read(&fscache_n_retrievals_wait),
77935- atomic_read(&fscache_n_retrievals_nodata),
77936- atomic_read(&fscache_n_retrievals_nobufs),
77937- atomic_read(&fscache_n_retrievals_intr),
77938- atomic_read(&fscache_n_retrievals_nomem));
77939+ atomic_read_unchecked(&fscache_n_retrievals),
77940+ atomic_read_unchecked(&fscache_n_retrievals_ok),
77941+ atomic_read_unchecked(&fscache_n_retrievals_wait),
77942+ atomic_read_unchecked(&fscache_n_retrievals_nodata),
77943+ atomic_read_unchecked(&fscache_n_retrievals_nobufs),
77944+ atomic_read_unchecked(&fscache_n_retrievals_intr),
77945+ atomic_read_unchecked(&fscache_n_retrievals_nomem));
77946 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
77947- atomic_read(&fscache_n_retrieval_ops),
77948- atomic_read(&fscache_n_retrieval_op_waits),
77949- atomic_read(&fscache_n_retrievals_object_dead));
77950+ atomic_read_unchecked(&fscache_n_retrieval_ops),
77951+ atomic_read_unchecked(&fscache_n_retrieval_op_waits),
77952+ atomic_read_unchecked(&fscache_n_retrievals_object_dead));
77953
77954 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
77955- atomic_read(&fscache_n_stores),
77956- atomic_read(&fscache_n_stores_ok),
77957- atomic_read(&fscache_n_stores_again),
77958- atomic_read(&fscache_n_stores_nobufs),
77959- atomic_read(&fscache_n_stores_oom));
77960+ atomic_read_unchecked(&fscache_n_stores),
77961+ atomic_read_unchecked(&fscache_n_stores_ok),
77962+ atomic_read_unchecked(&fscache_n_stores_again),
77963+ atomic_read_unchecked(&fscache_n_stores_nobufs),
77964+ atomic_read_unchecked(&fscache_n_stores_oom));
77965 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
77966- atomic_read(&fscache_n_store_ops),
77967- atomic_read(&fscache_n_store_calls),
77968- atomic_read(&fscache_n_store_pages),
77969- atomic_read(&fscache_n_store_radix_deletes),
77970- atomic_read(&fscache_n_store_pages_over_limit));
77971+ atomic_read_unchecked(&fscache_n_store_ops),
77972+ atomic_read_unchecked(&fscache_n_store_calls),
77973+ atomic_read_unchecked(&fscache_n_store_pages),
77974+ atomic_read_unchecked(&fscache_n_store_radix_deletes),
77975+ atomic_read_unchecked(&fscache_n_store_pages_over_limit));
77976
77977 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
77978- atomic_read(&fscache_n_store_vmscan_not_storing),
77979- atomic_read(&fscache_n_store_vmscan_gone),
77980- atomic_read(&fscache_n_store_vmscan_busy),
77981- atomic_read(&fscache_n_store_vmscan_cancelled),
77982- atomic_read(&fscache_n_store_vmscan_wait));
77983+ atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
77984+ atomic_read_unchecked(&fscache_n_store_vmscan_gone),
77985+ atomic_read_unchecked(&fscache_n_store_vmscan_busy),
77986+ atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
77987+ atomic_read_unchecked(&fscache_n_store_vmscan_wait));
77988
77989 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
77990- atomic_read(&fscache_n_op_pend),
77991- atomic_read(&fscache_n_op_run),
77992- atomic_read(&fscache_n_op_enqueue),
77993- atomic_read(&fscache_n_op_cancelled),
77994- atomic_read(&fscache_n_op_rejected));
77995+ atomic_read_unchecked(&fscache_n_op_pend),
77996+ atomic_read_unchecked(&fscache_n_op_run),
77997+ atomic_read_unchecked(&fscache_n_op_enqueue),
77998+ atomic_read_unchecked(&fscache_n_op_cancelled),
77999+ atomic_read_unchecked(&fscache_n_op_rejected));
78000 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
78001- atomic_read(&fscache_n_op_deferred_release),
78002- atomic_read(&fscache_n_op_release),
78003- atomic_read(&fscache_n_op_gc));
78004+ atomic_read_unchecked(&fscache_n_op_deferred_release),
78005+ atomic_read_unchecked(&fscache_n_op_release),
78006+ atomic_read_unchecked(&fscache_n_op_gc));
78007
78008 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
78009 atomic_read(&fscache_n_cop_alloc_object),
78010diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
78011index e5bbf74..9bfdaf3 100644
78012--- a/fs/fuse/cuse.c
78013+++ b/fs/fuse/cuse.c
78014@@ -602,10 +602,12 @@ static int __init cuse_init(void)
78015 INIT_LIST_HEAD(&cuse_conntbl[i]);
78016
78017 /* inherit and extend fuse_dev_operations */
78018- cuse_channel_fops = fuse_dev_operations;
78019- cuse_channel_fops.owner = THIS_MODULE;
78020- cuse_channel_fops.open = cuse_channel_open;
78021- cuse_channel_fops.release = cuse_channel_release;
78022+ pax_open_kernel();
78023+ memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
78024+ *(void **)&cuse_channel_fops.owner = THIS_MODULE;
78025+ *(void **)&cuse_channel_fops.open = cuse_channel_open;
78026+ *(void **)&cuse_channel_fops.release = cuse_channel_release;
78027+ pax_close_kernel();
78028
78029 cuse_class = class_create(THIS_MODULE, "cuse");
78030 if (IS_ERR(cuse_class))
78031diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
78032index c8b68ab..97190db 100644
78033--- a/fs/fuse/dev.c
78034+++ b/fs/fuse/dev.c
78035@@ -1398,7 +1398,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
78036 ret = 0;
78037 pipe_lock(pipe);
78038
78039- if (!pipe->readers) {
78040+ if (!atomic_read(&pipe->readers)) {
78041 send_sig(SIGPIPE, current, 0);
78042 if (!ret)
78043 ret = -EPIPE;
78044@@ -1427,7 +1427,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
78045 page_nr++;
78046 ret += buf->len;
78047
78048- if (pipe->files)
78049+ if (atomic_read(&pipe->files))
78050 do_wakeup = 1;
78051 }
78052
78053diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
78054index 0572bca..cb9c3fa 100644
78055--- a/fs/fuse/dir.c
78056+++ b/fs/fuse/dir.c
78057@@ -1394,7 +1394,7 @@ static char *read_link(struct dentry *dentry)
78058 return link;
78059 }
78060
78061-static void free_link(char *link)
78062+static void free_link(const char *link)
78063 {
78064 if (!IS_ERR(link))
78065 free_page((unsigned long) link);
78066diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
78067index 0fa8062..755b198 100644
78068--- a/fs/gfs2/glock.c
78069+++ b/fs/gfs2/glock.c
78070@@ -385,9 +385,9 @@ static void state_change(struct gfs2_glock *gl, unsigned int new_state)
78071 if (held1 != held2) {
78072 GLOCK_BUG_ON(gl, __lockref_is_dead(&gl->gl_lockref));
78073 if (held2)
78074- gl->gl_lockref.count++;
78075+ __lockref_inc(&gl->gl_lockref);
78076 else
78077- gl->gl_lockref.count--;
78078+ __lockref_dec(&gl->gl_lockref);
78079 }
78080 if (held1 && held2 && list_empty(&gl->gl_holders))
78081 clear_bit(GLF_QUEUED, &gl->gl_flags);
78082@@ -614,9 +614,9 @@ out:
78083 out_sched:
78084 clear_bit(GLF_LOCK, &gl->gl_flags);
78085 smp_mb__after_atomic();
78086- gl->gl_lockref.count++;
78087+ __lockref_inc(&gl->gl_lockref);
78088 if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0)
78089- gl->gl_lockref.count--;
78090+ __lockref_dec(&gl->gl_lockref);
78091 return;
78092
78093 out_unlock:
78094@@ -742,7 +742,7 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
78095 gl->gl_sbd = sdp;
78096 gl->gl_flags = 0;
78097 gl->gl_name = name;
78098- gl->gl_lockref.count = 1;
78099+ __lockref_set(&gl->gl_lockref, 1);
78100 gl->gl_state = LM_ST_UNLOCKED;
78101 gl->gl_target = LM_ST_UNLOCKED;
78102 gl->gl_demote_state = LM_ST_EXCLUSIVE;
78103@@ -1020,9 +1020,9 @@ int gfs2_glock_nq(struct gfs2_holder *gh)
78104 if (unlikely((LM_FLAG_NOEXP & gh->gh_flags) &&
78105 test_and_clear_bit(GLF_FROZEN, &gl->gl_flags))) {
78106 set_bit(GLF_REPLY_PENDING, &gl->gl_flags);
78107- gl->gl_lockref.count++;
78108+ __lockref_inc(&gl->gl_lockref);
78109 if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0)
78110- gl->gl_lockref.count--;
78111+ __lockref_dec(&gl->gl_lockref);
78112 }
78113 run_queue(gl, 1);
78114 spin_unlock(&gl->gl_spin);
78115@@ -1325,7 +1325,7 @@ void gfs2_glock_complete(struct gfs2_glock *gl, int ret)
78116 }
78117 }
78118
78119- gl->gl_lockref.count++;
78120+ __lockref_inc(&gl->gl_lockref);
78121 set_bit(GLF_REPLY_PENDING, &gl->gl_flags);
78122 spin_unlock(&gl->gl_spin);
78123
78124@@ -1384,12 +1384,12 @@ add_back_to_lru:
78125 goto add_back_to_lru;
78126 }
78127 clear_bit(GLF_LRU, &gl->gl_flags);
78128- gl->gl_lockref.count++;
78129+ __lockref_inc(&gl->gl_lockref);
78130 if (demote_ok(gl))
78131 handle_callback(gl, LM_ST_UNLOCKED, 0, false);
78132 WARN_ON(!test_and_clear_bit(GLF_LOCK, &gl->gl_flags));
78133 if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0)
78134- gl->gl_lockref.count--;
78135+ __lockref_dec(&gl->gl_lockref);
78136 spin_unlock(&gl->gl_spin);
78137 cond_resched_lock(&lru_lock);
78138 }
78139@@ -1719,7 +1719,7 @@ void gfs2_dump_glock(struct seq_file *seq, const struct gfs2_glock *gl)
78140 state2str(gl->gl_demote_state), dtime,
78141 atomic_read(&gl->gl_ail_count),
78142 atomic_read(&gl->gl_revokes),
78143- (int)gl->gl_lockref.count, gl->gl_hold_time);
78144+ __lockref_read(&gl->gl_lockref), gl->gl_hold_time);
78145
78146 list_for_each_entry(gh, &gl->gl_holders, gh_list)
78147 dump_holder(seq, gh);
78148diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c
78149index fe91951..ce38a6e 100644
78150--- a/fs/gfs2/glops.c
78151+++ b/fs/gfs2/glops.c
78152@@ -544,9 +544,9 @@ static void iopen_go_callback(struct gfs2_glock *gl, bool remote)
78153
78154 if (gl->gl_demote_state == LM_ST_UNLOCKED &&
78155 gl->gl_state == LM_ST_SHARED && ip) {
78156- gl->gl_lockref.count++;
78157+ __lockref_inc(&gl->gl_lockref);
78158 if (queue_work(gfs2_delete_workqueue, &gl->gl_delete) == 0)
78159- gl->gl_lockref.count--;
78160+ __lockref_dec(&gl->gl_lockref);
78161 }
78162 }
78163
78164diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c
78165index e3065cb..45e7117 100644
78166--- a/fs/gfs2/quota.c
78167+++ b/fs/gfs2/quota.c
78168@@ -154,7 +154,7 @@ static enum lru_status gfs2_qd_isolate(struct list_head *item,
78169 if (!spin_trylock(&qd->qd_lockref.lock))
78170 return LRU_SKIP;
78171
78172- if (qd->qd_lockref.count == 0) {
78173+ if (__lockref_read(&qd->qd_lockref) == 0) {
78174 lockref_mark_dead(&qd->qd_lockref);
78175 list_lru_isolate_move(lru, &qd->qd_lru, dispose);
78176 }
78177@@ -221,7 +221,7 @@ static struct gfs2_quota_data *qd_alloc(unsigned hash, struct gfs2_sbd *sdp, str
78178 return NULL;
78179
78180 qd->qd_sbd = sdp;
78181- qd->qd_lockref.count = 1;
78182+ __lockref_set(&qd->qd_lockref, 1);
78183 spin_lock_init(&qd->qd_lockref.lock);
78184 qd->qd_id = qid;
78185 qd->qd_slot = -1;
78186@@ -312,7 +312,7 @@ static void qd_put(struct gfs2_quota_data *qd)
78187 if (lockref_put_or_lock(&qd->qd_lockref))
78188 return;
78189
78190- qd->qd_lockref.count = 0;
78191+ __lockref_set(&qd->qd_lockref, 0);
78192 list_lru_add(&gfs2_qd_lru, &qd->qd_lru);
78193 spin_unlock(&qd->qd_lockref.lock);
78194
78195diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
78196index 07d8d8f..2c2a4e7 100644
78197--- a/fs/hostfs/hostfs_kern.c
78198+++ b/fs/hostfs/hostfs_kern.c
78199@@ -918,7 +918,7 @@ static void *hostfs_follow_link(struct dentry *dentry, struct nameidata *nd)
78200
78201 static void hostfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
78202 {
78203- char *s = nd_get_link(nd);
78204+ const char *s = nd_get_link(nd);
78205 if (!IS_ERR(s))
78206 __putname(s);
78207 }
78208diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
78209index 87724c1..5a5e53f 100644
78210--- a/fs/hugetlbfs/inode.c
78211+++ b/fs/hugetlbfs/inode.c
78212@@ -151,6 +151,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
78213 struct mm_struct *mm = current->mm;
78214 struct vm_area_struct *vma;
78215 struct hstate *h = hstate_file(file);
78216+ unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
78217 struct vm_unmapped_area_info info;
78218
78219 if (len & ~huge_page_mask(h))
78220@@ -164,17 +165,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
78221 return addr;
78222 }
78223
78224+#ifdef CONFIG_PAX_RANDMMAP
78225+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
78226+#endif
78227+
78228 if (addr) {
78229 addr = ALIGN(addr, huge_page_size(h));
78230 vma = find_vma(mm, addr);
78231- if (TASK_SIZE - len >= addr &&
78232- (!vma || addr + len <= vma->vm_start))
78233+ if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
78234 return addr;
78235 }
78236
78237 info.flags = 0;
78238 info.length = len;
78239 info.low_limit = TASK_UNMAPPED_BASE;
78240+
78241+#ifdef CONFIG_PAX_RANDMMAP
78242+ if (mm->pax_flags & MF_PAX_RANDMMAP)
78243+ info.low_limit += mm->delta_mmap;
78244+#endif
78245+
78246 info.high_limit = TASK_SIZE;
78247 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
78248 info.align_offset = 0;
78249@@ -939,7 +949,7 @@ static struct file_system_type hugetlbfs_fs_type = {
78250 };
78251 MODULE_ALIAS_FS("hugetlbfs");
78252
78253-static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
78254+struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
78255
78256 static int can_do_hugetlb_shm(void)
78257 {
78258diff --git a/fs/inode.c b/fs/inode.c
78259index 6e342ca..0538cb7 100644
78260--- a/fs/inode.c
78261+++ b/fs/inode.c
78262@@ -830,16 +830,20 @@ unsigned int get_next_ino(void)
78263 unsigned int *p = &get_cpu_var(last_ino);
78264 unsigned int res = *p;
78265
78266+start:
78267+
78268 #ifdef CONFIG_SMP
78269 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
78270- static atomic_t shared_last_ino;
78271- int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
78272+ static atomic_unchecked_t shared_last_ino;
78273+ int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
78274
78275 res = next - LAST_INO_BATCH;
78276 }
78277 #endif
78278
78279- *p = ++res;
78280+ if (unlikely(!++res))
78281+ goto start; /* never zero */
78282+ *p = res;
78283 put_cpu_var(last_ino);
78284 return res;
78285 }
78286diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
78287index 4a6cf28..d3a29d3 100644
78288--- a/fs/jffs2/erase.c
78289+++ b/fs/jffs2/erase.c
78290@@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
78291 struct jffs2_unknown_node marker = {
78292 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
78293 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
78294- .totlen = cpu_to_je32(c->cleanmarker_size)
78295+ .totlen = cpu_to_je32(c->cleanmarker_size),
78296+ .hdr_crc = cpu_to_je32(0)
78297 };
78298
78299 jffs2_prealloc_raw_node_refs(c, jeb, 1);
78300diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
78301index 09ed551..45684f8 100644
78302--- a/fs/jffs2/wbuf.c
78303+++ b/fs/jffs2/wbuf.c
78304@@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
78305 {
78306 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
78307 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
78308- .totlen = constant_cpu_to_je32(8)
78309+ .totlen = constant_cpu_to_je32(8),
78310+ .hdr_crc = constant_cpu_to_je32(0)
78311 };
78312
78313 /*
78314diff --git a/fs/jfs/super.c b/fs/jfs/super.c
78315index 4cd9798..8dfe86a 100644
78316--- a/fs/jfs/super.c
78317+++ b/fs/jfs/super.c
78318@@ -901,7 +901,7 @@ static int __init init_jfs_fs(void)
78319
78320 jfs_inode_cachep =
78321 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
78322- SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
78323+ SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
78324 init_once);
78325 if (jfs_inode_cachep == NULL)
78326 return -ENOMEM;
78327diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
78328index 2d48d28..82eddad 100644
78329--- a/fs/kernfs/dir.c
78330+++ b/fs/kernfs/dir.c
78331@@ -182,7 +182,7 @@ struct kernfs_node *kernfs_get_parent(struct kernfs_node *kn)
78332 *
78333 * Returns 31 bit hash of ns + name (so it fits in an off_t )
78334 */
78335-static unsigned int kernfs_name_hash(const char *name, const void *ns)
78336+static unsigned int kernfs_name_hash(const unsigned char *name, const void *ns)
78337 {
78338 unsigned long hash = init_name_hash();
78339 unsigned int len = strlen(name);
78340@@ -873,6 +873,12 @@ static int kernfs_iop_mkdir(struct inode *dir, struct dentry *dentry,
78341 ret = scops->mkdir(parent, dentry->d_name.name, mode);
78342
78343 kernfs_put_active(parent);
78344+
78345+ if (!ret) {
78346+ struct dentry *dentry_ret = kernfs_iop_lookup(dir, dentry, 0);
78347+ ret = PTR_ERR_OR_ZERO(dentry_ret);
78348+ }
78349+
78350 return ret;
78351 }
78352
78353diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c
78354index 2bacb99..f745182 100644
78355--- a/fs/kernfs/file.c
78356+++ b/fs/kernfs/file.c
78357@@ -34,7 +34,7 @@ static DEFINE_MUTEX(kernfs_open_file_mutex);
78358
78359 struct kernfs_open_node {
78360 atomic_t refcnt;
78361- atomic_t event;
78362+ atomic_unchecked_t event;
78363 wait_queue_head_t poll;
78364 struct list_head files; /* goes through kernfs_open_file.list */
78365 };
78366@@ -163,7 +163,7 @@ static int kernfs_seq_show(struct seq_file *sf, void *v)
78367 {
78368 struct kernfs_open_file *of = sf->private;
78369
78370- of->event = atomic_read(&of->kn->attr.open->event);
78371+ of->event = atomic_read_unchecked(&of->kn->attr.open->event);
78372
78373 return of->kn->attr.ops->seq_show(sf, v);
78374 }
78375@@ -207,7 +207,7 @@ static ssize_t kernfs_file_direct_read(struct kernfs_open_file *of,
78376 goto out_free;
78377 }
78378
78379- of->event = atomic_read(&of->kn->attr.open->event);
78380+ of->event = atomic_read_unchecked(&of->kn->attr.open->event);
78381 ops = kernfs_ops(of->kn);
78382 if (ops->read)
78383 len = ops->read(of, buf, len, *ppos);
78384@@ -272,7 +272,7 @@ static ssize_t kernfs_fop_write(struct file *file, const char __user *user_buf,
78385 {
78386 struct kernfs_open_file *of = kernfs_of(file);
78387 const struct kernfs_ops *ops;
78388- size_t len;
78389+ ssize_t len;
78390 char *buf;
78391
78392 if (of->atomic_write_len) {
78393@@ -385,12 +385,12 @@ static int kernfs_vma_page_mkwrite(struct vm_area_struct *vma,
78394 return ret;
78395 }
78396
78397-static int kernfs_vma_access(struct vm_area_struct *vma, unsigned long addr,
78398- void *buf, int len, int write)
78399+static ssize_t kernfs_vma_access(struct vm_area_struct *vma, unsigned long addr,
78400+ void *buf, size_t len, int write)
78401 {
78402 struct file *file = vma->vm_file;
78403 struct kernfs_open_file *of = kernfs_of(file);
78404- int ret;
78405+ ssize_t ret;
78406
78407 if (!of->vm_ops)
78408 return -EINVAL;
78409@@ -569,7 +569,7 @@ static int kernfs_get_open_node(struct kernfs_node *kn,
78410 return -ENOMEM;
78411
78412 atomic_set(&new_on->refcnt, 0);
78413- atomic_set(&new_on->event, 1);
78414+ atomic_set_unchecked(&new_on->event, 1);
78415 init_waitqueue_head(&new_on->poll);
78416 INIT_LIST_HEAD(&new_on->files);
78417 goto retry;
78418@@ -793,7 +793,7 @@ static unsigned int kernfs_fop_poll(struct file *filp, poll_table *wait)
78419
78420 kernfs_put_active(kn);
78421
78422- if (of->event != atomic_read(&on->event))
78423+ if (of->event != atomic_read_unchecked(&on->event))
78424 goto trigger;
78425
78426 return DEFAULT_POLLMASK;
78427@@ -824,7 +824,7 @@ repeat:
78428
78429 on = kn->attr.open;
78430 if (on) {
78431- atomic_inc(&on->event);
78432+ atomic_inc_unchecked(&on->event);
78433 wake_up_interruptible(&on->poll);
78434 }
78435
78436diff --git a/fs/kernfs/symlink.c b/fs/kernfs/symlink.c
78437index 8a19889..4c3069a 100644
78438--- a/fs/kernfs/symlink.c
78439+++ b/fs/kernfs/symlink.c
78440@@ -128,7 +128,7 @@ static void *kernfs_iop_follow_link(struct dentry *dentry, struct nameidata *nd)
78441 static void kernfs_iop_put_link(struct dentry *dentry, struct nameidata *nd,
78442 void *cookie)
78443 {
78444- char *page = nd_get_link(nd);
78445+ const char *page = nd_get_link(nd);
78446 if (!IS_ERR(page))
78447 free_page((unsigned long)page);
78448 }
78449diff --git a/fs/libfs.c b/fs/libfs.c
78450index 0281359..24971ac 100644
78451--- a/fs/libfs.c
78452+++ b/fs/libfs.c
78453@@ -160,6 +160,9 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
78454
78455 for (p = q->next; p != &dentry->d_subdirs; p = p->next) {
78456 struct dentry *next = list_entry(p, struct dentry, d_child);
78457+ char d_name[sizeof(next->d_iname)];
78458+ const unsigned char *name;
78459+
78460 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
78461 if (!simple_positive(next)) {
78462 spin_unlock(&next->d_lock);
78463@@ -168,7 +171,12 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
78464
78465 spin_unlock(&next->d_lock);
78466 spin_unlock(&dentry->d_lock);
78467- if (!dir_emit(ctx, next->d_name.name, next->d_name.len,
78468+ name = next->d_name.name;
78469+ if (name == next->d_iname) {
78470+ memcpy(d_name, name, next->d_name.len);
78471+ name = d_name;
78472+ }
78473+ if (!dir_emit(ctx, name, next->d_name.len,
78474 d_inode(next)->i_ino, dt_type(d_inode(next))))
78475 return 0;
78476 spin_lock(&dentry->d_lock);
78477@@ -1027,7 +1035,7 @@ EXPORT_SYMBOL(noop_fsync);
78478 void kfree_put_link(struct dentry *dentry, struct nameidata *nd,
78479 void *cookie)
78480 {
78481- char *s = nd_get_link(nd);
78482+ const char *s = nd_get_link(nd);
78483 if (!IS_ERR(s))
78484 kfree(s);
78485 }
78486diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
78487index acd3947..1f896e2 100644
78488--- a/fs/lockd/clntproc.c
78489+++ b/fs/lockd/clntproc.c
78490@@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
78491 /*
78492 * Cookie counter for NLM requests
78493 */
78494-static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
78495+static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
78496
78497 void nlmclnt_next_cookie(struct nlm_cookie *c)
78498 {
78499- u32 cookie = atomic_inc_return(&nlm_cookie);
78500+ u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
78501
78502 memcpy(c->data, &cookie, 4);
78503 c->len=4;
78504diff --git a/fs/mount.h b/fs/mount.h
78505index 6a61c2b..bd79179 100644
78506--- a/fs/mount.h
78507+++ b/fs/mount.h
78508@@ -13,7 +13,7 @@ struct mnt_namespace {
78509 u64 seq; /* Sequence number to prevent loops */
78510 wait_queue_head_t poll;
78511 u64 event;
78512-};
78513+} __randomize_layout;
78514
78515 struct mnt_pcp {
78516 int mnt_count;
78517@@ -65,7 +65,7 @@ struct mount {
78518 struct hlist_head mnt_pins;
78519 struct fs_pin mnt_umount;
78520 struct dentry *mnt_ex_mountpoint;
78521-};
78522+} __randomize_layout;
78523
78524 #define MNT_NS_INTERNAL ERR_PTR(-EINVAL) /* distinct from any mnt_namespace */
78525
78526diff --git a/fs/namei.c b/fs/namei.c
78527index fe30d3b..cf767ae 100644
78528--- a/fs/namei.c
78529+++ b/fs/namei.c
78530@@ -336,17 +336,32 @@ int generic_permission(struct inode *inode, int mask)
78531 if (ret != -EACCES)
78532 return ret;
78533
78534+#ifdef CONFIG_GRKERNSEC
78535+ /* we'll block if we have to log due to a denied capability use */
78536+ if (mask & MAY_NOT_BLOCK)
78537+ return -ECHILD;
78538+#endif
78539+
78540 if (S_ISDIR(inode->i_mode)) {
78541 /* DACs are overridable for directories */
78542- if (capable_wrt_inode_uidgid(inode, CAP_DAC_OVERRIDE))
78543- return 0;
78544 if (!(mask & MAY_WRITE))
78545- if (capable_wrt_inode_uidgid(inode,
78546- CAP_DAC_READ_SEARCH))
78547+ if (capable_wrt_inode_uidgid_nolog(inode, CAP_DAC_OVERRIDE) ||
78548+ capable_wrt_inode_uidgid(inode, CAP_DAC_READ_SEARCH))
78549 return 0;
78550+ if (capable_wrt_inode_uidgid(inode, CAP_DAC_OVERRIDE))
78551+ return 0;
78552 return -EACCES;
78553 }
78554 /*
78555+ * Searching includes executable on directories, else just read.
78556+ */
78557+ mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
78558+ if (mask == MAY_READ)
78559+ if (capable_wrt_inode_uidgid_nolog(inode, CAP_DAC_OVERRIDE) ||
78560+ capable_wrt_inode_uidgid(inode, CAP_DAC_READ_SEARCH))
78561+ return 0;
78562+
78563+ /*
78564 * Read/write DACs are always overridable.
78565 * Executable DACs are overridable when there is
78566 * at least one exec bit set.
78567@@ -355,14 +370,6 @@ int generic_permission(struct inode *inode, int mask)
78568 if (capable_wrt_inode_uidgid(inode, CAP_DAC_OVERRIDE))
78569 return 0;
78570
78571- /*
78572- * Searching includes executable on directories, else just read.
78573- */
78574- mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
78575- if (mask == MAY_READ)
78576- if (capable_wrt_inode_uidgid(inode, CAP_DAC_READ_SEARCH))
78577- return 0;
78578-
78579 return -EACCES;
78580 }
78581 EXPORT_SYMBOL(generic_permission);
78582@@ -502,7 +509,7 @@ struct nameidata {
78583 int last_type;
78584 unsigned depth;
78585 struct file *base;
78586- char *saved_names[MAX_NESTED_LINKS + 1];
78587+ const char *saved_names[MAX_NESTED_LINKS + 1];
78588 };
78589
78590 /*
78591@@ -713,13 +720,13 @@ void nd_jump_link(struct nameidata *nd, struct path *path)
78592 nd->flags |= LOOKUP_JUMPED;
78593 }
78594
78595-void nd_set_link(struct nameidata *nd, char *path)
78596+void nd_set_link(struct nameidata *nd, const char *path)
78597 {
78598 nd->saved_names[nd->depth] = path;
78599 }
78600 EXPORT_SYMBOL(nd_set_link);
78601
78602-char *nd_get_link(struct nameidata *nd)
78603+const char *nd_get_link(const struct nameidata *nd)
78604 {
78605 return nd->saved_names[nd->depth];
78606 }
78607@@ -854,7 +861,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
78608 {
78609 struct dentry *dentry = link->dentry;
78610 int error;
78611- char *s;
78612+ const char *s;
78613
78614 BUG_ON(nd->flags & LOOKUP_RCU);
78615
78616@@ -875,6 +882,11 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
78617 if (error)
78618 goto out_put_nd_path;
78619
78620+ if (gr_handle_follow_link(dentry, nd->path.mnt)) {
78621+ error = -EACCES;
78622+ goto out_put_nd_path;
78623+ }
78624+
78625 nd->last_type = LAST_BIND;
78626 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
78627 error = PTR_ERR(*p);
78628@@ -1647,6 +1659,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
78629 if (res)
78630 break;
78631 res = walk_component(nd, path, LOOKUP_FOLLOW);
78632+ if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
78633+ res = -EACCES;
78634 put_link(nd, &link, cookie);
78635 } while (res > 0);
78636
78637@@ -1719,7 +1733,7 @@ EXPORT_SYMBOL(full_name_hash);
78638 static inline u64 hash_name(const char *name)
78639 {
78640 unsigned long a, b, adata, bdata, mask, hash, len;
78641- const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
78642+ static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
78643
78644 hash = a = 0;
78645 len = -sizeof(unsigned long);
78646@@ -2015,6 +2029,8 @@ static int path_lookupat(int dfd, const struct filename *name,
78647 if (err)
78648 break;
78649 err = lookup_last(nd, &path);
78650+ if (!err && gr_handle_symlink_owner(&link, nd->inode))
78651+ err = -EACCES;
78652 put_link(nd, &link, cookie);
78653 }
78654 }
78655@@ -2022,6 +2038,13 @@ static int path_lookupat(int dfd, const struct filename *name,
78656 if (!err)
78657 err = complete_walk(nd);
78658
78659+ if (!err && !(nd->flags & LOOKUP_PARENT)) {
78660+ if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
78661+ path_put(&nd->path);
78662+ err = -ENOENT;
78663+ }
78664+ }
78665+
78666 if (!err && nd->flags & LOOKUP_DIRECTORY) {
78667 if (!d_can_lookup(nd->path.dentry)) {
78668 path_put(&nd->path);
78669@@ -2042,8 +2065,15 @@ static int filename_lookup(int dfd, struct filename *name,
78670 if (unlikely(retval == -ESTALE))
78671 retval = path_lookupat(dfd, name, flags | LOOKUP_REVAL, nd);
78672
78673- if (likely(!retval))
78674+ if (likely(!retval)) {
78675 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
78676+ if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
78677+ if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
78678+ path_put(&nd->path);
78679+ return -ENOENT;
78680+ }
78681+ }
78682+ }
78683 return retval;
78684 }
78685
78686@@ -2621,6 +2651,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
78687 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
78688 return -EPERM;
78689
78690+ if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
78691+ return -EPERM;
78692+ if (gr_handle_rawio(inode))
78693+ return -EPERM;
78694+ if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
78695+ return -EACCES;
78696+
78697 return 0;
78698 }
78699
78700@@ -2852,7 +2889,7 @@ looked_up:
78701 * cleared otherwise prior to returning.
78702 */
78703 static int lookup_open(struct nameidata *nd, struct path *path,
78704- struct file *file,
78705+ struct path *link, struct file *file,
78706 const struct open_flags *op,
78707 bool got_write, int *opened)
78708 {
78709@@ -2887,6 +2924,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
78710 /* Negative dentry, just create the file */
78711 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
78712 umode_t mode = op->mode;
78713+
78714+ if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
78715+ error = -EACCES;
78716+ goto out_dput;
78717+ }
78718+
78719+ if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
78720+ error = -EACCES;
78721+ goto out_dput;
78722+ }
78723+
78724 if (!IS_POSIXACL(dir->d_inode))
78725 mode &= ~current_umask();
78726 /*
78727@@ -2908,6 +2956,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
78728 nd->flags & LOOKUP_EXCL);
78729 if (error)
78730 goto out_dput;
78731+ else
78732+ gr_handle_create(dentry, nd->path.mnt);
78733 }
78734 out_no_open:
78735 path->dentry = dentry;
78736@@ -2922,7 +2972,7 @@ out_dput:
78737 /*
78738 * Handle the last step of open()
78739 */
78740-static int do_last(struct nameidata *nd, struct path *path,
78741+static int do_last(struct nameidata *nd, struct path *path, struct path *link,
78742 struct file *file, const struct open_flags *op,
78743 int *opened, struct filename *name)
78744 {
78745@@ -2972,6 +3022,15 @@ static int do_last(struct nameidata *nd, struct path *path,
78746 if (error)
78747 return error;
78748
78749+ if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
78750+ error = -ENOENT;
78751+ goto out;
78752+ }
78753+ if (link && gr_handle_symlink_owner(link, nd->inode)) {
78754+ error = -EACCES;
78755+ goto out;
78756+ }
78757+
78758 audit_inode(name, dir, LOOKUP_PARENT);
78759 error = -EISDIR;
78760 /* trailing slashes? */
78761@@ -2991,7 +3050,7 @@ retry_lookup:
78762 */
78763 }
78764 mutex_lock(&dir->d_inode->i_mutex);
78765- error = lookup_open(nd, path, file, op, got_write, opened);
78766+ error = lookup_open(nd, path, link, file, op, got_write, opened);
78767 mutex_unlock(&dir->d_inode->i_mutex);
78768
78769 if (error <= 0) {
78770@@ -3015,11 +3074,28 @@ retry_lookup:
78771 goto finish_open_created;
78772 }
78773
78774+ if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
78775+ error = -ENOENT;
78776+ goto exit_dput;
78777+ }
78778+ if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
78779+ error = -EACCES;
78780+ goto exit_dput;
78781+ }
78782+
78783 /*
78784 * create/update audit record if it already exists.
78785 */
78786- if (d_is_positive(path->dentry))
78787+ if (d_is_positive(path->dentry)) {
78788+ /* only check if O_CREAT is specified, all other checks need to go
78789+ into may_open */
78790+ if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
78791+ error = -EACCES;
78792+ goto exit_dput;
78793+ }
78794+
78795 audit_inode(name, path->dentry, 0);
78796+ }
78797
78798 /*
78799 * If atomic_open() acquired write access it is dropped now due to
78800@@ -3060,6 +3136,11 @@ finish_lookup:
78801 }
78802 }
78803 BUG_ON(inode != path->dentry->d_inode);
78804+ /* if we're resolving a symlink to another symlink */
78805+ if (link && gr_handle_symlink_owner(link, inode)) {
78806+ error = -EACCES;
78807+ goto out;
78808+ }
78809 return 1;
78810 }
78811
78812@@ -3079,7 +3160,18 @@ finish_open:
78813 path_put(&save_parent);
78814 return error;
78815 }
78816+
78817+ if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
78818+ error = -ENOENT;
78819+ goto out;
78820+ }
78821+ if (link && gr_handle_symlink_owner(link, nd->inode)) {
78822+ error = -EACCES;
78823+ goto out;
78824+ }
78825+
78826 audit_inode(name, nd->path.dentry, 0);
78827+
78828 error = -EISDIR;
78829 if ((open_flag & O_CREAT) && d_is_dir(nd->path.dentry))
78830 goto out;
78831@@ -3240,7 +3332,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
78832 if (unlikely(error))
78833 goto out;
78834
78835- error = do_last(nd, &path, file, op, &opened, pathname);
78836+ error = do_last(nd, &path, NULL, file, op, &opened, pathname);
78837 while (unlikely(error > 0)) { /* trailing symlink */
78838 struct path link = path;
78839 void *cookie;
78840@@ -3258,7 +3350,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
78841 error = follow_link(&link, nd, &cookie);
78842 if (unlikely(error))
78843 break;
78844- error = do_last(nd, &path, file, op, &opened, pathname);
78845+ error = do_last(nd, &path, &link, file, op, &opened, pathname);
78846 put_link(nd, &link, cookie);
78847 }
78848 out:
78849@@ -3361,9 +3453,11 @@ static struct dentry *filename_create(int dfd, struct filename *name,
78850 goto unlock;
78851
78852 error = -EEXIST;
78853- if (d_is_positive(dentry))
78854+ if (d_is_positive(dentry)) {
78855+ if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt))
78856+ error = -ENOENT;
78857 goto fail;
78858-
78859+ }
78860 /*
78861 * Special case - lookup gave negative, but... we had foo/bar/
78862 * From the vfs_mknod() POV we just have a negative dentry -
78863@@ -3428,6 +3522,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
78864 }
78865 EXPORT_SYMBOL(user_path_create);
78866
78867+static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
78868+{
78869+ struct filename *tmp = getname(pathname);
78870+ struct dentry *res;
78871+ if (IS_ERR(tmp))
78872+ return ERR_CAST(tmp);
78873+ res = kern_path_create(dfd, tmp->name, path, lookup_flags);
78874+ if (IS_ERR(res))
78875+ putname(tmp);
78876+ else
78877+ *to = tmp;
78878+ return res;
78879+}
78880+
78881 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
78882 {
78883 int error = may_create(dir, dentry);
78884@@ -3491,6 +3599,17 @@ retry:
78885
78886 if (!IS_POSIXACL(path.dentry->d_inode))
78887 mode &= ~current_umask();
78888+
78889+ if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
78890+ error = -EPERM;
78891+ goto out;
78892+ }
78893+
78894+ if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
78895+ error = -EACCES;
78896+ goto out;
78897+ }
78898+
78899 error = security_path_mknod(&path, dentry, mode, dev);
78900 if (error)
78901 goto out;
78902@@ -3506,6 +3625,8 @@ retry:
78903 error = vfs_mknod(path.dentry->d_inode,dentry,mode,0);
78904 break;
78905 }
78906+ if (!error)
78907+ gr_handle_create(dentry, path.mnt);
78908 out:
78909 done_path_create(&path, dentry);
78910 if (retry_estale(error, lookup_flags)) {
78911@@ -3560,9 +3681,16 @@ retry:
78912
78913 if (!IS_POSIXACL(path.dentry->d_inode))
78914 mode &= ~current_umask();
78915+ if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
78916+ error = -EACCES;
78917+ goto out;
78918+ }
78919 error = security_path_mkdir(&path, dentry, mode);
78920 if (!error)
78921 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
78922+ if (!error)
78923+ gr_handle_create(dentry, path.mnt);
78924+out:
78925 done_path_create(&path, dentry);
78926 if (retry_estale(error, lookup_flags)) {
78927 lookup_flags |= LOOKUP_REVAL;
78928@@ -3595,7 +3723,7 @@ void dentry_unhash(struct dentry *dentry)
78929 {
78930 shrink_dcache_parent(dentry);
78931 spin_lock(&dentry->d_lock);
78932- if (dentry->d_lockref.count == 1)
78933+ if (__lockref_read(&dentry->d_lockref) == 1)
78934 __d_drop(dentry);
78935 spin_unlock(&dentry->d_lock);
78936 }
78937@@ -3646,6 +3774,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
78938 struct filename *name;
78939 struct dentry *dentry;
78940 struct nameidata nd;
78941+ u64 saved_ino = 0;
78942+ dev_t saved_dev = 0;
78943 unsigned int lookup_flags = 0;
78944 retry:
78945 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
78946@@ -3678,10 +3808,21 @@ retry:
78947 error = -ENOENT;
78948 goto exit3;
78949 }
78950+
78951+ saved_ino = gr_get_ino_from_dentry(dentry);
78952+ saved_dev = gr_get_dev_from_dentry(dentry);
78953+
78954+ if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
78955+ error = -EACCES;
78956+ goto exit3;
78957+ }
78958+
78959 error = security_path_rmdir(&nd.path, dentry);
78960 if (error)
78961 goto exit3;
78962 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
78963+ if (!error && (saved_dev || saved_ino))
78964+ gr_handle_delete(saved_ino, saved_dev);
78965 exit3:
78966 dput(dentry);
78967 exit2:
78968@@ -3774,6 +3915,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
78969 struct nameidata nd;
78970 struct inode *inode = NULL;
78971 struct inode *delegated_inode = NULL;
78972+ u64 saved_ino = 0;
78973+ dev_t saved_dev = 0;
78974 unsigned int lookup_flags = 0;
78975 retry:
78976 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
78977@@ -3800,10 +3943,22 @@ retry_deleg:
78978 if (d_is_negative(dentry))
78979 goto slashes;
78980 ihold(inode);
78981+
78982+ if (inode->i_nlink <= 1) {
78983+ saved_ino = gr_get_ino_from_dentry(dentry);
78984+ saved_dev = gr_get_dev_from_dentry(dentry);
78985+ }
78986+ if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
78987+ error = -EACCES;
78988+ goto exit2;
78989+ }
78990+
78991 error = security_path_unlink(&nd.path, dentry);
78992 if (error)
78993 goto exit2;
78994 error = vfs_unlink(nd.path.dentry->d_inode, dentry, &delegated_inode);
78995+ if (!error && (saved_ino || saved_dev))
78996+ gr_handle_delete(saved_ino, saved_dev);
78997 exit2:
78998 dput(dentry);
78999 }
79000@@ -3892,9 +4047,17 @@ retry:
79001 if (IS_ERR(dentry))
79002 goto out_putname;
79003
79004+ if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
79005+ error = -EACCES;
79006+ goto out;
79007+ }
79008+
79009 error = security_path_symlink(&path, dentry, from->name);
79010 if (!error)
79011 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
79012+ if (!error)
79013+ gr_handle_create(dentry, path.mnt);
79014+out:
79015 done_path_create(&path, dentry);
79016 if (retry_estale(error, lookup_flags)) {
79017 lookup_flags |= LOOKUP_REVAL;
79018@@ -3998,6 +4161,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
79019 struct dentry *new_dentry;
79020 struct path old_path, new_path;
79021 struct inode *delegated_inode = NULL;
79022+ struct filename *to = NULL;
79023 int how = 0;
79024 int error;
79025
79026@@ -4021,7 +4185,7 @@ retry:
79027 if (error)
79028 return error;
79029
79030- new_dentry = user_path_create(newdfd, newname, &new_path,
79031+ new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
79032 (how & LOOKUP_REVAL));
79033 error = PTR_ERR(new_dentry);
79034 if (IS_ERR(new_dentry))
79035@@ -4033,11 +4197,26 @@ retry:
79036 error = may_linkat(&old_path);
79037 if (unlikely(error))
79038 goto out_dput;
79039+
79040+ if (gr_handle_hardlink(old_path.dentry, old_path.mnt, to)) {
79041+ error = -EACCES;
79042+ goto out_dput;
79043+ }
79044+
79045+ if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
79046+ old_path.dentry, old_path.mnt, to)) {
79047+ error = -EACCES;
79048+ goto out_dput;
79049+ }
79050+
79051 error = security_path_link(old_path.dentry, &new_path, new_dentry);
79052 if (error)
79053 goto out_dput;
79054 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry, &delegated_inode);
79055+ if (!error)
79056+ gr_handle_create(new_dentry, new_path.mnt);
79057 out_dput:
79058+ putname(to);
79059 done_path_create(&new_path, new_dentry);
79060 if (delegated_inode) {
79061 error = break_deleg_wait(&delegated_inode);
79062@@ -4353,6 +4532,20 @@ retry_deleg:
79063 if (new_dentry == trap)
79064 goto exit5;
79065
79066+ if (gr_bad_chroot_rename(old_dentry, oldnd.path.mnt, new_dentry, newnd.path.mnt)) {
79067+ /* use EXDEV error to cause 'mv' to switch to an alternative
79068+ * method for usability
79069+ */
79070+ error = -EXDEV;
79071+ goto exit5;
79072+ }
79073+
79074+ error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
79075+ old_dentry, d_backing_inode(old_dir), oldnd.path.mnt,
79076+ to, flags);
79077+ if (error)
79078+ goto exit5;
79079+
79080 error = security_path_rename(&oldnd.path, old_dentry,
79081 &newnd.path, new_dentry, flags);
79082 if (error)
79083@@ -4360,6 +4553,9 @@ retry_deleg:
79084 error = vfs_rename(old_dir->d_inode, old_dentry,
79085 new_dir->d_inode, new_dentry,
79086 &delegated_inode, flags);
79087+ if (!error)
79088+ gr_handle_rename(d_backing_inode(old_dir), d_backing_inode(new_dir), old_dentry,
79089+ new_dentry, oldnd.path.mnt, d_is_positive(new_dentry) ? 1 : 0, flags);
79090 exit5:
79091 dput(new_dentry);
79092 exit4:
79093@@ -4416,14 +4612,24 @@ EXPORT_SYMBOL(vfs_whiteout);
79094
79095 int readlink_copy(char __user *buffer, int buflen, const char *link)
79096 {
79097+ char tmpbuf[64];
79098+ const char *newlink;
79099 int len = PTR_ERR(link);
79100+
79101 if (IS_ERR(link))
79102 goto out;
79103
79104 len = strlen(link);
79105 if (len > (unsigned) buflen)
79106 len = buflen;
79107- if (copy_to_user(buffer, link, len))
79108+
79109+ if (len < sizeof(tmpbuf)) {
79110+ memcpy(tmpbuf, link, len);
79111+ newlink = tmpbuf;
79112+ } else
79113+ newlink = link;
79114+
79115+ if (copy_to_user(buffer, newlink, len))
79116 len = -EFAULT;
79117 out:
79118 return len;
79119diff --git a/fs/namespace.c b/fs/namespace.c
79120index 02c6875..ac3626c 100644
79121--- a/fs/namespace.c
79122+++ b/fs/namespace.c
79123@@ -1350,6 +1350,36 @@ enum umount_tree_flags {
79124 UMOUNT_PROPAGATE = 2,
79125 UMOUNT_CONNECTED = 4,
79126 };
79127+
79128+static bool disconnect_mount(struct mount *mnt, enum umount_tree_flags how)
79129+{
79130+ /* Leaving mounts connected is only valid for lazy umounts */
79131+ if (how & UMOUNT_SYNC)
79132+ return true;
79133+
79134+ /* A mount without a parent has nothing to be connected to */
79135+ if (!mnt_has_parent(mnt))
79136+ return true;
79137+
79138+ /* Because the reference counting rules change when mounts are
79139+ * unmounted and connected, umounted mounts may not be
79140+ * connected to mounted mounts.
79141+ */
79142+ if (!(mnt->mnt_parent->mnt.mnt_flags & MNT_UMOUNT))
79143+ return true;
79144+
79145+ /* Has it been requested that the mount remain connected? */
79146+ if (how & UMOUNT_CONNECTED)
79147+ return false;
79148+
79149+ /* Is the mount locked such that it needs to remain connected? */
79150+ if (IS_MNT_LOCKED(mnt))
79151+ return false;
79152+
79153+ /* By default disconnect the mount */
79154+ return true;
79155+}
79156+
79157 /*
79158 * mount_lock must be held
79159 * namespace_sem must be held for write
79160@@ -1387,10 +1417,7 @@ static void umount_tree(struct mount *mnt, enum umount_tree_flags how)
79161 if (how & UMOUNT_SYNC)
79162 p->mnt.mnt_flags |= MNT_SYNC_UMOUNT;
79163
79164- disconnect = !(((how & UMOUNT_CONNECTED) &&
79165- mnt_has_parent(p) &&
79166- (p->mnt_parent->mnt.mnt_flags & MNT_UMOUNT)) ||
79167- IS_MNT_LOCKED_AND_LAZY(p));
79168+ disconnect = disconnect_mount(p, how);
79169
79170 pin_insert_group(&p->mnt_umount, &p->mnt_parent->mnt,
79171 disconnect ? &unmounted : NULL);
79172@@ -1478,6 +1505,9 @@ static int do_umount(struct mount *mnt, int flags)
79173 if (!(sb->s_flags & MS_RDONLY))
79174 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
79175 up_write(&sb->s_umount);
79176+
79177+ gr_log_remount(mnt->mnt_devname, retval);
79178+
79179 return retval;
79180 }
79181
79182@@ -1500,6 +1530,9 @@ static int do_umount(struct mount *mnt, int flags)
79183 }
79184 unlock_mount_hash();
79185 namespace_unlock();
79186+
79187+ gr_log_unmount(mnt->mnt_devname, retval);
79188+
79189 return retval;
79190 }
79191
79192@@ -1527,11 +1560,8 @@ void __detach_mounts(struct dentry *dentry)
79193 while (!hlist_empty(&mp->m_list)) {
79194 mnt = hlist_entry(mp->m_list.first, struct mount, mnt_mp_list);
79195 if (mnt->mnt.mnt_flags & MNT_UMOUNT) {
79196- struct mount *p, *tmp;
79197- list_for_each_entry_safe(p, tmp, &mnt->mnt_mounts, mnt_child) {
79198- hlist_add_head(&p->mnt_umount.s_list, &unmounted);
79199- umount_mnt(p);
79200- }
79201+ hlist_add_head(&mnt->mnt_umount.s_list, &unmounted);
79202+ umount_mnt(mnt);
79203 }
79204 else umount_tree(mnt, UMOUNT_CONNECTED);
79205 }
79206@@ -1557,7 +1587,7 @@ static inline bool may_mount(void)
79207 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
79208 */
79209
79210-SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
79211+SYSCALL_DEFINE2(umount, const char __user *, name, int, flags)
79212 {
79213 struct path path;
79214 struct mount *mnt;
79215@@ -1602,7 +1632,7 @@ out:
79216 /*
79217 * The 2.0 compatible umount. No flags.
79218 */
79219-SYSCALL_DEFINE1(oldumount, char __user *, name)
79220+SYSCALL_DEFINE1(oldumount, const char __user *, name)
79221 {
79222 return sys_umount(name, 0);
79223 }
79224@@ -2677,6 +2707,16 @@ long do_mount(const char *dev_name, const char __user *dir_name,
79225 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
79226 MS_STRICTATIME);
79227
79228+ if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
79229+ retval = -EPERM;
79230+ goto dput_out;
79231+ }
79232+
79233+ if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
79234+ retval = -EPERM;
79235+ goto dput_out;
79236+ }
79237+
79238 if (flags & MS_REMOUNT)
79239 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
79240 data_page);
79241@@ -2690,7 +2730,10 @@ long do_mount(const char *dev_name, const char __user *dir_name,
79242 retval = do_new_mount(&path, type_page, flags, mnt_flags,
79243 dev_name, data_page);
79244 dput_out:
79245+ gr_log_mount(dev_name, &path, retval);
79246+
79247 path_put(&path);
79248+
79249 return retval;
79250 }
79251
79252@@ -2708,7 +2751,7 @@ static void free_mnt_ns(struct mnt_namespace *ns)
79253 * number incrementing at 10Ghz will take 12,427 years to wrap which
79254 * is effectively never, so we can ignore the possibility.
79255 */
79256-static atomic64_t mnt_ns_seq = ATOMIC64_INIT(1);
79257+static atomic64_unchecked_t mnt_ns_seq = ATOMIC64_INIT(1);
79258
79259 static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
79260 {
79261@@ -2724,7 +2767,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
79262 return ERR_PTR(ret);
79263 }
79264 new_ns->ns.ops = &mntns_operations;
79265- new_ns->seq = atomic64_add_return(1, &mnt_ns_seq);
79266+ new_ns->seq = atomic64_add_return_unchecked(1, &mnt_ns_seq);
79267 atomic_set(&new_ns->count, 1);
79268 new_ns->root = NULL;
79269 INIT_LIST_HEAD(&new_ns->list);
79270@@ -2734,7 +2777,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
79271 return new_ns;
79272 }
79273
79274-struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns,
79275+__latent_entropy struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns,
79276 struct user_namespace *user_ns, struct fs_struct *new_fs)
79277 {
79278 struct mnt_namespace *new_ns;
79279@@ -2855,8 +2898,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
79280 }
79281 EXPORT_SYMBOL(mount_subtree);
79282
79283-SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
79284- char __user *, type, unsigned long, flags, void __user *, data)
79285+SYSCALL_DEFINE5(mount, const char __user *, dev_name, const char __user *, dir_name,
79286+ const char __user *, type, unsigned long, flags, void __user *, data)
79287 {
79288 int ret;
79289 char *kernel_type;
79290@@ -2962,6 +3005,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
79291 if (error)
79292 goto out2;
79293
79294+ if (gr_handle_chroot_pivot()) {
79295+ error = -EPERM;
79296+ goto out2;
79297+ }
79298+
79299 get_fs_root(current->fs, &root);
79300 old_mp = lock_mount(&old);
79301 error = PTR_ERR(old_mp);
79302@@ -3263,7 +3311,7 @@ static int mntns_install(struct nsproxy *nsproxy, struct ns_common *ns)
79303 !ns_capable(current_user_ns(), CAP_SYS_ADMIN))
79304 return -EPERM;
79305
79306- if (fs->users != 1)
79307+ if (atomic_read(&fs->users) != 1)
79308 return -EINVAL;
79309
79310 get_mnt_ns(mnt_ns);
79311diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
79312index 19ca95c..b28702c 100644
79313--- a/fs/nfs/callback_xdr.c
79314+++ b/fs/nfs/callback_xdr.c
79315@@ -51,7 +51,7 @@ struct callback_op {
79316 callback_decode_arg_t decode_args;
79317 callback_encode_res_t encode_res;
79318 long res_maxsize;
79319-};
79320+} __do_const;
79321
79322 static struct callback_op callback_ops[];
79323
79324diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
79325index f734562..3fd6c4e 100644
79326--- a/fs/nfs/inode.c
79327+++ b/fs/nfs/inode.c
79328@@ -1275,16 +1275,16 @@ static int nfs_ctime_need_update(const struct inode *inode, const struct nfs_fat
79329 return timespec_compare(&fattr->ctime, &inode->i_ctime) > 0;
79330 }
79331
79332-static atomic_long_t nfs_attr_generation_counter;
79333+static atomic_long_unchecked_t nfs_attr_generation_counter;
79334
79335 static unsigned long nfs_read_attr_generation_counter(void)
79336 {
79337- return atomic_long_read(&nfs_attr_generation_counter);
79338+ return atomic_long_read_unchecked(&nfs_attr_generation_counter);
79339 }
79340
79341 unsigned long nfs_inc_attr_generation_counter(void)
79342 {
79343- return atomic_long_inc_return(&nfs_attr_generation_counter);
79344+ return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
79345 }
79346 EXPORT_SYMBOL_GPL(nfs_inc_attr_generation_counter);
79347
79348diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
79349index 9e6475b..7970138 100644
79350--- a/fs/nfs/internal.h
79351+++ b/fs/nfs/internal.h
79352@@ -296,6 +296,22 @@ extern struct rpc_procinfo nfs4_procedures[];
79353
79354 #ifdef CONFIG_NFS_V4_SECURITY_LABEL
79355 extern struct nfs4_label *nfs4_label_alloc(struct nfs_server *server, gfp_t flags);
79356+static inline struct nfs4_label *
79357+nfs4_label_copy(struct nfs4_label *dst, struct nfs4_label *src)
79358+{
79359+ if (!dst || !src)
79360+ return NULL;
79361+
79362+ if (src->len > NFS4_MAXLABELLEN)
79363+ return NULL;
79364+
79365+ dst->lfs = src->lfs;
79366+ dst->pi = src->pi;
79367+ dst->len = src->len;
79368+ memcpy(dst->label, src->label, src->len);
79369+
79370+ return dst;
79371+}
79372 static inline void nfs4_label_free(struct nfs4_label *label)
79373 {
79374 if (label) {
79375@@ -316,6 +332,11 @@ static inline void nfs4_label_free(void *label) {}
79376 static inline void nfs_zap_label_cache_locked(struct nfs_inode *nfsi)
79377 {
79378 }
79379+static inline struct nfs4_label *
79380+nfs4_label_copy(struct nfs4_label *dst, struct nfs4_label *src)
79381+{
79382+ return NULL;
79383+}
79384 #endif /* CONFIG_NFS_V4_SECURITY_LABEL */
79385
79386 /* proc.c */
79387diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
79388index 55e1e3a..3886f50 100644
79389--- a/fs/nfs/nfs4proc.c
79390+++ b/fs/nfs/nfs4proc.c
79391@@ -916,6 +916,7 @@ struct nfs4_opendata {
79392 struct nfs_open_confirmres c_res;
79393 struct nfs4_string owner_name;
79394 struct nfs4_string group_name;
79395+ struct nfs4_label *a_label;
79396 struct nfs_fattr f_attr;
79397 struct nfs4_label *f_label;
79398 struct dentry *dir;
79399@@ -1019,6 +1020,10 @@ static struct nfs4_opendata *nfs4_opendata_alloc(struct dentry *dentry,
79400 if (IS_ERR(p->f_label))
79401 goto err_free_p;
79402
79403+ p->a_label = nfs4_label_alloc(server, gfp_mask);
79404+ if (IS_ERR(p->a_label))
79405+ goto err_free_f;
79406+
79407 alloc_seqid = server->nfs_client->cl_mvops->alloc_seqid;
79408 p->o_arg.seqid = alloc_seqid(&sp->so_seqid, gfp_mask);
79409 if (IS_ERR(p->o_arg.seqid))
79410@@ -1047,7 +1052,7 @@ static struct nfs4_opendata *nfs4_opendata_alloc(struct dentry *dentry,
79411 p->o_arg.server = server;
79412 p->o_arg.bitmask = nfs4_bitmask(server, label);
79413 p->o_arg.open_bitmap = &nfs4_fattr_bitmap[0];
79414- p->o_arg.label = label;
79415+ p->o_arg.label = nfs4_label_copy(p->a_label, label);
79416 p->o_arg.claim = nfs4_map_atomic_open_claim(server, claim);
79417 switch (p->o_arg.claim) {
79418 case NFS4_OPEN_CLAIM_NULL:
79419@@ -1080,6 +1085,8 @@ static struct nfs4_opendata *nfs4_opendata_alloc(struct dentry *dentry,
79420 return p;
79421
79422 err_free_label:
79423+ nfs4_label_free(p->a_label);
79424+err_free_f:
79425 nfs4_label_free(p->f_label);
79426 err_free_p:
79427 kfree(p);
79428@@ -1099,6 +1106,7 @@ static void nfs4_opendata_free(struct kref *kref)
79429 nfs4_put_open_state(p->state);
79430 nfs4_put_state_owner(p->owner);
79431
79432+ nfs4_label_free(p->a_label);
79433 nfs4_label_free(p->f_label);
79434
79435 dput(p->dir);
79436diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
79437index 864e200..357c255 100644
79438--- a/fs/nfsd/nfs4proc.c
79439+++ b/fs/nfsd/nfs4proc.c
79440@@ -1496,7 +1496,7 @@ struct nfsd4_operation {
79441 nfsd4op_rsize op_rsize_bop;
79442 stateid_getter op_get_currentstateid;
79443 stateid_setter op_set_currentstateid;
79444-};
79445+} __do_const;
79446
79447 static struct nfsd4_operation nfsd4_ops[];
79448
79449diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
79450index 158badf..f7132ea 100644
79451--- a/fs/nfsd/nfs4xdr.c
79452+++ b/fs/nfsd/nfs4xdr.c
79453@@ -1703,7 +1703,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
79454
79455 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
79456
79457-static nfsd4_dec nfsd4_dec_ops[] = {
79458+static const nfsd4_dec nfsd4_dec_ops[] = {
79459 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
79460 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
79461 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
79462diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
79463index 46ec934..f384e41 100644
79464--- a/fs/nfsd/nfscache.c
79465+++ b/fs/nfsd/nfscache.c
79466@@ -541,7 +541,7 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
79467 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
79468 u32 hash;
79469 struct nfsd_drc_bucket *b;
79470- int len;
79471+ long len;
79472 size_t bufsize = 0;
79473
79474 if (!rp)
79475@@ -550,11 +550,14 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
79476 hash = nfsd_cache_hash(rp->c_xid);
79477 b = &drc_hashtbl[hash];
79478
79479- len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
79480- len >>= 2;
79481+ if (statp) {
79482+ len = (char*)statp - (char*)resv->iov_base;
79483+ len = resv->iov_len - len;
79484+ len >>= 2;
79485+ }
79486
79487 /* Don't cache excessive amounts of data and XDR failures */
79488- if (!statp || len > (256 >> 2)) {
79489+ if (!statp || len > (256 >> 2) || len < 0) {
79490 nfsd_reply_cache_free(b, rp);
79491 return;
79492 }
79493@@ -562,7 +565,7 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
79494 switch (cachetype) {
79495 case RC_REPLSTAT:
79496 if (len != 1)
79497- printk("nfsd: RC_REPLSTAT/reply len %d!\n",len);
79498+ printk("nfsd: RC_REPLSTAT/reply len %ld!\n",len);
79499 rp->c_replstat = *statp;
79500 break;
79501 case RC_REPLBUFF:
79502diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
79503index 84d770b..929bc5e 100644
79504--- a/fs/nfsd/vfs.c
79505+++ b/fs/nfsd/vfs.c
79506@@ -893,7 +893,7 @@ __be32 nfsd_readv(struct file *file, loff_t offset, struct kvec *vec, int vlen,
79507
79508 oldfs = get_fs();
79509 set_fs(KERNEL_DS);
79510- host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
79511+ host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
79512 set_fs(oldfs);
79513 return nfsd_finish_read(file, count, host_err);
79514 }
79515@@ -980,7 +980,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
79516
79517 /* Write the data. */
79518 oldfs = get_fs(); set_fs(KERNEL_DS);
79519- host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
79520+ host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
79521 set_fs(oldfs);
79522 if (host_err < 0)
79523 goto out_nfserr;
79524@@ -1525,7 +1525,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
79525 */
79526
79527 oldfs = get_fs(); set_fs(KERNEL_DS);
79528- host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
79529+ host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
79530 set_fs(oldfs);
79531
79532 if (host_err < 0)
79533diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
79534index 52ccd34..7a6b202 100644
79535--- a/fs/nls/nls_base.c
79536+++ b/fs/nls/nls_base.c
79537@@ -234,21 +234,25 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
79538
79539 int __register_nls(struct nls_table *nls, struct module *owner)
79540 {
79541- struct nls_table ** tmp = &tables;
79542+ struct nls_table *tmp = tables;
79543
79544 if (nls->next)
79545 return -EBUSY;
79546
79547- nls->owner = owner;
79548+ pax_open_kernel();
79549+ *(void **)&nls->owner = owner;
79550+ pax_close_kernel();
79551 spin_lock(&nls_lock);
79552- while (*tmp) {
79553- if (nls == *tmp) {
79554+ while (tmp) {
79555+ if (nls == tmp) {
79556 spin_unlock(&nls_lock);
79557 return -EBUSY;
79558 }
79559- tmp = &(*tmp)->next;
79560+ tmp = tmp->next;
79561 }
79562- nls->next = tables;
79563+ pax_open_kernel();
79564+ *(struct nls_table **)&nls->next = tables;
79565+ pax_close_kernel();
79566 tables = nls;
79567 spin_unlock(&nls_lock);
79568 return 0;
79569@@ -257,12 +261,14 @@ EXPORT_SYMBOL(__register_nls);
79570
79571 int unregister_nls(struct nls_table * nls)
79572 {
79573- struct nls_table ** tmp = &tables;
79574+ struct nls_table * const * tmp = &tables;
79575
79576 spin_lock(&nls_lock);
79577 while (*tmp) {
79578 if (nls == *tmp) {
79579- *tmp = nls->next;
79580+ pax_open_kernel();
79581+ *(struct nls_table **)tmp = nls->next;
79582+ pax_close_kernel();
79583 spin_unlock(&nls_lock);
79584 return 0;
79585 }
79586@@ -272,7 +278,7 @@ int unregister_nls(struct nls_table * nls)
79587 return -EINVAL;
79588 }
79589
79590-static struct nls_table *find_nls(char *charset)
79591+static struct nls_table *find_nls(const char *charset)
79592 {
79593 struct nls_table *nls;
79594 spin_lock(&nls_lock);
79595@@ -288,7 +294,7 @@ static struct nls_table *find_nls(char *charset)
79596 return nls;
79597 }
79598
79599-struct nls_table *load_nls(char *charset)
79600+struct nls_table *load_nls(const char *charset)
79601 {
79602 return try_then_request_module(find_nls(charset), "nls_%s", charset);
79603 }
79604diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
79605index 162b3f1..6076a7c 100644
79606--- a/fs/nls/nls_euc-jp.c
79607+++ b/fs/nls/nls_euc-jp.c
79608@@ -560,8 +560,10 @@ static int __init init_nls_euc_jp(void)
79609 p_nls = load_nls("cp932");
79610
79611 if (p_nls) {
79612- table.charset2upper = p_nls->charset2upper;
79613- table.charset2lower = p_nls->charset2lower;
79614+ pax_open_kernel();
79615+ *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
79616+ *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
79617+ pax_close_kernel();
79618 return register_nls(&table);
79619 }
79620
79621diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
79622index a80a741..7b96e1b 100644
79623--- a/fs/nls/nls_koi8-ru.c
79624+++ b/fs/nls/nls_koi8-ru.c
79625@@ -62,8 +62,10 @@ static int __init init_nls_koi8_ru(void)
79626 p_nls = load_nls("koi8-u");
79627
79628 if (p_nls) {
79629- table.charset2upper = p_nls->charset2upper;
79630- table.charset2lower = p_nls->charset2lower;
79631+ pax_open_kernel();
79632+ *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
79633+ *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
79634+ pax_close_kernel();
79635 return register_nls(&table);
79636 }
79637
79638diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
79639index cf27550..6c70f29d 100644
79640--- a/fs/notify/fanotify/fanotify_user.c
79641+++ b/fs/notify/fanotify/fanotify_user.c
79642@@ -216,8 +216,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
79643
79644 fd = fanotify_event_metadata.fd;
79645 ret = -EFAULT;
79646- if (copy_to_user(buf, &fanotify_event_metadata,
79647- fanotify_event_metadata.event_len))
79648+ if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
79649+ copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
79650 goto out_close_fd;
79651
79652 #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
79653diff --git a/fs/notify/notification.c b/fs/notify/notification.c
79654index a95d8e0..a91a5fd 100644
79655--- a/fs/notify/notification.c
79656+++ b/fs/notify/notification.c
79657@@ -48,7 +48,7 @@
79658 #include <linux/fsnotify_backend.h>
79659 #include "fsnotify.h"
79660
79661-static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
79662+static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
79663
79664 /**
79665 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
79666@@ -56,7 +56,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
79667 */
79668 u32 fsnotify_get_cookie(void)
79669 {
79670- return atomic_inc_return(&fsnotify_sync_cookie);
79671+ return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
79672 }
79673 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
79674
79675diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
79676index 9e38daf..5727cae 100644
79677--- a/fs/ntfs/dir.c
79678+++ b/fs/ntfs/dir.c
79679@@ -1310,7 +1310,7 @@ find_next_index_buffer:
79680 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
79681 ~(s64)(ndir->itype.index.block_size - 1)));
79682 /* Bounds checks. */
79683- if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
79684+ if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
79685 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
79686 "inode 0x%lx or driver bug.", vdir->i_ino);
79687 goto err_out;
79688diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
79689index 9e1e112..241a52a 100644
79690--- a/fs/ntfs/super.c
79691+++ b/fs/ntfs/super.c
79692@@ -688,7 +688,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
79693 if (!silent)
79694 ntfs_error(sb, "Primary boot sector is invalid.");
79695 } else if (!silent)
79696- ntfs_error(sb, read_err_str, "primary");
79697+ ntfs_error(sb, read_err_str, "%s", "primary");
79698 if (!(NTFS_SB(sb)->on_errors & ON_ERRORS_RECOVER)) {
79699 if (bh_primary)
79700 brelse(bh_primary);
79701@@ -704,7 +704,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
79702 goto hotfix_primary_boot_sector;
79703 brelse(bh_backup);
79704 } else if (!silent)
79705- ntfs_error(sb, read_err_str, "backup");
79706+ ntfs_error(sb, read_err_str, "%s", "backup");
79707 /* Try to read NT3.51- backup boot sector. */
79708 if ((bh_backup = sb_bread(sb, nr_blocks >> 1))) {
79709 if (is_boot_sector_ntfs(sb, (NTFS_BOOT_SECTOR*)
79710@@ -715,7 +715,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
79711 "sector.");
79712 brelse(bh_backup);
79713 } else if (!silent)
79714- ntfs_error(sb, read_err_str, "backup");
79715+ ntfs_error(sb, read_err_str, "%s", "backup");
79716 /* We failed. Cleanup and return. */
79717 if (bh_primary)
79718 brelse(bh_primary);
79719diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
79720index 857bbbc..3c47d15 100644
79721--- a/fs/ocfs2/localalloc.c
79722+++ b/fs/ocfs2/localalloc.c
79723@@ -1320,7 +1320,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
79724 goto bail;
79725 }
79726
79727- atomic_inc(&osb->alloc_stats.moves);
79728+ atomic_inc_unchecked(&osb->alloc_stats.moves);
79729
79730 bail:
79731 if (handle)
79732diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
79733index 460c6c3..b4ef513 100644
79734--- a/fs/ocfs2/ocfs2.h
79735+++ b/fs/ocfs2/ocfs2.h
79736@@ -247,11 +247,11 @@ enum ocfs2_vol_state
79737
79738 struct ocfs2_alloc_stats
79739 {
79740- atomic_t moves;
79741- atomic_t local_data;
79742- atomic_t bitmap_data;
79743- atomic_t bg_allocs;
79744- atomic_t bg_extends;
79745+ atomic_unchecked_t moves;
79746+ atomic_unchecked_t local_data;
79747+ atomic_unchecked_t bitmap_data;
79748+ atomic_unchecked_t bg_allocs;
79749+ atomic_unchecked_t bg_extends;
79750 };
79751
79752 enum ocfs2_local_alloc_state
79753diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
79754index 4479029..5de740b 100644
79755--- a/fs/ocfs2/suballoc.c
79756+++ b/fs/ocfs2/suballoc.c
79757@@ -867,7 +867,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
79758 mlog_errno(status);
79759 goto bail;
79760 }
79761- atomic_inc(&osb->alloc_stats.bg_extends);
79762+ atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
79763
79764 /* You should never ask for this much metadata */
79765 BUG_ON(bits_wanted >
79766@@ -2014,7 +2014,7 @@ int ocfs2_claim_metadata(handle_t *handle,
79767 mlog_errno(status);
79768 goto bail;
79769 }
79770- atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
79771+ atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
79772
79773 *suballoc_loc = res.sr_bg_blkno;
79774 *suballoc_bit_start = res.sr_bit_offset;
79775@@ -2180,7 +2180,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
79776 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
79777 res->sr_bits);
79778
79779- atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
79780+ atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
79781
79782 BUG_ON(res->sr_bits != 1);
79783
79784@@ -2222,7 +2222,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
79785 mlog_errno(status);
79786 goto bail;
79787 }
79788- atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
79789+ atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
79790
79791 BUG_ON(res.sr_bits != 1);
79792
79793@@ -2326,7 +2326,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
79794 cluster_start,
79795 num_clusters);
79796 if (!status)
79797- atomic_inc(&osb->alloc_stats.local_data);
79798+ atomic_inc_unchecked(&osb->alloc_stats.local_data);
79799 } else {
79800 if (min_clusters > (osb->bitmap_cpg - 1)) {
79801 /* The only paths asking for contiguousness
79802@@ -2352,7 +2352,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
79803 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
79804 res.sr_bg_blkno,
79805 res.sr_bit_offset);
79806- atomic_inc(&osb->alloc_stats.bitmap_data);
79807+ atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
79808 *num_clusters = res.sr_bits;
79809 }
79810 }
79811diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
79812index 403c566..6525b35 100644
79813--- a/fs/ocfs2/super.c
79814+++ b/fs/ocfs2/super.c
79815@@ -308,11 +308,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
79816 "%10s => GlobalAllocs: %d LocalAllocs: %d "
79817 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
79818 "Stats",
79819- atomic_read(&osb->alloc_stats.bitmap_data),
79820- atomic_read(&osb->alloc_stats.local_data),
79821- atomic_read(&osb->alloc_stats.bg_allocs),
79822- atomic_read(&osb->alloc_stats.moves),
79823- atomic_read(&osb->alloc_stats.bg_extends));
79824+ atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
79825+ atomic_read_unchecked(&osb->alloc_stats.local_data),
79826+ atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
79827+ atomic_read_unchecked(&osb->alloc_stats.moves),
79828+ atomic_read_unchecked(&osb->alloc_stats.bg_extends));
79829
79830 out += snprintf(buf + out, len - out,
79831 "%10s => State: %u Descriptor: %llu Size: %u bits "
79832@@ -2095,11 +2095,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
79833
79834 mutex_init(&osb->system_file_mutex);
79835
79836- atomic_set(&osb->alloc_stats.moves, 0);
79837- atomic_set(&osb->alloc_stats.local_data, 0);
79838- atomic_set(&osb->alloc_stats.bitmap_data, 0);
79839- atomic_set(&osb->alloc_stats.bg_allocs, 0);
79840- atomic_set(&osb->alloc_stats.bg_extends, 0);
79841+ atomic_set_unchecked(&osb->alloc_stats.moves, 0);
79842+ atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
79843+ atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
79844+ atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
79845+ atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
79846
79847 /* Copy the blockcheck stats from the superblock probe */
79848 osb->osb_ecc_stats = *stats;
79849diff --git a/fs/open.c b/fs/open.c
79850index 98e5a52..8e77e14 100644
79851--- a/fs/open.c
79852+++ b/fs/open.c
79853@@ -32,6 +32,8 @@
79854 #include <linux/dnotify.h>
79855 #include <linux/compat.h>
79856
79857+#define CREATE_TRACE_POINTS
79858+#include <trace/events/fs.h>
79859 #include "internal.h"
79860
79861 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
79862@@ -103,6 +105,8 @@ long vfs_truncate(struct path *path, loff_t length)
79863 error = locks_verify_truncate(inode, NULL, length);
79864 if (!error)
79865 error = security_path_truncate(path);
79866+ if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
79867+ error = -EACCES;
79868 if (!error)
79869 error = do_truncate(path->dentry, length, 0, NULL);
79870
79871@@ -187,6 +191,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
79872 error = locks_verify_truncate(inode, f.file, length);
79873 if (!error)
79874 error = security_path_truncate(&f.file->f_path);
79875+ if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
79876+ error = -EACCES;
79877 if (!error)
79878 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
79879 sb_end_write(inode->i_sb);
79880@@ -396,6 +402,9 @@ retry:
79881 if (__mnt_is_readonly(path.mnt))
79882 res = -EROFS;
79883
79884+ if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
79885+ res = -EACCES;
79886+
79887 out_path_release:
79888 path_put(&path);
79889 if (retry_estale(res, lookup_flags)) {
79890@@ -427,6 +436,8 @@ retry:
79891 if (error)
79892 goto dput_and_out;
79893
79894+ gr_log_chdir(path.dentry, path.mnt);
79895+
79896 set_fs_pwd(current->fs, &path);
79897
79898 dput_and_out:
79899@@ -456,6 +467,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
79900 goto out_putf;
79901
79902 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
79903+
79904+ if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
79905+ error = -EPERM;
79906+
79907+ if (!error)
79908+ gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
79909+
79910 if (!error)
79911 set_fs_pwd(current->fs, &f.file->f_path);
79912 out_putf:
79913@@ -485,7 +503,13 @@ retry:
79914 if (error)
79915 goto dput_and_out;
79916
79917+ if (gr_handle_chroot_chroot(path.dentry, path.mnt))
79918+ goto dput_and_out;
79919+
79920 set_fs_root(current->fs, &path);
79921+
79922+ gr_handle_chroot_chdir(&path);
79923+
79924 error = 0;
79925 dput_and_out:
79926 path_put(&path);
79927@@ -509,6 +533,16 @@ static int chmod_common(struct path *path, umode_t mode)
79928 return error;
79929 retry_deleg:
79930 mutex_lock(&inode->i_mutex);
79931+
79932+ if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
79933+ error = -EACCES;
79934+ goto out_unlock;
79935+ }
79936+ if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
79937+ error = -EACCES;
79938+ goto out_unlock;
79939+ }
79940+
79941 error = security_path_chmod(path, mode);
79942 if (error)
79943 goto out_unlock;
79944@@ -574,6 +608,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
79945 uid = make_kuid(current_user_ns(), user);
79946 gid = make_kgid(current_user_ns(), group);
79947
79948+ if (!gr_acl_handle_chown(path->dentry, path->mnt))
79949+ return -EACCES;
79950+
79951 retry_deleg:
79952 newattrs.ia_valid = ATTR_CTIME;
79953 if (user != (uid_t) -1) {
79954@@ -1018,6 +1055,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
79955 } else {
79956 fsnotify_open(f);
79957 fd_install(fd, f);
79958+ trace_do_sys_open(tmp->name, flags, mode);
79959 }
79960 }
79961 putname(tmp);
79962diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
79963index 04f1248..60b3be1 100644
79964--- a/fs/overlayfs/inode.c
79965+++ b/fs/overlayfs/inode.c
79966@@ -344,6 +344,9 @@ static int ovl_dentry_open(struct dentry *dentry, struct file *file,
79967 enum ovl_path_type type;
79968 bool want_write = false;
79969
79970+ if (d_is_dir(dentry))
79971+ return d_backing_inode(dentry);
79972+
79973 type = ovl_path_real(dentry, &realpath);
79974 if (ovl_open_need_copy_up(file->f_flags, type, realpath.dentry)) {
79975 want_write = true;
79976diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
79977index bf8537c..c16ef7d 100644
79978--- a/fs/overlayfs/super.c
79979+++ b/fs/overlayfs/super.c
79980@@ -172,7 +172,7 @@ void ovl_path_lower(struct dentry *dentry, struct path *path)
79981 {
79982 struct ovl_entry *oe = dentry->d_fsdata;
79983
79984- *path = oe->numlower ? oe->lowerstack[0] : (struct path) { NULL, NULL };
79985+ *path = oe->numlower ? oe->lowerstack[0] : (struct path) { .dentry = NULL, .mnt = NULL };
79986 }
79987
79988 int ovl_want_write(struct dentry *dentry)
79989@@ -816,8 +816,8 @@ static unsigned int ovl_split_lowerdirs(char *str)
79990
79991 static int ovl_fill_super(struct super_block *sb, void *data, int silent)
79992 {
79993- struct path upperpath = { NULL, NULL };
79994- struct path workpath = { NULL, NULL };
79995+ struct path upperpath = { .dentry = NULL, .mnt = NULL };
79996+ struct path workpath = { .dentry = NULL, .mnt = NULL };
79997 struct dentry *root_dentry;
79998 struct ovl_entry *oe;
79999 struct ovl_fs *ufs;
80000diff --git a/fs/pipe.c b/fs/pipe.c
80001index 8865f79..bd2c79b 100644
80002--- a/fs/pipe.c
80003+++ b/fs/pipe.c
80004@@ -36,7 +36,7 @@ unsigned int pipe_max_size = 1048576;
80005 /*
80006 * Minimum pipe size, as required by POSIX
80007 */
80008-unsigned int pipe_min_size = PAGE_SIZE;
80009+unsigned int pipe_min_size __read_only = PAGE_SIZE;
80010
80011 /*
80012 * We use a start+len construction, which provides full use of the
80013@@ -55,7 +55,7 @@ unsigned int pipe_min_size = PAGE_SIZE;
80014
80015 static void pipe_lock_nested(struct pipe_inode_info *pipe, int subclass)
80016 {
80017- if (pipe->files)
80018+ if (atomic_read(&pipe->files))
80019 mutex_lock_nested(&pipe->mutex, subclass);
80020 }
80021
80022@@ -70,7 +70,7 @@ EXPORT_SYMBOL(pipe_lock);
80023
80024 void pipe_unlock(struct pipe_inode_info *pipe)
80025 {
80026- if (pipe->files)
80027+ if (atomic_read(&pipe->files))
80028 mutex_unlock(&pipe->mutex);
80029 }
80030 EXPORT_SYMBOL(pipe_unlock);
80031@@ -291,9 +291,9 @@ pipe_read(struct kiocb *iocb, struct iov_iter *to)
80032 }
80033 if (bufs) /* More to do? */
80034 continue;
80035- if (!pipe->writers)
80036+ if (!atomic_read(&pipe->writers))
80037 break;
80038- if (!pipe->waiting_writers) {
80039+ if (!atomic_read(&pipe->waiting_writers)) {
80040 /* syscall merging: Usually we must not sleep
80041 * if O_NONBLOCK is set, or if we got some data.
80042 * But if a writer sleeps in kernel space, then
80043@@ -350,7 +350,7 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from)
80044
80045 __pipe_lock(pipe);
80046
80047- if (!pipe->readers) {
80048+ if (!atomic_read(&pipe->readers)) {
80049 send_sig(SIGPIPE, current, 0);
80050 ret = -EPIPE;
80051 goto out;
80052@@ -386,7 +386,7 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from)
80053 for (;;) {
80054 int bufs;
80055
80056- if (!pipe->readers) {
80057+ if (!atomic_read(&pipe->readers)) {
80058 send_sig(SIGPIPE, current, 0);
80059 if (!ret)
80060 ret = -EPIPE;
80061@@ -454,9 +454,9 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from)
80062 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
80063 do_wakeup = 0;
80064 }
80065- pipe->waiting_writers++;
80066+ atomic_inc(&pipe->waiting_writers);
80067 pipe_wait(pipe);
80068- pipe->waiting_writers--;
80069+ atomic_dec(&pipe->waiting_writers);
80070 }
80071 out:
80072 __pipe_unlock(pipe);
80073@@ -511,7 +511,7 @@ pipe_poll(struct file *filp, poll_table *wait)
80074 mask = 0;
80075 if (filp->f_mode & FMODE_READ) {
80076 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
80077- if (!pipe->writers && filp->f_version != pipe->w_counter)
80078+ if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
80079 mask |= POLLHUP;
80080 }
80081
80082@@ -521,7 +521,7 @@ pipe_poll(struct file *filp, poll_table *wait)
80083 * Most Unices do not set POLLERR for FIFOs but on Linux they
80084 * behave exactly like pipes for poll().
80085 */
80086- if (!pipe->readers)
80087+ if (!atomic_read(&pipe->readers))
80088 mask |= POLLERR;
80089 }
80090
80091@@ -533,7 +533,7 @@ static void put_pipe_info(struct inode *inode, struct pipe_inode_info *pipe)
80092 int kill = 0;
80093
80094 spin_lock(&inode->i_lock);
80095- if (!--pipe->files) {
80096+ if (atomic_dec_and_test(&pipe->files)) {
80097 inode->i_pipe = NULL;
80098 kill = 1;
80099 }
80100@@ -550,11 +550,11 @@ pipe_release(struct inode *inode, struct file *file)
80101
80102 __pipe_lock(pipe);
80103 if (file->f_mode & FMODE_READ)
80104- pipe->readers--;
80105+ atomic_dec(&pipe->readers);
80106 if (file->f_mode & FMODE_WRITE)
80107- pipe->writers--;
80108+ atomic_dec(&pipe->writers);
80109
80110- if (pipe->readers || pipe->writers) {
80111+ if (atomic_read(&pipe->readers) || atomic_read(&pipe->writers)) {
80112 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
80113 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
80114 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
80115@@ -619,7 +619,7 @@ void free_pipe_info(struct pipe_inode_info *pipe)
80116 kfree(pipe);
80117 }
80118
80119-static struct vfsmount *pipe_mnt __read_mostly;
80120+struct vfsmount *pipe_mnt __read_mostly;
80121
80122 /*
80123 * pipefs_dname() is called from d_path().
80124@@ -649,8 +649,9 @@ static struct inode * get_pipe_inode(void)
80125 goto fail_iput;
80126
80127 inode->i_pipe = pipe;
80128- pipe->files = 2;
80129- pipe->readers = pipe->writers = 1;
80130+ atomic_set(&pipe->files, 2);
80131+ atomic_set(&pipe->readers, 1);
80132+ atomic_set(&pipe->writers, 1);
80133 inode->i_fop = &pipefifo_fops;
80134
80135 /*
80136@@ -829,17 +830,17 @@ static int fifo_open(struct inode *inode, struct file *filp)
80137 spin_lock(&inode->i_lock);
80138 if (inode->i_pipe) {
80139 pipe = inode->i_pipe;
80140- pipe->files++;
80141+ atomic_inc(&pipe->files);
80142 spin_unlock(&inode->i_lock);
80143 } else {
80144 spin_unlock(&inode->i_lock);
80145 pipe = alloc_pipe_info();
80146 if (!pipe)
80147 return -ENOMEM;
80148- pipe->files = 1;
80149+ atomic_set(&pipe->files, 1);
80150 spin_lock(&inode->i_lock);
80151 if (unlikely(inode->i_pipe)) {
80152- inode->i_pipe->files++;
80153+ atomic_inc(&inode->i_pipe->files);
80154 spin_unlock(&inode->i_lock);
80155 free_pipe_info(pipe);
80156 pipe = inode->i_pipe;
80157@@ -864,10 +865,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
80158 * opened, even when there is no process writing the FIFO.
80159 */
80160 pipe->r_counter++;
80161- if (pipe->readers++ == 0)
80162+ if (atomic_inc_return(&pipe->readers) == 1)
80163 wake_up_partner(pipe);
80164
80165- if (!is_pipe && !pipe->writers) {
80166+ if (!is_pipe && !atomic_read(&pipe->writers)) {
80167 if ((filp->f_flags & O_NONBLOCK)) {
80168 /* suppress POLLHUP until we have
80169 * seen a writer */
80170@@ -886,14 +887,14 @@ static int fifo_open(struct inode *inode, struct file *filp)
80171 * errno=ENXIO when there is no process reading the FIFO.
80172 */
80173 ret = -ENXIO;
80174- if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !pipe->readers)
80175+ if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
80176 goto err;
80177
80178 pipe->w_counter++;
80179- if (!pipe->writers++)
80180+ if (atomic_inc_return(&pipe->writers) == 1)
80181 wake_up_partner(pipe);
80182
80183- if (!is_pipe && !pipe->readers) {
80184+ if (!is_pipe && !atomic_read(&pipe->readers)) {
80185 if (wait_for_partner(pipe, &pipe->r_counter))
80186 goto err_wr;
80187 }
80188@@ -907,11 +908,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
80189 * the process can at least talk to itself.
80190 */
80191
80192- pipe->readers++;
80193- pipe->writers++;
80194+ atomic_inc(&pipe->readers);
80195+ atomic_inc(&pipe->writers);
80196 pipe->r_counter++;
80197 pipe->w_counter++;
80198- if (pipe->readers == 1 || pipe->writers == 1)
80199+ if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
80200 wake_up_partner(pipe);
80201 break;
80202
80203@@ -925,13 +926,13 @@ static int fifo_open(struct inode *inode, struct file *filp)
80204 return 0;
80205
80206 err_rd:
80207- if (!--pipe->readers)
80208+ if (atomic_dec_and_test(&pipe->readers))
80209 wake_up_interruptible(&pipe->wait);
80210 ret = -ERESTARTSYS;
80211 goto err;
80212
80213 err_wr:
80214- if (!--pipe->writers)
80215+ if (atomic_dec_and_test(&pipe->writers))
80216 wake_up_interruptible(&pipe->wait);
80217 ret = -ERESTARTSYS;
80218 goto err;
80219@@ -1007,7 +1008,7 @@ static long pipe_set_size(struct pipe_inode_info *pipe, unsigned long nr_pages)
80220 * Currently we rely on the pipe array holding a power-of-2 number
80221 * of pages.
80222 */
80223-static inline unsigned int round_pipe_size(unsigned int size)
80224+static inline unsigned long round_pipe_size(unsigned long size)
80225 {
80226 unsigned long nr_pages;
80227
80228@@ -1055,13 +1056,16 @@ long pipe_fcntl(struct file *file, unsigned int cmd, unsigned long arg)
80229
80230 switch (cmd) {
80231 case F_SETPIPE_SZ: {
80232- unsigned int size, nr_pages;
80233+ unsigned long size, nr_pages;
80234+
80235+ ret = -EINVAL;
80236+ if (arg < pipe_min_size)
80237+ goto out;
80238
80239 size = round_pipe_size(arg);
80240 nr_pages = size >> PAGE_SHIFT;
80241
80242- ret = -EINVAL;
80243- if (!nr_pages)
80244+ if (size < pipe_min_size)
80245 goto out;
80246
80247 if (!capable(CAP_SYS_RESOURCE) && size > pipe_max_size) {
80248diff --git a/fs/pnode.h b/fs/pnode.h
80249index 7114ce6..0fcdbe7 100644
80250--- a/fs/pnode.h
80251+++ b/fs/pnode.h
80252@@ -20,8 +20,6 @@
80253 #define SET_MNT_MARK(m) ((m)->mnt.mnt_flags |= MNT_MARKED)
80254 #define CLEAR_MNT_MARK(m) ((m)->mnt.mnt_flags &= ~MNT_MARKED)
80255 #define IS_MNT_LOCKED(m) ((m)->mnt.mnt_flags & MNT_LOCKED)
80256-#define IS_MNT_LOCKED_AND_LAZY(m) \
80257- (((m)->mnt.mnt_flags & (MNT_LOCKED|MNT_SYNC_UMOUNT)) == MNT_LOCKED)
80258
80259 #define CL_EXPIRE 0x01
80260 #define CL_SLAVE 0x02
80261diff --git a/fs/posix_acl.c b/fs/posix_acl.c
80262index 84bb65b8..4270e47 100644
80263--- a/fs/posix_acl.c
80264+++ b/fs/posix_acl.c
80265@@ -20,6 +20,7 @@
80266 #include <linux/xattr.h>
80267 #include <linux/export.h>
80268 #include <linux/user_namespace.h>
80269+#include <linux/grsecurity.h>
80270
80271 struct posix_acl **acl_by_type(struct inode *inode, int type)
80272 {
80273@@ -277,7 +278,7 @@ posix_acl_equiv_mode(const struct posix_acl *acl, umode_t *mode_p)
80274 }
80275 }
80276 if (mode_p)
80277- *mode_p = (*mode_p & ~S_IRWXUGO) | mode;
80278+ *mode_p = ((*mode_p & ~S_IRWXUGO) | mode) & ~gr_acl_umask();
80279 return not_equiv;
80280 }
80281 EXPORT_SYMBOL(posix_acl_equiv_mode);
80282@@ -427,7 +428,7 @@ static int posix_acl_create_masq(struct posix_acl *acl, umode_t *mode_p)
80283 mode &= (group_obj->e_perm << 3) | ~S_IRWXG;
80284 }
80285
80286- *mode_p = (*mode_p & ~S_IRWXUGO) | mode;
80287+ *mode_p = ((*mode_p & ~S_IRWXUGO) | mode) & ~gr_acl_umask();
80288 return not_equiv;
80289 }
80290
80291@@ -485,6 +486,8 @@ __posix_acl_create(struct posix_acl **acl, gfp_t gfp, umode_t *mode_p)
80292 struct posix_acl *clone = posix_acl_clone(*acl, gfp);
80293 int err = -ENOMEM;
80294 if (clone) {
80295+ *mode_p &= ~gr_acl_umask();
80296+
80297 err = posix_acl_create_masq(clone, mode_p);
80298 if (err < 0) {
80299 posix_acl_release(clone);
80300@@ -663,11 +666,12 @@ struct posix_acl *
80301 posix_acl_from_xattr(struct user_namespace *user_ns,
80302 const void *value, size_t size)
80303 {
80304- posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
80305- posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
80306+ const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
80307+ const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
80308 int count;
80309 struct posix_acl *acl;
80310 struct posix_acl_entry *acl_e;
80311+ umode_t umask = gr_acl_umask();
80312
80313 if (!value)
80314 return NULL;
80315@@ -693,12 +697,18 @@ posix_acl_from_xattr(struct user_namespace *user_ns,
80316
80317 switch(acl_e->e_tag) {
80318 case ACL_USER_OBJ:
80319+ acl_e->e_perm &= ~((umask & S_IRWXU) >> 6);
80320+ break;
80321 case ACL_GROUP_OBJ:
80322 case ACL_MASK:
80323+ acl_e->e_perm &= ~((umask & S_IRWXG) >> 3);
80324+ break;
80325 case ACL_OTHER:
80326+ acl_e->e_perm &= ~(umask & S_IRWXO);
80327 break;
80328
80329 case ACL_USER:
80330+ acl_e->e_perm &= ~((umask & S_IRWXU) >> 6);
80331 acl_e->e_uid =
80332 make_kuid(user_ns,
80333 le32_to_cpu(entry->e_id));
80334@@ -706,6 +716,7 @@ posix_acl_from_xattr(struct user_namespace *user_ns,
80335 goto fail;
80336 break;
80337 case ACL_GROUP:
80338+ acl_e->e_perm &= ~((umask & S_IRWXG) >> 3);
80339 acl_e->e_gid =
80340 make_kgid(user_ns,
80341 le32_to_cpu(entry->e_id));
80342diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
80343index 2183fcf..3c32a98 100644
80344--- a/fs/proc/Kconfig
80345+++ b/fs/proc/Kconfig
80346@@ -30,7 +30,7 @@ config PROC_FS
80347
80348 config PROC_KCORE
80349 bool "/proc/kcore support" if !ARM
80350- depends on PROC_FS && MMU
80351+ depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
80352 help
80353 Provides a virtual ELF core file of the live kernel. This can
80354 be read with gdb and other ELF tools. No modifications can be
80355@@ -38,8 +38,8 @@ config PROC_KCORE
80356
80357 config PROC_VMCORE
80358 bool "/proc/vmcore support"
80359- depends on PROC_FS && CRASH_DUMP
80360- default y
80361+ depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
80362+ default n
80363 help
80364 Exports the dump image of crashed kernel in ELF format.
80365
80366@@ -63,8 +63,8 @@ config PROC_SYSCTL
80367 limited in memory.
80368
80369 config PROC_PAGE_MONITOR
80370- default y
80371- depends on PROC_FS && MMU
80372+ default n
80373+ depends on PROC_FS && MMU && !GRKERNSEC
80374 bool "Enable /proc page monitoring" if EXPERT
80375 help
80376 Various /proc files exist to monitor process memory utilization:
80377diff --git a/fs/proc/array.c b/fs/proc/array.c
80378index fd02a9e..7bc9dff 100644
80379--- a/fs/proc/array.c
80380+++ b/fs/proc/array.c
80381@@ -60,6 +60,7 @@
80382 #include <linux/tty.h>
80383 #include <linux/string.h>
80384 #include <linux/mman.h>
80385+#include <linux/grsecurity.h>
80386 #include <linux/proc_fs.h>
80387 #include <linux/ioport.h>
80388 #include <linux/uaccess.h>
80389@@ -340,6 +341,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
80390 cpumask_pr_args(&task->cpus_allowed));
80391 }
80392
80393+#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
80394+static inline void task_pax(struct seq_file *m, struct task_struct *p)
80395+{
80396+ if (p->mm)
80397+ seq_printf(m, "PaX:\t%c%c%c%c%c\n",
80398+ p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
80399+ p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
80400+ p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
80401+ p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
80402+ p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
80403+ else
80404+ seq_printf(m, "PaX:\t-----\n");
80405+}
80406+#endif
80407+
80408 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
80409 struct pid *pid, struct task_struct *task)
80410 {
80411@@ -358,9 +374,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
80412 task_cpus_allowed(m, task);
80413 cpuset_task_status_allowed(m, task);
80414 task_context_switch_counts(m, task);
80415+
80416+#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
80417+ task_pax(m, task);
80418+#endif
80419+
80420+#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
80421+ task_grsec_rbac(m, task);
80422+#endif
80423+
80424 return 0;
80425 }
80426
80427+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
80428+#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
80429+ (_mm->pax_flags & MF_PAX_RANDMMAP || \
80430+ _mm->pax_flags & MF_PAX_SEGMEXEC))
80431+#endif
80432+
80433 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
80434 struct pid *pid, struct task_struct *task, int whole)
80435 {
80436@@ -382,6 +413,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
80437 char tcomm[sizeof(task->comm)];
80438 unsigned long flags;
80439
80440+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
80441+ if (current->exec_id != m->exec_id) {
80442+ gr_log_badprocpid("stat");
80443+ return 0;
80444+ }
80445+#endif
80446+
80447 state = *get_task_state(task);
80448 vsize = eip = esp = 0;
80449 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
80450@@ -452,6 +490,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
80451 gtime = task_gtime(task);
80452 }
80453
80454+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
80455+ if (PAX_RAND_FLAGS(mm)) {
80456+ eip = 0;
80457+ esp = 0;
80458+ wchan = 0;
80459+ }
80460+#endif
80461+#ifdef CONFIG_GRKERNSEC_HIDESYM
80462+ wchan = 0;
80463+ eip =0;
80464+ esp =0;
80465+#endif
80466+
80467 /* scale priority and nice values from timeslices to -20..20 */
80468 /* to make it look like a "normal" Unix priority/nice value */
80469 priority = task_prio(task);
80470@@ -483,9 +534,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
80471 seq_put_decimal_ull(m, ' ', vsize);
80472 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
80473 seq_put_decimal_ull(m, ' ', rsslim);
80474+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
80475+ seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
80476+ seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
80477+ seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
80478+#else
80479 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
80480 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
80481 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
80482+#endif
80483 seq_put_decimal_ull(m, ' ', esp);
80484 seq_put_decimal_ull(m, ' ', eip);
80485 /* The signal information here is obsolete.
80486@@ -507,7 +564,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
80487 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
80488 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
80489
80490- if (mm && permitted) {
80491+ if (mm && permitted
80492+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
80493+ && !PAX_RAND_FLAGS(mm)
80494+#endif
80495+ ) {
80496 seq_put_decimal_ull(m, ' ', mm->start_data);
80497 seq_put_decimal_ull(m, ' ', mm->end_data);
80498 seq_put_decimal_ull(m, ' ', mm->start_brk);
80499@@ -545,8 +606,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
80500 struct pid *pid, struct task_struct *task)
80501 {
80502 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
80503- struct mm_struct *mm = get_task_mm(task);
80504+ struct mm_struct *mm;
80505
80506+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
80507+ if (current->exec_id != m->exec_id) {
80508+ gr_log_badprocpid("statm");
80509+ return 0;
80510+ }
80511+#endif
80512+ mm = get_task_mm(task);
80513 if (mm) {
80514 size = task_statm(mm, &shared, &text, &data, &resident);
80515 mmput(mm);
80516@@ -569,6 +637,20 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
80517 return 0;
80518 }
80519
80520+#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
80521+int proc_pid_ipaddr(struct seq_file *m, struct pid_namespace *ns, struct pid *pid, struct task_struct *task)
80522+{
80523+ unsigned long flags;
80524+ u32 curr_ip = 0;
80525+
80526+ if (lock_task_sighand(task, &flags)) {
80527+ curr_ip = task->signal->curr_ip;
80528+ unlock_task_sighand(task, &flags);
80529+ }
80530+ return seq_printf(m, "%pI4\n", &curr_ip);
80531+}
80532+#endif
80533+
80534 #ifdef CONFIG_CHECKPOINT_RESTORE
80535 static struct pid *
80536 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
80537diff --git a/fs/proc/base.c b/fs/proc/base.c
80538index 093ca14..322f097 100644
80539--- a/fs/proc/base.c
80540+++ b/fs/proc/base.c
80541@@ -113,6 +113,14 @@ struct pid_entry {
80542 union proc_op op;
80543 };
80544
80545+struct getdents_callback {
80546+ struct linux_dirent __user * current_dir;
80547+ struct linux_dirent __user * previous;
80548+ struct file * file;
80549+ int count;
80550+ int error;
80551+};
80552+
80553 #define NOD(NAME, MODE, IOP, FOP, OP) { \
80554 .name = (NAME), \
80555 .len = sizeof(NAME) - 1, \
80556@@ -208,12 +216,28 @@ static int proc_pid_cmdline(struct seq_file *m, struct pid_namespace *ns,
80557 return 0;
80558 }
80559
80560+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
80561+#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
80562+ (_mm->pax_flags & MF_PAX_RANDMMAP || \
80563+ _mm->pax_flags & MF_PAX_SEGMEXEC))
80564+#endif
80565+
80566 static int proc_pid_auxv(struct seq_file *m, struct pid_namespace *ns,
80567 struct pid *pid, struct task_struct *task)
80568 {
80569 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
80570 if (mm && !IS_ERR(mm)) {
80571 unsigned int nwords = 0;
80572+
80573+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
80574+ /* allow if we're currently ptracing this task */
80575+ if (PAX_RAND_FLAGS(mm) &&
80576+ (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
80577+ mmput(mm);
80578+ return 0;
80579+ }
80580+#endif
80581+
80582 do {
80583 nwords += 2;
80584 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
80585@@ -225,7 +249,7 @@ static int proc_pid_auxv(struct seq_file *m, struct pid_namespace *ns,
80586 }
80587
80588
80589-#ifdef CONFIG_KALLSYMS
80590+#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
80591 /*
80592 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
80593 * Returns the resolved symbol. If that fails, simply return the address.
80594@@ -267,7 +291,7 @@ static void unlock_trace(struct task_struct *task)
80595 mutex_unlock(&task->signal->cred_guard_mutex);
80596 }
80597
80598-#ifdef CONFIG_STACKTRACE
80599+#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
80600
80601 #define MAX_STACK_TRACE_DEPTH 64
80602
80603@@ -462,7 +486,7 @@ static int proc_pid_limits(struct seq_file *m, struct pid_namespace *ns,
80604 return 0;
80605 }
80606
80607-#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
80608+#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
80609 static int proc_pid_syscall(struct seq_file *m, struct pid_namespace *ns,
80610 struct pid *pid, struct task_struct *task)
80611 {
80612@@ -495,7 +519,7 @@ static int proc_pid_syscall(struct seq_file *m, struct pid_namespace *ns,
80613 /************************************************************************/
80614
80615 /* permission checks */
80616-static int proc_fd_access_allowed(struct inode *inode)
80617+static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
80618 {
80619 struct task_struct *task;
80620 int allowed = 0;
80621@@ -505,7 +529,10 @@ static int proc_fd_access_allowed(struct inode *inode)
80622 */
80623 task = get_proc_task(inode);
80624 if (task) {
80625- allowed = ptrace_may_access(task, PTRACE_MODE_READ);
80626+ if (log)
80627+ allowed = ptrace_may_access(task, PTRACE_MODE_READ);
80628+ else
80629+ allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
80630 put_task_struct(task);
80631 }
80632 return allowed;
80633@@ -536,10 +563,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
80634 struct task_struct *task,
80635 int hide_pid_min)
80636 {
80637+ if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
80638+ return false;
80639+
80640+#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
80641+ rcu_read_lock();
80642+ {
80643+ const struct cred *tmpcred = current_cred();
80644+ const struct cred *cred = __task_cred(task);
80645+
80646+ if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
80647+#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
80648+ || in_group_p(grsec_proc_gid)
80649+#endif
80650+ ) {
80651+ rcu_read_unlock();
80652+ return true;
80653+ }
80654+ }
80655+ rcu_read_unlock();
80656+
80657+ if (!pid->hide_pid)
80658+ return false;
80659+#endif
80660+
80661 if (pid->hide_pid < hide_pid_min)
80662 return true;
80663 if (in_group_p(pid->pid_gid))
80664 return true;
80665+
80666 return ptrace_may_access(task, PTRACE_MODE_READ);
80667 }
80668
80669@@ -557,7 +609,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
80670 put_task_struct(task);
80671
80672 if (!has_perms) {
80673+#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
80674+ {
80675+#else
80676 if (pid->hide_pid == 2) {
80677+#endif
80678 /*
80679 * Let's make getdents(), stat(), and open()
80680 * consistent with each other. If a process
80681@@ -618,6 +674,10 @@ struct mm_struct *proc_mem_open(struct inode *inode, unsigned int mode)
80682
80683 if (task) {
80684 mm = mm_access(task, mode);
80685+ if (!IS_ERR_OR_NULL(mm) && gr_acl_handle_procpidmem(task)) {
80686+ mmput(mm);
80687+ mm = ERR_PTR(-EPERM);
80688+ }
80689 put_task_struct(task);
80690
80691 if (!IS_ERR_OR_NULL(mm)) {
80692@@ -639,6 +699,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
80693 return PTR_ERR(mm);
80694
80695 file->private_data = mm;
80696+
80697+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
80698+ file->f_version = current->exec_id;
80699+#endif
80700+
80701 return 0;
80702 }
80703
80704@@ -660,6 +725,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
80705 ssize_t copied;
80706 char *page;
80707
80708+#ifdef CONFIG_GRKERNSEC
80709+ if (write)
80710+ return -EPERM;
80711+#endif
80712+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
80713+ if (file->f_version != current->exec_id) {
80714+ gr_log_badprocpid("mem");
80715+ return 0;
80716+ }
80717+#endif
80718+
80719 if (!mm)
80720 return 0;
80721
80722@@ -672,7 +748,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
80723 goto free;
80724
80725 while (count > 0) {
80726- int this_len = min_t(int, count, PAGE_SIZE);
80727+ ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
80728
80729 if (write && copy_from_user(page, buf, this_len)) {
80730 copied = -EFAULT;
80731@@ -764,6 +840,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
80732 if (!mm)
80733 return 0;
80734
80735+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
80736+ if (file->f_version != current->exec_id) {
80737+ gr_log_badprocpid("environ");
80738+ return 0;
80739+ }
80740+#endif
80741+
80742 page = (char *)__get_free_page(GFP_TEMPORARY);
80743 if (!page)
80744 return -ENOMEM;
80745@@ -773,7 +856,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
80746 goto free;
80747 while (count > 0) {
80748 size_t this_len, max_len;
80749- int retval;
80750+ ssize_t retval;
80751
80752 if (src >= (mm->env_end - mm->env_start))
80753 break;
80754@@ -1387,7 +1470,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
80755 int error = -EACCES;
80756
80757 /* Are we allowed to snoop on the tasks file descriptors? */
80758- if (!proc_fd_access_allowed(inode))
80759+ if (!proc_fd_access_allowed(inode, 0))
80760 goto out;
80761
80762 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
80763@@ -1431,8 +1514,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
80764 struct path path;
80765
80766 /* Are we allowed to snoop on the tasks file descriptors? */
80767- if (!proc_fd_access_allowed(inode))
80768- goto out;
80769+ /* logging this is needed for learning on chromium to work properly,
80770+ but we don't want to flood the logs from 'ps' which does a readlink
80771+ on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
80772+ CAP_SYS_PTRACE as it's not necessary for its basic functionality
80773+ */
80774+ if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
80775+ if (!proc_fd_access_allowed(inode,0))
80776+ goto out;
80777+ } else {
80778+ if (!proc_fd_access_allowed(inode,1))
80779+ goto out;
80780+ }
80781
80782 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
80783 if (error)
80784@@ -1482,7 +1575,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
80785 rcu_read_lock();
80786 cred = __task_cred(task);
80787 inode->i_uid = cred->euid;
80788+#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
80789+ inode->i_gid = grsec_proc_gid;
80790+#else
80791 inode->i_gid = cred->egid;
80792+#endif
80793 rcu_read_unlock();
80794 }
80795 security_task_to_inode(task, inode);
80796@@ -1518,10 +1615,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
80797 return -ENOENT;
80798 }
80799 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
80800+#ifdef CONFIG_GRKERNSEC_PROC_USER
80801+ (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
80802+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
80803+ (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
80804+#endif
80805 task_dumpable(task)) {
80806 cred = __task_cred(task);
80807 stat->uid = cred->euid;
80808+#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
80809+ stat->gid = grsec_proc_gid;
80810+#else
80811 stat->gid = cred->egid;
80812+#endif
80813 }
80814 }
80815 rcu_read_unlock();
80816@@ -1559,11 +1665,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
80817
80818 if (task) {
80819 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
80820+#ifdef CONFIG_GRKERNSEC_PROC_USER
80821+ (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
80822+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
80823+ (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
80824+#endif
80825 task_dumpable(task)) {
80826 rcu_read_lock();
80827 cred = __task_cred(task);
80828 inode->i_uid = cred->euid;
80829+#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
80830+ inode->i_gid = grsec_proc_gid;
80831+#else
80832 inode->i_gid = cred->egid;
80833+#endif
80834 rcu_read_unlock();
80835 } else {
80836 inode->i_uid = GLOBAL_ROOT_UID;
80837@@ -2095,6 +2210,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
80838 if (!task)
80839 goto out_no_task;
80840
80841+ if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
80842+ goto out;
80843+
80844 /*
80845 * Yes, it does not scale. And it should not. Don't add
80846 * new entries into /proc/<tgid>/ without very good reasons.
80847@@ -2125,6 +2243,9 @@ static int proc_pident_readdir(struct file *file, struct dir_context *ctx,
80848 if (!task)
80849 return -ENOENT;
80850
80851+ if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
80852+ goto out;
80853+
80854 if (!dir_emit_dots(file, ctx))
80855 goto out;
80856
80857@@ -2569,7 +2690,7 @@ static const struct pid_entry tgid_base_stuff[] = {
80858 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
80859 #endif
80860 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
80861-#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
80862+#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
80863 ONE("syscall", S_IRUSR, proc_pid_syscall),
80864 #endif
80865 ONE("cmdline", S_IRUGO, proc_pid_cmdline),
80866@@ -2594,10 +2715,10 @@ static const struct pid_entry tgid_base_stuff[] = {
80867 #ifdef CONFIG_SECURITY
80868 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
80869 #endif
80870-#ifdef CONFIG_KALLSYMS
80871+#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
80872 ONE("wchan", S_IRUGO, proc_pid_wchan),
80873 #endif
80874-#ifdef CONFIG_STACKTRACE
80875+#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
80876 ONE("stack", S_IRUSR, proc_pid_stack),
80877 #endif
80878 #ifdef CONFIG_SCHEDSTATS
80879@@ -2631,6 +2752,9 @@ static const struct pid_entry tgid_base_stuff[] = {
80880 #ifdef CONFIG_HARDWALL
80881 ONE("hardwall", S_IRUGO, proc_pid_hardwall),
80882 #endif
80883+#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
80884+ ONE("ipaddr", S_IRUSR, proc_pid_ipaddr),
80885+#endif
80886 #ifdef CONFIG_USER_NS
80887 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
80888 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
80889@@ -2763,7 +2887,14 @@ static int proc_pid_instantiate(struct inode *dir,
80890 if (!inode)
80891 goto out;
80892
80893+#ifdef CONFIG_GRKERNSEC_PROC_USER
80894+ inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
80895+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
80896+ inode->i_gid = grsec_proc_gid;
80897+ inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
80898+#else
80899 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
80900+#endif
80901 inode->i_op = &proc_tgid_base_inode_operations;
80902 inode->i_fop = &proc_tgid_base_operations;
80903 inode->i_flags|=S_IMMUTABLE;
80904@@ -2801,7 +2932,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
80905 if (!task)
80906 goto out;
80907
80908+ if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
80909+ goto out_put_task;
80910+
80911 result = proc_pid_instantiate(dir, dentry, task, NULL);
80912+out_put_task:
80913 put_task_struct(task);
80914 out:
80915 return ERR_PTR(result);
80916@@ -2915,7 +3050,7 @@ static const struct pid_entry tid_base_stuff[] = {
80917 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
80918 #endif
80919 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
80920-#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
80921+#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
80922 ONE("syscall", S_IRUSR, proc_pid_syscall),
80923 #endif
80924 ONE("cmdline", S_IRUGO, proc_pid_cmdline),
80925@@ -2942,10 +3077,10 @@ static const struct pid_entry tid_base_stuff[] = {
80926 #ifdef CONFIG_SECURITY
80927 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
80928 #endif
80929-#ifdef CONFIG_KALLSYMS
80930+#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
80931 ONE("wchan", S_IRUGO, proc_pid_wchan),
80932 #endif
80933-#ifdef CONFIG_STACKTRACE
80934+#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
80935 ONE("stack", S_IRUSR, proc_pid_stack),
80936 #endif
80937 #ifdef CONFIG_SCHEDSTATS
80938diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
80939index cbd82df..c0407d2 100644
80940--- a/fs/proc/cmdline.c
80941+++ b/fs/proc/cmdline.c
80942@@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
80943
80944 static int __init proc_cmdline_init(void)
80945 {
80946+#ifdef CONFIG_GRKERNSEC_PROC_ADD
80947+ proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
80948+#else
80949 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
80950+#endif
80951 return 0;
80952 }
80953 fs_initcall(proc_cmdline_init);
80954diff --git a/fs/proc/devices.c b/fs/proc/devices.c
80955index 50493ed..248166b 100644
80956--- a/fs/proc/devices.c
80957+++ b/fs/proc/devices.c
80958@@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
80959
80960 static int __init proc_devices_init(void)
80961 {
80962+#ifdef CONFIG_GRKERNSEC_PROC_ADD
80963+ proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
80964+#else
80965 proc_create("devices", 0, NULL, &proc_devinfo_operations);
80966+#endif
80967 return 0;
80968 }
80969 fs_initcall(proc_devices_init);
80970diff --git a/fs/proc/fd.c b/fs/proc/fd.c
80971index 6e5fcd0..06ea074 100644
80972--- a/fs/proc/fd.c
80973+++ b/fs/proc/fd.c
80974@@ -27,7 +27,8 @@ static int seq_show(struct seq_file *m, void *v)
80975 if (!task)
80976 return -ENOENT;
80977
80978- files = get_files_struct(task);
80979+ if (!gr_acl_handle_procpidmem(task))
80980+ files = get_files_struct(task);
80981 put_task_struct(task);
80982
80983 if (files) {
80984@@ -291,11 +292,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
80985 */
80986 int proc_fd_permission(struct inode *inode, int mask)
80987 {
80988+ struct task_struct *task;
80989 int rv = generic_permission(inode, mask);
80990- if (rv == 0)
80991- return 0;
80992+
80993 if (task_tgid(current) == proc_pid(inode))
80994 rv = 0;
80995+
80996+ task = get_proc_task(inode);
80997+ if (task == NULL)
80998+ return rv;
80999+
81000+ if (gr_acl_handle_procpidmem(task))
81001+ rv = -EACCES;
81002+
81003+ put_task_struct(task);
81004+
81005 return rv;
81006 }
81007
81008diff --git a/fs/proc/generic.c b/fs/proc/generic.c
81009index e5dee5c..dafe21b 100644
81010--- a/fs/proc/generic.c
81011+++ b/fs/proc/generic.c
81012@@ -22,6 +22,7 @@
81013 #include <linux/bitops.h>
81014 #include <linux/spinlock.h>
81015 #include <linux/completion.h>
81016+#include <linux/grsecurity.h>
81017 #include <asm/uaccess.h>
81018
81019 #include "internal.h"
81020@@ -253,6 +254,15 @@ struct dentry *proc_lookup(struct inode *dir, struct dentry *dentry,
81021 return proc_lookup_de(PDE(dir), dir, dentry);
81022 }
81023
81024+struct dentry *proc_lookup_restrict(struct inode *dir, struct dentry *dentry,
81025+ unsigned int flags)
81026+{
81027+ if (gr_proc_is_restricted())
81028+ return ERR_PTR(-EACCES);
81029+
81030+ return proc_lookup_de(PDE(dir), dir, dentry);
81031+}
81032+
81033 /*
81034 * This returns non-zero if at EOF, so that the /proc
81035 * root directory can use this and check if it should
81036@@ -310,6 +320,16 @@ int proc_readdir(struct file *file, struct dir_context *ctx)
81037 return proc_readdir_de(PDE(inode), file, ctx);
81038 }
81039
81040+int proc_readdir_restrict(struct file *file, struct dir_context *ctx)
81041+{
81042+ struct inode *inode = file_inode(file);
81043+
81044+ if (gr_proc_is_restricted())
81045+ return -EACCES;
81046+
81047+ return proc_readdir_de(PDE(inode), file, ctx);
81048+}
81049+
81050 /*
81051 * These are the generic /proc directory operations. They
81052 * use the in-memory "struct proc_dir_entry" tree to parse
81053@@ -321,6 +341,12 @@ static const struct file_operations proc_dir_operations = {
81054 .iterate = proc_readdir,
81055 };
81056
81057+static const struct file_operations proc_dir_restricted_operations = {
81058+ .llseek = generic_file_llseek,
81059+ .read = generic_read_dir,
81060+ .iterate = proc_readdir_restrict,
81061+};
81062+
81063 /*
81064 * proc directories can do almost nothing..
81065 */
81066@@ -330,6 +356,12 @@ static const struct inode_operations proc_dir_inode_operations = {
81067 .setattr = proc_notify_change,
81068 };
81069
81070+static const struct inode_operations proc_dir_restricted_inode_operations = {
81071+ .lookup = proc_lookup_restrict,
81072+ .getattr = proc_getattr,
81073+ .setattr = proc_notify_change,
81074+};
81075+
81076 static int proc_register(struct proc_dir_entry * dir, struct proc_dir_entry * dp)
81077 {
81078 int ret;
81079@@ -445,6 +477,31 @@ struct proc_dir_entry *proc_mkdir_data(const char *name, umode_t mode,
81080 }
81081 EXPORT_SYMBOL_GPL(proc_mkdir_data);
81082
81083+struct proc_dir_entry *proc_mkdir_data_restrict(const char *name, umode_t mode,
81084+ struct proc_dir_entry *parent, void *data)
81085+{
81086+ struct proc_dir_entry *ent;
81087+
81088+ if (mode == 0)
81089+ mode = S_IRUGO | S_IXUGO;
81090+
81091+ ent = __proc_create(&parent, name, S_IFDIR | mode, 2);
81092+ if (ent) {
81093+ ent->data = data;
81094+ ent->restricted = 1;
81095+ ent->proc_fops = &proc_dir_restricted_operations;
81096+ ent->proc_iops = &proc_dir_restricted_inode_operations;
81097+ parent->nlink++;
81098+ if (proc_register(parent, ent) < 0) {
81099+ kfree(ent);
81100+ parent->nlink--;
81101+ ent = NULL;
81102+ }
81103+ }
81104+ return ent;
81105+}
81106+EXPORT_SYMBOL_GPL(proc_mkdir_data_restrict);
81107+
81108 struct proc_dir_entry *proc_mkdir_mode(const char *name, umode_t mode,
81109 struct proc_dir_entry *parent)
81110 {
81111@@ -459,6 +516,13 @@ struct proc_dir_entry *proc_mkdir(const char *name,
81112 }
81113 EXPORT_SYMBOL(proc_mkdir);
81114
81115+struct proc_dir_entry *proc_mkdir_restrict(const char *name,
81116+ struct proc_dir_entry *parent)
81117+{
81118+ return proc_mkdir_data_restrict(name, 0, parent, NULL);
81119+}
81120+EXPORT_SYMBOL(proc_mkdir_restrict);
81121+
81122 struct proc_dir_entry *proc_create_mount_point(const char *name)
81123 {
81124 umode_t mode = S_IFDIR | S_IRUGO | S_IXUGO;
81125diff --git a/fs/proc/inode.c b/fs/proc/inode.c
81126index e3eb552..bcb0f25 100644
81127--- a/fs/proc/inode.c
81128+++ b/fs/proc/inode.c
81129@@ -24,11 +24,17 @@
81130 #include <linux/mount.h>
81131 #include <linux/magic.h>
81132 #include <linux/namei.h>
81133+#include <linux/grsecurity.h>
81134
81135 #include <asm/uaccess.h>
81136
81137 #include "internal.h"
81138
81139+#ifdef CONFIG_PROC_SYSCTL
81140+extern const struct inode_operations proc_sys_inode_operations;
81141+extern const struct inode_operations proc_sys_dir_operations;
81142+#endif
81143+
81144 static void proc_evict_inode(struct inode *inode)
81145 {
81146 struct proc_dir_entry *de;
81147@@ -49,6 +55,13 @@ static void proc_evict_inode(struct inode *inode)
81148 RCU_INIT_POINTER(PROC_I(inode)->sysctl, NULL);
81149 sysctl_head_put(head);
81150 }
81151+
81152+#ifdef CONFIG_PROC_SYSCTL
81153+ if (inode->i_op == &proc_sys_inode_operations ||
81154+ inode->i_op == &proc_sys_dir_operations)
81155+ gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
81156+#endif
81157+
81158 }
81159
81160 static struct kmem_cache * proc_inode_cachep;
81161@@ -430,7 +443,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
81162 if (de->mode) {
81163 inode->i_mode = de->mode;
81164 inode->i_uid = de->uid;
81165+#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
81166+ inode->i_gid = grsec_proc_gid;
81167+#else
81168 inode->i_gid = de->gid;
81169+#endif
81170 }
81171 if (de->size)
81172 inode->i_size = de->size;
81173diff --git a/fs/proc/internal.h b/fs/proc/internal.h
81174index aa27810..9f2d3b2 100644
81175--- a/fs/proc/internal.h
81176+++ b/fs/proc/internal.h
81177@@ -47,9 +47,10 @@ struct proc_dir_entry {
81178 struct completion *pde_unload_completion;
81179 struct list_head pde_openers; /* who did ->open, but not ->release */
81180 spinlock_t pde_unload_lock; /* proc_fops checks and pde_users bumps */
81181+ u8 restricted; /* a directory in /proc/net that should be restricted via GRKERNSEC_PROC */
81182 u8 namelen;
81183 char name[];
81184-};
81185+} __randomize_layout;
81186
81187 union proc_op {
81188 int (*proc_get_link)(struct dentry *, struct path *);
81189@@ -67,7 +68,7 @@ struct proc_inode {
81190 struct ctl_table *sysctl_entry;
81191 const struct proc_ns_operations *ns_ops;
81192 struct inode vfs_inode;
81193-};
81194+} __randomize_layout;
81195
81196 /*
81197 * General functions
81198@@ -155,6 +156,10 @@ extern int proc_pid_status(struct seq_file *, struct pid_namespace *,
81199 struct pid *, struct task_struct *);
81200 extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,
81201 struct pid *, struct task_struct *);
81202+#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
81203+extern int proc_pid_ipaddr(struct seq_file *, struct pid_namespace *,
81204+ struct pid *, struct task_struct *);
81205+#endif
81206
81207 /*
81208 * base.c
81209@@ -179,9 +184,11 @@ extern bool proc_fill_cache(struct file *, struct dir_context *, const char *, i
81210 * generic.c
81211 */
81212 extern struct dentry *proc_lookup(struct inode *, struct dentry *, unsigned int);
81213+extern struct dentry *proc_lookup_restrict(struct inode *, struct dentry *, unsigned int);
81214 extern struct dentry *proc_lookup_de(struct proc_dir_entry *, struct inode *,
81215 struct dentry *);
81216 extern int proc_readdir(struct file *, struct dir_context *);
81217+extern int proc_readdir_restrict(struct file *, struct dir_context *);
81218 extern int proc_readdir_de(struct proc_dir_entry *, struct file *, struct dir_context *);
81219
81220 static inline struct proc_dir_entry *pde_get(struct proc_dir_entry *pde)
81221diff --git a/fs/proc/interrupts.c b/fs/proc/interrupts.c
81222index a352d57..cb94a5c 100644
81223--- a/fs/proc/interrupts.c
81224+++ b/fs/proc/interrupts.c
81225@@ -47,7 +47,11 @@ static const struct file_operations proc_interrupts_operations = {
81226
81227 static int __init proc_interrupts_init(void)
81228 {
81229+#ifdef CONFIG_GRKERNSEC_PROC_ADD
81230+ proc_create_grsec("interrupts", 0, NULL, &proc_interrupts_operations);
81231+#else
81232 proc_create("interrupts", 0, NULL, &proc_interrupts_operations);
81233+#endif
81234 return 0;
81235 }
81236 fs_initcall(proc_interrupts_init);
81237diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
81238index 91a4e64..14bf8fa 100644
81239--- a/fs/proc/kcore.c
81240+++ b/fs/proc/kcore.c
81241@@ -483,9 +483,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
81242 * the addresses in the elf_phdr on our list.
81243 */
81244 start = kc_offset_to_vaddr(*fpos - elf_buflen);
81245- if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
81246+ tsz = PAGE_SIZE - (start & ~PAGE_MASK);
81247+ if (tsz > buflen)
81248 tsz = buflen;
81249-
81250+
81251 while (buflen) {
81252 struct kcore_list *m;
81253
81254@@ -515,19 +516,20 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
81255 } else {
81256 if (kern_addr_valid(start)) {
81257 unsigned long n;
81258+ char *elf_buf;
81259+ mm_segment_t oldfs;
81260
81261- n = copy_to_user(buffer, (char *)start, tsz);
81262- /*
81263- * We cannot distinguish between fault on source
81264- * and fault on destination. When this happens
81265- * we clear too and hope it will trigger the
81266- * EFAULT again.
81267- */
81268- if (n) {
81269- if (clear_user(buffer + tsz - n,
81270- n))
81271- return -EFAULT;
81272- }
81273+ elf_buf = kzalloc(tsz, GFP_KERNEL);
81274+ if (!elf_buf)
81275+ return -ENOMEM;
81276+ oldfs = get_fs();
81277+ set_fs(KERNEL_DS);
81278+ n = __copy_from_user(elf_buf, (const void __user *)start, tsz);
81279+ set_fs(oldfs);
81280+ n = copy_to_user(buffer, elf_buf, tsz);
81281+ kfree(elf_buf);
81282+ if (n)
81283+ return -EFAULT;
81284 } else {
81285 if (clear_user(buffer, tsz))
81286 return -EFAULT;
81287@@ -547,6 +549,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
81288
81289 static int open_kcore(struct inode *inode, struct file *filp)
81290 {
81291+#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
81292+ return -EPERM;
81293+#endif
81294 if (!capable(CAP_SYS_RAWIO))
81295 return -EPERM;
81296 if (kcore_need_update)
81297@@ -580,7 +585,7 @@ static int __meminit kcore_callback(struct notifier_block *self,
81298 return NOTIFY_OK;
81299 }
81300
81301-static struct notifier_block kcore_callback_nb __meminitdata = {
81302+static struct notifier_block kcore_callback_nb __meminitconst = {
81303 .notifier_call = kcore_callback,
81304 .priority = 0,
81305 };
81306diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
81307index d3ebf2e..6ad42d1 100644
81308--- a/fs/proc/meminfo.c
81309+++ b/fs/proc/meminfo.c
81310@@ -194,7 +194,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
81311 vmi.used >> 10,
81312 vmi.largest_chunk >> 10
81313 #ifdef CONFIG_MEMORY_FAILURE
81314- , atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
81315+ , atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
81316 #endif
81317 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
81318 , K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
81319diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
81320index d4a3574..b421ce9 100644
81321--- a/fs/proc/nommu.c
81322+++ b/fs/proc/nommu.c
81323@@ -64,7 +64,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
81324
81325 if (file) {
81326 seq_pad(m, ' ');
81327- seq_path(m, &file->f_path, "");
81328+ seq_path(m, &file->f_path, "\n\\");
81329 }
81330
81331 seq_putc(m, '\n');
81332diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
81333index 350984a..0fb02a9 100644
81334--- a/fs/proc/proc_net.c
81335+++ b/fs/proc/proc_net.c
81336@@ -23,9 +23,27 @@
81337 #include <linux/nsproxy.h>
81338 #include <net/net_namespace.h>
81339 #include <linux/seq_file.h>
81340+#include <linux/grsecurity.h>
81341
81342 #include "internal.h"
81343
81344+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
81345+static struct seq_operations *ipv6_seq_ops_addr;
81346+
81347+void register_ipv6_seq_ops_addr(struct seq_operations *addr)
81348+{
81349+ ipv6_seq_ops_addr = addr;
81350+}
81351+
81352+void unregister_ipv6_seq_ops_addr(void)
81353+{
81354+ ipv6_seq_ops_addr = NULL;
81355+}
81356+
81357+EXPORT_SYMBOL_GPL(register_ipv6_seq_ops_addr);
81358+EXPORT_SYMBOL_GPL(unregister_ipv6_seq_ops_addr);
81359+#endif
81360+
81361 static inline struct net *PDE_NET(struct proc_dir_entry *pde)
81362 {
81363 return pde->parent->data;
81364@@ -36,6 +54,8 @@ static struct net *get_proc_net(const struct inode *inode)
81365 return maybe_get_net(PDE_NET(PDE(inode)));
81366 }
81367
81368+extern const struct seq_operations dev_seq_ops;
81369+
81370 int seq_open_net(struct inode *ino, struct file *f,
81371 const struct seq_operations *ops, int size)
81372 {
81373@@ -44,6 +64,14 @@ int seq_open_net(struct inode *ino, struct file *f,
81374
81375 BUG_ON(size < sizeof(*p));
81376
81377+ /* only permit access to /proc/net/dev */
81378+ if (
81379+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
81380+ ops != ipv6_seq_ops_addr &&
81381+#endif
81382+ ops != &dev_seq_ops && gr_proc_is_restricted())
81383+ return -EACCES;
81384+
81385 net = get_proc_net(ino);
81386 if (net == NULL)
81387 return -ENXIO;
81388@@ -66,6 +94,9 @@ int single_open_net(struct inode *inode, struct file *file,
81389 int err;
81390 struct net *net;
81391
81392+ if (gr_proc_is_restricted())
81393+ return -EACCES;
81394+
81395 err = -ENXIO;
81396 net = get_proc_net(inode);
81397 if (net == NULL)
81398diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
81399index fdda62e..cd7c75f 100644
81400--- a/fs/proc/proc_sysctl.c
81401+++ b/fs/proc/proc_sysctl.c
81402@@ -11,13 +11,21 @@
81403 #include <linux/namei.h>
81404 #include <linux/mm.h>
81405 #include <linux/module.h>
81406+#include <linux/nsproxy.h>
81407+#ifdef CONFIG_GRKERNSEC
81408+#include <net/net_namespace.h>
81409+#endif
81410 #include "internal.h"
81411
81412+extern int gr_handle_chroot_sysctl(const int op);
81413+extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
81414+ const int op);
81415+
81416 static const struct dentry_operations proc_sys_dentry_operations;
81417 static const struct file_operations proc_sys_file_operations;
81418-static const struct inode_operations proc_sys_inode_operations;
81419+const struct inode_operations proc_sys_inode_operations;
81420 static const struct file_operations proc_sys_dir_file_operations;
81421-static const struct inode_operations proc_sys_dir_operations;
81422+const struct inode_operations proc_sys_dir_operations;
81423
81424 /* Support for permanently empty directories */
81425
81426@@ -32,13 +40,17 @@ static bool is_empty_dir(struct ctl_table_header *head)
81427
81428 static void set_empty_dir(struct ctl_dir *dir)
81429 {
81430- dir->header.ctl_table[0].child = sysctl_mount_point;
81431+ pax_open_kernel();
81432+ *(const void **)&dir->header.ctl_table[0].child = sysctl_mount_point;
81433+ pax_close_kernel();
81434 }
81435
81436 static void clear_empty_dir(struct ctl_dir *dir)
81437
81438 {
81439- dir->header.ctl_table[0].child = NULL;
81440+ pax_open_kernel();
81441+ *(void **)&dir->header.ctl_table[0].child = NULL;
81442+ pax_close_kernel();
81443 }
81444
81445 void proc_sys_poll_notify(struct ctl_table_poll *poll)
81446@@ -504,6 +516,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
81447
81448 err = NULL;
81449 d_set_d_op(dentry, &proc_sys_dentry_operations);
81450+
81451+ gr_handle_proc_create(dentry, inode);
81452+
81453 d_add(dentry, inode);
81454
81455 out:
81456@@ -519,6 +534,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
81457 struct inode *inode = file_inode(filp);
81458 struct ctl_table_header *head = grab_header(inode);
81459 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
81460+ int op = write ? MAY_WRITE : MAY_READ;
81461 ssize_t error;
81462 size_t res;
81463
81464@@ -530,7 +546,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
81465 * and won't be until we finish.
81466 */
81467 error = -EPERM;
81468- if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
81469+ if (sysctl_perm(head, table, op))
81470 goto out;
81471
81472 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
81473@@ -538,6 +554,27 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
81474 if (!table->proc_handler)
81475 goto out;
81476
81477+#ifdef CONFIG_GRKERNSEC
81478+ error = -EPERM;
81479+ if (gr_handle_chroot_sysctl(op))
81480+ goto out;
81481+ dget(filp->f_path.dentry);
81482+ if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
81483+ dput(filp->f_path.dentry);
81484+ goto out;
81485+ }
81486+ dput(filp->f_path.dentry);
81487+ if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
81488+ goto out;
81489+ if (write) {
81490+ if (current->nsproxy->net_ns != table->extra2) {
81491+ if (!capable(CAP_SYS_ADMIN))
81492+ goto out;
81493+ } else if (!ns_capable(current->nsproxy->net_ns->user_ns, CAP_NET_ADMIN))
81494+ goto out;
81495+ }
81496+#endif
81497+
81498 /* careful: calling conventions are nasty here */
81499 res = count;
81500 error = table->proc_handler(table, write, buf, &res, ppos);
81501@@ -635,6 +672,9 @@ static bool proc_sys_fill_cache(struct file *file,
81502 return false;
81503 } else {
81504 d_set_d_op(child, &proc_sys_dentry_operations);
81505+
81506+ gr_handle_proc_create(child, inode);
81507+
81508 d_add(child, inode);
81509 }
81510 } else {
81511@@ -678,6 +718,9 @@ static int scan(struct ctl_table_header *head, struct ctl_table *table,
81512 if ((*pos)++ < ctx->pos)
81513 return true;
81514
81515+ if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
81516+ return 0;
81517+
81518 if (unlikely(S_ISLNK(table->mode)))
81519 res = proc_sys_link_fill_cache(file, ctx, head, table);
81520 else
81521@@ -771,6 +814,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
81522 if (IS_ERR(head))
81523 return PTR_ERR(head);
81524
81525+ if (table && !gr_acl_handle_hidden_file(dentry, mnt))
81526+ return -ENOENT;
81527+
81528 generic_fillattr(inode, stat);
81529 if (table)
81530 stat->mode = (stat->mode & S_IFMT) | table->mode;
81531@@ -793,13 +839,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
81532 .llseek = generic_file_llseek,
81533 };
81534
81535-static const struct inode_operations proc_sys_inode_operations = {
81536+const struct inode_operations proc_sys_inode_operations = {
81537 .permission = proc_sys_permission,
81538 .setattr = proc_sys_setattr,
81539 .getattr = proc_sys_getattr,
81540 };
81541
81542-static const struct inode_operations proc_sys_dir_operations = {
81543+const struct inode_operations proc_sys_dir_operations = {
81544 .lookup = proc_sys_lookup,
81545 .permission = proc_sys_permission,
81546 .setattr = proc_sys_setattr,
81547@@ -876,7 +922,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
81548 static struct ctl_dir *new_dir(struct ctl_table_set *set,
81549 const char *name, int namelen)
81550 {
81551- struct ctl_table *table;
81552+ ctl_table_no_const *table;
81553 struct ctl_dir *new;
81554 struct ctl_node *node;
81555 char *new_name;
81556@@ -888,7 +934,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
81557 return NULL;
81558
81559 node = (struct ctl_node *)(new + 1);
81560- table = (struct ctl_table *)(node + 1);
81561+ table = (ctl_table_no_const *)(node + 1);
81562 new_name = (char *)(table + 2);
81563 memcpy(new_name, name, namelen);
81564 new_name[namelen] = '\0';
81565@@ -1057,7 +1103,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
81566 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
81567 struct ctl_table_root *link_root)
81568 {
81569- struct ctl_table *link_table, *entry, *link;
81570+ ctl_table_no_const *link_table, *link;
81571+ struct ctl_table *entry;
81572 struct ctl_table_header *links;
81573 struct ctl_node *node;
81574 char *link_name;
81575@@ -1080,7 +1127,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
81576 return NULL;
81577
81578 node = (struct ctl_node *)(links + 1);
81579- link_table = (struct ctl_table *)(node + nr_entries);
81580+ link_table = (ctl_table_no_const *)(node + nr_entries);
81581 link_name = (char *)&link_table[nr_entries + 1];
81582
81583 for (link = link_table, entry = table; entry->procname; link++, entry++) {
81584@@ -1328,8 +1375,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
81585 struct ctl_table_header ***subheader, struct ctl_table_set *set,
81586 struct ctl_table *table)
81587 {
81588- struct ctl_table *ctl_table_arg = NULL;
81589- struct ctl_table *entry, *files;
81590+ ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
81591+ struct ctl_table *entry;
81592 int nr_files = 0;
81593 int nr_dirs = 0;
81594 int err = -ENOMEM;
81595@@ -1341,10 +1388,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
81596 nr_files++;
81597 }
81598
81599- files = table;
81600 /* If there are mixed files and directories we need a new table */
81601 if (nr_dirs && nr_files) {
81602- struct ctl_table *new;
81603+ ctl_table_no_const *new;
81604 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
81605 GFP_KERNEL);
81606 if (!files)
81607@@ -1362,7 +1408,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
81608 /* Register everything except a directory full of subdirectories */
81609 if (nr_files || !nr_dirs) {
81610 struct ctl_table_header *header;
81611- header = __register_sysctl_table(set, path, files);
81612+ header = __register_sysctl_table(set, path, files ? files : table);
81613 if (!header) {
81614 kfree(ctl_table_arg);
81615 goto out;
81616diff --git a/fs/proc/root.c b/fs/proc/root.c
81617index 68feb0f..2c04780 100644
81618--- a/fs/proc/root.c
81619+++ b/fs/proc/root.c
81620@@ -185,7 +185,15 @@ void __init proc_root_init(void)
81621 proc_create_mount_point("openprom");
81622 #endif
81623 proc_tty_init();
81624+#ifdef CONFIG_GRKERNSEC_PROC_ADD
81625+#ifdef CONFIG_GRKERNSEC_PROC_USER
81626+ proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
81627+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
81628+ proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
81629+#endif
81630+#else
81631 proc_mkdir("bus", NULL);
81632+#endif
81633 proc_sys_init();
81634 }
81635
81636diff --git a/fs/proc/stat.c b/fs/proc/stat.c
81637index 510413eb..34d9a8c 100644
81638--- a/fs/proc/stat.c
81639+++ b/fs/proc/stat.c
81640@@ -11,6 +11,7 @@
81641 #include <linux/irqnr.h>
81642 #include <linux/cputime.h>
81643 #include <linux/tick.h>
81644+#include <linux/grsecurity.h>
81645
81646 #ifndef arch_irq_stat_cpu
81647 #define arch_irq_stat_cpu(cpu) 0
81648@@ -87,6 +88,18 @@ static int show_stat(struct seq_file *p, void *v)
81649 u64 sum_softirq = 0;
81650 unsigned int per_softirq_sums[NR_SOFTIRQS] = {0};
81651 struct timespec boottime;
81652+ int unrestricted = 1;
81653+
81654+#ifdef CONFIG_GRKERNSEC_PROC_ADD
81655+#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
81656+ if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)
81657+#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
81658+ && !in_group_p(grsec_proc_gid)
81659+#endif
81660+ )
81661+ unrestricted = 0;
81662+#endif
81663+#endif
81664
81665 user = nice = system = idle = iowait =
81666 irq = softirq = steal = 0;
81667@@ -99,23 +112,25 @@ static int show_stat(struct seq_file *p, void *v)
81668 nice += kcpustat_cpu(i).cpustat[CPUTIME_NICE];
81669 system += kcpustat_cpu(i).cpustat[CPUTIME_SYSTEM];
81670 idle += get_idle_time(i);
81671- iowait += get_iowait_time(i);
81672- irq += kcpustat_cpu(i).cpustat[CPUTIME_IRQ];
81673- softirq += kcpustat_cpu(i).cpustat[CPUTIME_SOFTIRQ];
81674- steal += kcpustat_cpu(i).cpustat[CPUTIME_STEAL];
81675- guest += kcpustat_cpu(i).cpustat[CPUTIME_GUEST];
81676- guest_nice += kcpustat_cpu(i).cpustat[CPUTIME_GUEST_NICE];
81677- sum += kstat_cpu_irqs_sum(i);
81678- sum += arch_irq_stat_cpu(i);
81679+ if (unrestricted) {
81680+ iowait += get_iowait_time(i);
81681+ irq += kcpustat_cpu(i).cpustat[CPUTIME_IRQ];
81682+ softirq += kcpustat_cpu(i).cpustat[CPUTIME_SOFTIRQ];
81683+ steal += kcpustat_cpu(i).cpustat[CPUTIME_STEAL];
81684+ guest += kcpustat_cpu(i).cpustat[CPUTIME_GUEST];
81685+ guest_nice += kcpustat_cpu(i).cpustat[CPUTIME_GUEST_NICE];
81686+ sum += kstat_cpu_irqs_sum(i);
81687+ sum += arch_irq_stat_cpu(i);
81688+ for (j = 0; j < NR_SOFTIRQS; j++) {
81689+ unsigned int softirq_stat = kstat_softirqs_cpu(j, i);
81690
81691- for (j = 0; j < NR_SOFTIRQS; j++) {
81692- unsigned int softirq_stat = kstat_softirqs_cpu(j, i);
81693-
81694- per_softirq_sums[j] += softirq_stat;
81695- sum_softirq += softirq_stat;
81696+ per_softirq_sums[j] += softirq_stat;
81697+ sum_softirq += softirq_stat;
81698+ }
81699 }
81700 }
81701- sum += arch_irq_stat();
81702+ if (unrestricted)
81703+ sum += arch_irq_stat();
81704
81705 seq_puts(p, "cpu ");
81706 seq_put_decimal_ull(p, ' ', cputime64_to_clock_t(user));
81707@@ -136,12 +151,14 @@ static int show_stat(struct seq_file *p, void *v)
81708 nice = kcpustat_cpu(i).cpustat[CPUTIME_NICE];
81709 system = kcpustat_cpu(i).cpustat[CPUTIME_SYSTEM];
81710 idle = get_idle_time(i);
81711- iowait = get_iowait_time(i);
81712- irq = kcpustat_cpu(i).cpustat[CPUTIME_IRQ];
81713- softirq = kcpustat_cpu(i).cpustat[CPUTIME_SOFTIRQ];
81714- steal = kcpustat_cpu(i).cpustat[CPUTIME_STEAL];
81715- guest = kcpustat_cpu(i).cpustat[CPUTIME_GUEST];
81716- guest_nice = kcpustat_cpu(i).cpustat[CPUTIME_GUEST_NICE];
81717+ if (unrestricted) {
81718+ iowait = get_iowait_time(i);
81719+ irq = kcpustat_cpu(i).cpustat[CPUTIME_IRQ];
81720+ softirq = kcpustat_cpu(i).cpustat[CPUTIME_SOFTIRQ];
81721+ steal = kcpustat_cpu(i).cpustat[CPUTIME_STEAL];
81722+ guest = kcpustat_cpu(i).cpustat[CPUTIME_GUEST];
81723+ guest_nice = kcpustat_cpu(i).cpustat[CPUTIME_GUEST_NICE];
81724+ }
81725 seq_printf(p, "cpu%d", i);
81726 seq_put_decimal_ull(p, ' ', cputime64_to_clock_t(user));
81727 seq_put_decimal_ull(p, ' ', cputime64_to_clock_t(nice));
81728@@ -159,7 +176,7 @@ static int show_stat(struct seq_file *p, void *v)
81729
81730 /* sum again ? it could be updated? */
81731 for_each_irq_nr(j)
81732- seq_put_decimal_ull(p, ' ', kstat_irqs_usr(j));
81733+ seq_put_decimal_ull(p, ' ', unrestricted ? kstat_irqs_usr(j) : 0ULL);
81734
81735 seq_printf(p,
81736 "\nctxt %llu\n"
81737@@ -167,11 +184,11 @@ static int show_stat(struct seq_file *p, void *v)
81738 "processes %lu\n"
81739 "procs_running %lu\n"
81740 "procs_blocked %lu\n",
81741- nr_context_switches(),
81742+ unrestricted ? nr_context_switches() : 0ULL,
81743 (unsigned long)jif,
81744- total_forks,
81745- nr_running(),
81746- nr_iowait());
81747+ unrestricted ? total_forks : 0UL,
81748+ unrestricted ? nr_running() : 0UL,
81749+ unrestricted ? nr_iowait() : 0UL);
81750
81751 seq_printf(p, "softirq %llu", (unsigned long long)sum_softirq);
81752
81753diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
81754index 6dee68d..1b4add0 100644
81755--- a/fs/proc/task_mmu.c
81756+++ b/fs/proc/task_mmu.c
81757@@ -13,12 +13,19 @@
81758 #include <linux/swap.h>
81759 #include <linux/swapops.h>
81760 #include <linux/mmu_notifier.h>
81761+#include <linux/grsecurity.h>
81762
81763 #include <asm/elf.h>
81764 #include <asm/uaccess.h>
81765 #include <asm/tlbflush.h>
81766 #include "internal.h"
81767
81768+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
81769+#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
81770+ (_mm->pax_flags & MF_PAX_RANDMMAP || \
81771+ _mm->pax_flags & MF_PAX_SEGMEXEC))
81772+#endif
81773+
81774 void task_mem(struct seq_file *m, struct mm_struct *mm)
81775 {
81776 unsigned long data, text, lib, swap, ptes, pmds;
81777@@ -57,8 +64,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
81778 "VmLib:\t%8lu kB\n"
81779 "VmPTE:\t%8lu kB\n"
81780 "VmPMD:\t%8lu kB\n"
81781- "VmSwap:\t%8lu kB\n",
81782- hiwater_vm << (PAGE_SHIFT-10),
81783+ "VmSwap:\t%8lu kB\n"
81784+
81785+#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
81786+ "CsBase:\t%8lx\nCsLim:\t%8lx\n"
81787+#endif
81788+
81789+ ,hiwater_vm << (PAGE_SHIFT-10),
81790 total_vm << (PAGE_SHIFT-10),
81791 mm->locked_vm << (PAGE_SHIFT-10),
81792 mm->pinned_vm << (PAGE_SHIFT-10),
81793@@ -68,7 +80,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
81794 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
81795 ptes >> 10,
81796 pmds >> 10,
81797- swap << (PAGE_SHIFT-10));
81798+ swap << (PAGE_SHIFT-10)
81799+
81800+#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
81801+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
81802+ , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
81803+ , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
81804+#else
81805+ , mm->context.user_cs_base
81806+ , mm->context.user_cs_limit
81807+#endif
81808+#endif
81809+
81810+ );
81811 }
81812
81813 unsigned long task_vsize(struct mm_struct *mm)
81814@@ -285,13 +309,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
81815 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
81816 }
81817
81818- /* We don't show the stack guard page in /proc/maps */
81819+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
81820+ start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
81821+ end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
81822+#else
81823 start = vma->vm_start;
81824- if (stack_guard_page_start(vma, start))
81825- start += PAGE_SIZE;
81826 end = vma->vm_end;
81827- if (stack_guard_page_end(vma, end))
81828- end -= PAGE_SIZE;
81829+#endif
81830
81831 seq_setwidth(m, 25 + sizeof(void *) * 6 - 1);
81832 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu ",
81833@@ -301,7 +325,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
81834 flags & VM_WRITE ? 'w' : '-',
81835 flags & VM_EXEC ? 'x' : '-',
81836 flags & VM_MAYSHARE ? 's' : 'p',
81837+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
81838+ PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
81839+#else
81840 pgoff,
81841+#endif
81842 MAJOR(dev), MINOR(dev), ino);
81843
81844 /*
81845@@ -310,7 +338,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
81846 */
81847 if (file) {
81848 seq_pad(m, ' ');
81849- seq_path(m, &file->f_path, "\n");
81850+ seq_path(m, &file->f_path, "\n\\");
81851 goto done;
81852 }
81853
81854@@ -341,8 +369,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
81855 * Thread stack in /proc/PID/task/TID/maps or
81856 * the main process stack.
81857 */
81858- if (!is_pid || (vma->vm_start <= mm->start_stack &&
81859- vma->vm_end >= mm->start_stack)) {
81860+ if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
81861+ (vma->vm_start <= mm->start_stack &&
81862+ vma->vm_end >= mm->start_stack)) {
81863 name = "[stack]";
81864 } else {
81865 /* Thread stack in /proc/PID/maps */
81866@@ -362,6 +391,12 @@ done:
81867
81868 static int show_map(struct seq_file *m, void *v, int is_pid)
81869 {
81870+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
81871+ if (current->exec_id != m->exec_id) {
81872+ gr_log_badprocpid("maps");
81873+ return 0;
81874+ }
81875+#endif
81876 show_map_vma(m, v, is_pid);
81877 m_cache_vma(m, v);
81878 return 0;
81879@@ -620,9 +655,18 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
81880 .private = &mss,
81881 };
81882
81883+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
81884+ if (current->exec_id != m->exec_id) {
81885+ gr_log_badprocpid("smaps");
81886+ return 0;
81887+ }
81888+#endif
81889 memset(&mss, 0, sizeof mss);
81890- /* mmap_sem is held in m_start */
81891- walk_page_vma(vma, &smaps_walk);
81892+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
81893+ if (!PAX_RAND_FLAGS(vma->vm_mm))
81894+#endif
81895+ /* mmap_sem is held in m_start */
81896+ walk_page_vma(vma, &smaps_walk);
81897
81898 show_map_vma(m, vma, is_pid);
81899
81900@@ -641,7 +685,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
81901 "KernelPageSize: %8lu kB\n"
81902 "MMUPageSize: %8lu kB\n"
81903 "Locked: %8lu kB\n",
81904+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
81905+ PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
81906+#else
81907 (vma->vm_end - vma->vm_start) >> 10,
81908+#endif
81909 mss.resident >> 10,
81910 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
81911 mss.shared_clean >> 10,
81912@@ -1491,6 +1539,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
81913 char buffer[64];
81914 int nid;
81915
81916+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
81917+ if (current->exec_id != m->exec_id) {
81918+ gr_log_badprocpid("numa_maps");
81919+ return 0;
81920+ }
81921+#endif
81922+
81923 if (!mm)
81924 return 0;
81925
81926@@ -1505,11 +1560,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
81927 mpol_to_str(buffer, sizeof(buffer), proc_priv->task_mempolicy);
81928 }
81929
81930+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
81931+ seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
81932+#else
81933 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
81934+#endif
81935
81936 if (file) {
81937 seq_puts(m, " file=");
81938- seq_path(m, &file->f_path, "\n\t= ");
81939+ seq_path(m, &file->f_path, "\n\t\\= ");
81940 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
81941 seq_puts(m, " heap");
81942 } else {
81943diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
81944index 599ec2e..f1413ae 100644
81945--- a/fs/proc/task_nommu.c
81946+++ b/fs/proc/task_nommu.c
81947@@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
81948 else
81949 bytes += kobjsize(mm);
81950
81951- if (current->fs && current->fs->users > 1)
81952+ if (current->fs && atomic_read(&current->fs->users) > 1)
81953 sbytes += kobjsize(current->fs);
81954 else
81955 bytes += kobjsize(current->fs);
81956@@ -180,7 +180,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
81957
81958 if (file) {
81959 seq_pad(m, ' ');
81960- seq_path(m, &file->f_path, "");
81961+ seq_path(m, &file->f_path, "\n\\");
81962 } else if (mm) {
81963 pid_t tid = pid_of_stack(priv, vma, is_pid);
81964
81965diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
81966index 4e61388..1a2523d 100644
81967--- a/fs/proc/vmcore.c
81968+++ b/fs/proc/vmcore.c
81969@@ -105,9 +105,13 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
81970 nr_bytes = count;
81971
81972 /* If pfn is not ram, return zeros for sparse dump files */
81973- if (pfn_is_ram(pfn) == 0)
81974- memset(buf, 0, nr_bytes);
81975- else {
81976+ if (pfn_is_ram(pfn) == 0) {
81977+ if (userbuf) {
81978+ if (clear_user((char __force_user *)buf, nr_bytes))
81979+ return -EFAULT;
81980+ } else
81981+ memset(buf, 0, nr_bytes);
81982+ } else {
81983 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
81984 offset, userbuf);
81985 if (tmp < 0)
81986@@ -170,7 +174,7 @@ int __weak remap_oldmem_pfn_range(struct vm_area_struct *vma,
81987 static int copy_to(void *target, void *src, size_t size, int userbuf)
81988 {
81989 if (userbuf) {
81990- if (copy_to_user((char __user *) target, src, size))
81991+ if (copy_to_user((char __force_user *) target, src, size))
81992 return -EFAULT;
81993 } else {
81994 memcpy(target, src, size);
81995@@ -233,7 +237,7 @@ static ssize_t __read_vmcore(char *buffer, size_t buflen, loff_t *fpos,
81996 if (*fpos < m->offset + m->size) {
81997 tsz = min_t(size_t, m->offset + m->size - *fpos, buflen);
81998 start = m->paddr + *fpos - m->offset;
81999- tmp = read_from_oldmem(buffer, tsz, &start, userbuf);
82000+ tmp = read_from_oldmem((char __force_kernel *)buffer, tsz, &start, userbuf);
82001 if (tmp < 0)
82002 return tmp;
82003 buflen -= tsz;
82004@@ -253,7 +257,7 @@ static ssize_t __read_vmcore(char *buffer, size_t buflen, loff_t *fpos,
82005 static ssize_t read_vmcore(struct file *file, char __user *buffer,
82006 size_t buflen, loff_t *fpos)
82007 {
82008- return __read_vmcore((__force char *) buffer, buflen, fpos, 1);
82009+ return __read_vmcore((__force_kernel char *) buffer, buflen, fpos, 1);
82010 }
82011
82012 /*
82013diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
82014index d3fb2b6..43a8140 100644
82015--- a/fs/qnx6/qnx6.h
82016+++ b/fs/qnx6/qnx6.h
82017@@ -74,7 +74,7 @@ enum {
82018 BYTESEX_BE,
82019 };
82020
82021-static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
82022+static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
82023 {
82024 if (sbi->s_bytesex == BYTESEX_LE)
82025 return le64_to_cpu((__force __le64)n);
82026@@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
82027 return (__force __fs64)cpu_to_be64(n);
82028 }
82029
82030-static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
82031+static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
82032 {
82033 if (sbi->s_bytesex == BYTESEX_LE)
82034 return le32_to_cpu((__force __le32)n);
82035diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
82036index bb2869f..d34ada8 100644
82037--- a/fs/quota/netlink.c
82038+++ b/fs/quota/netlink.c
82039@@ -44,7 +44,7 @@ static struct genl_family quota_genl_family = {
82040 void quota_send_warning(struct kqid qid, dev_t dev,
82041 const char warntype)
82042 {
82043- static atomic_t seq;
82044+ static atomic_unchecked_t seq;
82045 struct sk_buff *skb;
82046 void *msg_head;
82047 int ret;
82048@@ -60,7 +60,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
82049 "VFS: Not enough memory to send quota warning.\n");
82050 return;
82051 }
82052- msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
82053+ msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
82054 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
82055 if (!msg_head) {
82056 printk(KERN_ERR
82057diff --git a/fs/read_write.c b/fs/read_write.c
82058index 819ef3f..f07222d 100644
82059--- a/fs/read_write.c
82060+++ b/fs/read_write.c
82061@@ -505,7 +505,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
82062
82063 old_fs = get_fs();
82064 set_fs(get_ds());
82065- p = (__force const char __user *)buf;
82066+ p = (const char __force_user *)buf;
82067 if (count > MAX_RW_COUNT)
82068 count = MAX_RW_COUNT;
82069 ret = __vfs_write(file, p, count, pos);
82070diff --git a/fs/readdir.c b/fs/readdir.c
82071index ced6791..936687b 100644
82072--- a/fs/readdir.c
82073+++ b/fs/readdir.c
82074@@ -18,6 +18,7 @@
82075 #include <linux/security.h>
82076 #include <linux/syscalls.h>
82077 #include <linux/unistd.h>
82078+#include <linux/namei.h>
82079
82080 #include <asm/uaccess.h>
82081
82082@@ -71,6 +72,7 @@ struct old_linux_dirent {
82083 struct readdir_callback {
82084 struct dir_context ctx;
82085 struct old_linux_dirent __user * dirent;
82086+ struct file * file;
82087 int result;
82088 };
82089
82090@@ -89,6 +91,10 @@ static int fillonedir(struct dir_context *ctx, const char *name, int namlen,
82091 buf->result = -EOVERFLOW;
82092 return -EOVERFLOW;
82093 }
82094+
82095+ if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
82096+ return 0;
82097+
82098 buf->result++;
82099 dirent = buf->dirent;
82100 if (!access_ok(VERIFY_WRITE, dirent,
82101@@ -120,6 +126,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
82102 if (!f.file)
82103 return -EBADF;
82104
82105+ buf.file = f.file;
82106 error = iterate_dir(f.file, &buf.ctx);
82107 if (buf.result)
82108 error = buf.result;
82109@@ -145,6 +152,7 @@ struct getdents_callback {
82110 struct dir_context ctx;
82111 struct linux_dirent __user * current_dir;
82112 struct linux_dirent __user * previous;
82113+ struct file * file;
82114 int count;
82115 int error;
82116 };
82117@@ -167,6 +175,10 @@ static int filldir(struct dir_context *ctx, const char *name, int namlen,
82118 buf->error = -EOVERFLOW;
82119 return -EOVERFLOW;
82120 }
82121+
82122+ if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
82123+ return 0;
82124+
82125 dirent = buf->previous;
82126 if (dirent) {
82127 if (__put_user(offset, &dirent->d_off))
82128@@ -212,6 +224,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
82129 if (!f.file)
82130 return -EBADF;
82131
82132+ buf.file = f.file;
82133 error = iterate_dir(f.file, &buf.ctx);
82134 if (error >= 0)
82135 error = buf.error;
82136@@ -230,6 +243,7 @@ struct getdents_callback64 {
82137 struct dir_context ctx;
82138 struct linux_dirent64 __user * current_dir;
82139 struct linux_dirent64 __user * previous;
82140+ struct file *file;
82141 int count;
82142 int error;
82143 };
82144@@ -246,6 +260,10 @@ static int filldir64(struct dir_context *ctx, const char *name, int namlen,
82145 buf->error = -EINVAL; /* only used if we fail.. */
82146 if (reclen > buf->count)
82147 return -EINVAL;
82148+
82149+ if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
82150+ return 0;
82151+
82152 dirent = buf->previous;
82153 if (dirent) {
82154 if (__put_user(offset, &dirent->d_off))
82155@@ -293,6 +311,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
82156 if (!f.file)
82157 return -EBADF;
82158
82159+ buf.file = f.file;
82160 error = iterate_dir(f.file, &buf.ctx);
82161 if (error >= 0)
82162 error = buf.error;
82163diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
82164index 9c02d96..6562c10 100644
82165--- a/fs/reiserfs/do_balan.c
82166+++ b/fs/reiserfs/do_balan.c
82167@@ -1887,7 +1887,7 @@ void do_balance(struct tree_balance *tb, struct item_head *ih,
82168 return;
82169 }
82170
82171- atomic_inc(&fs_generation(tb->tb_sb));
82172+ atomic_inc_unchecked(&fs_generation(tb->tb_sb));
82173 do_balance_starts(tb);
82174
82175 /*
82176diff --git a/fs/reiserfs/item_ops.c b/fs/reiserfs/item_ops.c
82177index aca73dd..e3c558d 100644
82178--- a/fs/reiserfs/item_ops.c
82179+++ b/fs/reiserfs/item_ops.c
82180@@ -724,18 +724,18 @@ static void errcatch_print_vi(struct virtual_item *vi)
82181 }
82182
82183 static struct item_operations errcatch_ops = {
82184- errcatch_bytes_number,
82185- errcatch_decrement_key,
82186- errcatch_is_left_mergeable,
82187- errcatch_print_item,
82188- errcatch_check_item,
82189+ .bytes_number = errcatch_bytes_number,
82190+ .decrement_key = errcatch_decrement_key,
82191+ .is_left_mergeable = errcatch_is_left_mergeable,
82192+ .print_item = errcatch_print_item,
82193+ .check_item = errcatch_check_item,
82194
82195- errcatch_create_vi,
82196- errcatch_check_left,
82197- errcatch_check_right,
82198- errcatch_part_size,
82199- errcatch_unit_num,
82200- errcatch_print_vi
82201+ .create_vi = errcatch_create_vi,
82202+ .check_left = errcatch_check_left,
82203+ .check_right = errcatch_check_right,
82204+ .part_size = errcatch_part_size,
82205+ .unit_num = errcatch_unit_num,
82206+ .print_vi = errcatch_print_vi
82207 };
82208
82209 #if ! (TYPE_STAT_DATA == 0 && TYPE_INDIRECT == 1 && TYPE_DIRECT == 2 && TYPE_DIRENTRY == 3)
82210diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
82211index 621b9f3..af527fd 100644
82212--- a/fs/reiserfs/procfs.c
82213+++ b/fs/reiserfs/procfs.c
82214@@ -114,7 +114,7 @@ static int show_super(struct seq_file *m, void *unused)
82215 "SMALL_TAILS " : "NO_TAILS ",
82216 replay_only(sb) ? "REPLAY_ONLY " : "",
82217 convert_reiserfs(sb) ? "CONV " : "",
82218- atomic_read(&r->s_generation_counter),
82219+ atomic_read_unchecked(&r->s_generation_counter),
82220 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
82221 SF(s_do_balance), SF(s_unneeded_left_neighbor),
82222 SF(s_good_search_by_key_reada), SF(s_bmaps),
82223diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
82224index 2adcde1..7d27bc8 100644
82225--- a/fs/reiserfs/reiserfs.h
82226+++ b/fs/reiserfs/reiserfs.h
82227@@ -580,7 +580,7 @@ struct reiserfs_sb_info {
82228 /* Comment? -Hans */
82229 wait_queue_head_t s_wait;
82230 /* increased by one every time the tree gets re-balanced */
82231- atomic_t s_generation_counter;
82232+ atomic_unchecked_t s_generation_counter;
82233
82234 /* File system properties. Currently holds on-disk FS format */
82235 unsigned long s_properties;
82236@@ -2300,7 +2300,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
82237 #define REISERFS_USER_MEM 1 /* user memory mode */
82238
82239 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
82240-#define get_generation(s) atomic_read (&fs_generation(s))
82241+#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
82242 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
82243 #define __fs_changed(gen,s) (gen != get_generation (s))
82244 #define fs_changed(gen,s) \
82245diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
82246index 0111ad0..00f4749 100644
82247--- a/fs/reiserfs/super.c
82248+++ b/fs/reiserfs/super.c
82249@@ -1868,6 +1868,10 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
82250 sbi->s_mount_opt |= (1 << REISERFS_SMALLTAIL);
82251 sbi->s_mount_opt |= (1 << REISERFS_ERROR_RO);
82252 sbi->s_mount_opt |= (1 << REISERFS_BARRIER_FLUSH);
82253+#ifdef CONFIG_REISERFS_FS_XATTR
82254+ /* turn on user xattrs by default */
82255+ sbi->s_mount_opt |= (1 << REISERFS_XATTRS_USER);
82256+#endif
82257 /* no preallocation minimum, be smart in reiserfs_file_write instead */
82258 sbi->s_alloc_options.preallocmin = 0;
82259 /* Preallocate by 16 blocks (17-1) at once */
82260diff --git a/fs/select.c b/fs/select.c
82261index f684c75..4117611 100644
82262--- a/fs/select.c
82263+++ b/fs/select.c
82264@@ -20,6 +20,7 @@
82265 #include <linux/export.h>
82266 #include <linux/slab.h>
82267 #include <linux/poll.h>
82268+#include <linux/security.h>
82269 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
82270 #include <linux/file.h>
82271 #include <linux/fdtable.h>
82272@@ -880,6 +881,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
82273 struct poll_list *walk = head;
82274 unsigned long todo = nfds;
82275
82276+ gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
82277 if (nfds > rlimit(RLIMIT_NOFILE))
82278 return -EINVAL;
82279
82280diff --git a/fs/seq_file.c b/fs/seq_file.c
82281index 555f821..34684d7 100644
82282--- a/fs/seq_file.c
82283+++ b/fs/seq_file.c
82284@@ -12,6 +12,8 @@
82285 #include <linux/slab.h>
82286 #include <linux/cred.h>
82287 #include <linux/mm.h>
82288+#include <linux/sched.h>
82289+#include <linux/grsecurity.h>
82290
82291 #include <asm/uaccess.h>
82292 #include <asm/page.h>
82293@@ -23,16 +25,7 @@ static void seq_set_overflow(struct seq_file *m)
82294
82295 static void *seq_buf_alloc(unsigned long size)
82296 {
82297- void *buf;
82298-
82299- /*
82300- * __GFP_NORETRY to avoid oom-killings with high-order allocations -
82301- * it's better to fall back to vmalloc() than to kill things.
82302- */
82303- buf = kmalloc(size, GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN);
82304- if (!buf && size > PAGE_SIZE)
82305- buf = vmalloc(size);
82306- return buf;
82307+ return kmalloc(size, GFP_KERNEL | GFP_USERCOPY);
82308 }
82309
82310 /**
82311@@ -65,6 +58,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
82312 #ifdef CONFIG_USER_NS
82313 p->user_ns = file->f_cred->user_ns;
82314 #endif
82315+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
82316+ p->exec_id = current->exec_id;
82317+#endif
82318
82319 /*
82320 * Wrappers around seq_open(e.g. swaps_open) need to be
82321@@ -87,6 +83,16 @@ int seq_open(struct file *file, const struct seq_operations *op)
82322 }
82323 EXPORT_SYMBOL(seq_open);
82324
82325+
82326+int seq_open_restrict(struct file *file, const struct seq_operations *op)
82327+{
82328+ if (gr_proc_is_restricted())
82329+ return -EACCES;
82330+
82331+ return seq_open(file, op);
82332+}
82333+EXPORT_SYMBOL(seq_open_restrict);
82334+
82335 static int traverse(struct seq_file *m, loff_t offset)
82336 {
82337 loff_t pos = 0, index;
82338@@ -158,7 +164,7 @@ Eoverflow:
82339 ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
82340 {
82341 struct seq_file *m = file->private_data;
82342- size_t copied = 0;
82343+ ssize_t copied = 0;
82344 loff_t pos;
82345 size_t n;
82346 void *p;
82347@@ -557,7 +563,7 @@ static void single_stop(struct seq_file *p, void *v)
82348 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
82349 void *data)
82350 {
82351- struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
82352+ seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
82353 int res = -ENOMEM;
82354
82355 if (op) {
82356@@ -593,6 +599,17 @@ int single_open_size(struct file *file, int (*show)(struct seq_file *, void *),
82357 }
82358 EXPORT_SYMBOL(single_open_size);
82359
82360+int single_open_restrict(struct file *file, int (*show)(struct seq_file *, void *),
82361+ void *data)
82362+{
82363+ if (gr_proc_is_restricted())
82364+ return -EACCES;
82365+
82366+ return single_open(file, show, data);
82367+}
82368+EXPORT_SYMBOL(single_open_restrict);
82369+
82370+
82371 int single_release(struct inode *inode, struct file *file)
82372 {
82373 const struct seq_operations *op = ((struct seq_file *)file->private_data)->op;
82374diff --git a/fs/splice.c b/fs/splice.c
82375index bfe62ae..a84920d 100644
82376--- a/fs/splice.c
82377+++ b/fs/splice.c
82378@@ -192,7 +192,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
82379 pipe_lock(pipe);
82380
82381 for (;;) {
82382- if (!pipe->readers) {
82383+ if (!atomic_read(&pipe->readers)) {
82384 send_sig(SIGPIPE, current, 0);
82385 if (!ret)
82386 ret = -EPIPE;
82387@@ -215,7 +215,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
82388 page_nr++;
82389 ret += buf->len;
82390
82391- if (pipe->files)
82392+ if (atomic_read(&pipe->files))
82393 do_wakeup = 1;
82394
82395 if (!--spd->nr_pages)
82396@@ -246,9 +246,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
82397 do_wakeup = 0;
82398 }
82399
82400- pipe->waiting_writers++;
82401+ atomic_inc(&pipe->waiting_writers);
82402 pipe_wait(pipe);
82403- pipe->waiting_writers--;
82404+ atomic_dec(&pipe->waiting_writers);
82405 }
82406
82407 pipe_unlock(pipe);
82408@@ -578,7 +578,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
82409 old_fs = get_fs();
82410 set_fs(get_ds());
82411 /* The cast to a user pointer is valid due to the set_fs() */
82412- res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
82413+ res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
82414 set_fs(old_fs);
82415
82416 return res;
82417@@ -593,7 +593,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
82418 old_fs = get_fs();
82419 set_fs(get_ds());
82420 /* The cast to a user pointer is valid due to the set_fs() */
82421- res = vfs_write(file, (__force const char __user *)buf, count, &pos);
82422+ res = vfs_write(file, (const char __force_user *)buf, count, &pos);
82423 set_fs(old_fs);
82424
82425 return res;
82426@@ -646,7 +646,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
82427 goto err;
82428
82429 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
82430- vec[i].iov_base = (void __user *) page_address(page);
82431+ vec[i].iov_base = (void __force_user *) page_address(page);
82432 vec[i].iov_len = this_len;
82433 spd.pages[i] = page;
82434 spd.nr_pages++;
82435@@ -785,7 +785,7 @@ static int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_des
82436 ops->release(pipe, buf);
82437 pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1);
82438 pipe->nrbufs--;
82439- if (pipe->files)
82440+ if (atomic_read(&pipe->files))
82441 sd->need_wakeup = true;
82442 }
82443
82444@@ -809,10 +809,10 @@ static int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_des
82445 static int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
82446 {
82447 while (!pipe->nrbufs) {
82448- if (!pipe->writers)
82449+ if (!atomic_read(&pipe->writers))
82450 return 0;
82451
82452- if (!pipe->waiting_writers && sd->num_spliced)
82453+ if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
82454 return 0;
82455
82456 if (sd->flags & SPLICE_F_NONBLOCK)
82457@@ -1027,7 +1027,7 @@ iter_file_splice_write(struct pipe_inode_info *pipe, struct file *out,
82458 ops->release(pipe, buf);
82459 pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1);
82460 pipe->nrbufs--;
82461- if (pipe->files)
82462+ if (atomic_read(&pipe->files))
82463 sd.need_wakeup = true;
82464 } else {
82465 buf->offset += ret;
82466@@ -1187,7 +1187,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
82467 * out of the pipe right after the splice_to_pipe(). So set
82468 * PIPE_READERS appropriately.
82469 */
82470- pipe->readers = 1;
82471+ atomic_set(&pipe->readers, 1);
82472
82473 current->splice_pipe = pipe;
82474 }
82475@@ -1494,6 +1494,7 @@ static int get_iovec_page_array(const struct iovec __user *iov,
82476
82477 partial[buffers].offset = off;
82478 partial[buffers].len = plen;
82479+ partial[buffers].private = 0;
82480
82481 off = 0;
82482 len -= plen;
82483@@ -1725,9 +1726,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
82484 ret = -ERESTARTSYS;
82485 break;
82486 }
82487- if (!pipe->writers)
82488+ if (!atomic_read(&pipe->writers))
82489 break;
82490- if (!pipe->waiting_writers) {
82491+ if (!atomic_read(&pipe->waiting_writers)) {
82492 if (flags & SPLICE_F_NONBLOCK) {
82493 ret = -EAGAIN;
82494 break;
82495@@ -1759,7 +1760,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
82496 pipe_lock(pipe);
82497
82498 while (pipe->nrbufs >= pipe->buffers) {
82499- if (!pipe->readers) {
82500+ if (!atomic_read(&pipe->readers)) {
82501 send_sig(SIGPIPE, current, 0);
82502 ret = -EPIPE;
82503 break;
82504@@ -1772,9 +1773,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
82505 ret = -ERESTARTSYS;
82506 break;
82507 }
82508- pipe->waiting_writers++;
82509+ atomic_inc(&pipe->waiting_writers);
82510 pipe_wait(pipe);
82511- pipe->waiting_writers--;
82512+ atomic_dec(&pipe->waiting_writers);
82513 }
82514
82515 pipe_unlock(pipe);
82516@@ -1810,14 +1811,14 @@ retry:
82517 pipe_double_lock(ipipe, opipe);
82518
82519 do {
82520- if (!opipe->readers) {
82521+ if (!atomic_read(&opipe->readers)) {
82522 send_sig(SIGPIPE, current, 0);
82523 if (!ret)
82524 ret = -EPIPE;
82525 break;
82526 }
82527
82528- if (!ipipe->nrbufs && !ipipe->writers)
82529+ if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
82530 break;
82531
82532 /*
82533@@ -1914,7 +1915,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
82534 pipe_double_lock(ipipe, opipe);
82535
82536 do {
82537- if (!opipe->readers) {
82538+ if (!atomic_read(&opipe->readers)) {
82539 send_sig(SIGPIPE, current, 0);
82540 if (!ret)
82541 ret = -EPIPE;
82542@@ -1959,7 +1960,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
82543 * return EAGAIN if we have the potential of some data in the
82544 * future, otherwise just return 0
82545 */
82546- if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
82547+ if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
82548 ret = -EAGAIN;
82549
82550 pipe_unlock(ipipe);
82551diff --git a/fs/squashfs/xattr.c b/fs/squashfs/xattr.c
82552index e5e0ddf..09598c4 100644
82553--- a/fs/squashfs/xattr.c
82554+++ b/fs/squashfs/xattr.c
82555@@ -46,8 +46,8 @@ ssize_t squashfs_listxattr(struct dentry *d, char *buffer,
82556 + msblk->xattr_table;
82557 int offset = SQUASHFS_XATTR_OFFSET(squashfs_i(inode)->xattr);
82558 int count = squashfs_i(inode)->xattr_count;
82559- size_t rest = buffer_size;
82560- int err;
82561+ size_t used = 0;
82562+ ssize_t err;
82563
82564 /* check that the file system has xattrs */
82565 if (msblk->xattr_id_table == NULL)
82566@@ -68,11 +68,11 @@ ssize_t squashfs_listxattr(struct dentry *d, char *buffer,
82567 name_size = le16_to_cpu(entry.size);
82568 handler = squashfs_xattr_handler(le16_to_cpu(entry.type));
82569 if (handler)
82570- prefix_size = handler->list(d, buffer, rest, NULL,
82571+ prefix_size = handler->list(d, buffer, buffer ? buffer_size - used : 0, NULL,
82572 name_size, handler->flags);
82573 if (prefix_size) {
82574 if (buffer) {
82575- if (prefix_size + name_size + 1 > rest) {
82576+ if (prefix_size + name_size + 1 > buffer_size - used) {
82577 err = -ERANGE;
82578 goto failed;
82579 }
82580@@ -86,7 +86,7 @@ ssize_t squashfs_listxattr(struct dentry *d, char *buffer,
82581 buffer[name_size] = '\0';
82582 buffer += name_size + 1;
82583 }
82584- rest -= prefix_size + name_size + 1;
82585+ used += prefix_size + name_size + 1;
82586 } else {
82587 /* no handler or insuffficient privileges, so skip */
82588 err = squashfs_read_metadata(sb, NULL, &start,
82589@@ -107,7 +107,7 @@ ssize_t squashfs_listxattr(struct dentry *d, char *buffer,
82590 if (err < 0)
82591 goto failed;
82592 }
82593- err = buffer_size - rest;
82594+ err = used;
82595
82596 failed:
82597 return err;
82598diff --git a/fs/stat.c b/fs/stat.c
82599index cccc1aa..7fe8951 100644
82600--- a/fs/stat.c
82601+++ b/fs/stat.c
82602@@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
82603 stat->gid = inode->i_gid;
82604 stat->rdev = inode->i_rdev;
82605 stat->size = i_size_read(inode);
82606- stat->atime = inode->i_atime;
82607- stat->mtime = inode->i_mtime;
82608+ if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
82609+ stat->atime = inode->i_ctime;
82610+ stat->mtime = inode->i_ctime;
82611+ } else {
82612+ stat->atime = inode->i_atime;
82613+ stat->mtime = inode->i_mtime;
82614+ }
82615 stat->ctime = inode->i_ctime;
82616 stat->blksize = (1 << inode->i_blkbits);
82617 stat->blocks = inode->i_blocks;
82618@@ -52,9 +57,16 @@ EXPORT_SYMBOL(generic_fillattr);
82619 int vfs_getattr_nosec(struct path *path, struct kstat *stat)
82620 {
82621 struct inode *inode = d_backing_inode(path->dentry);
82622+ int retval;
82623
82624- if (inode->i_op->getattr)
82625- return inode->i_op->getattr(path->mnt, path->dentry, stat);
82626+ if (inode->i_op->getattr) {
82627+ retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
82628+ if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
82629+ stat->atime = stat->ctime;
82630+ stat->mtime = stat->ctime;
82631+ }
82632+ return retval;
82633+ }
82634
82635 generic_fillattr(inode, stat);
82636 return 0;
82637diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
82638index 94374e4..b5da3a1 100644
82639--- a/fs/sysfs/dir.c
82640+++ b/fs/sysfs/dir.c
82641@@ -33,6 +33,10 @@ void sysfs_warn_dup(struct kernfs_node *parent, const char *name)
82642 kfree(buf);
82643 }
82644
82645+#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
82646+extern int grsec_enable_sysfs_restrict;
82647+#endif
82648+
82649 /**
82650 * sysfs_create_dir_ns - create a directory for an object with a namespace tag
82651 * @kobj: object we're creating directory for
82652@@ -41,9 +45,16 @@ void sysfs_warn_dup(struct kernfs_node *parent, const char *name)
82653 int sysfs_create_dir_ns(struct kobject *kobj, const void *ns)
82654 {
82655 struct kernfs_node *parent, *kn;
82656+ const char *name;
82657+ umode_t mode = S_IRWXU | S_IRUGO | S_IXUGO;
82658+#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
82659+ const char *parent_name;
82660+#endif
82661
82662 BUG_ON(!kobj);
82663
82664+ name = kobject_name(kobj);
82665+
82666 if (kobj->parent)
82667 parent = kobj->parent->sd;
82668 else
82669@@ -52,11 +63,24 @@ int sysfs_create_dir_ns(struct kobject *kobj, const void *ns)
82670 if (!parent)
82671 return -ENOENT;
82672
82673- kn = kernfs_create_dir_ns(parent, kobject_name(kobj),
82674- S_IRWXU | S_IRUGO | S_IXUGO, kobj, ns);
82675+#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
82676+ parent_name = parent->name;
82677+ mode = S_IRWXU;
82678+
82679+ if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
82680+ (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
82681+ (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse") || !strcmp(name, "ecryptfs"))) ||
82682+ (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
82683+ mode = S_IRWXU | S_IRUGO | S_IXUGO;
82684+ if (!grsec_enable_sysfs_restrict)
82685+ mode = S_IRWXU | S_IRUGO | S_IXUGO;
82686+#endif
82687+
82688+ kn = kernfs_create_dir_ns(parent, name,
82689+ mode, kobj, ns);
82690 if (IS_ERR(kn)) {
82691 if (PTR_ERR(kn) == -EEXIST)
82692- sysfs_warn_dup(parent, kobject_name(kobj));
82693+ sysfs_warn_dup(parent, name);
82694 return PTR_ERR(kn);
82695 }
82696
82697diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
82698index 69d4889..a810bd4 100644
82699--- a/fs/sysv/sysv.h
82700+++ b/fs/sysv/sysv.h
82701@@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
82702 #endif
82703 }
82704
82705-static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
82706+static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
82707 {
82708 if (sbi->s_bytesex == BYTESEX_PDP)
82709 return PDP_swab((__force __u32)n);
82710diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
82711index a43df11..c368e71 100644
82712--- a/fs/tracefs/inode.c
82713+++ b/fs/tracefs/inode.c
82714@@ -53,7 +53,7 @@ static const struct file_operations tracefs_file_operations = {
82715 static struct tracefs_dir_ops {
82716 int (*mkdir)(const char *name);
82717 int (*rmdir)(const char *name);
82718-} tracefs_ops;
82719+} __no_const tracefs_ops __read_only;
82720
82721 static char *get_dname(struct dentry *dentry)
82722 {
82723@@ -490,8 +490,10 @@ struct dentry *tracefs_create_instance_dir(const char *name, struct dentry *pare
82724 if (!dentry)
82725 return NULL;
82726
82727- tracefs_ops.mkdir = mkdir;
82728- tracefs_ops.rmdir = rmdir;
82729+ pax_open_kernel();
82730+ *(void **)&tracefs_ops.mkdir = mkdir;
82731+ *(void **)&tracefs_ops.rmdir = rmdir;
82732+ pax_close_kernel();
82733
82734 return dentry;
82735 }
82736diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
82737index 97be412..974b37f 100644
82738--- a/fs/ubifs/io.c
82739+++ b/fs/ubifs/io.c
82740@@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
82741 return err;
82742 }
82743
82744-int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
82745+int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
82746 {
82747 int err;
82748
82749diff --git a/fs/udf/misc.c b/fs/udf/misc.c
82750index 71d1c25..084e2ad 100644
82751--- a/fs/udf/misc.c
82752+++ b/fs/udf/misc.c
82753@@ -288,7 +288,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
82754
82755 u8 udf_tag_checksum(const struct tag *t)
82756 {
82757- u8 *data = (u8 *)t;
82758+ const u8 *data = (const u8 *)t;
82759 u8 checksum = 0;
82760 int i;
82761 for (i = 0; i < sizeof(struct tag); ++i)
82762diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
82763index 8d974c4..b82f6ec 100644
82764--- a/fs/ufs/swab.h
82765+++ b/fs/ufs/swab.h
82766@@ -22,7 +22,7 @@ enum {
82767 BYTESEX_BE
82768 };
82769
82770-static inline u64
82771+static inline u64 __intentional_overflow(-1)
82772 fs64_to_cpu(struct super_block *sbp, __fs64 n)
82773 {
82774 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
82775@@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
82776 return (__force __fs64)cpu_to_be64(n);
82777 }
82778
82779-static inline u32
82780+static inline u32 __intentional_overflow(-1)
82781 fs32_to_cpu(struct super_block *sbp, __fs32 n)
82782 {
82783 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
82784diff --git a/fs/utimes.c b/fs/utimes.c
82785index aa138d6..5f3a811 100644
82786--- a/fs/utimes.c
82787+++ b/fs/utimes.c
82788@@ -1,6 +1,7 @@
82789 #include <linux/compiler.h>
82790 #include <linux/file.h>
82791 #include <linux/fs.h>
82792+#include <linux/security.h>
82793 #include <linux/linkage.h>
82794 #include <linux/mount.h>
82795 #include <linux/namei.h>
82796@@ -103,6 +104,12 @@ static int utimes_common(struct path *path, struct timespec *times)
82797 }
82798 }
82799 retry_deleg:
82800+
82801+ if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
82802+ error = -EACCES;
82803+ goto mnt_drop_write_and_out;
82804+ }
82805+
82806 mutex_lock(&inode->i_mutex);
82807 error = notify_change(path->dentry, &newattrs, &delegated_inode);
82808 mutex_unlock(&inode->i_mutex);
82809diff --git a/fs/xattr.c b/fs/xattr.c
82810index 4ef6985..a6cd6567 100644
82811--- a/fs/xattr.c
82812+++ b/fs/xattr.c
82813@@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
82814 return rc;
82815 }
82816
82817+#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
82818+ssize_t
82819+pax_getxattr(struct dentry *dentry, void *value, size_t size)
82820+{
82821+ struct inode *inode = dentry->d_inode;
82822+ ssize_t error;
82823+
82824+ error = inode_permission(inode, MAY_EXEC);
82825+ if (error)
82826+ return error;
82827+
82828+ if (inode->i_op->getxattr)
82829+ error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
82830+ else
82831+ error = -EOPNOTSUPP;
82832+
82833+ return error;
82834+}
82835+EXPORT_SYMBOL(pax_getxattr);
82836+#endif
82837+
82838 ssize_t
82839 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
82840 {
82841@@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
82842 * Extended attribute SET operations
82843 */
82844 static long
82845-setxattr(struct dentry *d, const char __user *name, const void __user *value,
82846+setxattr(struct path *path, const char __user *name, const void __user *value,
82847 size_t size, int flags)
82848 {
82849 int error;
82850@@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
82851 posix_acl_fix_xattr_from_user(kvalue, size);
82852 }
82853
82854- error = vfs_setxattr(d, kname, kvalue, size, flags);
82855+ if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
82856+ error = -EACCES;
82857+ goto out;
82858+ }
82859+
82860+ error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
82861 out:
82862 if (vvalue)
82863 vfree(vvalue);
82864@@ -376,7 +402,7 @@ retry:
82865 return error;
82866 error = mnt_want_write(path.mnt);
82867 if (!error) {
82868- error = setxattr(path.dentry, name, value, size, flags);
82869+ error = setxattr(&path, name, value, size, flags);
82870 mnt_drop_write(path.mnt);
82871 }
82872 path_put(&path);
82873@@ -412,7 +438,7 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
82874 audit_file(f.file);
82875 error = mnt_want_write_file(f.file);
82876 if (!error) {
82877- error = setxattr(f.file->f_path.dentry, name, value, size, flags);
82878+ error = setxattr(&f.file->f_path, name, value, size, flags);
82879 mnt_drop_write_file(f.file);
82880 }
82881 fdput(f);
82882@@ -598,7 +624,7 @@ SYSCALL_DEFINE3(flistxattr, int, fd, char __user *, list, size_t, size)
82883 * Extended attribute REMOVE operations
82884 */
82885 static long
82886-removexattr(struct dentry *d, const char __user *name)
82887+removexattr(struct path *path, const char __user *name)
82888 {
82889 int error;
82890 char kname[XATTR_NAME_MAX + 1];
82891@@ -609,7 +635,10 @@ removexattr(struct dentry *d, const char __user *name)
82892 if (error < 0)
82893 return error;
82894
82895- return vfs_removexattr(d, kname);
82896+ if (!gr_acl_handle_removexattr(path->dentry, path->mnt))
82897+ return -EACCES;
82898+
82899+ return vfs_removexattr(path->dentry, kname);
82900 }
82901
82902 static int path_removexattr(const char __user *pathname,
82903@@ -623,7 +652,7 @@ retry:
82904 return error;
82905 error = mnt_want_write(path.mnt);
82906 if (!error) {
82907- error = removexattr(path.dentry, name);
82908+ error = removexattr(&path, name);
82909 mnt_drop_write(path.mnt);
82910 }
82911 path_put(&path);
82912@@ -649,14 +678,16 @@ SYSCALL_DEFINE2(lremovexattr, const char __user *, pathname,
82913 SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name)
82914 {
82915 struct fd f = fdget(fd);
82916+ struct path *path;
82917 int error = -EBADF;
82918
82919 if (!f.file)
82920 return error;
82921+ path = &f.file->f_path;
82922 audit_file(f.file);
82923 error = mnt_want_write_file(f.file);
82924 if (!error) {
82925- error = removexattr(f.file->f_path.dentry, name);
82926+ error = removexattr(path, name);
82927 mnt_drop_write_file(f.file);
82928 }
82929 fdput(f);
82930diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
82931index f1026e8..a0fbe4f 100644
82932--- a/fs/xfs/libxfs/xfs_bmap.c
82933+++ b/fs/xfs/libxfs/xfs_bmap.c
82934@@ -554,7 +554,7 @@ xfs_bmap_validate_ret(
82935
82936 #else
82937 #define xfs_bmap_check_leaf_extents(cur, ip, whichfork) do { } while (0)
82938-#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
82939+#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do { } while (0)
82940 #endif /* DEBUG */
82941
82942 /*
82943diff --git a/fs/xfs/xfs_dir2_readdir.c b/fs/xfs/xfs_dir2_readdir.c
82944index 098cd78..724d3f8 100644
82945--- a/fs/xfs/xfs_dir2_readdir.c
82946+++ b/fs/xfs/xfs_dir2_readdir.c
82947@@ -140,7 +140,12 @@ xfs_dir2_sf_getdents(
82948 ino = dp->d_ops->sf_get_ino(sfp, sfep);
82949 filetype = dp->d_ops->sf_get_ftype(sfep);
82950 ctx->pos = off & 0x7fffffff;
82951- if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen, ino,
82952+ if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
82953+ char name[sfep->namelen];
82954+ memcpy(name, sfep->name, sfep->namelen);
82955+ if (!dir_emit(ctx, name, sfep->namelen, ino, xfs_dir3_get_dtype(dp->i_mount, filetype)))
82956+ return 0;
82957+ } else if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen, ino,
82958 xfs_dir3_get_dtype(dp->i_mount, filetype)))
82959 return 0;
82960 sfep = dp->d_ops->sf_nextentry(sfp, sfep);
82961diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
82962index 87f67c6..7e335bf 100644
82963--- a/fs/xfs/xfs_ioctl.c
82964+++ b/fs/xfs/xfs_ioctl.c
82965@@ -120,7 +120,7 @@ xfs_find_handle(
82966 }
82967
82968 error = -EFAULT;
82969- if (copy_to_user(hreq->ohandle, &handle, hsize) ||
82970+ if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
82971 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
82972 goto out_put;
82973
82974diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h
82975index 7c7842c..ce15222 100644
82976--- a/fs/xfs/xfs_linux.h
82977+++ b/fs/xfs/xfs_linux.h
82978@@ -225,7 +225,7 @@ static inline kgid_t xfs_gid_to_kgid(__uint32_t gid)
82979 * of the compiler which do not like us using do_div in the middle
82980 * of large functions.
82981 */
82982-static inline __u32 xfs_do_div(void *a, __u32 b, int n)
82983+static inline __u32 __intentional_overflow(-1) xfs_do_div(void *a, __u32 b, int n)
82984 {
82985 __u32 mod;
82986
82987@@ -281,7 +281,7 @@ static inline __u32 xfs_do_mod(void *a, __u32 b, int n)
82988 return 0;
82989 }
82990 #else
82991-static inline __u32 xfs_do_div(void *a, __u32 b, int n)
82992+static inline __u32 __intentional_overflow(-1) xfs_do_div(void *a, __u32 b, int n)
82993 {
82994 __u32 mod;
82995
82996diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
82997new file mode 100644
82998index 0000000..31f8fe4
82999--- /dev/null
83000+++ b/grsecurity/Kconfig
83001@@ -0,0 +1,1182 @@
83002+#
83003+# grecurity configuration
83004+#
83005+menu "Memory Protections"
83006+depends on GRKERNSEC
83007+
83008+config GRKERNSEC_KMEM
83009+ bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
83010+ default y if GRKERNSEC_CONFIG_AUTO
83011+ select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
83012+ help
83013+ If you say Y here, /dev/kmem and /dev/mem won't be allowed to
83014+ be written to or read from to modify or leak the contents of the running
83015+ kernel. /dev/port will also not be allowed to be opened, writing to
83016+ /dev/cpu/*/msr will be prevented, and support for kexec will be removed.
83017+ If you have module support disabled, enabling this will close up several
83018+ ways that are currently used to insert malicious code into the running
83019+ kernel.
83020+
83021+ Even with this feature enabled, we still highly recommend that
83022+ you use the RBAC system, as it is still possible for an attacker to
83023+ modify the running kernel through other more obscure methods.
83024+
83025+ It is highly recommended that you say Y here if you meet all the
83026+ conditions above.
83027+
83028+config GRKERNSEC_VM86
83029+ bool "Restrict VM86 mode"
83030+ default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
83031+ depends on X86_32
83032+
83033+ help
83034+ If you say Y here, only processes with CAP_SYS_RAWIO will be able to
83035+ make use of a special execution mode on 32bit x86 processors called
83036+ Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
83037+ video cards and will still work with this option enabled. The purpose
83038+ of the option is to prevent exploitation of emulation errors in
83039+ virtualization of vm86 mode like the one discovered in VMWare in 2009.
83040+ Nearly all users should be able to enable this option.
83041+
83042+config GRKERNSEC_IO
83043+ bool "Disable privileged I/O"
83044+ default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
83045+ depends on X86
83046+ select RTC_CLASS
83047+ select RTC_INTF_DEV
83048+ select RTC_DRV_CMOS
83049+
83050+ help
83051+ If you say Y here, all ioperm and iopl calls will return an error.
83052+ Ioperm and iopl can be used to modify the running kernel.
83053+ Unfortunately, some programs need this access to operate properly,
83054+ the most notable of which are XFree86 and hwclock. hwclock can be
83055+ remedied by having RTC support in the kernel, so real-time
83056+ clock support is enabled if this option is enabled, to ensure
83057+ that hwclock operates correctly. If hwclock still does not work,
83058+ either update udev or symlink /dev/rtc to /dev/rtc0.
83059+
83060+ If you're using XFree86 or a version of Xorg from 2012 or earlier,
83061+ you may not be able to boot into a graphical environment with this
83062+ option enabled. In this case, you should use the RBAC system instead.
83063+
83064+config GRKERNSEC_BPF_HARDEN
83065+ bool "Harden BPF interpreter"
83066+ default y if GRKERNSEC_CONFIG_AUTO
83067+ help
83068+ Unlike previous versions of grsecurity that hardened both the BPF
83069+ interpreted code against corruption at rest as well as the JIT code
83070+ against JIT-spray attacks and attacker-controlled immediate values
83071+ for ROP, this feature will enforce disabling of the new eBPF JIT engine
83072+ and will ensure the interpreted code is read-only at rest. This feature
83073+ may be removed at a later time when eBPF stabilizes to entirely revert
83074+ back to the more secure pre-3.16 BPF interpreter/JIT.
83075+
83076+ If you're using KERNEXEC, it's recommended that you enable this option
83077+ to supplement the hardening of the kernel.
83078+
83079+config GRKERNSEC_PERF_HARDEN
83080+ bool "Disable unprivileged PERF_EVENTS usage by default"
83081+ default y if GRKERNSEC_CONFIG_AUTO
83082+ depends on PERF_EVENTS
83083+ help
83084+ If you say Y here, the range of acceptable values for the
83085+ /proc/sys/kernel/perf_event_paranoid sysctl will be expanded to allow and
83086+ default to a new value: 3. When the sysctl is set to this value, no
83087+ unprivileged use of the PERF_EVENTS syscall interface will be permitted.
83088+
83089+ Though PERF_EVENTS can be used legitimately for performance monitoring
83090+ and low-level application profiling, it is forced on regardless of
83091+ configuration, has been at fault for several vulnerabilities, and
83092+ creates new opportunities for side channels and other information leaks.
83093+
83094+ This feature puts PERF_EVENTS into a secure default state and permits
83095+ the administrator to change out of it temporarily if unprivileged
83096+ application profiling is needed.
83097+
83098+config GRKERNSEC_RAND_THREADSTACK
83099+ bool "Insert random gaps between thread stacks"
83100+ default y if GRKERNSEC_CONFIG_AUTO
83101+ depends on PAX_RANDMMAP && !PPC
83102+ help
83103+ If you say Y here, a random-sized gap will be enforced between allocated
83104+ thread stacks. Glibc's NPTL and other threading libraries that
83105+ pass MAP_STACK to the kernel for thread stack allocation are supported.
83106+ The implementation currently provides 8 bits of entropy for the gap.
83107+
83108+ Many distributions do not compile threaded remote services with the
83109+ -fstack-check argument to GCC, causing the variable-sized stack-based
83110+ allocator, alloca(), to not probe the stack on allocation. This
83111+ permits an unbounded alloca() to skip over any guard page and potentially
83112+ modify another thread's stack reliably. An enforced random gap
83113+ reduces the reliability of such an attack and increases the chance
83114+ that such a read/write to another thread's stack instead lands in
83115+ an unmapped area, causing a crash and triggering grsecurity's
83116+ anti-bruteforcing logic.
83117+
83118+config GRKERNSEC_PROC_MEMMAP
83119+ bool "Harden ASLR against information leaks and entropy reduction"
83120+ default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
83121+ depends on PAX_NOEXEC || PAX_ASLR
83122+ help
83123+ If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
83124+ give no information about the addresses of its mappings if
83125+ PaX features that rely on random addresses are enabled on the task.
83126+ In addition to sanitizing this information and disabling other
83127+ dangerous sources of information, this option causes reads of sensitive
83128+ /proc/<pid> entries where the file descriptor was opened in a different
83129+ task than the one performing the read. Such attempts are logged.
83130+ This option also limits argv/env strings for suid/sgid binaries
83131+ to 512KB to prevent a complete exhaustion of the stack entropy provided
83132+ by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
83133+ binaries to prevent alternative mmap layouts from being abused.
83134+
83135+ If you use PaX it is essential that you say Y here as it closes up
83136+ several holes that make full ASLR useless locally.
83137+
83138+
83139+config GRKERNSEC_KSTACKOVERFLOW
83140+ bool "Prevent kernel stack overflows"
83141+ default y if GRKERNSEC_CONFIG_AUTO
83142+ depends on !IA64 && 64BIT
83143+ help
83144+ If you say Y here, the kernel's process stacks will be allocated
83145+ with vmalloc instead of the kernel's default allocator. This
83146+ introduces guard pages that in combination with the alloca checking
83147+ of the STACKLEAK feature prevents all forms of kernel process stack
83148+ overflow abuse. Note that this is different from kernel stack
83149+ buffer overflows.
83150+
83151+config GRKERNSEC_BRUTE
83152+ bool "Deter exploit bruteforcing"
83153+ default y if GRKERNSEC_CONFIG_AUTO
83154+ help
83155+ If you say Y here, attempts to bruteforce exploits against forking
83156+ daemons such as apache or sshd, as well as against suid/sgid binaries
83157+ will be deterred. When a child of a forking daemon is killed by PaX
83158+ or crashes due to an illegal instruction or other suspicious signal,
83159+ the parent process will be delayed 30 seconds upon every subsequent
83160+ fork until the administrator is able to assess the situation and
83161+ restart the daemon.
83162+ In the suid/sgid case, the attempt is logged, the user has all their
83163+ existing instances of the suid/sgid binary terminated and will
83164+ be unable to execute any suid/sgid binaries for 15 minutes.
83165+
83166+ It is recommended that you also enable signal logging in the auditing
83167+ section so that logs are generated when a process triggers a suspicious
83168+ signal.
83169+ If the sysctl option is enabled, a sysctl option with name
83170+ "deter_bruteforce" is created.
83171+
83172+config GRKERNSEC_MODHARDEN
83173+ bool "Harden module auto-loading"
83174+ default y if GRKERNSEC_CONFIG_AUTO
83175+ depends on MODULES
83176+ help
83177+ If you say Y here, module auto-loading in response to use of some
83178+ feature implemented by an unloaded module will be restricted to
83179+ root users. Enabling this option helps defend against attacks
83180+ by unprivileged users who abuse the auto-loading behavior to
83181+ cause a vulnerable module to load that is then exploited.
83182+
83183+ If this option prevents a legitimate use of auto-loading for a
83184+ non-root user, the administrator can execute modprobe manually
83185+ with the exact name of the module mentioned in the alert log.
83186+ Alternatively, the administrator can add the module to the list
83187+ of modules loaded at boot by modifying init scripts.
83188+
83189+ Modification of init scripts will most likely be needed on
83190+ Ubuntu servers with encrypted home directory support enabled,
83191+ as the first non-root user logging in will cause the ecb(aes),
83192+ ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
83193+
83194+config GRKERNSEC_HIDESYM
83195+ bool "Hide kernel symbols"
83196+ default y if GRKERNSEC_CONFIG_AUTO
83197+ select PAX_USERCOPY_SLABS
83198+ help
83199+ If you say Y here, getting information on loaded modules, and
83200+ displaying all kernel symbols through a syscall will be restricted
83201+ to users with CAP_SYS_MODULE. For software compatibility reasons,
83202+ /proc/kallsyms will be restricted to the root user. The RBAC
83203+ system can hide that entry even from root.
83204+
83205+ This option also prevents leaking of kernel addresses through
83206+ several /proc entries.
83207+
83208+ Note that this option is only effective provided the following
83209+ conditions are met:
83210+ 1) The kernel using grsecurity is not precompiled by some distribution
83211+ 2) You have also enabled GRKERNSEC_DMESG
83212+ 3) You are using the RBAC system and hiding other files such as your
83213+ kernel image and System.map. Alternatively, enabling this option
83214+ causes the permissions on /boot, /lib/modules, and the kernel
83215+ source directory to change at compile time to prevent
83216+ reading by non-root users.
83217+ If the above conditions are met, this option will aid in providing a
83218+ useful protection against local kernel exploitation of overflows
83219+ and arbitrary read/write vulnerabilities.
83220+
83221+ It is highly recommended that you enable GRKERNSEC_PERF_HARDEN
83222+ in addition to this feature.
83223+
83224+config GRKERNSEC_RANDSTRUCT
83225+ bool "Randomize layout of sensitive kernel structures"
83226+ default y if GRKERNSEC_CONFIG_AUTO
83227+ select GRKERNSEC_HIDESYM
83228+ select MODVERSIONS if MODULES
83229+ help
83230+ If you say Y here, the layouts of a number of sensitive kernel
83231+ structures (task, fs, cred, etc) and all structures composed entirely
83232+ of function pointers (aka "ops" structs) will be randomized at compile-time.
83233+ This can introduce the requirement of an additional infoleak
83234+ vulnerability for exploits targeting these structure types.
83235+
83236+ Enabling this feature will introduce some performance impact, slightly
83237+ increase memory usage, and prevent the use of forensic tools like
83238+ Volatility against the system (unless the kernel source tree isn't
83239+ cleaned after kernel installation).
83240+
83241+ The seed used for compilation is located at tools/gcc/randomize_layout_seed.h.
83242+ It remains after a make clean to allow for external modules to be compiled
83243+ with the existing seed and will be removed by a make mrproper or
83244+ make distclean.
83245+
83246+ Note that the implementation requires gcc 4.6.4. or newer. You may need
83247+ to install the supporting headers explicitly in addition to the normal
83248+ gcc package.
83249+
83250+config GRKERNSEC_RANDSTRUCT_PERFORMANCE
83251+ bool "Use cacheline-aware structure randomization"
83252+ depends on GRKERNSEC_RANDSTRUCT
83253+ default y if GRKERNSEC_CONFIG_PRIORITY_PERF
83254+ help
83255+ If you say Y here, the RANDSTRUCT randomization will make a best effort
83256+ at restricting randomization to cacheline-sized groups of elements. It
83257+ will further not randomize bitfields in structures. This reduces the
83258+ performance hit of RANDSTRUCT at the cost of weakened randomization.
83259+
83260+config GRKERNSEC_KERN_LOCKOUT
83261+ bool "Active kernel exploit response"
83262+ default y if GRKERNSEC_CONFIG_AUTO
83263+ depends on X86 || ARM || PPC || SPARC
83264+ help
83265+ If you say Y here, when a PaX alert is triggered due to suspicious
83266+ activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
83267+ or an OOPS occurs due to bad memory accesses, instead of just
83268+ terminating the offending process (and potentially allowing
83269+ a subsequent exploit from the same user), we will take one of two
83270+ actions:
83271+ If the user was root, we will panic the system
83272+ If the user was non-root, we will log the attempt, terminate
83273+ all processes owned by the user, then prevent them from creating
83274+ any new processes until the system is restarted
83275+ This deters repeated kernel exploitation/bruteforcing attempts
83276+ and is useful for later forensics.
83277+
83278+config GRKERNSEC_OLD_ARM_USERLAND
83279+ bool "Old ARM userland compatibility"
83280+ depends on ARM && (CPU_V6 || CPU_V6K || CPU_V7)
83281+ help
83282+ If you say Y here, stubs of executable code to perform such operations
83283+ as "compare-exchange" will be placed at fixed locations in the ARM vector
83284+ table. This is unfortunately needed for old ARM userland meant to run
83285+ across a wide range of processors. Without this option enabled,
83286+ the get_tls and data memory barrier stubs will be emulated by the kernel,
83287+ which is enough for Linaro userlands or other userlands designed for v6
83288+ and newer ARM CPUs. It's recommended that you try without this option enabled
83289+ first, and only enable it if your userland does not boot (it will likely fail
83290+ at init time).
83291+
83292+endmenu
83293+menu "Role Based Access Control Options"
83294+depends on GRKERNSEC
83295+
83296+config GRKERNSEC_RBAC_DEBUG
83297+ bool
83298+
83299+config GRKERNSEC_NO_RBAC
83300+ bool "Disable RBAC system"
83301+ help
83302+ If you say Y here, the /dev/grsec device will be removed from the kernel,
83303+ preventing the RBAC system from being enabled. You should only say Y
83304+ here if you have no intention of using the RBAC system, so as to prevent
83305+ an attacker with root access from misusing the RBAC system to hide files
83306+ and processes when loadable module support and /dev/[k]mem have been
83307+ locked down.
83308+
83309+config GRKERNSEC_ACL_HIDEKERN
83310+ bool "Hide kernel processes"
83311+ help
83312+ If you say Y here, all kernel threads will be hidden to all
83313+ processes but those whose subject has the "view hidden processes"
83314+ flag.
83315+
83316+config GRKERNSEC_ACL_MAXTRIES
83317+ int "Maximum tries before password lockout"
83318+ default 3
83319+ help
83320+ This option enforces the maximum number of times a user can attempt
83321+ to authorize themselves with the grsecurity RBAC system before being
83322+ denied the ability to attempt authorization again for a specified time.
83323+ The lower the number, the harder it will be to brute-force a password.
83324+
83325+config GRKERNSEC_ACL_TIMEOUT
83326+ int "Time to wait after max password tries, in seconds"
83327+ default 30
83328+ help
83329+ This option specifies the time the user must wait after attempting to
83330+ authorize to the RBAC system with the maximum number of invalid
83331+ passwords. The higher the number, the harder it will be to brute-force
83332+ a password.
83333+
83334+endmenu
83335+menu "Filesystem Protections"
83336+depends on GRKERNSEC
83337+
83338+config GRKERNSEC_PROC
83339+ bool "Proc restrictions"
83340+ default y if GRKERNSEC_CONFIG_AUTO
83341+ help
83342+ If you say Y here, the permissions of the /proc filesystem
83343+ will be altered to enhance system security and privacy. You MUST
83344+ choose either a user only restriction or a user and group restriction.
83345+ Depending upon the option you choose, you can either restrict users to
83346+ see only the processes they themselves run, or choose a group that can
83347+ view all processes and files normally restricted to root if you choose
83348+ the "restrict to user only" option. NOTE: If you're running identd or
83349+ ntpd as a non-root user, you will have to run it as the group you
83350+ specify here.
83351+
83352+config GRKERNSEC_PROC_USER
83353+ bool "Restrict /proc to user only"
83354+ depends on GRKERNSEC_PROC
83355+ help
83356+ If you say Y here, non-root users will only be able to view their own
83357+ processes, and restricts them from viewing network-related information,
83358+ and viewing kernel symbol and module information.
83359+
83360+config GRKERNSEC_PROC_USERGROUP
83361+ bool "Allow special group"
83362+ default y if GRKERNSEC_CONFIG_AUTO
83363+ depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
83364+ help
83365+ If you say Y here, you will be able to select a group that will be
83366+ able to view all processes and network-related information. If you've
83367+ enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
83368+ remain hidden. This option is useful if you want to run identd as
83369+ a non-root user. The group you select may also be chosen at boot time
83370+ via "grsec_proc_gid=" on the kernel commandline.
83371+
83372+config GRKERNSEC_PROC_GID
83373+ int "GID for special group"
83374+ depends on GRKERNSEC_PROC_USERGROUP
83375+ default 1001
83376+
83377+config GRKERNSEC_PROC_ADD
83378+ bool "Additional restrictions"
83379+ default y if GRKERNSEC_CONFIG_AUTO
83380+ depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
83381+ help
83382+ If you say Y here, additional restrictions will be placed on
83383+ /proc that keep normal users from viewing device information and
83384+ slabinfo information that could be useful for exploits.
83385+
83386+config GRKERNSEC_LINK
83387+ bool "Linking restrictions"
83388+ default y if GRKERNSEC_CONFIG_AUTO
83389+ help
83390+ If you say Y here, /tmp race exploits will be prevented, since users
83391+ will no longer be able to follow symlinks owned by other users in
83392+ world-writable +t directories (e.g. /tmp), unless the owner of the
83393+ symlink is the owner of the directory. users will also not be
83394+ able to hardlink to files they do not own. If the sysctl option is
83395+ enabled, a sysctl option with name "linking_restrictions" is created.
83396+
83397+config GRKERNSEC_SYMLINKOWN
83398+ bool "Kernel-enforced SymlinksIfOwnerMatch"
83399+ default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
83400+ help
83401+ Apache's SymlinksIfOwnerMatch option has an inherent race condition
83402+ that prevents it from being used as a security feature. As Apache
83403+ verifies the symlink by performing a stat() against the target of
83404+ the symlink before it is followed, an attacker can setup a symlink
83405+ to point to a same-owned file, then replace the symlink with one
83406+ that targets another user's file just after Apache "validates" the
83407+ symlink -- a classic TOCTOU race. If you say Y here, a complete,
83408+ race-free replacement for Apache's "SymlinksIfOwnerMatch" option
83409+ will be in place for the group you specify. If the sysctl option
83410+ is enabled, a sysctl option with name "enforce_symlinksifowner" is
83411+ created.
83412+
83413+config GRKERNSEC_SYMLINKOWN_GID
83414+ int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
83415+ depends on GRKERNSEC_SYMLINKOWN
83416+ default 1006
83417+ help
83418+ Setting this GID determines what group kernel-enforced
83419+ SymlinksIfOwnerMatch will be enabled for. If the sysctl option
83420+ is enabled, a sysctl option with name "symlinkown_gid" is created.
83421+
83422+config GRKERNSEC_FIFO
83423+ bool "FIFO restrictions"
83424+ default y if GRKERNSEC_CONFIG_AUTO
83425+ help
83426+ If you say Y here, users will not be able to write to FIFOs they don't
83427+ own in world-writable +t directories (e.g. /tmp), unless the owner of
83428+ the FIFO is the same owner of the directory it's held in. If the sysctl
83429+ option is enabled, a sysctl option with name "fifo_restrictions" is
83430+ created.
83431+
83432+config GRKERNSEC_SYSFS_RESTRICT
83433+ bool "Sysfs/debugfs restriction"
83434+ default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
83435+ depends on SYSFS
83436+ help
83437+ If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
83438+ any filesystem normally mounted under it (e.g. debugfs) will be
83439+ mostly accessible only by root. These filesystems generally provide access
83440+ to hardware and debug information that isn't appropriate for unprivileged
83441+ users of the system. Sysfs and debugfs have also become a large source
83442+ of new vulnerabilities, ranging from infoleaks to local compromise.
83443+ There has been very little oversight with an eye toward security involved
83444+ in adding new exporters of information to these filesystems, so their
83445+ use is discouraged.
83446+ For reasons of compatibility, a few directories have been whitelisted
83447+ for access by non-root users:
83448+ /sys/fs/selinux
83449+ /sys/fs/fuse
83450+ /sys/devices/system/cpu
83451+
83452+config GRKERNSEC_ROFS
83453+ bool "Runtime read-only mount protection"
83454+ depends on SYSCTL
83455+ help
83456+ If you say Y here, a sysctl option with name "romount_protect" will
83457+ be created. By setting this option to 1 at runtime, filesystems
83458+ will be protected in the following ways:
83459+ * No new writable mounts will be allowed
83460+ * Existing read-only mounts won't be able to be remounted read/write
83461+ * Write operations will be denied on all block devices
83462+ This option acts independently of grsec_lock: once it is set to 1,
83463+ it cannot be turned off. Therefore, please be mindful of the resulting
83464+ behavior if this option is enabled in an init script on a read-only
83465+ filesystem.
83466+ Also be aware that as with other root-focused features, GRKERNSEC_KMEM
83467+ and GRKERNSEC_IO should be enabled and module loading disabled via
83468+ config or at runtime.
83469+ This feature is mainly intended for secure embedded systems.
83470+
83471+
83472+config GRKERNSEC_DEVICE_SIDECHANNEL
83473+ bool "Eliminate stat/notify-based device sidechannels"
83474+ default y if GRKERNSEC_CONFIG_AUTO
83475+ help
83476+ If you say Y here, timing analyses on block or character
83477+ devices like /dev/ptmx using stat or inotify/dnotify/fanotify
83478+ will be thwarted for unprivileged users. If a process without
83479+ CAP_MKNOD stats such a device, the last access and last modify times
83480+ will match the device's create time. No access or modify events
83481+ will be triggered through inotify/dnotify/fanotify for such devices.
83482+ This feature will prevent attacks that may at a minimum
83483+ allow an attacker to determine the administrator's password length.
83484+
83485+config GRKERNSEC_CHROOT
83486+ bool "Chroot jail restrictions"
83487+ default y if GRKERNSEC_CONFIG_AUTO
83488+ help
83489+ If you say Y here, you will be able to choose several options that will
83490+ make breaking out of a chrooted jail much more difficult. If you
83491+ encounter no software incompatibilities with the following options, it
83492+ is recommended that you enable each one.
83493+
83494+ Note that the chroot restrictions are not intended to apply to "chroots"
83495+ to directories that are simple bind mounts of the global root filesystem.
83496+ For several other reasons, a user shouldn't expect any significant
83497+ security by performing such a chroot.
83498+
83499+config GRKERNSEC_CHROOT_MOUNT
83500+ bool "Deny mounts"
83501+ default y if GRKERNSEC_CONFIG_AUTO
83502+ depends on GRKERNSEC_CHROOT
83503+ help
83504+ If you say Y here, processes inside a chroot will not be able to
83505+ mount or remount filesystems. If the sysctl option is enabled, a
83506+ sysctl option with name "chroot_deny_mount" is created.
83507+
83508+config GRKERNSEC_CHROOT_DOUBLE
83509+ bool "Deny double-chroots"
83510+ default y if GRKERNSEC_CONFIG_AUTO
83511+ depends on GRKERNSEC_CHROOT
83512+ help
83513+ If you say Y here, processes inside a chroot will not be able to chroot
83514+ again outside the chroot. This is a widely used method of breaking
83515+ out of a chroot jail and should not be allowed. If the sysctl
83516+ option is enabled, a sysctl option with name
83517+ "chroot_deny_chroot" is created.
83518+
83519+config GRKERNSEC_CHROOT_PIVOT
83520+ bool "Deny pivot_root in chroot"
83521+ default y if GRKERNSEC_CONFIG_AUTO
83522+ depends on GRKERNSEC_CHROOT
83523+ help
83524+ If you say Y here, processes inside a chroot will not be able to use
83525+ a function called pivot_root() that was introduced in Linux 2.3.41. It
83526+ works similar to chroot in that it changes the root filesystem. This
83527+ function could be misused in a chrooted process to attempt to break out
83528+ of the chroot, and therefore should not be allowed. If the sysctl
83529+ option is enabled, a sysctl option with name "chroot_deny_pivot" is
83530+ created.
83531+
83532+config GRKERNSEC_CHROOT_CHDIR
83533+ bool "Enforce chdir(\"/\") on all chroots"
83534+ default y if GRKERNSEC_CONFIG_AUTO
83535+ depends on GRKERNSEC_CHROOT
83536+ help
83537+ If you say Y here, the current working directory of all newly-chrooted
83538+ applications will be set to the the root directory of the chroot.
83539+ The man page on chroot(2) states:
83540+ Note that this call does not change the current working
83541+ directory, so that `.' can be outside the tree rooted at
83542+ `/'. In particular, the super-user can escape from a
83543+ `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
83544+
83545+ It is recommended that you say Y here, since it's not known to break
83546+ any software. If the sysctl option is enabled, a sysctl option with
83547+ name "chroot_enforce_chdir" is created.
83548+
83549+config GRKERNSEC_CHROOT_CHMOD
83550+ bool "Deny (f)chmod +s"
83551+ default y if GRKERNSEC_CONFIG_AUTO
83552+ depends on GRKERNSEC_CHROOT
83553+ help
83554+ If you say Y here, processes inside a chroot will not be able to chmod
83555+ or fchmod files to make them have suid or sgid bits. This protects
83556+ against another published method of breaking a chroot. If the sysctl
83557+ option is enabled, a sysctl option with name "chroot_deny_chmod" is
83558+ created.
83559+
83560+config GRKERNSEC_CHROOT_FCHDIR
83561+ bool "Deny fchdir and fhandle out of chroot"
83562+ default y if GRKERNSEC_CONFIG_AUTO
83563+ depends on GRKERNSEC_CHROOT
83564+ help
83565+ If you say Y here, a well-known method of breaking chroots by fchdir'ing
83566+ to a file descriptor of the chrooting process that points to a directory
83567+ outside the filesystem will be stopped. Additionally, this option prevents
83568+ use of the recently-created syscall for opening files by a guessable "file
83569+ handle" inside a chroot. If the sysctl option is enabled, a sysctl option
83570+ with name "chroot_deny_fchdir" is created.
83571+
83572+config GRKERNSEC_CHROOT_MKNOD
83573+ bool "Deny mknod"
83574+ default y if GRKERNSEC_CONFIG_AUTO
83575+ depends on GRKERNSEC_CHROOT
83576+ help
83577+ If you say Y here, processes inside a chroot will not be allowed to
83578+ mknod. The problem with using mknod inside a chroot is that it
83579+ would allow an attacker to create a device entry that is the same
83580+ as one on the physical root of your system, which could range from
83581+ anything from the console device to a device for your harddrive (which
83582+ they could then use to wipe the drive or steal data). It is recommended
83583+ that you say Y here, unless you run into software incompatibilities.
83584+ If the sysctl option is enabled, a sysctl option with name
83585+ "chroot_deny_mknod" is created.
83586+
83587+config GRKERNSEC_CHROOT_SHMAT
83588+ bool "Deny shmat() out of chroot"
83589+ default y if GRKERNSEC_CONFIG_AUTO
83590+ depends on GRKERNSEC_CHROOT
83591+ help
83592+ If you say Y here, processes inside a chroot will not be able to attach
83593+ to shared memory segments that were created outside of the chroot jail.
83594+ It is recommended that you say Y here. If the sysctl option is enabled,
83595+ a sysctl option with name "chroot_deny_shmat" is created.
83596+
83597+config GRKERNSEC_CHROOT_UNIX
83598+ bool "Deny access to abstract AF_UNIX sockets out of chroot"
83599+ default y if GRKERNSEC_CONFIG_AUTO
83600+ depends on GRKERNSEC_CHROOT
83601+ help
83602+ If you say Y here, processes inside a chroot will not be able to
83603+ connect to abstract (meaning not belonging to a filesystem) Unix
83604+ domain sockets that were bound outside of a chroot. It is recommended
83605+ that you say Y here. If the sysctl option is enabled, a sysctl option
83606+ with name "chroot_deny_unix" is created.
83607+
83608+config GRKERNSEC_CHROOT_FINDTASK
83609+ bool "Protect outside processes"
83610+ default y if GRKERNSEC_CONFIG_AUTO
83611+ depends on GRKERNSEC_CHROOT
83612+ help
83613+ If you say Y here, processes inside a chroot will not be able to
83614+ kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
83615+ getsid, or view any process outside of the chroot. If the sysctl
83616+ option is enabled, a sysctl option with name "chroot_findtask" is
83617+ created.
83618+
83619+config GRKERNSEC_CHROOT_NICE
83620+ bool "Restrict priority changes"
83621+ default y if GRKERNSEC_CONFIG_AUTO
83622+ depends on GRKERNSEC_CHROOT
83623+ help
83624+ If you say Y here, processes inside a chroot will not be able to raise
83625+ the priority of processes in the chroot, or alter the priority of
83626+ processes outside the chroot. This provides more security than simply
83627+ removing CAP_SYS_NICE from the process' capability set. If the
83628+ sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
83629+ is created.
83630+
83631+config GRKERNSEC_CHROOT_SYSCTL
83632+ bool "Deny sysctl writes"
83633+ default y if GRKERNSEC_CONFIG_AUTO
83634+ depends on GRKERNSEC_CHROOT
83635+ help
83636+ If you say Y here, an attacker in a chroot will not be able to
83637+ write to sysctl entries, either by sysctl(2) or through a /proc
83638+ interface. It is strongly recommended that you say Y here. If the
83639+ sysctl option is enabled, a sysctl option with name
83640+ "chroot_deny_sysctl" is created.
83641+
83642+config GRKERNSEC_CHROOT_RENAME
83643+ bool "Deny bad renames"
83644+ default y if GRKERNSEC_CONFIG_AUTO
83645+ depends on GRKERNSEC_CHROOT
83646+ help
83647+ If you say Y here, an attacker in a chroot will not be able to
83648+ abuse the ability to create double chroots to break out of the
83649+ chroot by exploiting a race condition between a rename of a directory
83650+ within a chroot against an open of a symlink with relative path
83651+ components. This feature will likewise prevent an accomplice outside
83652+ a chroot from enabling a user inside the chroot to break out and make
83653+ use of their credentials on the global filesystem. Enabling this
83654+ feature is essential to prevent root users from breaking out of a
83655+ chroot. If the sysctl option is enabled, a sysctl option with name
83656+ "chroot_deny_bad_rename" is created.
83657+
83658+config GRKERNSEC_CHROOT_CAPS
83659+ bool "Capability restrictions"
83660+ default y if GRKERNSEC_CONFIG_AUTO
83661+ depends on GRKERNSEC_CHROOT
83662+ help
83663+ If you say Y here, the capabilities on all processes within a
83664+ chroot jail will be lowered to stop module insertion, raw i/o,
83665+ system and net admin tasks, rebooting the system, modifying immutable
83666+ files, modifying IPC owned by another, and changing the system time.
83667+ This is left an option because it can break some apps. Disable this
83668+ if your chrooted apps are having problems performing those kinds of
83669+ tasks. If the sysctl option is enabled, a sysctl option with
83670+ name "chroot_caps" is created.
83671+
83672+config GRKERNSEC_CHROOT_INITRD
83673+ bool "Exempt initrd tasks from restrictions"
83674+ default y if GRKERNSEC_CONFIG_AUTO
83675+ depends on GRKERNSEC_CHROOT && BLK_DEV_INITRD
83676+ help
83677+ If you say Y here, tasks started prior to init will be exempted from
83678+ grsecurity's chroot restrictions. This option is mainly meant to
83679+ resolve Plymouth's performing privileged operations unnecessarily
83680+ in a chroot.
83681+
83682+endmenu
83683+menu "Kernel Auditing"
83684+depends on GRKERNSEC
83685+
83686+config GRKERNSEC_AUDIT_GROUP
83687+ bool "Single group for auditing"
83688+ help
83689+ If you say Y here, the exec and chdir logging features will only operate
83690+ on a group you specify. This option is recommended if you only want to
83691+ watch certain users instead of having a large amount of logs from the
83692+ entire system. If the sysctl option is enabled, a sysctl option with
83693+ name "audit_group" is created.
83694+
83695+config GRKERNSEC_AUDIT_GID
83696+ int "GID for auditing"
83697+ depends on GRKERNSEC_AUDIT_GROUP
83698+ default 1007
83699+
83700+config GRKERNSEC_EXECLOG
83701+ bool "Exec logging"
83702+ help
83703+ If you say Y here, all execve() calls will be logged (since the
83704+ other exec*() calls are frontends to execve(), all execution
83705+ will be logged). Useful for shell-servers that like to keep track
83706+ of their users. If the sysctl option is enabled, a sysctl option with
83707+ name "exec_logging" is created.
83708+ WARNING: This option when enabled will produce a LOT of logs, especially
83709+ on an active system.
83710+
83711+config GRKERNSEC_RESLOG
83712+ bool "Resource logging"
83713+ default y if GRKERNSEC_CONFIG_AUTO
83714+ help
83715+ If you say Y here, all attempts to overstep resource limits will
83716+ be logged with the resource name, the requested size, and the current
83717+ limit. It is highly recommended that you say Y here. If the sysctl
83718+ option is enabled, a sysctl option with name "resource_logging" is
83719+ created. If the RBAC system is enabled, the sysctl value is ignored.
83720+
83721+config GRKERNSEC_CHROOT_EXECLOG
83722+ bool "Log execs within chroot"
83723+ help
83724+ If you say Y here, all executions inside a chroot jail will be logged
83725+ to syslog. This can cause a large amount of logs if certain
83726+ applications (eg. djb's daemontools) are installed on the system, and
83727+ is therefore left as an option. If the sysctl option is enabled, a
83728+ sysctl option with name "chroot_execlog" is created.
83729+
83730+config GRKERNSEC_AUDIT_PTRACE
83731+ bool "Ptrace logging"
83732+ help
83733+ If you say Y here, all attempts to attach to a process via ptrace
83734+ will be logged. If the sysctl option is enabled, a sysctl option
83735+ with name "audit_ptrace" is created.
83736+
83737+config GRKERNSEC_AUDIT_CHDIR
83738+ bool "Chdir logging"
83739+ help
83740+ If you say Y here, all chdir() calls will be logged. If the sysctl
83741+ option is enabled, a sysctl option with name "audit_chdir" is created.
83742+
83743+config GRKERNSEC_AUDIT_MOUNT
83744+ bool "(Un)Mount logging"
83745+ help
83746+ If you say Y here, all mounts and unmounts will be logged. If the
83747+ sysctl option is enabled, a sysctl option with name "audit_mount" is
83748+ created.
83749+
83750+config GRKERNSEC_SIGNAL
83751+ bool "Signal logging"
83752+ default y if GRKERNSEC_CONFIG_AUTO
83753+ help
83754+ If you say Y here, certain important signals will be logged, such as
83755+ SIGSEGV, which will as a result inform you of when a error in a program
83756+ occurred, which in some cases could mean a possible exploit attempt.
83757+ If the sysctl option is enabled, a sysctl option with name
83758+ "signal_logging" is created.
83759+
83760+config GRKERNSEC_FORKFAIL
83761+ bool "Fork failure logging"
83762+ help
83763+ If you say Y here, all failed fork() attempts will be logged.
83764+ This could suggest a fork bomb, or someone attempting to overstep
83765+ their process limit. If the sysctl option is enabled, a sysctl option
83766+ with name "forkfail_logging" is created.
83767+
83768+config GRKERNSEC_TIME
83769+ bool "Time change logging"
83770+ default y if GRKERNSEC_CONFIG_AUTO
83771+ help
83772+ If you say Y here, any changes of the system clock will be logged.
83773+ If the sysctl option is enabled, a sysctl option with name
83774+ "timechange_logging" is created.
83775+
83776+config GRKERNSEC_PROC_IPADDR
83777+ bool "/proc/<pid>/ipaddr support"
83778+ default y if GRKERNSEC_CONFIG_AUTO
83779+ help
83780+ If you say Y here, a new entry will be added to each /proc/<pid>
83781+ directory that contains the IP address of the person using the task.
83782+ The IP is carried across local TCP and AF_UNIX stream sockets.
83783+ This information can be useful for IDS/IPSes to perform remote response
83784+ to a local attack. The entry is readable by only the owner of the
83785+ process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
83786+ the RBAC system), and thus does not create privacy concerns.
83787+
83788+config GRKERNSEC_RWXMAP_LOG
83789+ bool 'Denied RWX mmap/mprotect logging'
83790+ default y if GRKERNSEC_CONFIG_AUTO
83791+ depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
83792+ help
83793+ If you say Y here, calls to mmap() and mprotect() with explicit
83794+ usage of PROT_WRITE and PROT_EXEC together will be logged when
83795+ denied by the PAX_MPROTECT feature. This feature will also
83796+ log other problematic scenarios that can occur when PAX_MPROTECT
83797+ is enabled on a binary, like textrels and PT_GNU_STACK. If the
83798+ sysctl option is enabled, a sysctl option with name "rwxmap_logging"
83799+ is created.
83800+
83801+endmenu
83802+
83803+menu "Executable Protections"
83804+depends on GRKERNSEC
83805+
83806+config GRKERNSEC_DMESG
83807+ bool "Dmesg(8) restriction"
83808+ default y if GRKERNSEC_CONFIG_AUTO
83809+ help
83810+ If you say Y here, non-root users will not be able to use dmesg(8)
83811+ to view the contents of the kernel's circular log buffer.
83812+ The kernel's log buffer often contains kernel addresses and other
83813+ identifying information useful to an attacker in fingerprinting a
83814+ system for a targeted exploit.
83815+ If the sysctl option is enabled, a sysctl option with name "dmesg" is
83816+ created.
83817+
83818+config GRKERNSEC_HARDEN_PTRACE
83819+ bool "Deter ptrace-based process snooping"
83820+ default y if GRKERNSEC_CONFIG_AUTO
83821+ help
83822+ If you say Y here, TTY sniffers and other malicious monitoring
83823+ programs implemented through ptrace will be defeated. If you
83824+ have been using the RBAC system, this option has already been
83825+ enabled for several years for all users, with the ability to make
83826+ fine-grained exceptions.
83827+
83828+ This option only affects the ability of non-root users to ptrace
83829+ processes that are not a descendent of the ptracing process.
83830+ This means that strace ./binary and gdb ./binary will still work,
83831+ but attaching to arbitrary processes will not. If the sysctl
83832+ option is enabled, a sysctl option with name "harden_ptrace" is
83833+ created.
83834+
83835+config GRKERNSEC_PTRACE_READEXEC
83836+ bool "Require read access to ptrace sensitive binaries"
83837+ default y if GRKERNSEC_CONFIG_AUTO
83838+ help
83839+ If you say Y here, unprivileged users will not be able to ptrace unreadable
83840+ binaries. This option is useful in environments that
83841+ remove the read bits (e.g. file mode 4711) from suid binaries to
83842+ prevent infoleaking of their contents. This option adds
83843+ consistency to the use of that file mode, as the binary could normally
83844+ be read out when run without privileges while ptracing.
83845+
83846+ If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
83847+ is created.
83848+
83849+config GRKERNSEC_SETXID
83850+ bool "Enforce consistent multithreaded privileges"
83851+ default y if GRKERNSEC_CONFIG_AUTO
83852+ depends on (X86 || SPARC64 || PPC || ARM || MIPS)
83853+ help
83854+ If you say Y here, a change from a root uid to a non-root uid
83855+ in a multithreaded application will cause the resulting uids,
83856+ gids, supplementary groups, and capabilities in that thread
83857+ to be propagated to the other threads of the process. In most
83858+ cases this is unnecessary, as glibc will emulate this behavior
83859+ on behalf of the application. Other libcs do not act in the
83860+ same way, allowing the other threads of the process to continue
83861+ running with root privileges. If the sysctl option is enabled,
83862+ a sysctl option with name "consistent_setxid" is created.
83863+
83864+config GRKERNSEC_HARDEN_IPC
83865+ bool "Disallow access to overly-permissive IPC objects"
83866+ default y if GRKERNSEC_CONFIG_AUTO
83867+ depends on SYSVIPC
83868+ help
83869+ If you say Y here, access to overly-permissive IPC objects (shared
83870+ memory, message queues, and semaphores) will be denied for processes
83871+ given the following criteria beyond normal permission checks:
83872+ 1) If the IPC object is world-accessible and the euid doesn't match
83873+ that of the creator or current uid for the IPC object
83874+ 2) If the IPC object is group-accessible and the egid doesn't
83875+ match that of the creator or current gid for the IPC object
83876+ It's a common error to grant too much permission to these objects,
83877+ with impact ranging from denial of service and information leaking to
83878+ privilege escalation. This feature was developed in response to
83879+ research by Tim Brown:
83880+ http://labs.portcullis.co.uk/whitepapers/memory-squatting-attacks-on-system-v-shared-memory/
83881+ who found hundreds of such insecure usages. Processes with
83882+ CAP_IPC_OWNER are still permitted to access these IPC objects.
83883+ If the sysctl option is enabled, a sysctl option with name
83884+ "harden_ipc" is created.
83885+
83886+config GRKERNSEC_TPE
83887+ bool "Trusted Path Execution (TPE)"
83888+ default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
83889+ help
83890+ If you say Y here, you will be able to choose a gid to add to the
83891+ supplementary groups of users you want to mark as "untrusted."
83892+ These users will not be able to execute any files that are not in
83893+ root-owned directories writable only by root. If the sysctl option
83894+ is enabled, a sysctl option with name "tpe" is created.
83895+
83896+config GRKERNSEC_TPE_ALL
83897+ bool "Partially restrict all non-root users"
83898+ depends on GRKERNSEC_TPE
83899+ help
83900+ If you say Y here, all non-root users will be covered under
83901+ a weaker TPE restriction. This is separate from, and in addition to,
83902+ the main TPE options that you have selected elsewhere. Thus, if a
83903+ "trusted" GID is chosen, this restriction applies to even that GID.
83904+ Under this restriction, all non-root users will only be allowed to
83905+ execute files in directories they own that are not group or
83906+ world-writable, or in directories owned by root and writable only by
83907+ root. If the sysctl option is enabled, a sysctl option with name
83908+ "tpe_restrict_all" is created.
83909+
83910+config GRKERNSEC_TPE_INVERT
83911+ bool "Invert GID option"
83912+ depends on GRKERNSEC_TPE
83913+ help
83914+ If you say Y here, the group you specify in the TPE configuration will
83915+ decide what group TPE restrictions will be *disabled* for. This
83916+ option is useful if you want TPE restrictions to be applied to most
83917+ users on the system. If the sysctl option is enabled, a sysctl option
83918+ with name "tpe_invert" is created. Unlike other sysctl options, this
83919+ entry will default to on for backward-compatibility.
83920+
83921+config GRKERNSEC_TPE_GID
83922+ int
83923+ default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
83924+ default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
83925+
83926+config GRKERNSEC_TPE_UNTRUSTED_GID
83927+ int "GID for TPE-untrusted users"
83928+ depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
83929+ default 1005
83930+ help
83931+ Setting this GID determines what group TPE restrictions will be
83932+ *enabled* for. If the sysctl option is enabled, a sysctl option
83933+ with name "tpe_gid" is created.
83934+
83935+config GRKERNSEC_TPE_TRUSTED_GID
83936+ int "GID for TPE-trusted users"
83937+ depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
83938+ default 1005
83939+ help
83940+ Setting this GID determines what group TPE restrictions will be
83941+ *disabled* for. If the sysctl option is enabled, a sysctl option
83942+ with name "tpe_gid" is created.
83943+
83944+endmenu
83945+menu "Network Protections"
83946+depends on GRKERNSEC
83947+
83948+config GRKERNSEC_BLACKHOLE
83949+ bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
83950+ default y if GRKERNSEC_CONFIG_AUTO
83951+ depends on NET
83952+ help
83953+ If you say Y here, neither TCP resets nor ICMP
83954+ destination-unreachable packets will be sent in response to packets
83955+ sent to ports for which no associated listening process exists.
83956+ It will also prevent the sending of ICMP protocol unreachable packets
83957+ in response to packets with unknown protocols.
83958+ This feature supports both IPV4 and IPV6 and exempts the
83959+ loopback interface from blackholing. Enabling this feature
83960+ makes a host more resilient to DoS attacks and reduces network
83961+ visibility against scanners.
83962+
83963+ The blackhole feature as-implemented is equivalent to the FreeBSD
83964+ blackhole feature, as it prevents RST responses to all packets, not
83965+ just SYNs. Under most application behavior this causes no
83966+ problems, but applications (like haproxy) may not close certain
83967+ connections in a way that cleanly terminates them on the remote
83968+ end, leaving the remote host in LAST_ACK state. Because of this
83969+ side-effect and to prevent intentional LAST_ACK DoSes, this
83970+ feature also adds automatic mitigation against such attacks.
83971+ The mitigation drastically reduces the amount of time a socket
83972+ can spend in LAST_ACK state. If you're using haproxy and not
83973+ all servers it connects to have this option enabled, consider
83974+ disabling this feature on the haproxy host.
83975+
83976+ If the sysctl option is enabled, two sysctl options with names
83977+ "ip_blackhole" and "lastack_retries" will be created.
83978+ While "ip_blackhole" takes the standard zero/non-zero on/off
83979+ toggle, "lastack_retries" uses the same kinds of values as
83980+ "tcp_retries1" and "tcp_retries2". The default value of 4
83981+ prevents a socket from lasting more than 45 seconds in LAST_ACK
83982+ state.
83983+
83984+config GRKERNSEC_NO_SIMULT_CONNECT
83985+ bool "Disable TCP Simultaneous Connect"
83986+ default y if GRKERNSEC_CONFIG_AUTO
83987+ depends on NET
83988+ help
83989+ If you say Y here, a feature by Willy Tarreau will be enabled that
83990+ removes a weakness in Linux's strict implementation of TCP that
83991+ allows two clients to connect to each other without either entering
83992+ a listening state. The weakness allows an attacker to easily prevent
83993+ a client from connecting to a known server provided the source port
83994+ for the connection is guessed correctly.
83995+
83996+ As the weakness could be used to prevent an antivirus or IPS from
83997+ fetching updates, or prevent an SSL gateway from fetching a CRL,
83998+ it should be eliminated by enabling this option. Though Linux is
83999+ one of few operating systems supporting simultaneous connect, it
84000+ has no legitimate use in practice and is rarely supported by firewalls.
84001+
84002+config GRKERNSEC_SOCKET
84003+ bool "Socket restrictions"
84004+ depends on NET
84005+ help
84006+ If you say Y here, you will be able to choose from several options.
84007+ If you assign a GID on your system and add it to the supplementary
84008+ groups of users you want to restrict socket access to, this patch
84009+ will perform up to three things, based on the option(s) you choose.
84010+
84011+config GRKERNSEC_SOCKET_ALL
84012+ bool "Deny any sockets to group"
84013+ depends on GRKERNSEC_SOCKET
84014+ help
84015+ If you say Y here, you will be able to choose a GID of whose users will
84016+ be unable to connect to other hosts from your machine or run server
84017+ applications from your machine. If the sysctl option is enabled, a
84018+ sysctl option with name "socket_all" is created.
84019+
84020+config GRKERNSEC_SOCKET_ALL_GID
84021+ int "GID to deny all sockets for"
84022+ depends on GRKERNSEC_SOCKET_ALL
84023+ default 1004
84024+ help
84025+ Here you can choose the GID to disable socket access for. Remember to
84026+ add the users you want socket access disabled for to the GID
84027+ specified here. If the sysctl option is enabled, a sysctl option
84028+ with name "socket_all_gid" is created.
84029+
84030+config GRKERNSEC_SOCKET_CLIENT
84031+ bool "Deny client sockets to group"
84032+ depends on GRKERNSEC_SOCKET
84033+ help
84034+ If you say Y here, you will be able to choose a GID of whose users will
84035+ be unable to connect to other hosts from your machine, but will be
84036+ able to run servers. If this option is enabled, all users in the group
84037+ you specify will have to use passive mode when initiating ftp transfers
84038+ from the shell on your machine. If the sysctl option is enabled, a
84039+ sysctl option with name "socket_client" is created.
84040+
84041+config GRKERNSEC_SOCKET_CLIENT_GID
84042+ int "GID to deny client sockets for"
84043+ depends on GRKERNSEC_SOCKET_CLIENT
84044+ default 1003
84045+ help
84046+ Here you can choose the GID to disable client socket access for.
84047+ Remember to add the users you want client socket access disabled for to
84048+ the GID specified here. If the sysctl option is enabled, a sysctl
84049+ option with name "socket_client_gid" is created.
84050+
84051+config GRKERNSEC_SOCKET_SERVER
84052+ bool "Deny server sockets to group"
84053+ depends on GRKERNSEC_SOCKET
84054+ help
84055+ If you say Y here, you will be able to choose a GID of whose users will
84056+ be unable to run server applications from your machine. If the sysctl
84057+ option is enabled, a sysctl option with name "socket_server" is created.
84058+
84059+config GRKERNSEC_SOCKET_SERVER_GID
84060+ int "GID to deny server sockets for"
84061+ depends on GRKERNSEC_SOCKET_SERVER
84062+ default 1002
84063+ help
84064+ Here you can choose the GID to disable server socket access for.
84065+ Remember to add the users you want server socket access disabled for to
84066+ the GID specified here. If the sysctl option is enabled, a sysctl
84067+ option with name "socket_server_gid" is created.
84068+
84069+endmenu
84070+
84071+menu "Physical Protections"
84072+depends on GRKERNSEC
84073+
84074+config GRKERNSEC_DENYUSB
84075+ bool "Deny new USB connections after toggle"
84076+ default y if GRKERNSEC_CONFIG_AUTO
84077+ depends on SYSCTL && USB_SUPPORT
84078+ help
84079+ If you say Y here, a new sysctl option with name "deny_new_usb"
84080+ will be created. Setting its value to 1 will prevent any new
84081+ USB devices from being recognized by the OS. Any attempted USB
84082+ device insertion will be logged. This option is intended to be
84083+ used against custom USB devices designed to exploit vulnerabilities
84084+ in various USB device drivers.
84085+
84086+ For greatest effectiveness, this sysctl should be set after any
84087+ relevant init scripts. This option is safe to enable in distros
84088+ as each user can choose whether or not to toggle the sysctl.
84089+
84090+config GRKERNSEC_DENYUSB_FORCE
84091+ bool "Reject all USB devices not connected at boot"
84092+ select USB
84093+ depends on GRKERNSEC_DENYUSB
84094+ help
84095+ If you say Y here, a variant of GRKERNSEC_DENYUSB will be enabled
84096+ that doesn't involve a sysctl entry. This option should only be
84097+ enabled if you're sure you want to deny all new USB connections
84098+ at runtime and don't want to modify init scripts. This should not
84099+ be enabled by distros. It forces the core USB code to be built
84100+ into the kernel image so that all devices connected at boot time
84101+ can be recognized and new USB device connections can be prevented
84102+ prior to init running.
84103+
84104+endmenu
84105+
84106+menu "Sysctl Support"
84107+depends on GRKERNSEC && SYSCTL
84108+
84109+config GRKERNSEC_SYSCTL
84110+ bool "Sysctl support"
84111+ default y if GRKERNSEC_CONFIG_AUTO
84112+ help
84113+ If you say Y here, you will be able to change the options that
84114+ grsecurity runs with at bootup, without having to recompile your
84115+ kernel. You can echo values to files in /proc/sys/kernel/grsecurity
84116+ to enable (1) or disable (0) various features. All the sysctl entries
84117+ are mutable until the "grsec_lock" entry is set to a non-zero value.
84118+ All features enabled in the kernel configuration are disabled at boot
84119+ if you do not say Y to the "Turn on features by default" option.
84120+ All options should be set at startup, and the grsec_lock entry should
84121+ be set to a non-zero value after all the options are set.
84122+ *THIS IS EXTREMELY IMPORTANT*
84123+
84124+config GRKERNSEC_SYSCTL_DISTRO
84125+ bool "Extra sysctl support for distro makers (READ HELP)"
84126+ depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
84127+ help
84128+ If you say Y here, additional sysctl options will be created
84129+ for features that affect processes running as root. Therefore,
84130+ it is critical when using this option that the grsec_lock entry be
84131+ enabled after boot. Only distros with prebuilt kernel packages
84132+ with this option enabled that can ensure grsec_lock is enabled
84133+ after boot should use this option.
84134+ *Failure to set grsec_lock after boot makes all grsec features
84135+ this option covers useless*
84136+
84137+ Currently this option creates the following sysctl entries:
84138+ "Disable Privileged I/O": "disable_priv_io"
84139+
84140+config GRKERNSEC_SYSCTL_ON
84141+ bool "Turn on features by default"
84142+ default y if GRKERNSEC_CONFIG_AUTO
84143+ depends on GRKERNSEC_SYSCTL
84144+ help
84145+ If you say Y here, instead of having all features enabled in the
84146+ kernel configuration disabled at boot time, the features will be
84147+ enabled at boot time. It is recommended you say Y here unless
84148+ there is some reason you would want all sysctl-tunable features to
84149+ be disabled by default. As mentioned elsewhere, it is important
84150+ to enable the grsec_lock entry once you have finished modifying
84151+ the sysctl entries.
84152+
84153+endmenu
84154+menu "Logging Options"
84155+depends on GRKERNSEC
84156+
84157+config GRKERNSEC_FLOODTIME
84158+ int "Seconds in between log messages (minimum)"
84159+ default 10
84160+ help
84161+ This option allows you to enforce the number of seconds between
84162+ grsecurity log messages. The default should be suitable for most
84163+ people, however, if you choose to change it, choose a value small enough
84164+ to allow informative logs to be produced, but large enough to
84165+ prevent flooding.
84166+
84167+ Setting both this value and GRKERNSEC_FLOODBURST to 0 will disable
84168+ any rate limiting on grsecurity log messages.
84169+
84170+config GRKERNSEC_FLOODBURST
84171+ int "Number of messages in a burst (maximum)"
84172+ default 6
84173+ help
84174+ This option allows you to choose the maximum number of messages allowed
84175+ within the flood time interval you chose in a separate option. The
84176+ default should be suitable for most people, however if you find that
84177+ many of your logs are being interpreted as flooding, you may want to
84178+ raise this value.
84179+
84180+ Setting both this value and GRKERNSEC_FLOODTIME to 0 will disable
84181+ any rate limiting on grsecurity log messages.
84182+
84183+endmenu
84184diff --git a/grsecurity/Makefile b/grsecurity/Makefile
84185new file mode 100644
84186index 0000000..30ababb
84187--- /dev/null
84188+++ b/grsecurity/Makefile
84189@@ -0,0 +1,54 @@
84190+# grsecurity – access control and security hardening for Linux
84191+# All code in this directory and various hooks located throughout the Linux kernel are
84192+# Copyright (C) 2001-2014 Bradley Spengler, Open Source Security, Inc.
84193+# http://www.grsecurity.net spender@grsecurity.net
84194+#
84195+# This program is free software; you can redistribute it and/or
84196+# modify it under the terms of the GNU General Public License version 2
84197+# as published by the Free Software Foundation.
84198+#
84199+# This program is distributed in the hope that it will be useful,
84200+# but WITHOUT ANY WARRANTY; without even the implied warranty of
84201+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
84202+# GNU General Public License for more details.
84203+#
84204+# You should have received a copy of the GNU General Public License
84205+# along with this program; if not, write to the Free Software
84206+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
84207+
84208+KBUILD_CFLAGS += -Werror
84209+
84210+obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
84211+ grsec_mount.o grsec_sig.o grsec_sysctl.o \
84212+ grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o \
84213+ grsec_usb.o grsec_ipc.o grsec_proc.o
84214+
84215+obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
84216+ gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
84217+ gracl_learn.o grsec_log.o gracl_policy.o
84218+ifdef CONFIG_COMPAT
84219+obj-$(CONFIG_GRKERNSEC) += gracl_compat.o
84220+endif
84221+
84222+obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
84223+
84224+ifdef CONFIG_NET
84225+obj-y += grsec_sock.o
84226+obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
84227+endif
84228+
84229+ifndef CONFIG_GRKERNSEC
84230+obj-y += grsec_disabled.o
84231+endif
84232+
84233+ifdef CONFIG_GRKERNSEC_HIDESYM
84234+extra-y := grsec_hidesym.o
84235+$(obj)/grsec_hidesym.o:
84236+ @-chmod -f 500 /boot
84237+ @-chmod -f 500 /lib/modules
84238+ @-chmod -f 500 /lib64/modules
84239+ @-chmod -f 500 /lib32/modules
84240+ @-chmod -f 700 .
84241+ @-chmod -f 700 $(objtree)
84242+ @echo ' grsec: protected kernel image paths'
84243+endif
84244diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
84245new file mode 100644
84246index 0000000..7ad630a
84247--- /dev/null
84248+++ b/grsecurity/gracl.c
84249@@ -0,0 +1,2757 @@
84250+#include <linux/kernel.h>
84251+#include <linux/module.h>
84252+#include <linux/sched.h>
84253+#include <linux/mm.h>
84254+#include <linux/file.h>
84255+#include <linux/fs.h>
84256+#include <linux/namei.h>
84257+#include <linux/mount.h>
84258+#include <linux/tty.h>
84259+#include <linux/proc_fs.h>
84260+#include <linux/lglock.h>
84261+#include <linux/slab.h>
84262+#include <linux/vmalloc.h>
84263+#include <linux/types.h>
84264+#include <linux/sysctl.h>
84265+#include <linux/netdevice.h>
84266+#include <linux/ptrace.h>
84267+#include <linux/gracl.h>
84268+#include <linux/gralloc.h>
84269+#include <linux/security.h>
84270+#include <linux/grinternal.h>
84271+#include <linux/pid_namespace.h>
84272+#include <linux/stop_machine.h>
84273+#include <linux/fdtable.h>
84274+#include <linux/percpu.h>
84275+#include <linux/lglock.h>
84276+#include <linux/hugetlb.h>
84277+#include <linux/posix-timers.h>
84278+#include <linux/prefetch.h>
84279+#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
84280+#include <linux/magic.h>
84281+#include <linux/pagemap.h>
84282+#include "../fs/btrfs/async-thread.h"
84283+#include "../fs/btrfs/ctree.h"
84284+#include "../fs/btrfs/btrfs_inode.h"
84285+#endif
84286+#include "../fs/mount.h"
84287+
84288+#include <asm/uaccess.h>
84289+#include <asm/errno.h>
84290+#include <asm/mman.h>
84291+
84292+#define FOR_EACH_ROLE_START(role) \
84293+ role = running_polstate.role_list; \
84294+ while (role) {
84295+
84296+#define FOR_EACH_ROLE_END(role) \
84297+ role = role->prev; \
84298+ }
84299+
84300+extern struct path gr_real_root;
84301+
84302+static struct gr_policy_state running_polstate;
84303+struct gr_policy_state *polstate = &running_polstate;
84304+extern struct gr_alloc_state *current_alloc_state;
84305+
84306+extern char *gr_shared_page[4];
84307+DEFINE_RWLOCK(gr_inode_lock);
84308+
84309+static unsigned int gr_status __read_only = GR_STATUS_INIT;
84310+
84311+#ifdef CONFIG_NET
84312+extern struct vfsmount *sock_mnt;
84313+#endif
84314+
84315+extern struct vfsmount *pipe_mnt;
84316+extern struct vfsmount *shm_mnt;
84317+
84318+#ifdef CONFIG_HUGETLBFS
84319+extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
84320+#endif
84321+
84322+extern u16 acl_sp_role_value;
84323+extern struct acl_object_label *fakefs_obj_rw;
84324+extern struct acl_object_label *fakefs_obj_rwx;
84325+
84326+int gr_acl_is_enabled(void)
84327+{
84328+ return (gr_status & GR_READY);
84329+}
84330+
84331+void gr_enable_rbac_system(void)
84332+{
84333+ pax_open_kernel();
84334+ gr_status |= GR_READY;
84335+ pax_close_kernel();
84336+}
84337+
84338+int gr_rbac_disable(void *unused)
84339+{
84340+ pax_open_kernel();
84341+ gr_status &= ~GR_READY;
84342+ pax_close_kernel();
84343+
84344+ return 0;
84345+}
84346+
84347+static inline dev_t __get_dev(const struct dentry *dentry)
84348+{
84349+ struct dentry *ldentry = d_backing_dentry((struct dentry *)dentry);
84350+
84351+#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
84352+ if (ldentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
84353+ return BTRFS_I(d_inode(ldentry))->root->anon_dev;
84354+ else
84355+#endif
84356+ return d_inode(ldentry)->i_sb->s_dev;
84357+}
84358+
84359+static inline u64 __get_ino(const struct dentry *dentry)
84360+{
84361+ struct dentry *ldentry = d_backing_dentry((struct dentry *)dentry);
84362+
84363+#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
84364+ if (ldentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
84365+ return btrfs_ino(d_inode(dentry));
84366+ else
84367+#endif
84368+ return d_inode(ldentry)->i_ino;
84369+}
84370+
84371+dev_t gr_get_dev_from_dentry(struct dentry *dentry)
84372+{
84373+ return __get_dev(dentry);
84374+}
84375+
84376+u64 gr_get_ino_from_dentry(struct dentry *dentry)
84377+{
84378+ return __get_ino(dentry);
84379+}
84380+
84381+static char gr_task_roletype_to_char(struct task_struct *task)
84382+{
84383+ switch (task->role->roletype &
84384+ (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
84385+ GR_ROLE_SPECIAL)) {
84386+ case GR_ROLE_DEFAULT:
84387+ return 'D';
84388+ case GR_ROLE_USER:
84389+ return 'U';
84390+ case GR_ROLE_GROUP:
84391+ return 'G';
84392+ case GR_ROLE_SPECIAL:
84393+ return 'S';
84394+ }
84395+
84396+ return 'X';
84397+}
84398+
84399+char gr_roletype_to_char(void)
84400+{
84401+ return gr_task_roletype_to_char(current);
84402+}
84403+
84404+int
84405+gr_acl_tpe_check(void)
84406+{
84407+ if (unlikely(!(gr_status & GR_READY)))
84408+ return 0;
84409+ if (current->role->roletype & GR_ROLE_TPE)
84410+ return 1;
84411+ else
84412+ return 0;
84413+}
84414+
84415+int
84416+gr_handle_rawio(const struct inode *inode)
84417+{
84418+#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
84419+ if (inode && (S_ISBLK(inode->i_mode) || (S_ISCHR(inode->i_mode) && imajor(inode) == RAW_MAJOR)) &&
84420+ grsec_enable_chroot_caps && proc_is_chrooted(current) &&
84421+ !capable(CAP_SYS_RAWIO))
84422+ return 1;
84423+#endif
84424+ return 0;
84425+}
84426+
84427+int
84428+gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
84429+{
84430+ if (likely(lena != lenb))
84431+ return 0;
84432+
84433+ return !memcmp(a, b, lena);
84434+}
84435+
84436+static int prepend(char **buffer, int *buflen, const char *str, int namelen)
84437+{
84438+ *buflen -= namelen;
84439+ if (*buflen < 0)
84440+ return -ENAMETOOLONG;
84441+ *buffer -= namelen;
84442+ memcpy(*buffer, str, namelen);
84443+ return 0;
84444+}
84445+
84446+static int prepend_name(char **buffer, int *buflen, struct qstr *name)
84447+{
84448+ return prepend(buffer, buflen, name->name, name->len);
84449+}
84450+
84451+static int prepend_path(const struct path *path, struct path *root,
84452+ char **buffer, int *buflen)
84453+{
84454+ struct dentry *dentry = path->dentry;
84455+ struct vfsmount *vfsmnt = path->mnt;
84456+ struct mount *mnt = real_mount(vfsmnt);
84457+ bool slash = false;
84458+ int error = 0;
84459+
84460+ while (dentry != root->dentry || vfsmnt != root->mnt) {
84461+ struct dentry * parent;
84462+
84463+ if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
84464+ /* Global root? */
84465+ if (!mnt_has_parent(mnt)) {
84466+ goto out;
84467+ }
84468+ dentry = mnt->mnt_mountpoint;
84469+ mnt = mnt->mnt_parent;
84470+ vfsmnt = &mnt->mnt;
84471+ continue;
84472+ }
84473+ parent = dentry->d_parent;
84474+ prefetch(parent);
84475+ spin_lock(&dentry->d_lock);
84476+ error = prepend_name(buffer, buflen, &dentry->d_name);
84477+ spin_unlock(&dentry->d_lock);
84478+ if (!error)
84479+ error = prepend(buffer, buflen, "/", 1);
84480+ if (error)
84481+ break;
84482+
84483+ slash = true;
84484+ dentry = parent;
84485+ }
84486+
84487+out:
84488+ if (!error && !slash)
84489+ error = prepend(buffer, buflen, "/", 1);
84490+
84491+ return error;
84492+}
84493+
84494+/* this must be called with mount_lock and rename_lock held */
84495+
84496+static char *__our_d_path(const struct path *path, struct path *root,
84497+ char *buf, int buflen)
84498+{
84499+ char *res = buf + buflen;
84500+ int error;
84501+
84502+ prepend(&res, &buflen, "\0", 1);
84503+ error = prepend_path(path, root, &res, &buflen);
84504+ if (error)
84505+ return ERR_PTR(error);
84506+
84507+ return res;
84508+}
84509+
84510+static char *
84511+gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
84512+{
84513+ char *retval;
84514+
84515+ retval = __our_d_path(path, root, buf, buflen);
84516+ if (unlikely(IS_ERR(retval)))
84517+ retval = strcpy(buf, "<path too long>");
84518+ else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
84519+ retval[1] = '\0';
84520+
84521+ return retval;
84522+}
84523+
84524+static char *
84525+__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
84526+ char *buf, int buflen)
84527+{
84528+ struct path path;
84529+ char *res;
84530+
84531+ path.dentry = (struct dentry *)dentry;
84532+ path.mnt = (struct vfsmount *)vfsmnt;
84533+
84534+ /* we can use gr_real_root.dentry, gr_real_root.mnt, because this is only called
84535+ by the RBAC system */
84536+ res = gen_full_path(&path, &gr_real_root, buf, buflen);
84537+
84538+ return res;
84539+}
84540+
84541+static char *
84542+d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
84543+ char *buf, int buflen)
84544+{
84545+ char *res;
84546+ struct path path;
84547+ struct path root;
84548+ struct task_struct *reaper = init_pid_ns.child_reaper;
84549+
84550+ path.dentry = (struct dentry *)dentry;
84551+ path.mnt = (struct vfsmount *)vfsmnt;
84552+
84553+ /* we can't use gr_real_root.dentry, gr_real_root.mnt, because they belong only to the RBAC system */
84554+ get_fs_root(reaper->fs, &root);
84555+
84556+ read_seqlock_excl(&mount_lock);
84557+ write_seqlock(&rename_lock);
84558+ res = gen_full_path(&path, &root, buf, buflen);
84559+ write_sequnlock(&rename_lock);
84560+ read_sequnlock_excl(&mount_lock);
84561+
84562+ path_put(&root);
84563+ return res;
84564+}
84565+
84566+char *
84567+gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
84568+{
84569+ char *ret;
84570+ read_seqlock_excl(&mount_lock);
84571+ write_seqlock(&rename_lock);
84572+ ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
84573+ PAGE_SIZE);
84574+ write_sequnlock(&rename_lock);
84575+ read_sequnlock_excl(&mount_lock);
84576+ return ret;
84577+}
84578+
84579+static char *
84580+gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
84581+{
84582+ char *ret;
84583+ char *buf;
84584+ int buflen;
84585+
84586+ read_seqlock_excl(&mount_lock);
84587+ write_seqlock(&rename_lock);
84588+ buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
84589+ ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
84590+ buflen = (int)(ret - buf);
84591+ if (buflen >= 5)
84592+ prepend(&ret, &buflen, "/proc", 5);
84593+ else
84594+ ret = strcpy(buf, "<path too long>");
84595+ write_sequnlock(&rename_lock);
84596+ read_sequnlock_excl(&mount_lock);
84597+ return ret;
84598+}
84599+
84600+char *
84601+gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
84602+{
84603+ return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
84604+ PAGE_SIZE);
84605+}
84606+
84607+char *
84608+gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
84609+{
84610+ return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
84611+ PAGE_SIZE);
84612+}
84613+
84614+char *
84615+gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
84616+{
84617+ return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
84618+ PAGE_SIZE);
84619+}
84620+
84621+char *
84622+gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
84623+{
84624+ return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
84625+ PAGE_SIZE);
84626+}
84627+
84628+char *
84629+gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
84630+{
84631+ return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
84632+ PAGE_SIZE);
84633+}
84634+
84635+__u32
84636+to_gr_audit(const __u32 reqmode)
84637+{
84638+ /* masks off auditable permission flags, then shifts them to create
84639+ auditing flags, and adds the special case of append auditing if
84640+ we're requesting write */
84641+ return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
84642+}
84643+
84644+struct acl_role_label *
84645+__lookup_acl_role_label(const struct gr_policy_state *state, const struct task_struct *task, const uid_t uid,
84646+ const gid_t gid)
84647+{
84648+ unsigned int index = gr_rhash(uid, GR_ROLE_USER, state->acl_role_set.r_size);
84649+ struct acl_role_label *match;
84650+ struct role_allowed_ip *ipp;
84651+ unsigned int x;
84652+ u32 curr_ip = task->signal->saved_ip;
84653+
84654+ match = state->acl_role_set.r_hash[index];
84655+
84656+ while (match) {
84657+ if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
84658+ for (x = 0; x < match->domain_child_num; x++) {
84659+ if (match->domain_children[x] == uid)
84660+ goto found;
84661+ }
84662+ } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
84663+ break;
84664+ match = match->next;
84665+ }
84666+found:
84667+ if (match == NULL) {
84668+ try_group:
84669+ index = gr_rhash(gid, GR_ROLE_GROUP, state->acl_role_set.r_size);
84670+ match = state->acl_role_set.r_hash[index];
84671+
84672+ while (match) {
84673+ if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
84674+ for (x = 0; x < match->domain_child_num; x++) {
84675+ if (match->domain_children[x] == gid)
84676+ goto found2;
84677+ }
84678+ } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
84679+ break;
84680+ match = match->next;
84681+ }
84682+found2:
84683+ if (match == NULL)
84684+ match = state->default_role;
84685+ if (match->allowed_ips == NULL)
84686+ return match;
84687+ else {
84688+ for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
84689+ if (likely
84690+ ((ntohl(curr_ip) & ipp->netmask) ==
84691+ (ntohl(ipp->addr) & ipp->netmask)))
84692+ return match;
84693+ }
84694+ match = state->default_role;
84695+ }
84696+ } else if (match->allowed_ips == NULL) {
84697+ return match;
84698+ } else {
84699+ for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
84700+ if (likely
84701+ ((ntohl(curr_ip) & ipp->netmask) ==
84702+ (ntohl(ipp->addr) & ipp->netmask)))
84703+ return match;
84704+ }
84705+ goto try_group;
84706+ }
84707+
84708+ return match;
84709+}
84710+
84711+static struct acl_role_label *
84712+lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
84713+ const gid_t gid)
84714+{
84715+ return __lookup_acl_role_label(&running_polstate, task, uid, gid);
84716+}
84717+
84718+struct acl_subject_label *
84719+lookup_acl_subj_label(const u64 ino, const dev_t dev,
84720+ const struct acl_role_label *role)
84721+{
84722+ unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
84723+ struct acl_subject_label *match;
84724+
84725+ match = role->subj_hash[index];
84726+
84727+ while (match && (match->inode != ino || match->device != dev ||
84728+ (match->mode & GR_DELETED))) {
84729+ match = match->next;
84730+ }
84731+
84732+ if (match && !(match->mode & GR_DELETED))
84733+ return match;
84734+ else
84735+ return NULL;
84736+}
84737+
84738+struct acl_subject_label *
84739+lookup_acl_subj_label_deleted(const u64 ino, const dev_t dev,
84740+ const struct acl_role_label *role)
84741+{
84742+ unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
84743+ struct acl_subject_label *match;
84744+
84745+ match = role->subj_hash[index];
84746+
84747+ while (match && (match->inode != ino || match->device != dev ||
84748+ !(match->mode & GR_DELETED))) {
84749+ match = match->next;
84750+ }
84751+
84752+ if (match && (match->mode & GR_DELETED))
84753+ return match;
84754+ else
84755+ return NULL;
84756+}
84757+
84758+static struct acl_object_label *
84759+lookup_acl_obj_label(const u64 ino, const dev_t dev,
84760+ const struct acl_subject_label *subj)
84761+{
84762+ unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
84763+ struct acl_object_label *match;
84764+
84765+ match = subj->obj_hash[index];
84766+
84767+ while (match && (match->inode != ino || match->device != dev ||
84768+ (match->mode & GR_DELETED))) {
84769+ match = match->next;
84770+ }
84771+
84772+ if (match && !(match->mode & GR_DELETED))
84773+ return match;
84774+ else
84775+ return NULL;
84776+}
84777+
84778+static struct acl_object_label *
84779+lookup_acl_obj_label_create(const u64 ino, const dev_t dev,
84780+ const struct acl_subject_label *subj)
84781+{
84782+ unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
84783+ struct acl_object_label *match;
84784+
84785+ match = subj->obj_hash[index];
84786+
84787+ while (match && (match->inode != ino || match->device != dev ||
84788+ !(match->mode & GR_DELETED))) {
84789+ match = match->next;
84790+ }
84791+
84792+ if (match && (match->mode & GR_DELETED))
84793+ return match;
84794+
84795+ match = subj->obj_hash[index];
84796+
84797+ while (match && (match->inode != ino || match->device != dev ||
84798+ (match->mode & GR_DELETED))) {
84799+ match = match->next;
84800+ }
84801+
84802+ if (match && !(match->mode & GR_DELETED))
84803+ return match;
84804+ else
84805+ return NULL;
84806+}
84807+
84808+struct name_entry *
84809+__lookup_name_entry(const struct gr_policy_state *state, const char *name)
84810+{
84811+ unsigned int len = strlen(name);
84812+ unsigned int key = full_name_hash(name, len);
84813+ unsigned int index = key % state->name_set.n_size;
84814+ struct name_entry *match;
84815+
84816+ match = state->name_set.n_hash[index];
84817+
84818+ while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
84819+ match = match->next;
84820+
84821+ return match;
84822+}
84823+
84824+static struct name_entry *
84825+lookup_name_entry(const char *name)
84826+{
84827+ return __lookup_name_entry(&running_polstate, name);
84828+}
84829+
84830+static struct name_entry *
84831+lookup_name_entry_create(const char *name)
84832+{
84833+ unsigned int len = strlen(name);
84834+ unsigned int key = full_name_hash(name, len);
84835+ unsigned int index = key % running_polstate.name_set.n_size;
84836+ struct name_entry *match;
84837+
84838+ match = running_polstate.name_set.n_hash[index];
84839+
84840+ while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
84841+ !match->deleted))
84842+ match = match->next;
84843+
84844+ if (match && match->deleted)
84845+ return match;
84846+
84847+ match = running_polstate.name_set.n_hash[index];
84848+
84849+ while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
84850+ match->deleted))
84851+ match = match->next;
84852+
84853+ if (match && !match->deleted)
84854+ return match;
84855+ else
84856+ return NULL;
84857+}
84858+
84859+static struct inodev_entry *
84860+lookup_inodev_entry(const u64 ino, const dev_t dev)
84861+{
84862+ unsigned int index = gr_fhash(ino, dev, running_polstate.inodev_set.i_size);
84863+ struct inodev_entry *match;
84864+
84865+ match = running_polstate.inodev_set.i_hash[index];
84866+
84867+ while (match && (match->nentry->inode != ino || match->nentry->device != dev))
84868+ match = match->next;
84869+
84870+ return match;
84871+}
84872+
84873+void
84874+__insert_inodev_entry(const struct gr_policy_state *state, struct inodev_entry *entry)
84875+{
84876+ unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
84877+ state->inodev_set.i_size);
84878+ struct inodev_entry **curr;
84879+
84880+ entry->prev = NULL;
84881+
84882+ curr = &state->inodev_set.i_hash[index];
84883+ if (*curr != NULL)
84884+ (*curr)->prev = entry;
84885+
84886+ entry->next = *curr;
84887+ *curr = entry;
84888+
84889+ return;
84890+}
84891+
84892+static void
84893+insert_inodev_entry(struct inodev_entry *entry)
84894+{
84895+ __insert_inodev_entry(&running_polstate, entry);
84896+}
84897+
84898+void
84899+insert_acl_obj_label(struct acl_object_label *obj,
84900+ struct acl_subject_label *subj)
84901+{
84902+ unsigned int index =
84903+ gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
84904+ struct acl_object_label **curr;
84905+
84906+ obj->prev = NULL;
84907+
84908+ curr = &subj->obj_hash[index];
84909+ if (*curr != NULL)
84910+ (*curr)->prev = obj;
84911+
84912+ obj->next = *curr;
84913+ *curr = obj;
84914+
84915+ return;
84916+}
84917+
84918+void
84919+insert_acl_subj_label(struct acl_subject_label *obj,
84920+ struct acl_role_label *role)
84921+{
84922+ unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
84923+ struct acl_subject_label **curr;
84924+
84925+ obj->prev = NULL;
84926+
84927+ curr = &role->subj_hash[index];
84928+ if (*curr != NULL)
84929+ (*curr)->prev = obj;
84930+
84931+ obj->next = *curr;
84932+ *curr = obj;
84933+
84934+ return;
84935+}
84936+
84937+/* derived from glibc fnmatch() 0: match, 1: no match*/
84938+
84939+static int
84940+glob_match(const char *p, const char *n)
84941+{
84942+ char c;
84943+
84944+ while ((c = *p++) != '\0') {
84945+ switch (c) {
84946+ case '?':
84947+ if (*n == '\0')
84948+ return 1;
84949+ else if (*n == '/')
84950+ return 1;
84951+ break;
84952+ case '\\':
84953+ if (*n != c)
84954+ return 1;
84955+ break;
84956+ case '*':
84957+ for (c = *p++; c == '?' || c == '*'; c = *p++) {
84958+ if (*n == '/')
84959+ return 1;
84960+ else if (c == '?') {
84961+ if (*n == '\0')
84962+ return 1;
84963+ else
84964+ ++n;
84965+ }
84966+ }
84967+ if (c == '\0') {
84968+ return 0;
84969+ } else {
84970+ const char *endp;
84971+
84972+ if ((endp = strchr(n, '/')) == NULL)
84973+ endp = n + strlen(n);
84974+
84975+ if (c == '[') {
84976+ for (--p; n < endp; ++n)
84977+ if (!glob_match(p, n))
84978+ return 0;
84979+ } else if (c == '/') {
84980+ while (*n != '\0' && *n != '/')
84981+ ++n;
84982+ if (*n == '/' && !glob_match(p, n + 1))
84983+ return 0;
84984+ } else {
84985+ for (--p; n < endp; ++n)
84986+ if (*n == c && !glob_match(p, n))
84987+ return 0;
84988+ }
84989+
84990+ return 1;
84991+ }
84992+ case '[':
84993+ {
84994+ int not;
84995+ char cold;
84996+
84997+ if (*n == '\0' || *n == '/')
84998+ return 1;
84999+
85000+ not = (*p == '!' || *p == '^');
85001+ if (not)
85002+ ++p;
85003+
85004+ c = *p++;
85005+ for (;;) {
85006+ unsigned char fn = (unsigned char)*n;
85007+
85008+ if (c == '\0')
85009+ return 1;
85010+ else {
85011+ if (c == fn)
85012+ goto matched;
85013+ cold = c;
85014+ c = *p++;
85015+
85016+ if (c == '-' && *p != ']') {
85017+ unsigned char cend = *p++;
85018+
85019+ if (cend == '\0')
85020+ return 1;
85021+
85022+ if (cold <= fn && fn <= cend)
85023+ goto matched;
85024+
85025+ c = *p++;
85026+ }
85027+ }
85028+
85029+ if (c == ']')
85030+ break;
85031+ }
85032+ if (!not)
85033+ return 1;
85034+ break;
85035+ matched:
85036+ while (c != ']') {
85037+ if (c == '\0')
85038+ return 1;
85039+
85040+ c = *p++;
85041+ }
85042+ if (not)
85043+ return 1;
85044+ }
85045+ break;
85046+ default:
85047+ if (c != *n)
85048+ return 1;
85049+ }
85050+
85051+ ++n;
85052+ }
85053+
85054+ if (*n == '\0')
85055+ return 0;
85056+
85057+ if (*n == '/')
85058+ return 0;
85059+
85060+ return 1;
85061+}
85062+
85063+static struct acl_object_label *
85064+chk_glob_label(struct acl_object_label *globbed,
85065+ const struct dentry *dentry, const struct vfsmount *mnt, char **path)
85066+{
85067+ struct acl_object_label *tmp;
85068+
85069+ if (*path == NULL)
85070+ *path = gr_to_filename_nolock(dentry, mnt);
85071+
85072+ tmp = globbed;
85073+
85074+ while (tmp) {
85075+ if (!glob_match(tmp->filename, *path))
85076+ return tmp;
85077+ tmp = tmp->next;
85078+ }
85079+
85080+ return NULL;
85081+}
85082+
85083+static struct acl_object_label *
85084+__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
85085+ const u64 curr_ino, const dev_t curr_dev,
85086+ const struct acl_subject_label *subj, char **path, const int checkglob)
85087+{
85088+ struct acl_subject_label *tmpsubj;
85089+ struct acl_object_label *retval;
85090+ struct acl_object_label *retval2;
85091+
85092+ tmpsubj = (struct acl_subject_label *) subj;
85093+ read_lock(&gr_inode_lock);
85094+ do {
85095+ retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
85096+ if (retval) {
85097+ if (checkglob && retval->globbed) {
85098+ retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
85099+ if (retval2)
85100+ retval = retval2;
85101+ }
85102+ break;
85103+ }
85104+ } while ((tmpsubj = tmpsubj->parent_subject));
85105+ read_unlock(&gr_inode_lock);
85106+
85107+ return retval;
85108+}
85109+
85110+static struct acl_object_label *
85111+full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
85112+ struct dentry *curr_dentry,
85113+ const struct acl_subject_label *subj, char **path, const int checkglob)
85114+{
85115+ int newglob = checkglob;
85116+ u64 inode;
85117+ dev_t device;
85118+
85119+ /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
85120+ as we don't want a / * rule to match instead of the / object
85121+ don't do this for create lookups that call this function though, since they're looking up
85122+ on the parent and thus need globbing checks on all paths
85123+ */
85124+ if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
85125+ newglob = GR_NO_GLOB;
85126+
85127+ spin_lock(&curr_dentry->d_lock);
85128+ inode = __get_ino(curr_dentry);
85129+ device = __get_dev(curr_dentry);
85130+ spin_unlock(&curr_dentry->d_lock);
85131+
85132+ return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
85133+}
85134+
85135+#ifdef CONFIG_HUGETLBFS
85136+static inline bool
85137+is_hugetlbfs_mnt(const struct vfsmount *mnt)
85138+{
85139+ int i;
85140+ for (i = 0; i < HUGE_MAX_HSTATE; i++) {
85141+ if (unlikely(hugetlbfs_vfsmount[i] == mnt))
85142+ return true;
85143+ }
85144+
85145+ return false;
85146+}
85147+#endif
85148+
85149+static struct acl_object_label *
85150+__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
85151+ const struct acl_subject_label *subj, char *path, const int checkglob)
85152+{
85153+ struct dentry *dentry = (struct dentry *) l_dentry;
85154+ struct vfsmount *mnt = (struct vfsmount *) l_mnt;
85155+ struct inode * inode = d_backing_inode(dentry);
85156+ struct mount *real_mnt = real_mount(mnt);
85157+ struct acl_object_label *retval;
85158+ struct dentry *parent;
85159+
85160+ read_seqlock_excl(&mount_lock);
85161+ write_seqlock(&rename_lock);
85162+
85163+ if (unlikely((mnt == shm_mnt && inode->i_nlink == 0) || mnt == pipe_mnt ||
85164+#ifdef CONFIG_NET
85165+ mnt == sock_mnt ||
85166+#endif
85167+#ifdef CONFIG_HUGETLBFS
85168+ (is_hugetlbfs_mnt(mnt) && inode->i_nlink == 0) ||
85169+#endif
85170+ /* ignore Eric Biederman */
85171+ IS_PRIVATE(inode))) {
85172+ retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
85173+ goto out;
85174+ }
85175+
85176+ for (;;) {
85177+ if (dentry == gr_real_root.dentry && mnt == gr_real_root.mnt)
85178+ break;
85179+
85180+ if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
85181+ if (!mnt_has_parent(real_mnt))
85182+ break;
85183+
85184+ retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
85185+ if (retval != NULL)
85186+ goto out;
85187+
85188+ dentry = real_mnt->mnt_mountpoint;
85189+ real_mnt = real_mnt->mnt_parent;
85190+ mnt = &real_mnt->mnt;
85191+ continue;
85192+ }
85193+
85194+ parent = dentry->d_parent;
85195+ retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
85196+ if (retval != NULL)
85197+ goto out;
85198+
85199+ dentry = parent;
85200+ }
85201+
85202+ retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
85203+
85204+ /* gr_real_root is pinned so we don't have to hold a reference */
85205+ if (retval == NULL)
85206+ retval = full_lookup(l_dentry, l_mnt, gr_real_root.dentry, subj, &path, checkglob);
85207+out:
85208+ write_sequnlock(&rename_lock);
85209+ read_sequnlock_excl(&mount_lock);
85210+
85211+ BUG_ON(retval == NULL);
85212+
85213+ return retval;
85214+}
85215+
85216+static struct acl_object_label *
85217+chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
85218+ const struct acl_subject_label *subj)
85219+{
85220+ char *path = NULL;
85221+ return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
85222+}
85223+
85224+static struct acl_object_label *
85225+chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
85226+ const struct acl_subject_label *subj)
85227+{
85228+ char *path = NULL;
85229+ return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
85230+}
85231+
85232+static struct acl_object_label *
85233+chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
85234+ const struct acl_subject_label *subj, char *path)
85235+{
85236+ return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
85237+}
85238+
85239+struct acl_subject_label *
85240+chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
85241+ const struct acl_role_label *role)
85242+{
85243+ struct dentry *dentry = (struct dentry *) l_dentry;
85244+ struct vfsmount *mnt = (struct vfsmount *) l_mnt;
85245+ struct mount *real_mnt = real_mount(mnt);
85246+ struct acl_subject_label *retval;
85247+ struct dentry *parent;
85248+
85249+ read_seqlock_excl(&mount_lock);
85250+ write_seqlock(&rename_lock);
85251+
85252+ for (;;) {
85253+ if (dentry == gr_real_root.dentry && mnt == gr_real_root.mnt)
85254+ break;
85255+ if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
85256+ if (!mnt_has_parent(real_mnt))
85257+ break;
85258+
85259+ spin_lock(&dentry->d_lock);
85260+ read_lock(&gr_inode_lock);
85261+ retval =
85262+ lookup_acl_subj_label(__get_ino(dentry),
85263+ __get_dev(dentry), role);
85264+ read_unlock(&gr_inode_lock);
85265+ spin_unlock(&dentry->d_lock);
85266+ if (retval != NULL)
85267+ goto out;
85268+
85269+ dentry = real_mnt->mnt_mountpoint;
85270+ real_mnt = real_mnt->mnt_parent;
85271+ mnt = &real_mnt->mnt;
85272+ continue;
85273+ }
85274+
85275+ spin_lock(&dentry->d_lock);
85276+ read_lock(&gr_inode_lock);
85277+ retval = lookup_acl_subj_label(__get_ino(dentry),
85278+ __get_dev(dentry), role);
85279+ read_unlock(&gr_inode_lock);
85280+ parent = dentry->d_parent;
85281+ spin_unlock(&dentry->d_lock);
85282+
85283+ if (retval != NULL)
85284+ goto out;
85285+
85286+ dentry = parent;
85287+ }
85288+
85289+ spin_lock(&dentry->d_lock);
85290+ read_lock(&gr_inode_lock);
85291+ retval = lookup_acl_subj_label(__get_ino(dentry),
85292+ __get_dev(dentry), role);
85293+ read_unlock(&gr_inode_lock);
85294+ spin_unlock(&dentry->d_lock);
85295+
85296+ if (unlikely(retval == NULL)) {
85297+ /* gr_real_root is pinned, we don't need to hold a reference */
85298+ read_lock(&gr_inode_lock);
85299+ retval = lookup_acl_subj_label(__get_ino(gr_real_root.dentry),
85300+ __get_dev(gr_real_root.dentry), role);
85301+ read_unlock(&gr_inode_lock);
85302+ }
85303+out:
85304+ write_sequnlock(&rename_lock);
85305+ read_sequnlock_excl(&mount_lock);
85306+
85307+ BUG_ON(retval == NULL);
85308+
85309+ return retval;
85310+}
85311+
85312+void
85313+assign_special_role(const char *rolename)
85314+{
85315+ struct acl_object_label *obj;
85316+ struct acl_role_label *r;
85317+ struct acl_role_label *assigned = NULL;
85318+ struct task_struct *tsk;
85319+ struct file *filp;
85320+
85321+ FOR_EACH_ROLE_START(r)
85322+ if (!strcmp(rolename, r->rolename) &&
85323+ (r->roletype & GR_ROLE_SPECIAL)) {
85324+ assigned = r;
85325+ break;
85326+ }
85327+ FOR_EACH_ROLE_END(r)
85328+
85329+ if (!assigned)
85330+ return;
85331+
85332+ read_lock(&tasklist_lock);
85333+ read_lock(&grsec_exec_file_lock);
85334+
85335+ tsk = current->real_parent;
85336+ if (tsk == NULL)
85337+ goto out_unlock;
85338+
85339+ filp = tsk->exec_file;
85340+ if (filp == NULL)
85341+ goto out_unlock;
85342+
85343+ tsk->is_writable = 0;
85344+ tsk->inherited = 0;
85345+
85346+ tsk->acl_sp_role = 1;
85347+ tsk->acl_role_id = ++acl_sp_role_value;
85348+ tsk->role = assigned;
85349+ tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
85350+
85351+ /* ignore additional mmap checks for processes that are writable
85352+ by the default ACL */
85353+ obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, running_polstate.default_role->root_label);
85354+ if (unlikely(obj->mode & GR_WRITE))
85355+ tsk->is_writable = 1;
85356+ obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
85357+ if (unlikely(obj->mode & GR_WRITE))
85358+ tsk->is_writable = 1;
85359+
85360+#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
85361+ printk(KERN_ALERT "Assigning special role:%s subject:%s to process (%s:%d)\n", tsk->role->rolename,
85362+ tsk->acl->filename, tsk->comm, task_pid_nr(tsk));
85363+#endif
85364+
85365+out_unlock:
85366+ read_unlock(&grsec_exec_file_lock);
85367+ read_unlock(&tasklist_lock);
85368+ return;
85369+}
85370+
85371+
85372+static void
85373+gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
85374+{
85375+ struct task_struct *task = current;
85376+ const struct cred *cred = current_cred();
85377+
85378+ security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
85379+ GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
85380+ task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
85381+ 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
85382+
85383+ return;
85384+}
85385+
85386+static void
85387+gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
85388+{
85389+ struct task_struct *task = current;
85390+ const struct cred *cred = current_cred();
85391+
85392+ security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
85393+ GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
85394+ task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
85395+ 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
85396+
85397+ return;
85398+}
85399+
85400+static void
85401+gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
85402+{
85403+ struct task_struct *task = current;
85404+ const struct cred *cred = current_cred();
85405+
85406+ security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
85407+ GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
85408+ task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
85409+ 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
85410+
85411+ return;
85412+}
85413+
85414+static void
85415+gr_set_proc_res(struct task_struct *task)
85416+{
85417+ struct acl_subject_label *proc;
85418+ unsigned short i;
85419+
85420+ proc = task->acl;
85421+
85422+ if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
85423+ return;
85424+
85425+ for (i = 0; i < RLIM_NLIMITS; i++) {
85426+ unsigned long rlim_cur, rlim_max;
85427+
85428+ if (!(proc->resmask & (1U << i)))
85429+ continue;
85430+
85431+ rlim_cur = proc->res[i].rlim_cur;
85432+ rlim_max = proc->res[i].rlim_max;
85433+
85434+ if (i == RLIMIT_NOFILE) {
85435+ unsigned long saved_sysctl_nr_open = sysctl_nr_open;
85436+ if (rlim_cur > saved_sysctl_nr_open)
85437+ rlim_cur = saved_sysctl_nr_open;
85438+ if (rlim_max > saved_sysctl_nr_open)
85439+ rlim_max = saved_sysctl_nr_open;
85440+ }
85441+
85442+ task->signal->rlim[i].rlim_cur = rlim_cur;
85443+ task->signal->rlim[i].rlim_max = rlim_max;
85444+
85445+ if (i == RLIMIT_CPU)
85446+ update_rlimit_cpu(task, rlim_cur);
85447+ }
85448+
85449+ return;
85450+}
85451+
85452+/* both of the below must be called with
85453+ rcu_read_lock();
85454+ read_lock(&tasklist_lock);
85455+ read_lock(&grsec_exec_file_lock);
85456+ except in the case of gr_set_role_label() (for __gr_get_subject_for_task)
85457+*/
85458+
85459+struct acl_subject_label *__gr_get_subject_for_task(const struct gr_policy_state *state, struct task_struct *task, const char *filename, int fallback)
85460+{
85461+ char *tmpname;
85462+ struct acl_subject_label *tmpsubj;
85463+ struct file *filp;
85464+ struct name_entry *nmatch;
85465+
85466+ filp = task->exec_file;
85467+ if (filp == NULL)
85468+ return NULL;
85469+
85470+ /* the following is to apply the correct subject
85471+ on binaries running when the RBAC system
85472+ is enabled, when the binaries have been
85473+ replaced or deleted since their execution
85474+ -----
85475+ when the RBAC system starts, the inode/dev
85476+ from exec_file will be one the RBAC system
85477+ is unaware of. It only knows the inode/dev
85478+ of the present file on disk, or the absence
85479+ of it.
85480+ */
85481+
85482+ if (filename)
85483+ nmatch = __lookup_name_entry(state, filename);
85484+ else {
85485+ preempt_disable();
85486+ tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
85487+
85488+ nmatch = __lookup_name_entry(state, tmpname);
85489+ preempt_enable();
85490+ }
85491+ tmpsubj = NULL;
85492+ if (nmatch) {
85493+ if (nmatch->deleted)
85494+ tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
85495+ else
85496+ tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
85497+ }
85498+ /* this also works for the reload case -- if we don't match a potentially inherited subject
85499+ then we fall back to a normal lookup based on the binary's ino/dev
85500+ */
85501+ if (tmpsubj == NULL && fallback)
85502+ tmpsubj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, task->role);
85503+
85504+ return tmpsubj;
85505+}
85506+
85507+static struct acl_subject_label *gr_get_subject_for_task(struct task_struct *task, const char *filename, int fallback)
85508+{
85509+ return __gr_get_subject_for_task(&running_polstate, task, filename, fallback);
85510+}
85511+
85512+void __gr_apply_subject_to_task(const struct gr_policy_state *state, struct task_struct *task, struct acl_subject_label *subj)
85513+{
85514+ struct acl_object_label *obj;
85515+ struct file *filp;
85516+
85517+ filp = task->exec_file;
85518+
85519+ task->acl = subj;
85520+ task->is_writable = 0;
85521+ /* ignore additional mmap checks for processes that are writable
85522+ by the default ACL */
85523+ obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, state->default_role->root_label);
85524+ if (unlikely(obj->mode & GR_WRITE))
85525+ task->is_writable = 1;
85526+ obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
85527+ if (unlikely(obj->mode & GR_WRITE))
85528+ task->is_writable = 1;
85529+
85530+ gr_set_proc_res(task);
85531+
85532+#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
85533+ 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);
85534+#endif
85535+}
85536+
85537+static void gr_apply_subject_to_task(struct task_struct *task, struct acl_subject_label *subj)
85538+{
85539+ __gr_apply_subject_to_task(&running_polstate, task, subj);
85540+}
85541+
85542+__u32
85543+gr_search_file(const struct dentry * dentry, const __u32 mode,
85544+ const struct vfsmount * mnt)
85545+{
85546+ __u32 retval = mode;
85547+ struct acl_subject_label *curracl;
85548+ struct acl_object_label *currobj;
85549+
85550+ if (unlikely(!(gr_status & GR_READY)))
85551+ return (mode & ~GR_AUDITS);
85552+
85553+ curracl = current->acl;
85554+
85555+ currobj = chk_obj_label(dentry, mnt, curracl);
85556+ retval = currobj->mode & mode;
85557+
85558+ /* if we're opening a specified transfer file for writing
85559+ (e.g. /dev/initctl), then transfer our role to init
85560+ */
85561+ if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
85562+ current->role->roletype & GR_ROLE_PERSIST)) {
85563+ struct task_struct *task = init_pid_ns.child_reaper;
85564+
85565+ if (task->role != current->role) {
85566+ struct acl_subject_label *subj;
85567+
85568+ task->acl_sp_role = 0;
85569+ task->acl_role_id = current->acl_role_id;
85570+ task->role = current->role;
85571+ rcu_read_lock();
85572+ read_lock(&grsec_exec_file_lock);
85573+ subj = gr_get_subject_for_task(task, NULL, 1);
85574+ gr_apply_subject_to_task(task, subj);
85575+ read_unlock(&grsec_exec_file_lock);
85576+ rcu_read_unlock();
85577+ gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
85578+ }
85579+ }
85580+
85581+ if (unlikely
85582+ ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
85583+ && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
85584+ __u32 new_mode = mode;
85585+
85586+ new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
85587+
85588+ retval = new_mode;
85589+
85590+ if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
85591+ new_mode |= GR_INHERIT;
85592+
85593+ if (!(mode & GR_NOLEARN))
85594+ gr_log_learn(dentry, mnt, new_mode);
85595+ }
85596+
85597+ return retval;
85598+}
85599+
85600+struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
85601+ const struct dentry *parent,
85602+ const struct vfsmount *mnt)
85603+{
85604+ struct name_entry *match;
85605+ struct acl_object_label *matchpo;
85606+ struct acl_subject_label *curracl;
85607+ char *path;
85608+
85609+ if (unlikely(!(gr_status & GR_READY)))
85610+ return NULL;
85611+
85612+ preempt_disable();
85613+ path = gr_to_filename_rbac(new_dentry, mnt);
85614+ match = lookup_name_entry_create(path);
85615+
85616+ curracl = current->acl;
85617+
85618+ if (match) {
85619+ read_lock(&gr_inode_lock);
85620+ matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
85621+ read_unlock(&gr_inode_lock);
85622+
85623+ if (matchpo) {
85624+ preempt_enable();
85625+ return matchpo;
85626+ }
85627+ }
85628+
85629+ // lookup parent
85630+
85631+ matchpo = chk_obj_create_label(parent, mnt, curracl, path);
85632+
85633+ preempt_enable();
85634+ return matchpo;
85635+}
85636+
85637+__u32
85638+gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
85639+ const struct vfsmount * mnt, const __u32 mode)
85640+{
85641+ struct acl_object_label *matchpo;
85642+ __u32 retval;
85643+
85644+ if (unlikely(!(gr_status & GR_READY)))
85645+ return (mode & ~GR_AUDITS);
85646+
85647+ matchpo = gr_get_create_object(new_dentry, parent, mnt);
85648+
85649+ retval = matchpo->mode & mode;
85650+
85651+ if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
85652+ && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
85653+ __u32 new_mode = mode;
85654+
85655+ new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
85656+
85657+ gr_log_learn(new_dentry, mnt, new_mode);
85658+ return new_mode;
85659+ }
85660+
85661+ return retval;
85662+}
85663+
85664+__u32
85665+gr_check_link(const struct dentry * new_dentry,
85666+ const struct dentry * parent_dentry,
85667+ const struct vfsmount * parent_mnt,
85668+ const struct dentry * old_dentry, const struct vfsmount * old_mnt)
85669+{
85670+ struct acl_object_label *obj;
85671+ __u32 oldmode, newmode;
85672+ __u32 needmode;
85673+ __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
85674+ GR_DELETE | GR_INHERIT;
85675+
85676+ if (unlikely(!(gr_status & GR_READY)))
85677+ return (GR_CREATE | GR_LINK);
85678+
85679+ obj = chk_obj_label(old_dentry, old_mnt, current->acl);
85680+ oldmode = obj->mode;
85681+
85682+ obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
85683+ newmode = obj->mode;
85684+
85685+ needmode = newmode & checkmodes;
85686+
85687+ // old name for hardlink must have at least the permissions of the new name
85688+ if ((oldmode & needmode) != needmode)
85689+ goto bad;
85690+
85691+ // if old name had restrictions/auditing, make sure the new name does as well
85692+ needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
85693+
85694+ // don't allow hardlinking of suid/sgid/fcapped files without permission
85695+ if (is_privileged_binary(old_dentry))
85696+ needmode |= GR_SETID;
85697+
85698+ if ((newmode & needmode) != needmode)
85699+ goto bad;
85700+
85701+ // enforce minimum permissions
85702+ if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
85703+ return newmode;
85704+bad:
85705+ needmode = oldmode;
85706+ if (is_privileged_binary(old_dentry))
85707+ needmode |= GR_SETID;
85708+
85709+ if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
85710+ gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
85711+ return (GR_CREATE | GR_LINK);
85712+ } else if (newmode & GR_SUPPRESS)
85713+ return GR_SUPPRESS;
85714+ else
85715+ return 0;
85716+}
85717+
85718+int
85719+gr_check_hidden_task(const struct task_struct *task)
85720+{
85721+ if (unlikely(!(gr_status & GR_READY)))
85722+ return 0;
85723+
85724+ if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
85725+ return 1;
85726+
85727+ return 0;
85728+}
85729+
85730+int
85731+gr_check_protected_task(const struct task_struct *task)
85732+{
85733+ if (unlikely(!(gr_status & GR_READY) || !task))
85734+ return 0;
85735+
85736+ if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
85737+ task->acl != current->acl)
85738+ return 1;
85739+
85740+ return 0;
85741+}
85742+
85743+int
85744+gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
85745+{
85746+ struct task_struct *p;
85747+ int ret = 0;
85748+
85749+ if (unlikely(!(gr_status & GR_READY) || !pid))
85750+ return ret;
85751+
85752+ read_lock(&tasklist_lock);
85753+ do_each_pid_task(pid, type, p) {
85754+ if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
85755+ p->acl != current->acl) {
85756+ ret = 1;
85757+ goto out;
85758+ }
85759+ } while_each_pid_task(pid, type, p);
85760+out:
85761+ read_unlock(&tasklist_lock);
85762+
85763+ return ret;
85764+}
85765+
85766+void
85767+gr_copy_label(struct task_struct *tsk)
85768+{
85769+ struct task_struct *p = current;
85770+
85771+ tsk->inherited = p->inherited;
85772+ tsk->acl_sp_role = 0;
85773+ tsk->acl_role_id = p->acl_role_id;
85774+ tsk->acl = p->acl;
85775+ tsk->role = p->role;
85776+ tsk->signal->used_accept = 0;
85777+ tsk->signal->curr_ip = p->signal->curr_ip;
85778+ tsk->signal->saved_ip = p->signal->saved_ip;
85779+ if (p->exec_file)
85780+ get_file(p->exec_file);
85781+ tsk->exec_file = p->exec_file;
85782+ tsk->is_writable = p->is_writable;
85783+ if (unlikely(p->signal->used_accept)) {
85784+ p->signal->curr_ip = 0;
85785+ p->signal->saved_ip = 0;
85786+ }
85787+
85788+ return;
85789+}
85790+
85791+extern int gr_process_kernel_setuid_ban(struct user_struct *user);
85792+
85793+int
85794+gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
85795+{
85796+ unsigned int i;
85797+ __u16 num;
85798+ uid_t *uidlist;
85799+ uid_t curuid;
85800+ int realok = 0;
85801+ int effectiveok = 0;
85802+ int fsok = 0;
85803+ uid_t globalreal, globaleffective, globalfs;
85804+
85805+#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT)
85806+ struct user_struct *user;
85807+
85808+ if (!uid_valid(real))
85809+ goto skipit;
85810+
85811+ /* find user based on global namespace */
85812+
85813+ globalreal = GR_GLOBAL_UID(real);
85814+
85815+ user = find_user(make_kuid(&init_user_ns, globalreal));
85816+ if (user == NULL)
85817+ goto skipit;
85818+
85819+ if (gr_process_kernel_setuid_ban(user)) {
85820+ /* for find_user */
85821+ free_uid(user);
85822+ return 1;
85823+ }
85824+
85825+ /* for find_user */
85826+ free_uid(user);
85827+
85828+skipit:
85829+#endif
85830+
85831+ if (unlikely(!(gr_status & GR_READY)))
85832+ return 0;
85833+
85834+ if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
85835+ gr_log_learn_uid_change(real, effective, fs);
85836+
85837+ num = current->acl->user_trans_num;
85838+ uidlist = current->acl->user_transitions;
85839+
85840+ if (uidlist == NULL)
85841+ return 0;
85842+
85843+ if (!uid_valid(real)) {
85844+ realok = 1;
85845+ globalreal = (uid_t)-1;
85846+ } else {
85847+ globalreal = GR_GLOBAL_UID(real);
85848+ }
85849+ if (!uid_valid(effective)) {
85850+ effectiveok = 1;
85851+ globaleffective = (uid_t)-1;
85852+ } else {
85853+ globaleffective = GR_GLOBAL_UID(effective);
85854+ }
85855+ if (!uid_valid(fs)) {
85856+ fsok = 1;
85857+ globalfs = (uid_t)-1;
85858+ } else {
85859+ globalfs = GR_GLOBAL_UID(fs);
85860+ }
85861+
85862+ if (current->acl->user_trans_type & GR_ID_ALLOW) {
85863+ for (i = 0; i < num; i++) {
85864+ curuid = uidlist[i];
85865+ if (globalreal == curuid)
85866+ realok = 1;
85867+ if (globaleffective == curuid)
85868+ effectiveok = 1;
85869+ if (globalfs == curuid)
85870+ fsok = 1;
85871+ }
85872+ } else if (current->acl->user_trans_type & GR_ID_DENY) {
85873+ for (i = 0; i < num; i++) {
85874+ curuid = uidlist[i];
85875+ if (globalreal == curuid)
85876+ break;
85877+ if (globaleffective == curuid)
85878+ break;
85879+ if (globalfs == curuid)
85880+ break;
85881+ }
85882+ /* not in deny list */
85883+ if (i == num) {
85884+ realok = 1;
85885+ effectiveok = 1;
85886+ fsok = 1;
85887+ }
85888+ }
85889+
85890+ if (realok && effectiveok && fsok)
85891+ return 0;
85892+ else {
85893+ gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
85894+ return 1;
85895+ }
85896+}
85897+
85898+int
85899+gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
85900+{
85901+ unsigned int i;
85902+ __u16 num;
85903+ gid_t *gidlist;
85904+ gid_t curgid;
85905+ int realok = 0;
85906+ int effectiveok = 0;
85907+ int fsok = 0;
85908+ gid_t globalreal, globaleffective, globalfs;
85909+
85910+ if (unlikely(!(gr_status & GR_READY)))
85911+ return 0;
85912+
85913+ if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
85914+ gr_log_learn_gid_change(real, effective, fs);
85915+
85916+ num = current->acl->group_trans_num;
85917+ gidlist = current->acl->group_transitions;
85918+
85919+ if (gidlist == NULL)
85920+ return 0;
85921+
85922+ if (!gid_valid(real)) {
85923+ realok = 1;
85924+ globalreal = (gid_t)-1;
85925+ } else {
85926+ globalreal = GR_GLOBAL_GID(real);
85927+ }
85928+ if (!gid_valid(effective)) {
85929+ effectiveok = 1;
85930+ globaleffective = (gid_t)-1;
85931+ } else {
85932+ globaleffective = GR_GLOBAL_GID(effective);
85933+ }
85934+ if (!gid_valid(fs)) {
85935+ fsok = 1;
85936+ globalfs = (gid_t)-1;
85937+ } else {
85938+ globalfs = GR_GLOBAL_GID(fs);
85939+ }
85940+
85941+ if (current->acl->group_trans_type & GR_ID_ALLOW) {
85942+ for (i = 0; i < num; i++) {
85943+ curgid = gidlist[i];
85944+ if (globalreal == curgid)
85945+ realok = 1;
85946+ if (globaleffective == curgid)
85947+ effectiveok = 1;
85948+ if (globalfs == curgid)
85949+ fsok = 1;
85950+ }
85951+ } else if (current->acl->group_trans_type & GR_ID_DENY) {
85952+ for (i = 0; i < num; i++) {
85953+ curgid = gidlist[i];
85954+ if (globalreal == curgid)
85955+ break;
85956+ if (globaleffective == curgid)
85957+ break;
85958+ if (globalfs == curgid)
85959+ break;
85960+ }
85961+ /* not in deny list */
85962+ if (i == num) {
85963+ realok = 1;
85964+ effectiveok = 1;
85965+ fsok = 1;
85966+ }
85967+ }
85968+
85969+ if (realok && effectiveok && fsok)
85970+ return 0;
85971+ else {
85972+ gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
85973+ return 1;
85974+ }
85975+}
85976+
85977+extern int gr_acl_is_capable(const int cap);
85978+
85979+void
85980+gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
85981+{
85982+ struct acl_role_label *role = task->role;
85983+ struct acl_role_label *origrole = role;
85984+ struct acl_subject_label *subj = NULL;
85985+ struct acl_object_label *obj;
85986+ struct file *filp;
85987+ uid_t uid;
85988+ gid_t gid;
85989+
85990+ if (unlikely(!(gr_status & GR_READY)))
85991+ return;
85992+
85993+ uid = GR_GLOBAL_UID(kuid);
85994+ gid = GR_GLOBAL_GID(kgid);
85995+
85996+ filp = task->exec_file;
85997+
85998+ /* kernel process, we'll give them the kernel role */
85999+ if (unlikely(!filp)) {
86000+ task->role = running_polstate.kernel_role;
86001+ task->acl = running_polstate.kernel_role->root_label;
86002+ return;
86003+ } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL)) {
86004+ /* save the current ip at time of role lookup so that the proper
86005+ IP will be learned for role_allowed_ip */
86006+ task->signal->saved_ip = task->signal->curr_ip;
86007+ role = lookup_acl_role_label(task, uid, gid);
86008+ }
86009+
86010+ /* don't change the role if we're not a privileged process */
86011+ if (role && task->role != role &&
86012+ (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
86013+ ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
86014+ return;
86015+
86016+ task->role = role;
86017+
86018+ if (task->inherited) {
86019+ /* if we reached our subject through inheritance, then first see
86020+ if there's a subject of the same name in the new role that has
86021+ an object that would result in the same inherited subject
86022+ */
86023+ subj = gr_get_subject_for_task(task, task->acl->filename, 0);
86024+ if (subj) {
86025+ obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, subj);
86026+ if (!(obj->mode & GR_INHERIT))
86027+ subj = NULL;
86028+ }
86029+
86030+ }
86031+ if (subj == NULL) {
86032+ /* otherwise:
86033+ perform subject lookup in possibly new role
86034+ we can use this result below in the case where role == task->role
86035+ */
86036+ subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
86037+ }
86038+
86039+ /* if we changed uid/gid, but result in the same role
86040+ and are using inheritance, don't lose the inherited subject
86041+ if current subject is other than what normal lookup
86042+ would result in, we arrived via inheritance, don't
86043+ lose subject
86044+ */
86045+ if (role != origrole || (!(task->acl->mode & GR_INHERITLEARN) &&
86046+ (subj == task->acl)))
86047+ task->acl = subj;
86048+
86049+ /* leave task->inherited unaffected */
86050+
86051+ task->is_writable = 0;
86052+
86053+ /* ignore additional mmap checks for processes that are writable
86054+ by the default ACL */
86055+ obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, running_polstate.default_role->root_label);
86056+ if (unlikely(obj->mode & GR_WRITE))
86057+ task->is_writable = 1;
86058+ obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
86059+ if (unlikely(obj->mode & GR_WRITE))
86060+ task->is_writable = 1;
86061+
86062+#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
86063+ 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);
86064+#endif
86065+
86066+ gr_set_proc_res(task);
86067+
86068+ return;
86069+}
86070+
86071+int
86072+gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
86073+ const int unsafe_flags)
86074+{
86075+ struct task_struct *task = current;
86076+ struct acl_subject_label *newacl;
86077+ struct acl_object_label *obj;
86078+ __u32 retmode;
86079+
86080+ if (unlikely(!(gr_status & GR_READY)))
86081+ return 0;
86082+
86083+ newacl = chk_subj_label(dentry, mnt, task->role);
86084+
86085+ /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
86086+ did an exec
86087+ */
86088+ rcu_read_lock();
86089+ read_lock(&tasklist_lock);
86090+ if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
86091+ (task->parent->acl->mode & GR_POVERRIDE))) {
86092+ read_unlock(&tasklist_lock);
86093+ rcu_read_unlock();
86094+ goto skip_check;
86095+ }
86096+ read_unlock(&tasklist_lock);
86097+ rcu_read_unlock();
86098+
86099+ if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
86100+ !(task->role->roletype & GR_ROLE_GOD) &&
86101+ !gr_search_file(dentry, GR_PTRACERD, mnt) &&
86102+ !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
86103+ if (unsafe_flags & LSM_UNSAFE_SHARE)
86104+ gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
86105+ else
86106+ gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
86107+ return -EACCES;
86108+ }
86109+
86110+skip_check:
86111+
86112+ obj = chk_obj_label(dentry, mnt, task->acl);
86113+ retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
86114+
86115+ if (!(task->acl->mode & GR_INHERITLEARN) &&
86116+ ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
86117+ if (obj->nested)
86118+ task->acl = obj->nested;
86119+ else
86120+ task->acl = newacl;
86121+ task->inherited = 0;
86122+ } else {
86123+ task->inherited = 1;
86124+ if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
86125+ gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
86126+ }
86127+
86128+ task->is_writable = 0;
86129+
86130+ /* ignore additional mmap checks for processes that are writable
86131+ by the default ACL */
86132+ obj = chk_obj_label(dentry, mnt, running_polstate.default_role->root_label);
86133+ if (unlikely(obj->mode & GR_WRITE))
86134+ task->is_writable = 1;
86135+ obj = chk_obj_label(dentry, mnt, task->role->root_label);
86136+ if (unlikely(obj->mode & GR_WRITE))
86137+ task->is_writable = 1;
86138+
86139+ gr_set_proc_res(task);
86140+
86141+#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
86142+ 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);
86143+#endif
86144+ return 0;
86145+}
86146+
86147+/* always called with valid inodev ptr */
86148+static void
86149+do_handle_delete(struct inodev_entry *inodev, const u64 ino, const dev_t dev)
86150+{
86151+ struct acl_object_label *matchpo;
86152+ struct acl_subject_label *matchps;
86153+ struct acl_subject_label *subj;
86154+ struct acl_role_label *role;
86155+ unsigned int x;
86156+
86157+ FOR_EACH_ROLE_START(role)
86158+ FOR_EACH_SUBJECT_START(role, subj, x)
86159+ if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
86160+ matchpo->mode |= GR_DELETED;
86161+ FOR_EACH_SUBJECT_END(subj,x)
86162+ FOR_EACH_NESTED_SUBJECT_START(role, subj)
86163+ /* nested subjects aren't in the role's subj_hash table */
86164+ if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
86165+ matchpo->mode |= GR_DELETED;
86166+ FOR_EACH_NESTED_SUBJECT_END(subj)
86167+ if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
86168+ matchps->mode |= GR_DELETED;
86169+ FOR_EACH_ROLE_END(role)
86170+
86171+ inodev->nentry->deleted = 1;
86172+
86173+ return;
86174+}
86175+
86176+void
86177+gr_handle_delete(const u64 ino, const dev_t dev)
86178+{
86179+ struct inodev_entry *inodev;
86180+
86181+ if (unlikely(!(gr_status & GR_READY)))
86182+ return;
86183+
86184+ write_lock(&gr_inode_lock);
86185+ inodev = lookup_inodev_entry(ino, dev);
86186+ if (inodev != NULL)
86187+ do_handle_delete(inodev, ino, dev);
86188+ write_unlock(&gr_inode_lock);
86189+
86190+ return;
86191+}
86192+
86193+static void
86194+update_acl_obj_label(const u64 oldinode, const dev_t olddevice,
86195+ const u64 newinode, const dev_t newdevice,
86196+ struct acl_subject_label *subj)
86197+{
86198+ unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
86199+ struct acl_object_label *match;
86200+
86201+ match = subj->obj_hash[index];
86202+
86203+ while (match && (match->inode != oldinode ||
86204+ match->device != olddevice ||
86205+ !(match->mode & GR_DELETED)))
86206+ match = match->next;
86207+
86208+ if (match && (match->inode == oldinode)
86209+ && (match->device == olddevice)
86210+ && (match->mode & GR_DELETED)) {
86211+ if (match->prev == NULL) {
86212+ subj->obj_hash[index] = match->next;
86213+ if (match->next != NULL)
86214+ match->next->prev = NULL;
86215+ } else {
86216+ match->prev->next = match->next;
86217+ if (match->next != NULL)
86218+ match->next->prev = match->prev;
86219+ }
86220+ match->prev = NULL;
86221+ match->next = NULL;
86222+ match->inode = newinode;
86223+ match->device = newdevice;
86224+ match->mode &= ~GR_DELETED;
86225+
86226+ insert_acl_obj_label(match, subj);
86227+ }
86228+
86229+ return;
86230+}
86231+
86232+static void
86233+update_acl_subj_label(const u64 oldinode, const dev_t olddevice,
86234+ const u64 newinode, const dev_t newdevice,
86235+ struct acl_role_label *role)
86236+{
86237+ unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
86238+ struct acl_subject_label *match;
86239+
86240+ match = role->subj_hash[index];
86241+
86242+ while (match && (match->inode != oldinode ||
86243+ match->device != olddevice ||
86244+ !(match->mode & GR_DELETED)))
86245+ match = match->next;
86246+
86247+ if (match && (match->inode == oldinode)
86248+ && (match->device == olddevice)
86249+ && (match->mode & GR_DELETED)) {
86250+ if (match->prev == NULL) {
86251+ role->subj_hash[index] = match->next;
86252+ if (match->next != NULL)
86253+ match->next->prev = NULL;
86254+ } else {
86255+ match->prev->next = match->next;
86256+ if (match->next != NULL)
86257+ match->next->prev = match->prev;
86258+ }
86259+ match->prev = NULL;
86260+ match->next = NULL;
86261+ match->inode = newinode;
86262+ match->device = newdevice;
86263+ match->mode &= ~GR_DELETED;
86264+
86265+ insert_acl_subj_label(match, role);
86266+ }
86267+
86268+ return;
86269+}
86270+
86271+static void
86272+update_inodev_entry(const u64 oldinode, const dev_t olddevice,
86273+ const u64 newinode, const dev_t newdevice)
86274+{
86275+ unsigned int index = gr_fhash(oldinode, olddevice, running_polstate.inodev_set.i_size);
86276+ struct inodev_entry *match;
86277+
86278+ match = running_polstate.inodev_set.i_hash[index];
86279+
86280+ while (match && (match->nentry->inode != oldinode ||
86281+ match->nentry->device != olddevice || !match->nentry->deleted))
86282+ match = match->next;
86283+
86284+ if (match && (match->nentry->inode == oldinode)
86285+ && (match->nentry->device == olddevice) &&
86286+ match->nentry->deleted) {
86287+ if (match->prev == NULL) {
86288+ running_polstate.inodev_set.i_hash[index] = match->next;
86289+ if (match->next != NULL)
86290+ match->next->prev = NULL;
86291+ } else {
86292+ match->prev->next = match->next;
86293+ if (match->next != NULL)
86294+ match->next->prev = match->prev;
86295+ }
86296+ match->prev = NULL;
86297+ match->next = NULL;
86298+ match->nentry->inode = newinode;
86299+ match->nentry->device = newdevice;
86300+ match->nentry->deleted = 0;
86301+
86302+ insert_inodev_entry(match);
86303+ }
86304+
86305+ return;
86306+}
86307+
86308+static void
86309+__do_handle_create(const struct name_entry *matchn, u64 ino, dev_t dev)
86310+{
86311+ struct acl_subject_label *subj;
86312+ struct acl_role_label *role;
86313+ unsigned int x;
86314+
86315+ FOR_EACH_ROLE_START(role)
86316+ update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
86317+
86318+ FOR_EACH_NESTED_SUBJECT_START(role, subj)
86319+ if ((subj->inode == ino) && (subj->device == dev)) {
86320+ subj->inode = ino;
86321+ subj->device = dev;
86322+ }
86323+ /* nested subjects aren't in the role's subj_hash table */
86324+ update_acl_obj_label(matchn->inode, matchn->device,
86325+ ino, dev, subj);
86326+ FOR_EACH_NESTED_SUBJECT_END(subj)
86327+ FOR_EACH_SUBJECT_START(role, subj, x)
86328+ update_acl_obj_label(matchn->inode, matchn->device,
86329+ ino, dev, subj);
86330+ FOR_EACH_SUBJECT_END(subj,x)
86331+ FOR_EACH_ROLE_END(role)
86332+
86333+ update_inodev_entry(matchn->inode, matchn->device, ino, dev);
86334+
86335+ return;
86336+}
86337+
86338+static void
86339+do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
86340+ const struct vfsmount *mnt)
86341+{
86342+ u64 ino = __get_ino(dentry);
86343+ dev_t dev = __get_dev(dentry);
86344+
86345+ __do_handle_create(matchn, ino, dev);
86346+
86347+ return;
86348+}
86349+
86350+void
86351+gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
86352+{
86353+ struct name_entry *matchn;
86354+
86355+ if (unlikely(!(gr_status & GR_READY)))
86356+ return;
86357+
86358+ preempt_disable();
86359+ matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
86360+
86361+ if (unlikely((unsigned long)matchn)) {
86362+ write_lock(&gr_inode_lock);
86363+ do_handle_create(matchn, dentry, mnt);
86364+ write_unlock(&gr_inode_lock);
86365+ }
86366+ preempt_enable();
86367+
86368+ return;
86369+}
86370+
86371+void
86372+gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
86373+{
86374+ struct name_entry *matchn;
86375+
86376+ if (unlikely(!(gr_status & GR_READY)))
86377+ return;
86378+
86379+ preempt_disable();
86380+ matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
86381+
86382+ if (unlikely((unsigned long)matchn)) {
86383+ write_lock(&gr_inode_lock);
86384+ __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
86385+ write_unlock(&gr_inode_lock);
86386+ }
86387+ preempt_enable();
86388+
86389+ return;
86390+}
86391+
86392+void
86393+gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
86394+ struct dentry *old_dentry,
86395+ struct dentry *new_dentry,
86396+ struct vfsmount *mnt, const __u8 replace, unsigned int flags)
86397+{
86398+ struct name_entry *matchn;
86399+ struct name_entry *matchn2 = NULL;
86400+ struct inodev_entry *inodev;
86401+ struct inode *inode = d_backing_inode(new_dentry);
86402+ struct inode *old_inode = d_backing_inode(old_dentry);
86403+ u64 old_ino = __get_ino(old_dentry);
86404+ dev_t old_dev = __get_dev(old_dentry);
86405+ unsigned int exchange = flags & RENAME_EXCHANGE;
86406+
86407+ /* vfs_rename swaps the name and parent link for old_dentry and
86408+ new_dentry
86409+ at this point, old_dentry has the new name, parent link, and inode
86410+ for the renamed file
86411+ if a file is being replaced by a rename, new_dentry has the inode
86412+ and name for the replaced file
86413+ */
86414+
86415+ if (unlikely(!(gr_status & GR_READY)))
86416+ return;
86417+
86418+ preempt_disable();
86419+ matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
86420+
86421+ /* exchange cases:
86422+ a filename exists for the source, but not dest
86423+ do a recreate on source
86424+ a filename exists for the dest, but not source
86425+ do a recreate on dest
86426+ a filename exists for both source and dest
86427+ delete source and dest, then create source and dest
86428+ a filename exists for neither source nor dest
86429+ no updates needed
86430+
86431+ the name entry lookups get us the old inode/dev associated with
86432+ each name, so do the deletes first (if possible) so that when
86433+ we do the create, we pick up on the right entries
86434+ */
86435+
86436+ if (exchange)
86437+ matchn2 = lookup_name_entry(gr_to_filename_rbac(new_dentry, mnt));
86438+
86439+ /* we wouldn't have to check d_inode if it weren't for
86440+ NFS silly-renaming
86441+ */
86442+
86443+ write_lock(&gr_inode_lock);
86444+ if (unlikely((replace || exchange) && inode)) {
86445+ u64 new_ino = __get_ino(new_dentry);
86446+ dev_t new_dev = __get_dev(new_dentry);
86447+
86448+ inodev = lookup_inodev_entry(new_ino, new_dev);
86449+ if (inodev != NULL && ((inode->i_nlink <= 1) || d_is_dir(new_dentry)))
86450+ do_handle_delete(inodev, new_ino, new_dev);
86451+ }
86452+
86453+ inodev = lookup_inodev_entry(old_ino, old_dev);
86454+ if (inodev != NULL && ((old_inode->i_nlink <= 1) || d_is_dir(old_dentry)))
86455+ do_handle_delete(inodev, old_ino, old_dev);
86456+
86457+ if (unlikely(matchn != NULL))
86458+ do_handle_create(matchn, old_dentry, mnt);
86459+
86460+ if (unlikely(matchn2 != NULL))
86461+ do_handle_create(matchn2, new_dentry, mnt);
86462+
86463+ write_unlock(&gr_inode_lock);
86464+ preempt_enable();
86465+
86466+ return;
86467+}
86468+
86469+#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
86470+static const unsigned long res_learn_bumps[GR_NLIMITS] = {
86471+ [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
86472+ [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
86473+ [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
86474+ [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
86475+ [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
86476+ [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
86477+ [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
86478+ [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
86479+ [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
86480+ [RLIMIT_AS] = GR_RLIM_AS_BUMP,
86481+ [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
86482+ [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
86483+ [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
86484+ [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
86485+ [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
86486+ [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
86487+};
86488+
86489+void
86490+gr_learn_resource(const struct task_struct *task,
86491+ const int res, const unsigned long wanted, const int gt)
86492+{
86493+ struct acl_subject_label *acl;
86494+ const struct cred *cred;
86495+
86496+ if (unlikely((gr_status & GR_READY) &&
86497+ task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
86498+ goto skip_reslog;
86499+
86500+ gr_log_resource(task, res, wanted, gt);
86501+skip_reslog:
86502+
86503+ if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
86504+ return;
86505+
86506+ acl = task->acl;
86507+
86508+ if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
86509+ !(acl->resmask & (1U << (unsigned short) res))))
86510+ return;
86511+
86512+ if (wanted >= acl->res[res].rlim_cur) {
86513+ unsigned long res_add;
86514+
86515+ res_add = wanted + res_learn_bumps[res];
86516+
86517+ acl->res[res].rlim_cur = res_add;
86518+
86519+ if (wanted > acl->res[res].rlim_max)
86520+ acl->res[res].rlim_max = res_add;
86521+
86522+ /* only log the subject filename, since resource logging is supported for
86523+ single-subject learning only */
86524+ rcu_read_lock();
86525+ cred = __task_cred(task);
86526+ security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
86527+ task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
86528+ acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
86529+ "", (unsigned long) res, &task->signal->saved_ip);
86530+ rcu_read_unlock();
86531+ }
86532+
86533+ return;
86534+}
86535+EXPORT_SYMBOL_GPL(gr_learn_resource);
86536+#endif
86537+
86538+#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
86539+void
86540+pax_set_initial_flags(struct linux_binprm *bprm)
86541+{
86542+ struct task_struct *task = current;
86543+ struct acl_subject_label *proc;
86544+ unsigned long flags;
86545+
86546+ if (unlikely(!(gr_status & GR_READY)))
86547+ return;
86548+
86549+ flags = pax_get_flags(task);
86550+
86551+ proc = task->acl;
86552+
86553+ if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
86554+ flags &= ~MF_PAX_PAGEEXEC;
86555+ if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
86556+ flags &= ~MF_PAX_SEGMEXEC;
86557+ if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
86558+ flags &= ~MF_PAX_RANDMMAP;
86559+ if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
86560+ flags &= ~MF_PAX_EMUTRAMP;
86561+ if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
86562+ flags &= ~MF_PAX_MPROTECT;
86563+
86564+ if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
86565+ flags |= MF_PAX_PAGEEXEC;
86566+ if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
86567+ flags |= MF_PAX_SEGMEXEC;
86568+ if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
86569+ flags |= MF_PAX_RANDMMAP;
86570+ if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
86571+ flags |= MF_PAX_EMUTRAMP;
86572+ if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
86573+ flags |= MF_PAX_MPROTECT;
86574+
86575+ pax_set_flags(task, flags);
86576+
86577+ return;
86578+}
86579+#endif
86580+
86581+int
86582+gr_handle_proc_ptrace(struct task_struct *task)
86583+{
86584+ struct file *filp;
86585+ struct task_struct *tmp = task;
86586+ struct task_struct *curtemp = current;
86587+ __u32 retmode;
86588+
86589+#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
86590+ if (unlikely(!(gr_status & GR_READY)))
86591+ return 0;
86592+#endif
86593+
86594+ read_lock(&tasklist_lock);
86595+ read_lock(&grsec_exec_file_lock);
86596+ filp = task->exec_file;
86597+
86598+ while (task_pid_nr(tmp) > 0) {
86599+ if (tmp == curtemp)
86600+ break;
86601+ tmp = tmp->real_parent;
86602+ }
86603+
86604+ if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
86605+ ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
86606+ read_unlock(&grsec_exec_file_lock);
86607+ read_unlock(&tasklist_lock);
86608+ return 1;
86609+ }
86610+
86611+#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
86612+ if (!(gr_status & GR_READY)) {
86613+ read_unlock(&grsec_exec_file_lock);
86614+ read_unlock(&tasklist_lock);
86615+ return 0;
86616+ }
86617+#endif
86618+
86619+ retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
86620+ read_unlock(&grsec_exec_file_lock);
86621+ read_unlock(&tasklist_lock);
86622+
86623+ if (retmode & GR_NOPTRACE)
86624+ return 1;
86625+
86626+ if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
86627+ && (current->acl != task->acl || (current->acl != current->role->root_label
86628+ && task_pid_nr(current) != task_pid_nr(task))))
86629+ return 1;
86630+
86631+ return 0;
86632+}
86633+
86634+void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
86635+{
86636+ if (unlikely(!(gr_status & GR_READY)))
86637+ return;
86638+
86639+ if (!(current->role->roletype & GR_ROLE_GOD))
86640+ return;
86641+
86642+ seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
86643+ p->role->rolename, gr_task_roletype_to_char(p),
86644+ p->acl->filename);
86645+}
86646+
86647+int
86648+gr_handle_ptrace(struct task_struct *task, const long request)
86649+{
86650+ struct task_struct *tmp = task;
86651+ struct task_struct *curtemp = current;
86652+ __u32 retmode;
86653+
86654+#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
86655+ if (unlikely(!(gr_status & GR_READY)))
86656+ return 0;
86657+#endif
86658+ if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
86659+ read_lock(&tasklist_lock);
86660+ while (task_pid_nr(tmp) > 0) {
86661+ if (tmp == curtemp)
86662+ break;
86663+ tmp = tmp->real_parent;
86664+ }
86665+
86666+ if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
86667+ ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
86668+ read_unlock(&tasklist_lock);
86669+ gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
86670+ return 1;
86671+ }
86672+ read_unlock(&tasklist_lock);
86673+ }
86674+
86675+#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
86676+ if (!(gr_status & GR_READY))
86677+ return 0;
86678+#endif
86679+
86680+ read_lock(&grsec_exec_file_lock);
86681+ if (unlikely(!task->exec_file)) {
86682+ read_unlock(&grsec_exec_file_lock);
86683+ return 0;
86684+ }
86685+
86686+ retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
86687+ read_unlock(&grsec_exec_file_lock);
86688+
86689+ if (retmode & GR_NOPTRACE) {
86690+ gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
86691+ return 1;
86692+ }
86693+
86694+ if (retmode & GR_PTRACERD) {
86695+ switch (request) {
86696+ case PTRACE_SEIZE:
86697+ case PTRACE_POKETEXT:
86698+ case PTRACE_POKEDATA:
86699+ case PTRACE_POKEUSR:
86700+#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
86701+ case PTRACE_SETREGS:
86702+ case PTRACE_SETFPREGS:
86703+#endif
86704+#ifdef CONFIG_X86
86705+ case PTRACE_SETFPXREGS:
86706+#endif
86707+#ifdef CONFIG_ALTIVEC
86708+ case PTRACE_SETVRREGS:
86709+#endif
86710+ return 1;
86711+ default:
86712+ return 0;
86713+ }
86714+ } else if (!(current->acl->mode & GR_POVERRIDE) &&
86715+ !(current->role->roletype & GR_ROLE_GOD) &&
86716+ (current->acl != task->acl)) {
86717+ gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
86718+ return 1;
86719+ }
86720+
86721+ return 0;
86722+}
86723+
86724+static int is_writable_mmap(const struct file *filp)
86725+{
86726+ struct task_struct *task = current;
86727+ struct acl_object_label *obj, *obj2;
86728+ struct dentry *dentry = filp->f_path.dentry;
86729+ struct vfsmount *mnt = filp->f_path.mnt;
86730+ struct inode *inode = d_backing_inode(dentry);
86731+
86732+ if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
86733+ !task->is_writable && d_is_reg(dentry) && (mnt != shm_mnt || (inode->i_nlink > 0))) {
86734+ obj = chk_obj_label(dentry, mnt, running_polstate.default_role->root_label);
86735+ obj2 = chk_obj_label(dentry, mnt, task->role->root_label);
86736+ if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
86737+ gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, dentry, mnt);
86738+ return 1;
86739+ }
86740+ }
86741+ return 0;
86742+}
86743+
86744+int
86745+gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
86746+{
86747+ __u32 mode;
86748+
86749+ if (unlikely(!file || !(prot & PROT_EXEC)))
86750+ return 1;
86751+
86752+ if (is_writable_mmap(file))
86753+ return 0;
86754+
86755+ mode =
86756+ gr_search_file(file->f_path.dentry,
86757+ GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
86758+ file->f_path.mnt);
86759+
86760+ if (!gr_tpe_allow(file))
86761+ return 0;
86762+
86763+ if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
86764+ gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
86765+ return 0;
86766+ } else if (unlikely(!(mode & GR_EXEC))) {
86767+ return 0;
86768+ } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
86769+ gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
86770+ return 1;
86771+ }
86772+
86773+ return 1;
86774+}
86775+
86776+int
86777+gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
86778+{
86779+ __u32 mode;
86780+
86781+ if (unlikely(!file || !(prot & PROT_EXEC)))
86782+ return 1;
86783+
86784+ if (is_writable_mmap(file))
86785+ return 0;
86786+
86787+ mode =
86788+ gr_search_file(file->f_path.dentry,
86789+ GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
86790+ file->f_path.mnt);
86791+
86792+ if (!gr_tpe_allow(file))
86793+ return 0;
86794+
86795+ if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
86796+ gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
86797+ return 0;
86798+ } else if (unlikely(!(mode & GR_EXEC))) {
86799+ return 0;
86800+ } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
86801+ gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
86802+ return 1;
86803+ }
86804+
86805+ return 1;
86806+}
86807+
86808+void
86809+gr_acl_handle_psacct(struct task_struct *task, const long code)
86810+{
86811+ unsigned long runtime, cputime;
86812+ cputime_t utime, stime;
86813+ unsigned int wday, cday;
86814+ __u8 whr, chr;
86815+ __u8 wmin, cmin;
86816+ __u8 wsec, csec;
86817+ struct timespec curtime, starttime;
86818+
86819+ if (unlikely(!(gr_status & GR_READY) || !task->acl ||
86820+ !(task->acl->mode & GR_PROCACCT)))
86821+ return;
86822+
86823+ curtime = ns_to_timespec(ktime_get_ns());
86824+ starttime = ns_to_timespec(task->start_time);
86825+ runtime = curtime.tv_sec - starttime.tv_sec;
86826+ wday = runtime / (60 * 60 * 24);
86827+ runtime -= wday * (60 * 60 * 24);
86828+ whr = runtime / (60 * 60);
86829+ runtime -= whr * (60 * 60);
86830+ wmin = runtime / 60;
86831+ runtime -= wmin * 60;
86832+ wsec = runtime;
86833+
86834+ task_cputime(task, &utime, &stime);
86835+ cputime = cputime_to_secs(utime + stime);
86836+ cday = cputime / (60 * 60 * 24);
86837+ cputime -= cday * (60 * 60 * 24);
86838+ chr = cputime / (60 * 60);
86839+ cputime -= chr * (60 * 60);
86840+ cmin = cputime / 60;
86841+ cputime -= cmin * 60;
86842+ csec = cputime;
86843+
86844+ gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
86845+
86846+ return;
86847+}
86848+
86849+#ifdef CONFIG_TASKSTATS
86850+int gr_is_taskstats_denied(int pid)
86851+{
86852+ struct task_struct *task;
86853+#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
86854+ const struct cred *cred;
86855+#endif
86856+ int ret = 0;
86857+
86858+ /* restrict taskstats viewing to un-chrooted root users
86859+ who have the 'view' subject flag if the RBAC system is enabled
86860+ */
86861+
86862+ rcu_read_lock();
86863+ read_lock(&tasklist_lock);
86864+ task = find_task_by_vpid(pid);
86865+ if (task) {
86866+#ifdef CONFIG_GRKERNSEC_CHROOT
86867+ if (proc_is_chrooted(task))
86868+ ret = -EACCES;
86869+#endif
86870+#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
86871+ cred = __task_cred(task);
86872+#ifdef CONFIG_GRKERNSEC_PROC_USER
86873+ if (gr_is_global_nonroot(cred->uid))
86874+ ret = -EACCES;
86875+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
86876+ if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
86877+ ret = -EACCES;
86878+#endif
86879+#endif
86880+ if (gr_status & GR_READY) {
86881+ if (!(task->acl->mode & GR_VIEW))
86882+ ret = -EACCES;
86883+ }
86884+ } else
86885+ ret = -ENOENT;
86886+
86887+ read_unlock(&tasklist_lock);
86888+ rcu_read_unlock();
86889+
86890+ return ret;
86891+}
86892+#endif
86893+
86894+/* AUXV entries are filled via a descendant of search_binary_handler
86895+ after we've already applied the subject for the target
86896+*/
86897+int gr_acl_enable_at_secure(void)
86898+{
86899+ if (unlikely(!(gr_status & GR_READY)))
86900+ return 0;
86901+
86902+ if (current->acl->mode & GR_ATSECURE)
86903+ return 1;
86904+
86905+ return 0;
86906+}
86907+
86908+int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const u64 ino)
86909+{
86910+ struct task_struct *task = current;
86911+ struct dentry *dentry = file->f_path.dentry;
86912+ struct vfsmount *mnt = file->f_path.mnt;
86913+ struct acl_object_label *obj, *tmp;
86914+ struct acl_subject_label *subj;
86915+ unsigned int bufsize;
86916+ int is_not_root;
86917+ char *path;
86918+ dev_t dev = __get_dev(dentry);
86919+
86920+ if (unlikely(!(gr_status & GR_READY)))
86921+ return 1;
86922+
86923+ if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
86924+ return 1;
86925+
86926+ /* ignore Eric Biederman */
86927+ if (IS_PRIVATE(d_backing_inode(dentry)))
86928+ return 1;
86929+
86930+ subj = task->acl;
86931+ read_lock(&gr_inode_lock);
86932+ do {
86933+ obj = lookup_acl_obj_label(ino, dev, subj);
86934+ if (obj != NULL) {
86935+ read_unlock(&gr_inode_lock);
86936+ return (obj->mode & GR_FIND) ? 1 : 0;
86937+ }
86938+ } while ((subj = subj->parent_subject));
86939+ read_unlock(&gr_inode_lock);
86940+
86941+ /* this is purely an optimization since we're looking for an object
86942+ for the directory we're doing a readdir on
86943+ if it's possible for any globbed object to match the entry we're
86944+ filling into the directory, then the object we find here will be
86945+ an anchor point with attached globbed objects
86946+ */
86947+ obj = chk_obj_label_noglob(dentry, mnt, task->acl);
86948+ if (obj->globbed == NULL)
86949+ return (obj->mode & GR_FIND) ? 1 : 0;
86950+
86951+ is_not_root = ((obj->filename[0] == '/') &&
86952+ (obj->filename[1] == '\0')) ? 0 : 1;
86953+ bufsize = PAGE_SIZE - namelen - is_not_root;
86954+
86955+ /* check bufsize > PAGE_SIZE || bufsize == 0 */
86956+ if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
86957+ return 1;
86958+
86959+ preempt_disable();
86960+ path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
86961+ bufsize);
86962+
86963+ bufsize = strlen(path);
86964+
86965+ /* if base is "/", don't append an additional slash */
86966+ if (is_not_root)
86967+ *(path + bufsize) = '/';
86968+ memcpy(path + bufsize + is_not_root, name, namelen);
86969+ *(path + bufsize + namelen + is_not_root) = '\0';
86970+
86971+ tmp = obj->globbed;
86972+ while (tmp) {
86973+ if (!glob_match(tmp->filename, path)) {
86974+ preempt_enable();
86975+ return (tmp->mode & GR_FIND) ? 1 : 0;
86976+ }
86977+ tmp = tmp->next;
86978+ }
86979+ preempt_enable();
86980+ return (obj->mode & GR_FIND) ? 1 : 0;
86981+}
86982+
86983+void gr_put_exec_file(struct task_struct *task)
86984+{
86985+ struct file *filp;
86986+
86987+ write_lock(&grsec_exec_file_lock);
86988+ filp = task->exec_file;
86989+ task->exec_file = NULL;
86990+ write_unlock(&grsec_exec_file_lock);
86991+
86992+ if (filp)
86993+ fput(filp);
86994+
86995+ return;
86996+}
86997+
86998+
86999+#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
87000+EXPORT_SYMBOL_GPL(gr_acl_is_enabled);
87001+#endif
87002+#ifdef CONFIG_SECURITY
87003+EXPORT_SYMBOL_GPL(gr_check_user_change);
87004+EXPORT_SYMBOL_GPL(gr_check_group_change);
87005+#endif
87006+
87007diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
87008new file mode 100644
87009index 0000000..9adc75c
87010--- /dev/null
87011+++ b/grsecurity/gracl_alloc.c
87012@@ -0,0 +1,105 @@
87013+#include <linux/kernel.h>
87014+#include <linux/mm.h>
87015+#include <linux/slab.h>
87016+#include <linux/vmalloc.h>
87017+#include <linux/gracl.h>
87018+#include <linux/grsecurity.h>
87019+
87020+static struct gr_alloc_state __current_alloc_state = { 1, 1, NULL };
87021+struct gr_alloc_state *current_alloc_state = &__current_alloc_state;
87022+
87023+static int
87024+alloc_pop(void)
87025+{
87026+ if (current_alloc_state->alloc_stack_next == 1)
87027+ return 0;
87028+
87029+ kfree(current_alloc_state->alloc_stack[current_alloc_state->alloc_stack_next - 2]);
87030+
87031+ current_alloc_state->alloc_stack_next--;
87032+
87033+ return 1;
87034+}
87035+
87036+static int
87037+alloc_push(void *buf)
87038+{
87039+ if (current_alloc_state->alloc_stack_next >= current_alloc_state->alloc_stack_size)
87040+ return 1;
87041+
87042+ current_alloc_state->alloc_stack[current_alloc_state->alloc_stack_next - 1] = buf;
87043+
87044+ current_alloc_state->alloc_stack_next++;
87045+
87046+ return 0;
87047+}
87048+
87049+void *
87050+acl_alloc(unsigned long len)
87051+{
87052+ void *ret = NULL;
87053+
87054+ if (!len || len > PAGE_SIZE)
87055+ goto out;
87056+
87057+ ret = kmalloc(len, GFP_KERNEL);
87058+
87059+ if (ret) {
87060+ if (alloc_push(ret)) {
87061+ kfree(ret);
87062+ ret = NULL;
87063+ }
87064+ }
87065+
87066+out:
87067+ return ret;
87068+}
87069+
87070+void *
87071+acl_alloc_num(unsigned long num, unsigned long len)
87072+{
87073+ if (!len || (num > (PAGE_SIZE / len)))
87074+ return NULL;
87075+
87076+ return acl_alloc(num * len);
87077+}
87078+
87079+void
87080+acl_free_all(void)
87081+{
87082+ if (!current_alloc_state->alloc_stack)
87083+ return;
87084+
87085+ while (alloc_pop()) ;
87086+
87087+ if (current_alloc_state->alloc_stack) {
87088+ if ((current_alloc_state->alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
87089+ kfree(current_alloc_state->alloc_stack);
87090+ else
87091+ vfree(current_alloc_state->alloc_stack);
87092+ }
87093+
87094+ current_alloc_state->alloc_stack = NULL;
87095+ current_alloc_state->alloc_stack_size = 1;
87096+ current_alloc_state->alloc_stack_next = 1;
87097+
87098+ return;
87099+}
87100+
87101+int
87102+acl_alloc_stack_init(unsigned long size)
87103+{
87104+ if ((size * sizeof (void *)) <= PAGE_SIZE)
87105+ current_alloc_state->alloc_stack =
87106+ (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
87107+ else
87108+ current_alloc_state->alloc_stack = (void **) vmalloc(size * sizeof (void *));
87109+
87110+ current_alloc_state->alloc_stack_size = size;
87111+ current_alloc_state->alloc_stack_next = 1;
87112+
87113+ if (!current_alloc_state->alloc_stack)
87114+ return 0;
87115+ else
87116+ return 1;
87117+}
87118diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
87119new file mode 100644
87120index 0000000..1a94c11
87121--- /dev/null
87122+++ b/grsecurity/gracl_cap.c
87123@@ -0,0 +1,127 @@
87124+#include <linux/kernel.h>
87125+#include <linux/module.h>
87126+#include <linux/sched.h>
87127+#include <linux/gracl.h>
87128+#include <linux/grsecurity.h>
87129+#include <linux/grinternal.h>
87130+
87131+extern const char *captab_log[];
87132+extern int captab_log_entries;
87133+
87134+int gr_learn_cap(const struct task_struct *task, const struct cred *cred, const int cap)
87135+{
87136+ struct acl_subject_label *curracl;
87137+
87138+ if (!gr_acl_is_enabled())
87139+ return 1;
87140+
87141+ curracl = task->acl;
87142+
87143+ if (curracl->mode & (GR_LEARN | GR_INHERITLEARN)) {
87144+ security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
87145+ task->role->roletype, GR_GLOBAL_UID(cred->uid),
87146+ GR_GLOBAL_GID(cred->gid), task->exec_file ?
87147+ gr_to_filename(task->exec_file->f_path.dentry,
87148+ task->exec_file->f_path.mnt) : curracl->filename,
87149+ curracl->filename, 0UL,
87150+ 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
87151+ return 1;
87152+ }
87153+
87154+ return 0;
87155+}
87156+
87157+int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
87158+{
87159+ struct acl_subject_label *curracl;
87160+ kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
87161+ kernel_cap_t cap_audit = __cap_empty_set;
87162+
87163+ if (!gr_acl_is_enabled())
87164+ return 1;
87165+
87166+ curracl = task->acl;
87167+
87168+ cap_drop = curracl->cap_lower;
87169+ cap_mask = curracl->cap_mask;
87170+ cap_audit = curracl->cap_invert_audit;
87171+
87172+ while ((curracl = curracl->parent_subject)) {
87173+ /* if the cap isn't specified in the current computed mask but is specified in the
87174+ current level subject, and is lowered in the current level subject, then add
87175+ it to the set of dropped capabilities
87176+ otherwise, add the current level subject's mask to the current computed mask
87177+ */
87178+ if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
87179+ cap_raise(cap_mask, cap);
87180+ if (cap_raised(curracl->cap_lower, cap))
87181+ cap_raise(cap_drop, cap);
87182+ if (cap_raised(curracl->cap_invert_audit, cap))
87183+ cap_raise(cap_audit, cap);
87184+ }
87185+ }
87186+
87187+ if (!cap_raised(cap_drop, cap)) {
87188+ if (cap_raised(cap_audit, cap))
87189+ gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
87190+ return 1;
87191+ }
87192+
87193+ /* only learn the capability use if the process has the capability in the
87194+ general case, the two uses in sys.c of gr_learn_cap are an exception
87195+ to this rule to ensure any role transition involves what the full-learned
87196+ policy believes in a privileged process
87197+ */
87198+ if (cap_raised(cred->cap_effective, cap) && gr_learn_cap(task, cred, cap))
87199+ return 1;
87200+
87201+ if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
87202+ gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
87203+
87204+ return 0;
87205+}
87206+
87207+int
87208+gr_acl_is_capable(const int cap)
87209+{
87210+ return gr_task_acl_is_capable(current, current_cred(), cap);
87211+}
87212+
87213+int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
87214+{
87215+ struct acl_subject_label *curracl;
87216+ kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
87217+
87218+ if (!gr_acl_is_enabled())
87219+ return 1;
87220+
87221+ curracl = task->acl;
87222+
87223+ cap_drop = curracl->cap_lower;
87224+ cap_mask = curracl->cap_mask;
87225+
87226+ while ((curracl = curracl->parent_subject)) {
87227+ /* if the cap isn't specified in the current computed mask but is specified in the
87228+ current level subject, and is lowered in the current level subject, then add
87229+ it to the set of dropped capabilities
87230+ otherwise, add the current level subject's mask to the current computed mask
87231+ */
87232+ if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
87233+ cap_raise(cap_mask, cap);
87234+ if (cap_raised(curracl->cap_lower, cap))
87235+ cap_raise(cap_drop, cap);
87236+ }
87237+ }
87238+
87239+ if (!cap_raised(cap_drop, cap))
87240+ return 1;
87241+
87242+ return 0;
87243+}
87244+
87245+int
87246+gr_acl_is_capable_nolog(const int cap)
87247+{
87248+ return gr_task_acl_is_capable_nolog(current, cap);
87249+}
87250+
87251diff --git a/grsecurity/gracl_compat.c b/grsecurity/gracl_compat.c
87252new file mode 100644
87253index 0000000..a43dd06
87254--- /dev/null
87255+++ b/grsecurity/gracl_compat.c
87256@@ -0,0 +1,269 @@
87257+#include <linux/kernel.h>
87258+#include <linux/gracl.h>
87259+#include <linux/compat.h>
87260+#include <linux/gracl_compat.h>
87261+
87262+#include <asm/uaccess.h>
87263+
87264+int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap)
87265+{
87266+ struct gr_arg_wrapper_compat uwrapcompat;
87267+
87268+ if (copy_from_user(&uwrapcompat, buf, sizeof(uwrapcompat)))
87269+ return -EFAULT;
87270+
87271+ if ((uwrapcompat.version != GRSECURITY_VERSION) ||
87272+ (uwrapcompat.size != sizeof(struct gr_arg_compat)))
87273+ return -EINVAL;
87274+
87275+ uwrap->arg = compat_ptr(uwrapcompat.arg);
87276+ uwrap->version = uwrapcompat.version;
87277+ uwrap->size = sizeof(struct gr_arg);
87278+
87279+ return 0;
87280+}
87281+
87282+int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg)
87283+{
87284+ struct gr_arg_compat argcompat;
87285+
87286+ if (copy_from_user(&argcompat, buf, sizeof(argcompat)))
87287+ return -EFAULT;
87288+
87289+ arg->role_db.r_table = compat_ptr(argcompat.role_db.r_table);
87290+ arg->role_db.num_pointers = argcompat.role_db.num_pointers;
87291+ arg->role_db.num_roles = argcompat.role_db.num_roles;
87292+ arg->role_db.num_domain_children = argcompat.role_db.num_domain_children;
87293+ arg->role_db.num_subjects = argcompat.role_db.num_subjects;
87294+ arg->role_db.num_objects = argcompat.role_db.num_objects;
87295+
87296+ memcpy(&arg->pw, &argcompat.pw, sizeof(arg->pw));
87297+ memcpy(&arg->salt, &argcompat.salt, sizeof(arg->salt));
87298+ memcpy(&arg->sum, &argcompat.sum, sizeof(arg->sum));
87299+ memcpy(&arg->sp_role, &argcompat.sp_role, sizeof(arg->sp_role));
87300+ arg->sprole_pws = compat_ptr(argcompat.sprole_pws);
87301+ arg->segv_device = argcompat.segv_device;
87302+ arg->segv_inode = argcompat.segv_inode;
87303+ arg->segv_uid = argcompat.segv_uid;
87304+ arg->num_sprole_pws = argcompat.num_sprole_pws;
87305+ arg->mode = argcompat.mode;
87306+
87307+ return 0;
87308+}
87309+
87310+int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp)
87311+{
87312+ struct acl_object_label_compat objcompat;
87313+
87314+ if (copy_from_user(&objcompat, userp, sizeof(objcompat)))
87315+ return -EFAULT;
87316+
87317+ obj->filename = compat_ptr(objcompat.filename);
87318+ obj->inode = objcompat.inode;
87319+ obj->device = objcompat.device;
87320+ obj->mode = objcompat.mode;
87321+
87322+ obj->nested = compat_ptr(objcompat.nested);
87323+ obj->globbed = compat_ptr(objcompat.globbed);
87324+
87325+ obj->prev = compat_ptr(objcompat.prev);
87326+ obj->next = compat_ptr(objcompat.next);
87327+
87328+ return 0;
87329+}
87330+
87331+int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp)
87332+{
87333+ unsigned int i;
87334+ struct acl_subject_label_compat subjcompat;
87335+
87336+ if (copy_from_user(&subjcompat, userp, sizeof(subjcompat)))
87337+ return -EFAULT;
87338+
87339+ subj->filename = compat_ptr(subjcompat.filename);
87340+ subj->inode = subjcompat.inode;
87341+ subj->device = subjcompat.device;
87342+ subj->mode = subjcompat.mode;
87343+ subj->cap_mask = subjcompat.cap_mask;
87344+ subj->cap_lower = subjcompat.cap_lower;
87345+ subj->cap_invert_audit = subjcompat.cap_invert_audit;
87346+
87347+ for (i = 0; i < GR_NLIMITS; i++) {
87348+ if (subjcompat.res[i].rlim_cur == COMPAT_RLIM_INFINITY)
87349+ subj->res[i].rlim_cur = RLIM_INFINITY;
87350+ else
87351+ subj->res[i].rlim_cur = subjcompat.res[i].rlim_cur;
87352+ if (subjcompat.res[i].rlim_max == COMPAT_RLIM_INFINITY)
87353+ subj->res[i].rlim_max = RLIM_INFINITY;
87354+ else
87355+ subj->res[i].rlim_max = subjcompat.res[i].rlim_max;
87356+ }
87357+ subj->resmask = subjcompat.resmask;
87358+
87359+ subj->user_trans_type = subjcompat.user_trans_type;
87360+ subj->group_trans_type = subjcompat.group_trans_type;
87361+ subj->user_transitions = compat_ptr(subjcompat.user_transitions);
87362+ subj->group_transitions = compat_ptr(subjcompat.group_transitions);
87363+ subj->user_trans_num = subjcompat.user_trans_num;
87364+ subj->group_trans_num = subjcompat.group_trans_num;
87365+
87366+ memcpy(&subj->sock_families, &subjcompat.sock_families, sizeof(subj->sock_families));
87367+ memcpy(&subj->ip_proto, &subjcompat.ip_proto, sizeof(subj->ip_proto));
87368+ subj->ip_type = subjcompat.ip_type;
87369+ subj->ips = compat_ptr(subjcompat.ips);
87370+ subj->ip_num = subjcompat.ip_num;
87371+ subj->inaddr_any_override = subjcompat.inaddr_any_override;
87372+
87373+ subj->crashes = subjcompat.crashes;
87374+ subj->expires = subjcompat.expires;
87375+
87376+ subj->parent_subject = compat_ptr(subjcompat.parent_subject);
87377+ subj->hash = compat_ptr(subjcompat.hash);
87378+ subj->prev = compat_ptr(subjcompat.prev);
87379+ subj->next = compat_ptr(subjcompat.next);
87380+
87381+ subj->obj_hash = compat_ptr(subjcompat.obj_hash);
87382+ subj->obj_hash_size = subjcompat.obj_hash_size;
87383+ subj->pax_flags = subjcompat.pax_flags;
87384+
87385+ return 0;
87386+}
87387+
87388+int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp)
87389+{
87390+ struct acl_role_label_compat rolecompat;
87391+
87392+ if (copy_from_user(&rolecompat, userp, sizeof(rolecompat)))
87393+ return -EFAULT;
87394+
87395+ role->rolename = compat_ptr(rolecompat.rolename);
87396+ role->uidgid = rolecompat.uidgid;
87397+ role->roletype = rolecompat.roletype;
87398+
87399+ role->auth_attempts = rolecompat.auth_attempts;
87400+ role->expires = rolecompat.expires;
87401+
87402+ role->root_label = compat_ptr(rolecompat.root_label);
87403+ role->hash = compat_ptr(rolecompat.hash);
87404+
87405+ role->prev = compat_ptr(rolecompat.prev);
87406+ role->next = compat_ptr(rolecompat.next);
87407+
87408+ role->transitions = compat_ptr(rolecompat.transitions);
87409+ role->allowed_ips = compat_ptr(rolecompat.allowed_ips);
87410+ role->domain_children = compat_ptr(rolecompat.domain_children);
87411+ role->domain_child_num = rolecompat.domain_child_num;
87412+
87413+ role->umask = rolecompat.umask;
87414+
87415+ role->subj_hash = compat_ptr(rolecompat.subj_hash);
87416+ role->subj_hash_size = rolecompat.subj_hash_size;
87417+
87418+ return 0;
87419+}
87420+
87421+int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
87422+{
87423+ struct role_allowed_ip_compat roleip_compat;
87424+
87425+ if (copy_from_user(&roleip_compat, userp, sizeof(roleip_compat)))
87426+ return -EFAULT;
87427+
87428+ roleip->addr = roleip_compat.addr;
87429+ roleip->netmask = roleip_compat.netmask;
87430+
87431+ roleip->prev = compat_ptr(roleip_compat.prev);
87432+ roleip->next = compat_ptr(roleip_compat.next);
87433+
87434+ return 0;
87435+}
87436+
87437+int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp)
87438+{
87439+ struct role_transition_compat trans_compat;
87440+
87441+ if (copy_from_user(&trans_compat, userp, sizeof(trans_compat)))
87442+ return -EFAULT;
87443+
87444+ trans->rolename = compat_ptr(trans_compat.rolename);
87445+
87446+ trans->prev = compat_ptr(trans_compat.prev);
87447+ trans->next = compat_ptr(trans_compat.next);
87448+
87449+ return 0;
87450+
87451+}
87452+
87453+int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
87454+{
87455+ struct gr_hash_struct_compat hash_compat;
87456+
87457+ if (copy_from_user(&hash_compat, userp, sizeof(hash_compat)))
87458+ return -EFAULT;
87459+
87460+ hash->table = compat_ptr(hash_compat.table);
87461+ hash->nametable = compat_ptr(hash_compat.nametable);
87462+ hash->first = compat_ptr(hash_compat.first);
87463+
87464+ hash->table_size = hash_compat.table_size;
87465+ hash->used_size = hash_compat.used_size;
87466+
87467+ hash->type = hash_compat.type;
87468+
87469+ return 0;
87470+}
87471+
87472+int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp)
87473+{
87474+ compat_uptr_t ptrcompat;
87475+
87476+ if (copy_from_user(&ptrcompat, userp + (idx * sizeof(ptrcompat)), sizeof(ptrcompat)))
87477+ return -EFAULT;
87478+
87479+ *(void **)ptr = compat_ptr(ptrcompat);
87480+
87481+ return 0;
87482+}
87483+
87484+int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp)
87485+{
87486+ struct acl_ip_label_compat ip_compat;
87487+
87488+ if (copy_from_user(&ip_compat, userp, sizeof(ip_compat)))
87489+ return -EFAULT;
87490+
87491+ ip->iface = compat_ptr(ip_compat.iface);
87492+ ip->addr = ip_compat.addr;
87493+ ip->netmask = ip_compat.netmask;
87494+ ip->low = ip_compat.low;
87495+ ip->high = ip_compat.high;
87496+ ip->mode = ip_compat.mode;
87497+ ip->type = ip_compat.type;
87498+
87499+ memcpy(&ip->proto, &ip_compat.proto, sizeof(ip->proto));
87500+
87501+ ip->prev = compat_ptr(ip_compat.prev);
87502+ ip->next = compat_ptr(ip_compat.next);
87503+
87504+ return 0;
87505+}
87506+
87507+int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
87508+{
87509+ struct sprole_pw_compat pw_compat;
87510+
87511+ if (copy_from_user(&pw_compat, (const void *)userp + (sizeof(pw_compat) * idx), sizeof(pw_compat)))
87512+ return -EFAULT;
87513+
87514+ pw->rolename = compat_ptr(pw_compat.rolename);
87515+ memcpy(&pw->salt, pw_compat.salt, sizeof(pw->salt));
87516+ memcpy(&pw->sum, pw_compat.sum, sizeof(pw->sum));
87517+
87518+ return 0;
87519+}
87520+
87521+size_t get_gr_arg_wrapper_size_compat(void)
87522+{
87523+ return sizeof(struct gr_arg_wrapper_compat);
87524+}
87525+
87526diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
87527new file mode 100644
87528index 0000000..fce7f71
87529--- /dev/null
87530+++ b/grsecurity/gracl_fs.c
87531@@ -0,0 +1,448 @@
87532+#include <linux/kernel.h>
87533+#include <linux/sched.h>
87534+#include <linux/types.h>
87535+#include <linux/fs.h>
87536+#include <linux/file.h>
87537+#include <linux/stat.h>
87538+#include <linux/grsecurity.h>
87539+#include <linux/grinternal.h>
87540+#include <linux/gracl.h>
87541+
87542+umode_t
87543+gr_acl_umask(void)
87544+{
87545+ if (unlikely(!gr_acl_is_enabled()))
87546+ return 0;
87547+
87548+ return current->role->umask;
87549+}
87550+
87551+__u32
87552+gr_acl_handle_hidden_file(const struct dentry * dentry,
87553+ const struct vfsmount * mnt)
87554+{
87555+ __u32 mode;
87556+
87557+ if (unlikely(d_is_negative(dentry)))
87558+ return GR_FIND;
87559+
87560+ mode =
87561+ gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
87562+
87563+ if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
87564+ gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
87565+ return mode;
87566+ } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
87567+ gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
87568+ return 0;
87569+ } else if (unlikely(!(mode & GR_FIND)))
87570+ return 0;
87571+
87572+ return GR_FIND;
87573+}
87574+
87575+__u32
87576+gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
87577+ int acc_mode)
87578+{
87579+ __u32 reqmode = GR_FIND;
87580+ __u32 mode;
87581+
87582+ if (unlikely(d_is_negative(dentry)))
87583+ return reqmode;
87584+
87585+ if (acc_mode & MAY_APPEND)
87586+ reqmode |= GR_APPEND;
87587+ else if (acc_mode & MAY_WRITE)
87588+ reqmode |= GR_WRITE;
87589+ if ((acc_mode & MAY_READ) && !d_is_dir(dentry))
87590+ reqmode |= GR_READ;
87591+
87592+ mode =
87593+ gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
87594+ mnt);
87595+
87596+ if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
87597+ gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
87598+ reqmode & GR_READ ? " reading" : "",
87599+ reqmode & GR_WRITE ? " writing" : reqmode &
87600+ GR_APPEND ? " appending" : "");
87601+ return reqmode;
87602+ } else
87603+ if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
87604+ {
87605+ gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
87606+ reqmode & GR_READ ? " reading" : "",
87607+ reqmode & GR_WRITE ? " writing" : reqmode &
87608+ GR_APPEND ? " appending" : "");
87609+ return 0;
87610+ } else if (unlikely((mode & reqmode) != reqmode))
87611+ return 0;
87612+
87613+ return reqmode;
87614+}
87615+
87616+__u32
87617+gr_acl_handle_creat(const struct dentry * dentry,
87618+ const struct dentry * p_dentry,
87619+ const struct vfsmount * p_mnt, int open_flags, int acc_mode,
87620+ const int imode)
87621+{
87622+ __u32 reqmode = GR_WRITE | GR_CREATE;
87623+ __u32 mode;
87624+
87625+ if (acc_mode & MAY_APPEND)
87626+ reqmode |= GR_APPEND;
87627+ // if a directory was required or the directory already exists, then
87628+ // don't count this open as a read
87629+ if ((acc_mode & MAY_READ) &&
87630+ !((open_flags & O_DIRECTORY) || d_is_dir(dentry)))
87631+ reqmode |= GR_READ;
87632+ if ((open_flags & O_CREAT) &&
87633+ ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
87634+ reqmode |= GR_SETID;
87635+
87636+ mode =
87637+ gr_check_create(dentry, p_dentry, p_mnt,
87638+ reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
87639+
87640+ if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
87641+ gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
87642+ reqmode & GR_READ ? " reading" : "",
87643+ reqmode & GR_WRITE ? " writing" : reqmode &
87644+ GR_APPEND ? " appending" : "");
87645+ return reqmode;
87646+ } else
87647+ if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
87648+ {
87649+ gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
87650+ reqmode & GR_READ ? " reading" : "",
87651+ reqmode & GR_WRITE ? " writing" : reqmode &
87652+ GR_APPEND ? " appending" : "");
87653+ return 0;
87654+ } else if (unlikely((mode & reqmode) != reqmode))
87655+ return 0;
87656+
87657+ return reqmode;
87658+}
87659+
87660+__u32
87661+gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
87662+ const int fmode)
87663+{
87664+ __u32 mode, reqmode = GR_FIND;
87665+
87666+ if ((fmode & S_IXOTH) && !d_is_dir(dentry))
87667+ reqmode |= GR_EXEC;
87668+ if (fmode & S_IWOTH)
87669+ reqmode |= GR_WRITE;
87670+ if (fmode & S_IROTH)
87671+ reqmode |= GR_READ;
87672+
87673+ mode =
87674+ gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
87675+ mnt);
87676+
87677+ if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
87678+ gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
87679+ reqmode & GR_READ ? " reading" : "",
87680+ reqmode & GR_WRITE ? " writing" : "",
87681+ reqmode & GR_EXEC ? " executing" : "");
87682+ return reqmode;
87683+ } else
87684+ if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
87685+ {
87686+ gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
87687+ reqmode & GR_READ ? " reading" : "",
87688+ reqmode & GR_WRITE ? " writing" : "",
87689+ reqmode & GR_EXEC ? " executing" : "");
87690+ return 0;
87691+ } else if (unlikely((mode & reqmode) != reqmode))
87692+ return 0;
87693+
87694+ return reqmode;
87695+}
87696+
87697+static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
87698+{
87699+ __u32 mode;
87700+
87701+ mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
87702+
87703+ if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
87704+ gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
87705+ return mode;
87706+ } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
87707+ gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
87708+ return 0;
87709+ } else if (unlikely((mode & (reqmode)) != (reqmode)))
87710+ return 0;
87711+
87712+ return (reqmode);
87713+}
87714+
87715+__u32
87716+gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
87717+{
87718+ return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
87719+}
87720+
87721+__u32
87722+gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
87723+{
87724+ return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
87725+}
87726+
87727+__u32
87728+gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
87729+{
87730+ return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
87731+}
87732+
87733+__u32
87734+gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
87735+{
87736+ return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
87737+}
87738+
87739+__u32
87740+gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
87741+ umode_t *modeptr)
87742+{
87743+ umode_t mode;
87744+ struct inode *inode = d_backing_inode(dentry);
87745+
87746+ *modeptr &= ~gr_acl_umask();
87747+ mode = *modeptr;
87748+
87749+ if (unlikely(inode && S_ISSOCK(inode->i_mode)))
87750+ return 1;
87751+
87752+ if (unlikely(!d_is_dir(dentry) &&
87753+ ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
87754+ return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
87755+ GR_CHMOD_ACL_MSG);
87756+ } else {
87757+ return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
87758+ }
87759+}
87760+
87761+__u32
87762+gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
87763+{
87764+ return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
87765+}
87766+
87767+__u32
87768+gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
87769+{
87770+ return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
87771+}
87772+
87773+__u32
87774+gr_acl_handle_removexattr(const struct dentry *dentry, const struct vfsmount *mnt)
87775+{
87776+ return generic_fs_handler(dentry, mnt, GR_WRITE, GR_REMOVEXATTR_ACL_MSG);
87777+}
87778+
87779+__u32
87780+gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
87781+{
87782+ return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
87783+}
87784+
87785+__u32
87786+gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
87787+{
87788+ return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
87789+ GR_UNIXCONNECT_ACL_MSG);
87790+}
87791+
87792+/* hardlinks require at minimum create and link permission,
87793+ any additional privilege required is based on the
87794+ privilege of the file being linked to
87795+*/
87796+__u32
87797+gr_acl_handle_link(const struct dentry * new_dentry,
87798+ const struct dentry * parent_dentry,
87799+ const struct vfsmount * parent_mnt,
87800+ const struct dentry * old_dentry,
87801+ const struct vfsmount * old_mnt, const struct filename *to)
87802+{
87803+ __u32 mode;
87804+ __u32 needmode = GR_CREATE | GR_LINK;
87805+ __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
87806+
87807+ mode =
87808+ gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
87809+ old_mnt);
87810+
87811+ if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
87812+ gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
87813+ return mode;
87814+ } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
87815+ gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
87816+ return 0;
87817+ } else if (unlikely((mode & needmode) != needmode))
87818+ return 0;
87819+
87820+ return 1;
87821+}
87822+
87823+__u32
87824+gr_acl_handle_symlink(const struct dentry * new_dentry,
87825+ const struct dentry * parent_dentry,
87826+ const struct vfsmount * parent_mnt, const struct filename *from)
87827+{
87828+ __u32 needmode = GR_WRITE | GR_CREATE;
87829+ __u32 mode;
87830+
87831+ mode =
87832+ gr_check_create(new_dentry, parent_dentry, parent_mnt,
87833+ GR_CREATE | GR_AUDIT_CREATE |
87834+ GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
87835+
87836+ if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
87837+ gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
87838+ return mode;
87839+ } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
87840+ gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
87841+ return 0;
87842+ } else if (unlikely((mode & needmode) != needmode))
87843+ return 0;
87844+
87845+ return (GR_WRITE | GR_CREATE);
87846+}
87847+
87848+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)
87849+{
87850+ __u32 mode;
87851+
87852+ mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
87853+
87854+ if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
87855+ gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
87856+ return mode;
87857+ } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
87858+ gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
87859+ return 0;
87860+ } else if (unlikely((mode & (reqmode)) != (reqmode)))
87861+ return 0;
87862+
87863+ return (reqmode);
87864+}
87865+
87866+__u32
87867+gr_acl_handle_mknod(const struct dentry * new_dentry,
87868+ const struct dentry * parent_dentry,
87869+ const struct vfsmount * parent_mnt,
87870+ const int mode)
87871+{
87872+ __u32 reqmode = GR_WRITE | GR_CREATE;
87873+ if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
87874+ reqmode |= GR_SETID;
87875+
87876+ return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
87877+ reqmode, GR_MKNOD_ACL_MSG);
87878+}
87879+
87880+__u32
87881+gr_acl_handle_mkdir(const struct dentry *new_dentry,
87882+ const struct dentry *parent_dentry,
87883+ const struct vfsmount *parent_mnt)
87884+{
87885+ return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
87886+ GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
87887+}
87888+
87889+#define RENAME_CHECK_SUCCESS(old, new) \
87890+ (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
87891+ ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
87892+
87893+int
87894+gr_acl_handle_rename(struct dentry *new_dentry,
87895+ struct dentry *parent_dentry,
87896+ const struct vfsmount *parent_mnt,
87897+ struct dentry *old_dentry,
87898+ struct inode *old_parent_inode,
87899+ struct vfsmount *old_mnt, const struct filename *newname, unsigned int flags)
87900+{
87901+ __u32 comp1, comp2;
87902+ int error = 0;
87903+
87904+ if (unlikely(!gr_acl_is_enabled()))
87905+ return 0;
87906+
87907+ if (flags & RENAME_EXCHANGE) {
87908+ comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
87909+ GR_AUDIT_READ | GR_AUDIT_WRITE |
87910+ GR_SUPPRESS, parent_mnt);
87911+ comp2 =
87912+ gr_search_file(old_dentry,
87913+ GR_READ | GR_WRITE | GR_AUDIT_READ |
87914+ GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
87915+ } else if (d_is_negative(new_dentry)) {
87916+ comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
87917+ GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
87918+ GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
87919+ comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
87920+ GR_DELETE | GR_AUDIT_DELETE |
87921+ GR_AUDIT_READ | GR_AUDIT_WRITE |
87922+ GR_SUPPRESS, old_mnt);
87923+ } else {
87924+ comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
87925+ GR_CREATE | GR_DELETE |
87926+ GR_AUDIT_CREATE | GR_AUDIT_DELETE |
87927+ GR_AUDIT_READ | GR_AUDIT_WRITE |
87928+ GR_SUPPRESS, parent_mnt);
87929+ comp2 =
87930+ gr_search_file(old_dentry,
87931+ GR_READ | GR_WRITE | GR_AUDIT_READ |
87932+ GR_DELETE | GR_AUDIT_DELETE |
87933+ GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
87934+ }
87935+
87936+ if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
87937+ ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
87938+ gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
87939+ else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
87940+ && !(comp2 & GR_SUPPRESS)) {
87941+ gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
87942+ error = -EACCES;
87943+ } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
87944+ error = -EACCES;
87945+
87946+ return error;
87947+}
87948+
87949+void
87950+gr_acl_handle_exit(void)
87951+{
87952+ u16 id;
87953+ char *rolename;
87954+
87955+ if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
87956+ !(current->role->roletype & GR_ROLE_PERSIST))) {
87957+ id = current->acl_role_id;
87958+ rolename = current->role->rolename;
87959+ gr_set_acls(1);
87960+ gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
87961+ }
87962+
87963+ gr_put_exec_file(current);
87964+ return;
87965+}
87966+
87967+int
87968+gr_acl_handle_procpidmem(const struct task_struct *task)
87969+{
87970+ if (unlikely(!gr_acl_is_enabled()))
87971+ return 0;
87972+
87973+ if (task != current && (task->acl->mode & GR_PROTPROCFD) &&
87974+ !(current->acl->mode & GR_POVERRIDE) &&
87975+ !(current->role->roletype & GR_ROLE_GOD))
87976+ return -EACCES;
87977+
87978+ return 0;
87979+}
87980diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
87981new file mode 100644
87982index 0000000..ed6ee43
87983--- /dev/null
87984+++ b/grsecurity/gracl_ip.c
87985@@ -0,0 +1,386 @@
87986+#include <linux/kernel.h>
87987+#include <asm/uaccess.h>
87988+#include <asm/errno.h>
87989+#include <net/sock.h>
87990+#include <linux/file.h>
87991+#include <linux/fs.h>
87992+#include <linux/net.h>
87993+#include <linux/in.h>
87994+#include <linux/skbuff.h>
87995+#include <linux/ip.h>
87996+#include <linux/udp.h>
87997+#include <linux/types.h>
87998+#include <linux/sched.h>
87999+#include <linux/netdevice.h>
88000+#include <linux/inetdevice.h>
88001+#include <linux/gracl.h>
88002+#include <linux/grsecurity.h>
88003+#include <linux/grinternal.h>
88004+
88005+#define GR_BIND 0x01
88006+#define GR_CONNECT 0x02
88007+#define GR_INVERT 0x04
88008+#define GR_BINDOVERRIDE 0x08
88009+#define GR_CONNECTOVERRIDE 0x10
88010+#define GR_SOCK_FAMILY 0x20
88011+
88012+static const char * gr_protocols[IPPROTO_MAX] = {
88013+ "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
88014+ "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
88015+ "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
88016+ "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
88017+ "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
88018+ "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
88019+ "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
88020+ "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
88021+ "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
88022+ "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
88023+ "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
88024+ "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
88025+ "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
88026+ "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
88027+ "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
88028+ "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
88029+ "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
88030+ "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
88031+ "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
88032+ "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
88033+ "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
88034+ "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
88035+ "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
88036+ "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
88037+ "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
88038+ "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
88039+ "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
88040+ "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
88041+ "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
88042+ "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
88043+ "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
88044+ "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
88045+ };
88046+
88047+static const char * gr_socktypes[SOCK_MAX] = {
88048+ "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
88049+ "unknown:7", "unknown:8", "unknown:9", "packet"
88050+ };
88051+
88052+static const char * gr_sockfamilies[AF_MAX+1] = {
88053+ "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
88054+ "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
88055+ "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
88056+ "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf", "alg", "nfc", "vsock"
88057+ };
88058+
88059+const char *
88060+gr_proto_to_name(unsigned char proto)
88061+{
88062+ return gr_protocols[proto];
88063+}
88064+
88065+const char *
88066+gr_socktype_to_name(unsigned char type)
88067+{
88068+ return gr_socktypes[type];
88069+}
88070+
88071+const char *
88072+gr_sockfamily_to_name(unsigned char family)
88073+{
88074+ return gr_sockfamilies[family];
88075+}
88076+
88077+extern const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
88078+
88079+int
88080+gr_search_socket(const int domain, const int type, const int protocol)
88081+{
88082+ struct acl_subject_label *curr;
88083+ const struct cred *cred = current_cred();
88084+
88085+ if (unlikely(!gr_acl_is_enabled()))
88086+ goto exit;
88087+
88088+ if ((domain < 0) || (type < 0) || (protocol < 0) ||
88089+ (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
88090+ goto exit; // let the kernel handle it
88091+
88092+ curr = current->acl;
88093+
88094+ if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
88095+ /* the family is allowed, if this is PF_INET allow it only if
88096+ the extra sock type/protocol checks pass */
88097+ if (domain == PF_INET)
88098+ goto inet_check;
88099+ goto exit;
88100+ } else {
88101+ if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
88102+ __u32 fakeip = 0;
88103+ security_learn(GR_IP_LEARN_MSG, current->role->rolename,
88104+ current->role->roletype, GR_GLOBAL_UID(cred->uid),
88105+ GR_GLOBAL_GID(cred->gid), current->exec_file ?
88106+ gr_to_filename(current->exec_file->f_path.dentry,
88107+ current->exec_file->f_path.mnt) :
88108+ curr->filename, curr->filename,
88109+ &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
88110+ &current->signal->saved_ip);
88111+ goto exit;
88112+ }
88113+ goto exit_fail;
88114+ }
88115+
88116+inet_check:
88117+ /* the rest of this checking is for IPv4 only */
88118+ if (!curr->ips)
88119+ goto exit;
88120+
88121+ if ((curr->ip_type & (1U << type)) &&
88122+ (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
88123+ goto exit;
88124+
88125+ if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
88126+ /* we don't place acls on raw sockets , and sometimes
88127+ dgram/ip sockets are opened for ioctl and not
88128+ bind/connect, so we'll fake a bind learn log */
88129+ if (type == SOCK_RAW || type == SOCK_PACKET) {
88130+ __u32 fakeip = 0;
88131+ security_learn(GR_IP_LEARN_MSG, current->role->rolename,
88132+ current->role->roletype, GR_GLOBAL_UID(cred->uid),
88133+ GR_GLOBAL_GID(cred->gid), current->exec_file ?
88134+ gr_to_filename(current->exec_file->f_path.dentry,
88135+ current->exec_file->f_path.mnt) :
88136+ curr->filename, curr->filename,
88137+ &fakeip, 0, type,
88138+ protocol, GR_CONNECT, &current->signal->saved_ip);
88139+ } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
88140+ __u32 fakeip = 0;
88141+ security_learn(GR_IP_LEARN_MSG, current->role->rolename,
88142+ current->role->roletype, GR_GLOBAL_UID(cred->uid),
88143+ GR_GLOBAL_GID(cred->gid), current->exec_file ?
88144+ gr_to_filename(current->exec_file->f_path.dentry,
88145+ current->exec_file->f_path.mnt) :
88146+ curr->filename, curr->filename,
88147+ &fakeip, 0, type,
88148+ protocol, GR_BIND, &current->signal->saved_ip);
88149+ }
88150+ /* we'll log when they use connect or bind */
88151+ goto exit;
88152+ }
88153+
88154+exit_fail:
88155+ if (domain == PF_INET)
88156+ gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
88157+ gr_socktype_to_name(type), gr_proto_to_name(protocol));
88158+ else if (rcu_access_pointer(net_families[domain]) != NULL)
88159+ gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
88160+ gr_socktype_to_name(type), protocol);
88161+
88162+ return 0;
88163+exit:
88164+ return 1;
88165+}
88166+
88167+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)
88168+{
88169+ if ((ip->mode & mode) &&
88170+ (ip_port >= ip->low) &&
88171+ (ip_port <= ip->high) &&
88172+ ((ntohl(ip_addr) & our_netmask) ==
88173+ (ntohl(our_addr) & our_netmask))
88174+ && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
88175+ && (ip->type & (1U << type))) {
88176+ if (ip->mode & GR_INVERT)
88177+ return 2; // specifically denied
88178+ else
88179+ return 1; // allowed
88180+ }
88181+
88182+ return 0; // not specifically allowed, may continue parsing
88183+}
88184+
88185+static int
88186+gr_search_connectbind(const int full_mode, struct sock *sk,
88187+ struct sockaddr_in *addr, const int type)
88188+{
88189+ char iface[IFNAMSIZ] = {0};
88190+ struct acl_subject_label *curr;
88191+ struct acl_ip_label *ip;
88192+ struct inet_sock *isk;
88193+ struct net_device *dev;
88194+ struct in_device *idev;
88195+ unsigned long i;
88196+ int ret;
88197+ int mode = full_mode & (GR_BIND | GR_CONNECT);
88198+ __u32 ip_addr = 0;
88199+ __u32 our_addr;
88200+ __u32 our_netmask;
88201+ char *p;
88202+ __u16 ip_port = 0;
88203+ const struct cred *cred = current_cred();
88204+
88205+ if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
88206+ return 0;
88207+
88208+ curr = current->acl;
88209+ isk = inet_sk(sk);
88210+
88211+ /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
88212+ if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
88213+ addr->sin_addr.s_addr = curr->inaddr_any_override;
88214+ if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
88215+ struct sockaddr_in saddr;
88216+ int err;
88217+
88218+ saddr.sin_family = AF_INET;
88219+ saddr.sin_addr.s_addr = curr->inaddr_any_override;
88220+ saddr.sin_port = isk->inet_sport;
88221+
88222+ err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
88223+ if (err)
88224+ return err;
88225+
88226+ err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
88227+ if (err)
88228+ return err;
88229+ }
88230+
88231+ if (!curr->ips)
88232+ return 0;
88233+
88234+ ip_addr = addr->sin_addr.s_addr;
88235+ ip_port = ntohs(addr->sin_port);
88236+
88237+ if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
88238+ security_learn(GR_IP_LEARN_MSG, current->role->rolename,
88239+ current->role->roletype, GR_GLOBAL_UID(cred->uid),
88240+ GR_GLOBAL_GID(cred->gid), current->exec_file ?
88241+ gr_to_filename(current->exec_file->f_path.dentry,
88242+ current->exec_file->f_path.mnt) :
88243+ curr->filename, curr->filename,
88244+ &ip_addr, ip_port, type,
88245+ sk->sk_protocol, mode, &current->signal->saved_ip);
88246+ return 0;
88247+ }
88248+
88249+ for (i = 0; i < curr->ip_num; i++) {
88250+ ip = *(curr->ips + i);
88251+ if (ip->iface != NULL) {
88252+ strncpy(iface, ip->iface, IFNAMSIZ - 1);
88253+ p = strchr(iface, ':');
88254+ if (p != NULL)
88255+ *p = '\0';
88256+ dev = dev_get_by_name(sock_net(sk), iface);
88257+ if (dev == NULL)
88258+ continue;
88259+ idev = in_dev_get(dev);
88260+ if (idev == NULL) {
88261+ dev_put(dev);
88262+ continue;
88263+ }
88264+ rcu_read_lock();
88265+ for_ifa(idev) {
88266+ if (!strcmp(ip->iface, ifa->ifa_label)) {
88267+ our_addr = ifa->ifa_address;
88268+ our_netmask = 0xffffffff;
88269+ ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
88270+ if (ret == 1) {
88271+ rcu_read_unlock();
88272+ in_dev_put(idev);
88273+ dev_put(dev);
88274+ return 0;
88275+ } else if (ret == 2) {
88276+ rcu_read_unlock();
88277+ in_dev_put(idev);
88278+ dev_put(dev);
88279+ goto denied;
88280+ }
88281+ }
88282+ } endfor_ifa(idev);
88283+ rcu_read_unlock();
88284+ in_dev_put(idev);
88285+ dev_put(dev);
88286+ } else {
88287+ our_addr = ip->addr;
88288+ our_netmask = ip->netmask;
88289+ ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
88290+ if (ret == 1)
88291+ return 0;
88292+ else if (ret == 2)
88293+ goto denied;
88294+ }
88295+ }
88296+
88297+denied:
88298+ if (mode == GR_BIND)
88299+ 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));
88300+ else if (mode == GR_CONNECT)
88301+ 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));
88302+
88303+ return -EACCES;
88304+}
88305+
88306+int
88307+gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
88308+{
88309+ /* always allow disconnection of dgram sockets with connect */
88310+ if (addr->sin_family == AF_UNSPEC)
88311+ return 0;
88312+ return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
88313+}
88314+
88315+int
88316+gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
88317+{
88318+ return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
88319+}
88320+
88321+int gr_search_listen(struct socket *sock)
88322+{
88323+ struct sock *sk = sock->sk;
88324+ struct sockaddr_in addr;
88325+
88326+ addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
88327+ addr.sin_port = inet_sk(sk)->inet_sport;
88328+
88329+ return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
88330+}
88331+
88332+int gr_search_accept(struct socket *sock)
88333+{
88334+ struct sock *sk = sock->sk;
88335+ struct sockaddr_in addr;
88336+
88337+ addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
88338+ addr.sin_port = inet_sk(sk)->inet_sport;
88339+
88340+ return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
88341+}
88342+
88343+int
88344+gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
88345+{
88346+ if (addr)
88347+ return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
88348+ else {
88349+ struct sockaddr_in sin;
88350+ const struct inet_sock *inet = inet_sk(sk);
88351+
88352+ sin.sin_addr.s_addr = inet->inet_daddr;
88353+ sin.sin_port = inet->inet_dport;
88354+
88355+ return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
88356+ }
88357+}
88358+
88359+int
88360+gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
88361+{
88362+ struct sockaddr_in sin;
88363+
88364+ if (unlikely(skb->len < sizeof (struct udphdr)))
88365+ return 0; // skip this packet
88366+
88367+ sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
88368+ sin.sin_port = udp_hdr(skb)->source;
88369+
88370+ return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
88371+}
88372diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
88373new file mode 100644
88374index 0000000..25f54ef
88375--- /dev/null
88376+++ b/grsecurity/gracl_learn.c
88377@@ -0,0 +1,207 @@
88378+#include <linux/kernel.h>
88379+#include <linux/mm.h>
88380+#include <linux/sched.h>
88381+#include <linux/poll.h>
88382+#include <linux/string.h>
88383+#include <linux/file.h>
88384+#include <linux/types.h>
88385+#include <linux/vmalloc.h>
88386+#include <linux/grinternal.h>
88387+
88388+extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
88389+ size_t count, loff_t *ppos);
88390+extern int gr_acl_is_enabled(void);
88391+
88392+static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
88393+static int gr_learn_attached;
88394+
88395+/* use a 512k buffer */
88396+#define LEARN_BUFFER_SIZE (512 * 1024)
88397+
88398+static DEFINE_SPINLOCK(gr_learn_lock);
88399+static DEFINE_MUTEX(gr_learn_user_mutex);
88400+
88401+/* we need to maintain two buffers, so that the kernel context of grlearn
88402+ uses a semaphore around the userspace copying, and the other kernel contexts
88403+ use a spinlock when copying into the buffer, since they cannot sleep
88404+*/
88405+static char *learn_buffer;
88406+static char *learn_buffer_user;
88407+static int learn_buffer_len;
88408+static int learn_buffer_user_len;
88409+
88410+static ssize_t
88411+read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
88412+{
88413+ DECLARE_WAITQUEUE(wait, current);
88414+ ssize_t retval = 0;
88415+
88416+ add_wait_queue(&learn_wait, &wait);
88417+ set_current_state(TASK_INTERRUPTIBLE);
88418+ do {
88419+ mutex_lock(&gr_learn_user_mutex);
88420+ spin_lock(&gr_learn_lock);
88421+ if (learn_buffer_len)
88422+ break;
88423+ spin_unlock(&gr_learn_lock);
88424+ mutex_unlock(&gr_learn_user_mutex);
88425+ if (file->f_flags & O_NONBLOCK) {
88426+ retval = -EAGAIN;
88427+ goto out;
88428+ }
88429+ if (signal_pending(current)) {
88430+ retval = -ERESTARTSYS;
88431+ goto out;
88432+ }
88433+
88434+ schedule();
88435+ } while (1);
88436+
88437+ memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
88438+ learn_buffer_user_len = learn_buffer_len;
88439+ retval = learn_buffer_len;
88440+ learn_buffer_len = 0;
88441+
88442+ spin_unlock(&gr_learn_lock);
88443+
88444+ if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
88445+ retval = -EFAULT;
88446+
88447+ mutex_unlock(&gr_learn_user_mutex);
88448+out:
88449+ set_current_state(TASK_RUNNING);
88450+ remove_wait_queue(&learn_wait, &wait);
88451+ return retval;
88452+}
88453+
88454+static unsigned int
88455+poll_learn(struct file * file, poll_table * wait)
88456+{
88457+ poll_wait(file, &learn_wait, wait);
88458+
88459+ if (learn_buffer_len)
88460+ return (POLLIN | POLLRDNORM);
88461+
88462+ return 0;
88463+}
88464+
88465+void
88466+gr_clear_learn_entries(void)
88467+{
88468+ char *tmp;
88469+
88470+ mutex_lock(&gr_learn_user_mutex);
88471+ spin_lock(&gr_learn_lock);
88472+ tmp = learn_buffer;
88473+ learn_buffer = NULL;
88474+ spin_unlock(&gr_learn_lock);
88475+ if (tmp)
88476+ vfree(tmp);
88477+ if (learn_buffer_user != NULL) {
88478+ vfree(learn_buffer_user);
88479+ learn_buffer_user = NULL;
88480+ }
88481+ learn_buffer_len = 0;
88482+ mutex_unlock(&gr_learn_user_mutex);
88483+
88484+ return;
88485+}
88486+
88487+void
88488+gr_add_learn_entry(const char *fmt, ...)
88489+{
88490+ va_list args;
88491+ unsigned int len;
88492+
88493+ if (!gr_learn_attached)
88494+ return;
88495+
88496+ spin_lock(&gr_learn_lock);
88497+
88498+ /* leave a gap at the end so we know when it's "full" but don't have to
88499+ compute the exact length of the string we're trying to append
88500+ */
88501+ if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
88502+ spin_unlock(&gr_learn_lock);
88503+ wake_up_interruptible(&learn_wait);
88504+ return;
88505+ }
88506+ if (learn_buffer == NULL) {
88507+ spin_unlock(&gr_learn_lock);
88508+ return;
88509+ }
88510+
88511+ va_start(args, fmt);
88512+ len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
88513+ va_end(args);
88514+
88515+ learn_buffer_len += len + 1;
88516+
88517+ spin_unlock(&gr_learn_lock);
88518+ wake_up_interruptible(&learn_wait);
88519+
88520+ return;
88521+}
88522+
88523+static int
88524+open_learn(struct inode *inode, struct file *file)
88525+{
88526+ if (file->f_mode & FMODE_READ && gr_learn_attached)
88527+ return -EBUSY;
88528+ if (file->f_mode & FMODE_READ) {
88529+ int retval = 0;
88530+ mutex_lock(&gr_learn_user_mutex);
88531+ if (learn_buffer == NULL)
88532+ learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
88533+ if (learn_buffer_user == NULL)
88534+ learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
88535+ if (learn_buffer == NULL) {
88536+ retval = -ENOMEM;
88537+ goto out_error;
88538+ }
88539+ if (learn_buffer_user == NULL) {
88540+ retval = -ENOMEM;
88541+ goto out_error;
88542+ }
88543+ learn_buffer_len = 0;
88544+ learn_buffer_user_len = 0;
88545+ gr_learn_attached = 1;
88546+out_error:
88547+ mutex_unlock(&gr_learn_user_mutex);
88548+ return retval;
88549+ }
88550+ return 0;
88551+}
88552+
88553+static int
88554+close_learn(struct inode *inode, struct file *file)
88555+{
88556+ if (file->f_mode & FMODE_READ) {
88557+ char *tmp = NULL;
88558+ mutex_lock(&gr_learn_user_mutex);
88559+ spin_lock(&gr_learn_lock);
88560+ tmp = learn_buffer;
88561+ learn_buffer = NULL;
88562+ spin_unlock(&gr_learn_lock);
88563+ if (tmp)
88564+ vfree(tmp);
88565+ if (learn_buffer_user != NULL) {
88566+ vfree(learn_buffer_user);
88567+ learn_buffer_user = NULL;
88568+ }
88569+ learn_buffer_len = 0;
88570+ learn_buffer_user_len = 0;
88571+ gr_learn_attached = 0;
88572+ mutex_unlock(&gr_learn_user_mutex);
88573+ }
88574+
88575+ return 0;
88576+}
88577+
88578+const struct file_operations grsec_fops = {
88579+ .read = read_learn,
88580+ .write = write_grsec_handler,
88581+ .open = open_learn,
88582+ .release = close_learn,
88583+ .poll = poll_learn,
88584+};
88585diff --git a/grsecurity/gracl_policy.c b/grsecurity/gracl_policy.c
88586new file mode 100644
88587index 0000000..0773423
88588--- /dev/null
88589+++ b/grsecurity/gracl_policy.c
88590@@ -0,0 +1,1786 @@
88591+#include <linux/kernel.h>
88592+#include <linux/module.h>
88593+#include <linux/sched.h>
88594+#include <linux/mm.h>
88595+#include <linux/file.h>
88596+#include <linux/fs.h>
88597+#include <linux/namei.h>
88598+#include <linux/mount.h>
88599+#include <linux/tty.h>
88600+#include <linux/proc_fs.h>
88601+#include <linux/lglock.h>
88602+#include <linux/slab.h>
88603+#include <linux/vmalloc.h>
88604+#include <linux/types.h>
88605+#include <linux/sysctl.h>
88606+#include <linux/netdevice.h>
88607+#include <linux/ptrace.h>
88608+#include <linux/gracl.h>
88609+#include <linux/gralloc.h>
88610+#include <linux/security.h>
88611+#include <linux/grinternal.h>
88612+#include <linux/pid_namespace.h>
88613+#include <linux/stop_machine.h>
88614+#include <linux/fdtable.h>
88615+#include <linux/percpu.h>
88616+#include <linux/lglock.h>
88617+#include <linux/hugetlb.h>
88618+#include <linux/posix-timers.h>
88619+#include "../fs/mount.h"
88620+
88621+#include <asm/uaccess.h>
88622+#include <asm/errno.h>
88623+#include <asm/mman.h>
88624+
88625+extern struct gr_policy_state *polstate;
88626+
88627+#define FOR_EACH_ROLE_START(role) \
88628+ role = polstate->role_list; \
88629+ while (role) {
88630+
88631+#define FOR_EACH_ROLE_END(role) \
88632+ role = role->prev; \
88633+ }
88634+
88635+struct path gr_real_root;
88636+
88637+extern struct gr_alloc_state *current_alloc_state;
88638+
88639+u16 acl_sp_role_value;
88640+
88641+static DEFINE_MUTEX(gr_dev_mutex);
88642+
88643+extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
88644+extern void gr_clear_learn_entries(void);
88645+
88646+struct gr_arg *gr_usermode __read_only;
88647+unsigned char *gr_system_salt __read_only;
88648+unsigned char *gr_system_sum __read_only;
88649+
88650+static unsigned int gr_auth_attempts = 0;
88651+static unsigned long gr_auth_expires = 0UL;
88652+
88653+struct acl_object_label *fakefs_obj_rw;
88654+struct acl_object_label *fakefs_obj_rwx;
88655+
88656+extern int gr_init_uidset(void);
88657+extern void gr_free_uidset(void);
88658+extern void gr_remove_uid(uid_t uid);
88659+extern int gr_find_uid(uid_t uid);
88660+
88661+extern struct acl_subject_label *__gr_get_subject_for_task(const struct gr_policy_state *state, struct task_struct *task, const char *filename, int fallback);
88662+extern void __gr_apply_subject_to_task(struct gr_policy_state *state, struct task_struct *task, struct acl_subject_label *subj);
88663+extern int gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb);
88664+extern void __insert_inodev_entry(const struct gr_policy_state *state, struct inodev_entry *entry);
88665+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);
88666+extern void insert_acl_obj_label(struct acl_object_label *obj, struct acl_subject_label *subj);
88667+extern void insert_acl_subj_label(struct acl_subject_label *obj, struct acl_role_label *role);
88668+extern struct name_entry * __lookup_name_entry(const struct gr_policy_state *state, const char *name);
88669+extern char *gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt);
88670+extern struct acl_subject_label *lookup_acl_subj_label(const u64 ino, const dev_t dev, const struct acl_role_label *role);
88671+extern struct acl_subject_label *lookup_acl_subj_label_deleted(const u64 ino, const dev_t dev, const struct acl_role_label *role);
88672+extern void assign_special_role(const char *rolename);
88673+extern struct acl_subject_label *chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt, const struct acl_role_label *role);
88674+extern int gr_rbac_disable(void *unused);
88675+extern void gr_enable_rbac_system(void);
88676+
88677+static int copy_acl_object_label_normal(struct acl_object_label *obj, const struct acl_object_label *userp)
88678+{
88679+ if (copy_from_user(obj, userp, sizeof(struct acl_object_label)))
88680+ return -EFAULT;
88681+
88682+ return 0;
88683+}
88684+
88685+static int copy_acl_ip_label_normal(struct acl_ip_label *ip, const struct acl_ip_label *userp)
88686+{
88687+ if (copy_from_user(ip, userp, sizeof(struct acl_ip_label)))
88688+ return -EFAULT;
88689+
88690+ return 0;
88691+}
88692+
88693+static int copy_acl_subject_label_normal(struct acl_subject_label *subj, const struct acl_subject_label *userp)
88694+{
88695+ if (copy_from_user(subj, userp, sizeof(struct acl_subject_label)))
88696+ return -EFAULT;
88697+
88698+ return 0;
88699+}
88700+
88701+static int copy_acl_role_label_normal(struct acl_role_label *role, const struct acl_role_label *userp)
88702+{
88703+ if (copy_from_user(role, userp, sizeof(struct acl_role_label)))
88704+ return -EFAULT;
88705+
88706+ return 0;
88707+}
88708+
88709+static int copy_role_allowed_ip_normal(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
88710+{
88711+ if (copy_from_user(roleip, userp, sizeof(struct role_allowed_ip)))
88712+ return -EFAULT;
88713+
88714+ return 0;
88715+}
88716+
88717+static int copy_sprole_pw_normal(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
88718+{
88719+ if (copy_from_user(pw, userp + idx, sizeof(struct sprole_pw)))
88720+ return -EFAULT;
88721+
88722+ return 0;
88723+}
88724+
88725+static int copy_gr_hash_struct_normal(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
88726+{
88727+ if (copy_from_user(hash, userp, sizeof(struct gr_hash_struct)))
88728+ return -EFAULT;
88729+
88730+ return 0;
88731+}
88732+
88733+static int copy_role_transition_normal(struct role_transition *trans, const struct role_transition *userp)
88734+{
88735+ if (copy_from_user(trans, userp, sizeof(struct role_transition)))
88736+ return -EFAULT;
88737+
88738+ return 0;
88739+}
88740+
88741+int copy_pointer_from_array_normal(void *ptr, unsigned long idx, const void *userp)
88742+{
88743+ if (copy_from_user(ptr, userp + (idx * sizeof(void *)), sizeof(void *)))
88744+ return -EFAULT;
88745+
88746+ return 0;
88747+}
88748+
88749+static int copy_gr_arg_wrapper_normal(const char __user *buf, struct gr_arg_wrapper *uwrap)
88750+{
88751+ if (copy_from_user(uwrap, buf, sizeof (struct gr_arg_wrapper)))
88752+ return -EFAULT;
88753+
88754+ if ((uwrap->version != GRSECURITY_VERSION) ||
88755+ (uwrap->size != sizeof(struct gr_arg)))
88756+ return -EINVAL;
88757+
88758+ return 0;
88759+}
88760+
88761+static int copy_gr_arg_normal(const struct gr_arg __user *buf, struct gr_arg *arg)
88762+{
88763+ if (copy_from_user(arg, buf, sizeof (struct gr_arg)))
88764+ return -EFAULT;
88765+
88766+ return 0;
88767+}
88768+
88769+static size_t get_gr_arg_wrapper_size_normal(void)
88770+{
88771+ return sizeof(struct gr_arg_wrapper);
88772+}
88773+
88774+#ifdef CONFIG_COMPAT
88775+extern int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap);
88776+extern int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg);
88777+extern int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp);
88778+extern int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp);
88779+extern int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp);
88780+extern int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp);
88781+extern int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp);
88782+extern int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp);
88783+extern int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp);
88784+extern int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp);
88785+extern int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp);
88786+extern size_t get_gr_arg_wrapper_size_compat(void);
88787+
88788+int (* copy_gr_arg_wrapper)(const char *buf, struct gr_arg_wrapper *uwrap) __read_only;
88789+int (* copy_gr_arg)(const struct gr_arg *buf, struct gr_arg *arg) __read_only;
88790+int (* copy_acl_object_label)(struct acl_object_label *obj, const struct acl_object_label *userp) __read_only;
88791+int (* copy_acl_subject_label)(struct acl_subject_label *subj, const struct acl_subject_label *userp) __read_only;
88792+int (* copy_acl_role_label)(struct acl_role_label *role, const struct acl_role_label *userp) __read_only;
88793+int (* copy_acl_ip_label)(struct acl_ip_label *ip, const struct acl_ip_label *userp) __read_only;
88794+int (* copy_pointer_from_array)(void *ptr, unsigned long idx, const void *userp) __read_only;
88795+int (* copy_sprole_pw)(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp) __read_only;
88796+int (* copy_gr_hash_struct)(struct gr_hash_struct *hash, const struct gr_hash_struct *userp) __read_only;
88797+int (* copy_role_transition)(struct role_transition *trans, const struct role_transition *userp) __read_only;
88798+int (* copy_role_allowed_ip)(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp) __read_only;
88799+size_t (* get_gr_arg_wrapper_size)(void) __read_only;
88800+
88801+#else
88802+#define copy_gr_arg_wrapper copy_gr_arg_wrapper_normal
88803+#define copy_gr_arg copy_gr_arg_normal
88804+#define copy_gr_hash_struct copy_gr_hash_struct_normal
88805+#define copy_acl_object_label copy_acl_object_label_normal
88806+#define copy_acl_subject_label copy_acl_subject_label_normal
88807+#define copy_acl_role_label copy_acl_role_label_normal
88808+#define copy_acl_ip_label copy_acl_ip_label_normal
88809+#define copy_pointer_from_array copy_pointer_from_array_normal
88810+#define copy_sprole_pw copy_sprole_pw_normal
88811+#define copy_role_transition copy_role_transition_normal
88812+#define copy_role_allowed_ip copy_role_allowed_ip_normal
88813+#define get_gr_arg_wrapper_size get_gr_arg_wrapper_size_normal
88814+#endif
88815+
88816+static struct acl_subject_label *
88817+lookup_subject_map(const struct acl_subject_label *userp)
88818+{
88819+ unsigned int index = gr_shash(userp, polstate->subj_map_set.s_size);
88820+ struct subject_map *match;
88821+
88822+ match = polstate->subj_map_set.s_hash[index];
88823+
88824+ while (match && match->user != userp)
88825+ match = match->next;
88826+
88827+ if (match != NULL)
88828+ return match->kernel;
88829+ else
88830+ return NULL;
88831+}
88832+
88833+static void
88834+insert_subj_map_entry(struct subject_map *subjmap)
88835+{
88836+ unsigned int index = gr_shash(subjmap->user, polstate->subj_map_set.s_size);
88837+ struct subject_map **curr;
88838+
88839+ subjmap->prev = NULL;
88840+
88841+ curr = &polstate->subj_map_set.s_hash[index];
88842+ if (*curr != NULL)
88843+ (*curr)->prev = subjmap;
88844+
88845+ subjmap->next = *curr;
88846+ *curr = subjmap;
88847+
88848+ return;
88849+}
88850+
88851+static void
88852+__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
88853+{
88854+ unsigned int index =
88855+ gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), polstate->acl_role_set.r_size);
88856+ struct acl_role_label **curr;
88857+ struct acl_role_label *tmp, *tmp2;
88858+
88859+ curr = &polstate->acl_role_set.r_hash[index];
88860+
88861+ /* simple case, slot is empty, just set it to our role */
88862+ if (*curr == NULL) {
88863+ *curr = role;
88864+ } else {
88865+ /* example:
88866+ 1 -> 2 -> 3 (adding 2 -> 3 to here)
88867+ 2 -> 3
88868+ */
88869+ /* first check to see if we can already be reached via this slot */
88870+ tmp = *curr;
88871+ while (tmp && tmp != role)
88872+ tmp = tmp->next;
88873+ if (tmp == role) {
88874+ /* we don't need to add ourselves to this slot's chain */
88875+ return;
88876+ }
88877+ /* we need to add ourselves to this chain, two cases */
88878+ if (role->next == NULL) {
88879+ /* simple case, append the current chain to our role */
88880+ role->next = *curr;
88881+ *curr = role;
88882+ } else {
88883+ /* 1 -> 2 -> 3 -> 4
88884+ 2 -> 3 -> 4
88885+ 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
88886+ */
88887+ /* trickier case: walk our role's chain until we find
88888+ the role for the start of the current slot's chain */
88889+ tmp = role;
88890+ tmp2 = *curr;
88891+ while (tmp->next && tmp->next != tmp2)
88892+ tmp = tmp->next;
88893+ if (tmp->next == tmp2) {
88894+ /* from example above, we found 3, so just
88895+ replace this slot's chain with ours */
88896+ *curr = role;
88897+ } else {
88898+ /* we didn't find a subset of our role's chain
88899+ in the current slot's chain, so append their
88900+ chain to ours, and set us as the first role in
88901+ the slot's chain
88902+
88903+ we could fold this case with the case above,
88904+ but making it explicit for clarity
88905+ */
88906+ tmp->next = tmp2;
88907+ *curr = role;
88908+ }
88909+ }
88910+ }
88911+
88912+ return;
88913+}
88914+
88915+static void
88916+insert_acl_role_label(struct acl_role_label *role)
88917+{
88918+ int i;
88919+
88920+ if (polstate->role_list == NULL) {
88921+ polstate->role_list = role;
88922+ role->prev = NULL;
88923+ } else {
88924+ role->prev = polstate->role_list;
88925+ polstate->role_list = role;
88926+ }
88927+
88928+ /* used for hash chains */
88929+ role->next = NULL;
88930+
88931+ if (role->roletype & GR_ROLE_DOMAIN) {
88932+ for (i = 0; i < role->domain_child_num; i++)
88933+ __insert_acl_role_label(role, role->domain_children[i]);
88934+ } else
88935+ __insert_acl_role_label(role, role->uidgid);
88936+}
88937+
88938+static int
88939+insert_name_entry(char *name, const u64 inode, const dev_t device, __u8 deleted)
88940+{
88941+ struct name_entry **curr, *nentry;
88942+ struct inodev_entry *ientry;
88943+ unsigned int len = strlen(name);
88944+ unsigned int key = full_name_hash(name, len);
88945+ unsigned int index = key % polstate->name_set.n_size;
88946+
88947+ curr = &polstate->name_set.n_hash[index];
88948+
88949+ while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
88950+ curr = &((*curr)->next);
88951+
88952+ if (*curr != NULL)
88953+ return 1;
88954+
88955+ nentry = acl_alloc(sizeof (struct name_entry));
88956+ if (nentry == NULL)
88957+ return 0;
88958+ ientry = acl_alloc(sizeof (struct inodev_entry));
88959+ if (ientry == NULL)
88960+ return 0;
88961+ ientry->nentry = nentry;
88962+
88963+ nentry->key = key;
88964+ nentry->name = name;
88965+ nentry->inode = inode;
88966+ nentry->device = device;
88967+ nentry->len = len;
88968+ nentry->deleted = deleted;
88969+
88970+ nentry->prev = NULL;
88971+ curr = &polstate->name_set.n_hash[index];
88972+ if (*curr != NULL)
88973+ (*curr)->prev = nentry;
88974+ nentry->next = *curr;
88975+ *curr = nentry;
88976+
88977+ /* insert us into the table searchable by inode/dev */
88978+ __insert_inodev_entry(polstate, ientry);
88979+
88980+ return 1;
88981+}
88982+
88983+/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
88984+
88985+static void *
88986+create_table(__u32 * len, int elementsize)
88987+{
88988+ unsigned int table_sizes[] = {
88989+ 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
88990+ 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
88991+ 4194301, 8388593, 16777213, 33554393, 67108859
88992+ };
88993+ void *newtable = NULL;
88994+ unsigned int pwr = 0;
88995+
88996+ while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
88997+ table_sizes[pwr] <= *len)
88998+ pwr++;
88999+
89000+ if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
89001+ return newtable;
89002+
89003+ if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
89004+ newtable =
89005+ kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
89006+ else
89007+ newtable = vmalloc(table_sizes[pwr] * elementsize);
89008+
89009+ *len = table_sizes[pwr];
89010+
89011+ return newtable;
89012+}
89013+
89014+static int
89015+init_variables(const struct gr_arg *arg, bool reload)
89016+{
89017+ struct task_struct *reaper = init_pid_ns.child_reaper;
89018+ unsigned int stacksize;
89019+
89020+ polstate->subj_map_set.s_size = arg->role_db.num_subjects;
89021+ polstate->acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
89022+ polstate->name_set.n_size = arg->role_db.num_objects;
89023+ polstate->inodev_set.i_size = arg->role_db.num_objects;
89024+
89025+ if (!polstate->subj_map_set.s_size || !polstate->acl_role_set.r_size ||
89026+ !polstate->name_set.n_size || !polstate->inodev_set.i_size)
89027+ return 1;
89028+
89029+ if (!reload) {
89030+ if (!gr_init_uidset())
89031+ return 1;
89032+ }
89033+
89034+ /* set up the stack that holds allocation info */
89035+
89036+ stacksize = arg->role_db.num_pointers + 5;
89037+
89038+ if (!acl_alloc_stack_init(stacksize))
89039+ return 1;
89040+
89041+ if (!reload) {
89042+ /* grab reference for the real root dentry and vfsmount */
89043+ get_fs_root(reaper->fs, &gr_real_root);
89044+
89045+#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
89046+ printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", gr_get_dev_from_dentry(gr_real_root.dentry), gr_get_ino_from_dentry(gr_real_root.dentry));
89047+#endif
89048+
89049+ fakefs_obj_rw = kzalloc(sizeof(struct acl_object_label), GFP_KERNEL);
89050+ if (fakefs_obj_rw == NULL)
89051+ return 1;
89052+ fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
89053+
89054+ fakefs_obj_rwx = kzalloc(sizeof(struct acl_object_label), GFP_KERNEL);
89055+ if (fakefs_obj_rwx == NULL)
89056+ return 1;
89057+ fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
89058+ }
89059+
89060+ polstate->subj_map_set.s_hash =
89061+ (struct subject_map **) create_table(&polstate->subj_map_set.s_size, sizeof(void *));
89062+ polstate->acl_role_set.r_hash =
89063+ (struct acl_role_label **) create_table(&polstate->acl_role_set.r_size, sizeof(void *));
89064+ polstate->name_set.n_hash = (struct name_entry **) create_table(&polstate->name_set.n_size, sizeof(void *));
89065+ polstate->inodev_set.i_hash =
89066+ (struct inodev_entry **) create_table(&polstate->inodev_set.i_size, sizeof(void *));
89067+
89068+ if (!polstate->subj_map_set.s_hash || !polstate->acl_role_set.r_hash ||
89069+ !polstate->name_set.n_hash || !polstate->inodev_set.i_hash)
89070+ return 1;
89071+
89072+ memset(polstate->subj_map_set.s_hash, 0,
89073+ sizeof(struct subject_map *) * polstate->subj_map_set.s_size);
89074+ memset(polstate->acl_role_set.r_hash, 0,
89075+ sizeof (struct acl_role_label *) * polstate->acl_role_set.r_size);
89076+ memset(polstate->name_set.n_hash, 0,
89077+ sizeof (struct name_entry *) * polstate->name_set.n_size);
89078+ memset(polstate->inodev_set.i_hash, 0,
89079+ sizeof (struct inodev_entry *) * polstate->inodev_set.i_size);
89080+
89081+ return 0;
89082+}
89083+
89084+/* free information not needed after startup
89085+ currently contains user->kernel pointer mappings for subjects
89086+*/
89087+
89088+static void
89089+free_init_variables(void)
89090+{
89091+ __u32 i;
89092+
89093+ if (polstate->subj_map_set.s_hash) {
89094+ for (i = 0; i < polstate->subj_map_set.s_size; i++) {
89095+ if (polstate->subj_map_set.s_hash[i]) {
89096+ kfree(polstate->subj_map_set.s_hash[i]);
89097+ polstate->subj_map_set.s_hash[i] = NULL;
89098+ }
89099+ }
89100+
89101+ if ((polstate->subj_map_set.s_size * sizeof (struct subject_map *)) <=
89102+ PAGE_SIZE)
89103+ kfree(polstate->subj_map_set.s_hash);
89104+ else
89105+ vfree(polstate->subj_map_set.s_hash);
89106+ }
89107+
89108+ return;
89109+}
89110+
89111+static void
89112+free_variables(bool reload)
89113+{
89114+ struct acl_subject_label *s;
89115+ struct acl_role_label *r;
89116+ struct task_struct *task, *task2;
89117+ unsigned int x;
89118+
89119+ if (!reload) {
89120+ gr_clear_learn_entries();
89121+
89122+ read_lock(&tasklist_lock);
89123+ do_each_thread(task2, task) {
89124+ task->acl_sp_role = 0;
89125+ task->acl_role_id = 0;
89126+ task->inherited = 0;
89127+ task->acl = NULL;
89128+ task->role = NULL;
89129+ } while_each_thread(task2, task);
89130+ read_unlock(&tasklist_lock);
89131+
89132+ kfree(fakefs_obj_rw);
89133+ fakefs_obj_rw = NULL;
89134+ kfree(fakefs_obj_rwx);
89135+ fakefs_obj_rwx = NULL;
89136+
89137+ /* release the reference to the real root dentry and vfsmount */
89138+ path_put(&gr_real_root);
89139+ memset(&gr_real_root, 0, sizeof(gr_real_root));
89140+ }
89141+
89142+ /* free all object hash tables */
89143+
89144+ FOR_EACH_ROLE_START(r)
89145+ if (r->subj_hash == NULL)
89146+ goto next_role;
89147+ FOR_EACH_SUBJECT_START(r, s, x)
89148+ if (s->obj_hash == NULL)
89149+ break;
89150+ if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
89151+ kfree(s->obj_hash);
89152+ else
89153+ vfree(s->obj_hash);
89154+ FOR_EACH_SUBJECT_END(s, x)
89155+ FOR_EACH_NESTED_SUBJECT_START(r, s)
89156+ if (s->obj_hash == NULL)
89157+ break;
89158+ if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
89159+ kfree(s->obj_hash);
89160+ else
89161+ vfree(s->obj_hash);
89162+ FOR_EACH_NESTED_SUBJECT_END(s)
89163+ if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
89164+ kfree(r->subj_hash);
89165+ else
89166+ vfree(r->subj_hash);
89167+ r->subj_hash = NULL;
89168+next_role:
89169+ FOR_EACH_ROLE_END(r)
89170+
89171+ acl_free_all();
89172+
89173+ if (polstate->acl_role_set.r_hash) {
89174+ if ((polstate->acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
89175+ PAGE_SIZE)
89176+ kfree(polstate->acl_role_set.r_hash);
89177+ else
89178+ vfree(polstate->acl_role_set.r_hash);
89179+ }
89180+ if (polstate->name_set.n_hash) {
89181+ if ((polstate->name_set.n_size * sizeof (struct name_entry *)) <=
89182+ PAGE_SIZE)
89183+ kfree(polstate->name_set.n_hash);
89184+ else
89185+ vfree(polstate->name_set.n_hash);
89186+ }
89187+
89188+ if (polstate->inodev_set.i_hash) {
89189+ if ((polstate->inodev_set.i_size * sizeof (struct inodev_entry *)) <=
89190+ PAGE_SIZE)
89191+ kfree(polstate->inodev_set.i_hash);
89192+ else
89193+ vfree(polstate->inodev_set.i_hash);
89194+ }
89195+
89196+ if (!reload)
89197+ gr_free_uidset();
89198+
89199+ memset(&polstate->name_set, 0, sizeof (struct name_db));
89200+ memset(&polstate->inodev_set, 0, sizeof (struct inodev_db));
89201+ memset(&polstate->acl_role_set, 0, sizeof (struct acl_role_db));
89202+ memset(&polstate->subj_map_set, 0, sizeof (struct acl_subj_map_db));
89203+
89204+ polstate->default_role = NULL;
89205+ polstate->kernel_role = NULL;
89206+ polstate->role_list = NULL;
89207+
89208+ return;
89209+}
89210+
89211+static struct acl_subject_label *
89212+do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
89213+
89214+static int alloc_and_copy_string(char **name, unsigned int maxlen)
89215+{
89216+ unsigned int len = strnlen_user(*name, maxlen);
89217+ char *tmp;
89218+
89219+ if (!len || len >= maxlen)
89220+ return -EINVAL;
89221+
89222+ if ((tmp = (char *) acl_alloc(len)) == NULL)
89223+ return -ENOMEM;
89224+
89225+ if (copy_from_user(tmp, *name, len))
89226+ return -EFAULT;
89227+
89228+ tmp[len-1] = '\0';
89229+ *name = tmp;
89230+
89231+ return 0;
89232+}
89233+
89234+static int
89235+copy_user_glob(struct acl_object_label *obj)
89236+{
89237+ struct acl_object_label *g_tmp, **guser;
89238+ int error;
89239+
89240+ if (obj->globbed == NULL)
89241+ return 0;
89242+
89243+ guser = &obj->globbed;
89244+ while (*guser) {
89245+ g_tmp = (struct acl_object_label *)
89246+ acl_alloc(sizeof (struct acl_object_label));
89247+ if (g_tmp == NULL)
89248+ return -ENOMEM;
89249+
89250+ if (copy_acl_object_label(g_tmp, *guser))
89251+ return -EFAULT;
89252+
89253+ error = alloc_and_copy_string(&g_tmp->filename, PATH_MAX);
89254+ if (error)
89255+ return error;
89256+
89257+ *guser = g_tmp;
89258+ guser = &(g_tmp->next);
89259+ }
89260+
89261+ return 0;
89262+}
89263+
89264+static int
89265+copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
89266+ struct acl_role_label *role)
89267+{
89268+ struct acl_object_label *o_tmp;
89269+ int ret;
89270+
89271+ while (userp) {
89272+ if ((o_tmp = (struct acl_object_label *)
89273+ acl_alloc(sizeof (struct acl_object_label))) == NULL)
89274+ return -ENOMEM;
89275+
89276+ if (copy_acl_object_label(o_tmp, userp))
89277+ return -EFAULT;
89278+
89279+ userp = o_tmp->prev;
89280+
89281+ ret = alloc_and_copy_string(&o_tmp->filename, PATH_MAX);
89282+ if (ret)
89283+ return ret;
89284+
89285+ insert_acl_obj_label(o_tmp, subj);
89286+ if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
89287+ o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
89288+ return -ENOMEM;
89289+
89290+ ret = copy_user_glob(o_tmp);
89291+ if (ret)
89292+ return ret;
89293+
89294+ if (o_tmp->nested) {
89295+ int already_copied;
89296+
89297+ o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
89298+ if (IS_ERR(o_tmp->nested))
89299+ return PTR_ERR(o_tmp->nested);
89300+
89301+ /* insert into nested subject list if we haven't copied this one yet
89302+ to prevent duplicate entries */
89303+ if (!already_copied) {
89304+ o_tmp->nested->next = role->hash->first;
89305+ role->hash->first = o_tmp->nested;
89306+ }
89307+ }
89308+ }
89309+
89310+ return 0;
89311+}
89312+
89313+static __u32
89314+count_user_subjs(struct acl_subject_label *userp)
89315+{
89316+ struct acl_subject_label s_tmp;
89317+ __u32 num = 0;
89318+
89319+ while (userp) {
89320+ if (copy_acl_subject_label(&s_tmp, userp))
89321+ break;
89322+
89323+ userp = s_tmp.prev;
89324+ }
89325+
89326+ return num;
89327+}
89328+
89329+static int
89330+copy_user_allowedips(struct acl_role_label *rolep)
89331+{
89332+ struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
89333+
89334+ ruserip = rolep->allowed_ips;
89335+
89336+ while (ruserip) {
89337+ rlast = rtmp;
89338+
89339+ if ((rtmp = (struct role_allowed_ip *)
89340+ acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
89341+ return -ENOMEM;
89342+
89343+ if (copy_role_allowed_ip(rtmp, ruserip))
89344+ return -EFAULT;
89345+
89346+ ruserip = rtmp->prev;
89347+
89348+ if (!rlast) {
89349+ rtmp->prev = NULL;
89350+ rolep->allowed_ips = rtmp;
89351+ } else {
89352+ rlast->next = rtmp;
89353+ rtmp->prev = rlast;
89354+ }
89355+
89356+ if (!ruserip)
89357+ rtmp->next = NULL;
89358+ }
89359+
89360+ return 0;
89361+}
89362+
89363+static int
89364+copy_user_transitions(struct acl_role_label *rolep)
89365+{
89366+ struct role_transition *rusertp, *rtmp = NULL, *rlast;
89367+ int error;
89368+
89369+ rusertp = rolep->transitions;
89370+
89371+ while (rusertp) {
89372+ rlast = rtmp;
89373+
89374+ if ((rtmp = (struct role_transition *)
89375+ acl_alloc(sizeof (struct role_transition))) == NULL)
89376+ return -ENOMEM;
89377+
89378+ if (copy_role_transition(rtmp, rusertp))
89379+ return -EFAULT;
89380+
89381+ rusertp = rtmp->prev;
89382+
89383+ error = alloc_and_copy_string(&rtmp->rolename, GR_SPROLE_LEN);
89384+ if (error)
89385+ return error;
89386+
89387+ if (!rlast) {
89388+ rtmp->prev = NULL;
89389+ rolep->transitions = rtmp;
89390+ } else {
89391+ rlast->next = rtmp;
89392+ rtmp->prev = rlast;
89393+ }
89394+
89395+ if (!rusertp)
89396+ rtmp->next = NULL;
89397+ }
89398+
89399+ return 0;
89400+}
89401+
89402+static __u32 count_user_objs(const struct acl_object_label __user *userp)
89403+{
89404+ struct acl_object_label o_tmp;
89405+ __u32 num = 0;
89406+
89407+ while (userp) {
89408+ if (copy_acl_object_label(&o_tmp, userp))
89409+ break;
89410+
89411+ userp = o_tmp.prev;
89412+ num++;
89413+ }
89414+
89415+ return num;
89416+}
89417+
89418+static struct acl_subject_label *
89419+do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
89420+{
89421+ struct acl_subject_label *s_tmp = NULL, *s_tmp2;
89422+ __u32 num_objs;
89423+ struct acl_ip_label **i_tmp, *i_utmp2;
89424+ struct gr_hash_struct ghash;
89425+ struct subject_map *subjmap;
89426+ unsigned int i_num;
89427+ int err;
89428+
89429+ if (already_copied != NULL)
89430+ *already_copied = 0;
89431+
89432+ s_tmp = lookup_subject_map(userp);
89433+
89434+ /* we've already copied this subject into the kernel, just return
89435+ the reference to it, and don't copy it over again
89436+ */
89437+ if (s_tmp) {
89438+ if (already_copied != NULL)
89439+ *already_copied = 1;
89440+ return(s_tmp);
89441+ }
89442+
89443+ if ((s_tmp = (struct acl_subject_label *)
89444+ acl_alloc(sizeof (struct acl_subject_label))) == NULL)
89445+ return ERR_PTR(-ENOMEM);
89446+
89447+ subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
89448+ if (subjmap == NULL)
89449+ return ERR_PTR(-ENOMEM);
89450+
89451+ subjmap->user = userp;
89452+ subjmap->kernel = s_tmp;
89453+ insert_subj_map_entry(subjmap);
89454+
89455+ if (copy_acl_subject_label(s_tmp, userp))
89456+ return ERR_PTR(-EFAULT);
89457+
89458+ err = alloc_and_copy_string(&s_tmp->filename, PATH_MAX);
89459+ if (err)
89460+ return ERR_PTR(err);
89461+
89462+ if (!strcmp(s_tmp->filename, "/"))
89463+ role->root_label = s_tmp;
89464+
89465+ if (copy_gr_hash_struct(&ghash, s_tmp->hash))
89466+ return ERR_PTR(-EFAULT);
89467+
89468+ /* copy user and group transition tables */
89469+
89470+ if (s_tmp->user_trans_num) {
89471+ uid_t *uidlist;
89472+
89473+ uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
89474+ if (uidlist == NULL)
89475+ return ERR_PTR(-ENOMEM);
89476+ if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
89477+ return ERR_PTR(-EFAULT);
89478+
89479+ s_tmp->user_transitions = uidlist;
89480+ }
89481+
89482+ if (s_tmp->group_trans_num) {
89483+ gid_t *gidlist;
89484+
89485+ gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
89486+ if (gidlist == NULL)
89487+ return ERR_PTR(-ENOMEM);
89488+ if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
89489+ return ERR_PTR(-EFAULT);
89490+
89491+ s_tmp->group_transitions = gidlist;
89492+ }
89493+
89494+ /* set up object hash table */
89495+ num_objs = count_user_objs(ghash.first);
89496+
89497+ s_tmp->obj_hash_size = num_objs;
89498+ s_tmp->obj_hash =
89499+ (struct acl_object_label **)
89500+ create_table(&(s_tmp->obj_hash_size), sizeof(void *));
89501+
89502+ if (!s_tmp->obj_hash)
89503+ return ERR_PTR(-ENOMEM);
89504+
89505+ memset(s_tmp->obj_hash, 0,
89506+ s_tmp->obj_hash_size *
89507+ sizeof (struct acl_object_label *));
89508+
89509+ /* add in objects */
89510+ err = copy_user_objs(ghash.first, s_tmp, role);
89511+
89512+ if (err)
89513+ return ERR_PTR(err);
89514+
89515+ /* set pointer for parent subject */
89516+ if (s_tmp->parent_subject) {
89517+ s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
89518+
89519+ if (IS_ERR(s_tmp2))
89520+ return s_tmp2;
89521+
89522+ s_tmp->parent_subject = s_tmp2;
89523+ }
89524+
89525+ /* add in ip acls */
89526+
89527+ if (!s_tmp->ip_num) {
89528+ s_tmp->ips = NULL;
89529+ goto insert;
89530+ }
89531+
89532+ i_tmp =
89533+ (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
89534+ sizeof (struct acl_ip_label *));
89535+
89536+ if (!i_tmp)
89537+ return ERR_PTR(-ENOMEM);
89538+
89539+ for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
89540+ *(i_tmp + i_num) =
89541+ (struct acl_ip_label *)
89542+ acl_alloc(sizeof (struct acl_ip_label));
89543+ if (!*(i_tmp + i_num))
89544+ return ERR_PTR(-ENOMEM);
89545+
89546+ if (copy_pointer_from_array(&i_utmp2, i_num, s_tmp->ips))
89547+ return ERR_PTR(-EFAULT);
89548+
89549+ if (copy_acl_ip_label(*(i_tmp + i_num), i_utmp2))
89550+ return ERR_PTR(-EFAULT);
89551+
89552+ if ((*(i_tmp + i_num))->iface == NULL)
89553+ continue;
89554+
89555+ err = alloc_and_copy_string(&(*(i_tmp + i_num))->iface, IFNAMSIZ);
89556+ if (err)
89557+ return ERR_PTR(err);
89558+ }
89559+
89560+ s_tmp->ips = i_tmp;
89561+
89562+insert:
89563+ if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
89564+ s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
89565+ return ERR_PTR(-ENOMEM);
89566+
89567+ return s_tmp;
89568+}
89569+
89570+static int
89571+copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
89572+{
89573+ struct acl_subject_label s_pre;
89574+ struct acl_subject_label * ret;
89575+ int err;
89576+
89577+ while (userp) {
89578+ if (copy_acl_subject_label(&s_pre, userp))
89579+ return -EFAULT;
89580+
89581+ ret = do_copy_user_subj(userp, role, NULL);
89582+
89583+ err = PTR_ERR(ret);
89584+ if (IS_ERR(ret))
89585+ return err;
89586+
89587+ insert_acl_subj_label(ret, role);
89588+
89589+ userp = s_pre.prev;
89590+ }
89591+
89592+ return 0;
89593+}
89594+
89595+static int
89596+copy_user_acl(struct gr_arg *arg)
89597+{
89598+ struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
89599+ struct acl_subject_label *subj_list;
89600+ struct sprole_pw *sptmp;
89601+ struct gr_hash_struct *ghash;
89602+ uid_t *domainlist;
89603+ unsigned int r_num;
89604+ int err = 0;
89605+ __u16 i;
89606+ __u32 num_subjs;
89607+
89608+ /* we need a default and kernel role */
89609+ if (arg->role_db.num_roles < 2)
89610+ return -EINVAL;
89611+
89612+ /* copy special role authentication info from userspace */
89613+
89614+ polstate->num_sprole_pws = arg->num_sprole_pws;
89615+ polstate->acl_special_roles = (struct sprole_pw **) acl_alloc_num(polstate->num_sprole_pws, sizeof(struct sprole_pw *));
89616+
89617+ if (!polstate->acl_special_roles && polstate->num_sprole_pws)
89618+ return -ENOMEM;
89619+
89620+ for (i = 0; i < polstate->num_sprole_pws; i++) {
89621+ sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
89622+ if (!sptmp)
89623+ return -ENOMEM;
89624+ if (copy_sprole_pw(sptmp, i, arg->sprole_pws))
89625+ return -EFAULT;
89626+
89627+ err = alloc_and_copy_string((char **)&sptmp->rolename, GR_SPROLE_LEN);
89628+ if (err)
89629+ return err;
89630+
89631+#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
89632+ printk(KERN_ALERT "Copying special role %s\n", sptmp->rolename);
89633+#endif
89634+
89635+ polstate->acl_special_roles[i] = sptmp;
89636+ }
89637+
89638+ r_utmp = (struct acl_role_label **) arg->role_db.r_table;
89639+
89640+ for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
89641+ r_tmp = acl_alloc(sizeof (struct acl_role_label));
89642+
89643+ if (!r_tmp)
89644+ return -ENOMEM;
89645+
89646+ if (copy_pointer_from_array(&r_utmp2, r_num, r_utmp))
89647+ return -EFAULT;
89648+
89649+ if (copy_acl_role_label(r_tmp, r_utmp2))
89650+ return -EFAULT;
89651+
89652+ err = alloc_and_copy_string(&r_tmp->rolename, GR_SPROLE_LEN);
89653+ if (err)
89654+ return err;
89655+
89656+ if (!strcmp(r_tmp->rolename, "default")
89657+ && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
89658+ polstate->default_role = r_tmp;
89659+ } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
89660+ polstate->kernel_role = r_tmp;
89661+ }
89662+
89663+ if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
89664+ return -ENOMEM;
89665+
89666+ if (copy_gr_hash_struct(ghash, r_tmp->hash))
89667+ return -EFAULT;
89668+
89669+ r_tmp->hash = ghash;
89670+
89671+ num_subjs = count_user_subjs(r_tmp->hash->first);
89672+
89673+ r_tmp->subj_hash_size = num_subjs;
89674+ r_tmp->subj_hash =
89675+ (struct acl_subject_label **)
89676+ create_table(&(r_tmp->subj_hash_size), sizeof(void *));
89677+
89678+ if (!r_tmp->subj_hash)
89679+ return -ENOMEM;
89680+
89681+ err = copy_user_allowedips(r_tmp);
89682+ if (err)
89683+ return err;
89684+
89685+ /* copy domain info */
89686+ if (r_tmp->domain_children != NULL) {
89687+ domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
89688+ if (domainlist == NULL)
89689+ return -ENOMEM;
89690+
89691+ if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
89692+ return -EFAULT;
89693+
89694+ r_tmp->domain_children = domainlist;
89695+ }
89696+
89697+ err = copy_user_transitions(r_tmp);
89698+ if (err)
89699+ return err;
89700+
89701+ memset(r_tmp->subj_hash, 0,
89702+ r_tmp->subj_hash_size *
89703+ sizeof (struct acl_subject_label *));
89704+
89705+ /* acquire the list of subjects, then NULL out
89706+ the list prior to parsing the subjects for this role,
89707+ as during this parsing the list is replaced with a list
89708+ of *nested* subjects for the role
89709+ */
89710+ subj_list = r_tmp->hash->first;
89711+
89712+ /* set nested subject list to null */
89713+ r_tmp->hash->first = NULL;
89714+
89715+ err = copy_user_subjs(subj_list, r_tmp);
89716+
89717+ if (err)
89718+ return err;
89719+
89720+ insert_acl_role_label(r_tmp);
89721+ }
89722+
89723+ if (polstate->default_role == NULL || polstate->kernel_role == NULL)
89724+ return -EINVAL;
89725+
89726+ return err;
89727+}
89728+
89729+static int gracl_reload_apply_policies(void *reload)
89730+{
89731+ struct gr_reload_state *reload_state = (struct gr_reload_state *)reload;
89732+ struct task_struct *task, *task2;
89733+ struct acl_role_label *role, *rtmp;
89734+ struct acl_subject_label *subj;
89735+ const struct cred *cred;
89736+ int role_applied;
89737+ int ret = 0;
89738+
89739+ memcpy(&reload_state->oldpolicy, reload_state->oldpolicy_ptr, sizeof(struct gr_policy_state));
89740+ memcpy(&reload_state->oldalloc, reload_state->oldalloc_ptr, sizeof(struct gr_alloc_state));
89741+
89742+ /* first make sure we'll be able to apply the new policy cleanly */
89743+ do_each_thread(task2, task) {
89744+ if (task->exec_file == NULL)
89745+ continue;
89746+ role_applied = 0;
89747+ if (!reload_state->oldmode && task->role->roletype & GR_ROLE_SPECIAL) {
89748+ /* preserve special roles */
89749+ FOR_EACH_ROLE_START(role)
89750+ if ((role->roletype & GR_ROLE_SPECIAL) && !strcmp(task->role->rolename, role->rolename)) {
89751+ rtmp = task->role;
89752+ task->role = role;
89753+ role_applied = 1;
89754+ break;
89755+ }
89756+ FOR_EACH_ROLE_END(role)
89757+ }
89758+ if (!role_applied) {
89759+ cred = __task_cred(task);
89760+ rtmp = task->role;
89761+ task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
89762+ }
89763+ /* this handles non-nested inherited subjects, nested subjects will still
89764+ be dropped currently */
89765+ subj = __gr_get_subject_for_task(polstate, task, task->acl->filename, 1);
89766+ task->tmpacl = __gr_get_subject_for_task(polstate, task, NULL, 1);
89767+ /* change the role back so that we've made no modifications to the policy */
89768+ task->role = rtmp;
89769+
89770+ if (subj == NULL || task->tmpacl == NULL) {
89771+ ret = -EINVAL;
89772+ goto out;
89773+ }
89774+ } while_each_thread(task2, task);
89775+
89776+ /* now actually apply the policy */
89777+
89778+ do_each_thread(task2, task) {
89779+ if (task->exec_file) {
89780+ role_applied = 0;
89781+ if (!reload_state->oldmode && task->role->roletype & GR_ROLE_SPECIAL) {
89782+ /* preserve special roles */
89783+ FOR_EACH_ROLE_START(role)
89784+ if ((role->roletype & GR_ROLE_SPECIAL) && !strcmp(task->role->rolename, role->rolename)) {
89785+ task->role = role;
89786+ role_applied = 1;
89787+ break;
89788+ }
89789+ FOR_EACH_ROLE_END(role)
89790+ }
89791+ if (!role_applied) {
89792+ cred = __task_cred(task);
89793+ task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
89794+ }
89795+ /* this handles non-nested inherited subjects, nested subjects will still
89796+ be dropped currently */
89797+ if (!reload_state->oldmode && task->inherited)
89798+ subj = __gr_get_subject_for_task(polstate, task, task->acl->filename, 1);
89799+ else {
89800+ /* looked up and tagged to the task previously */
89801+ subj = task->tmpacl;
89802+ }
89803+ /* subj will be non-null */
89804+ __gr_apply_subject_to_task(polstate, task, subj);
89805+ if (reload_state->oldmode) {
89806+ task->acl_role_id = 0;
89807+ task->acl_sp_role = 0;
89808+ task->inherited = 0;
89809+ }
89810+ } else {
89811+ // it's a kernel process
89812+ task->role = polstate->kernel_role;
89813+ task->acl = polstate->kernel_role->root_label;
89814+#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
89815+ task->acl->mode &= ~GR_PROCFIND;
89816+#endif
89817+ }
89818+ } while_each_thread(task2, task);
89819+
89820+ memcpy(reload_state->oldpolicy_ptr, &reload_state->newpolicy, sizeof(struct gr_policy_state));
89821+ memcpy(reload_state->oldalloc_ptr, &reload_state->newalloc, sizeof(struct gr_alloc_state));
89822+
89823+out:
89824+
89825+ return ret;
89826+}
89827+
89828+static int gracl_reload(struct gr_arg *args, unsigned char oldmode)
89829+{
89830+ struct gr_reload_state new_reload_state = { };
89831+ int err;
89832+
89833+ new_reload_state.oldpolicy_ptr = polstate;
89834+ new_reload_state.oldalloc_ptr = current_alloc_state;
89835+ new_reload_state.oldmode = oldmode;
89836+
89837+ current_alloc_state = &new_reload_state.newalloc;
89838+ polstate = &new_reload_state.newpolicy;
89839+
89840+ /* everything relevant is now saved off, copy in the new policy */
89841+ if (init_variables(args, true)) {
89842+ gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
89843+ err = -ENOMEM;
89844+ goto error;
89845+ }
89846+
89847+ err = copy_user_acl(args);
89848+ free_init_variables();
89849+ if (err)
89850+ goto error;
89851+ /* the new policy is copied in, with the old policy available via saved_state
89852+ first go through applying roles, making sure to preserve special roles
89853+ then apply new subjects, making sure to preserve inherited and nested subjects,
89854+ though currently only inherited subjects will be preserved
89855+ */
89856+ err = stop_machine(gracl_reload_apply_policies, &new_reload_state, NULL);
89857+ if (err)
89858+ goto error;
89859+
89860+ /* we've now applied the new policy, so restore the old policy state to free it */
89861+ polstate = &new_reload_state.oldpolicy;
89862+ current_alloc_state = &new_reload_state.oldalloc;
89863+ free_variables(true);
89864+
89865+ /* oldpolicy/oldalloc_ptr point to the new policy/alloc states as they were copied
89866+ to running_polstate/current_alloc_state inside stop_machine
89867+ */
89868+ err = 0;
89869+ goto out;
89870+error:
89871+ /* on error of loading the new policy, we'll just keep the previous
89872+ policy set around
89873+ */
89874+ free_variables(true);
89875+
89876+ /* doesn't affect runtime, but maintains consistent state */
89877+out:
89878+ polstate = new_reload_state.oldpolicy_ptr;
89879+ current_alloc_state = new_reload_state.oldalloc_ptr;
89880+
89881+ return err;
89882+}
89883+
89884+static int
89885+gracl_init(struct gr_arg *args)
89886+{
89887+ int error = 0;
89888+
89889+ memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
89890+ memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
89891+
89892+ if (init_variables(args, false)) {
89893+ gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
89894+ error = -ENOMEM;
89895+ goto out;
89896+ }
89897+
89898+ error = copy_user_acl(args);
89899+ free_init_variables();
89900+ if (error)
89901+ goto out;
89902+
89903+ error = gr_set_acls(0);
89904+ if (error)
89905+ goto out;
89906+
89907+ gr_enable_rbac_system();
89908+
89909+ return 0;
89910+
89911+out:
89912+ free_variables(false);
89913+ return error;
89914+}
89915+
89916+static int
89917+lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
89918+ unsigned char **sum)
89919+{
89920+ struct acl_role_label *r;
89921+ struct role_allowed_ip *ipp;
89922+ struct role_transition *trans;
89923+ unsigned int i;
89924+ int found = 0;
89925+ u32 curr_ip = current->signal->curr_ip;
89926+
89927+ current->signal->saved_ip = curr_ip;
89928+
89929+ /* check transition table */
89930+
89931+ for (trans = current->role->transitions; trans; trans = trans->next) {
89932+ if (!strcmp(rolename, trans->rolename)) {
89933+ found = 1;
89934+ break;
89935+ }
89936+ }
89937+
89938+ if (!found)
89939+ return 0;
89940+
89941+ /* handle special roles that do not require authentication
89942+ and check ip */
89943+
89944+ FOR_EACH_ROLE_START(r)
89945+ if (!strcmp(rolename, r->rolename) &&
89946+ (r->roletype & GR_ROLE_SPECIAL)) {
89947+ found = 0;
89948+ if (r->allowed_ips != NULL) {
89949+ for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
89950+ if ((ntohl(curr_ip) & ipp->netmask) ==
89951+ (ntohl(ipp->addr) & ipp->netmask))
89952+ found = 1;
89953+ }
89954+ } else
89955+ found = 2;
89956+ if (!found)
89957+ return 0;
89958+
89959+ if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
89960+ ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
89961+ *salt = NULL;
89962+ *sum = NULL;
89963+ return 1;
89964+ }
89965+ }
89966+ FOR_EACH_ROLE_END(r)
89967+
89968+ for (i = 0; i < polstate->num_sprole_pws; i++) {
89969+ if (!strcmp(rolename, polstate->acl_special_roles[i]->rolename)) {
89970+ *salt = polstate->acl_special_roles[i]->salt;
89971+ *sum = polstate->acl_special_roles[i]->sum;
89972+ return 1;
89973+ }
89974+ }
89975+
89976+ return 0;
89977+}
89978+
89979+int gr_check_secure_terminal(struct task_struct *task)
89980+{
89981+ struct task_struct *p, *p2, *p3;
89982+ struct files_struct *files;
89983+ struct fdtable *fdt;
89984+ struct file *our_file = NULL, *file;
89985+ struct inode *our_inode = NULL;
89986+ int i;
89987+
89988+ if (task->signal->tty == NULL)
89989+ return 1;
89990+
89991+ files = get_files_struct(task);
89992+ if (files != NULL) {
89993+ rcu_read_lock();
89994+ fdt = files_fdtable(files);
89995+ for (i=0; i < fdt->max_fds; i++) {
89996+ file = fcheck_files(files, i);
89997+ if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
89998+ get_file(file);
89999+ our_file = file;
90000+ }
90001+ }
90002+ rcu_read_unlock();
90003+ put_files_struct(files);
90004+ }
90005+
90006+ if (our_file == NULL)
90007+ return 1;
90008+
90009+ our_inode = d_backing_inode(our_file->f_path.dentry);
90010+
90011+ read_lock(&tasklist_lock);
90012+ do_each_thread(p2, p) {
90013+ files = get_files_struct(p);
90014+ if (files == NULL ||
90015+ (p->signal && p->signal->tty == task->signal->tty)) {
90016+ if (files != NULL)
90017+ put_files_struct(files);
90018+ continue;
90019+ }
90020+ rcu_read_lock();
90021+ fdt = files_fdtable(files);
90022+ for (i=0; i < fdt->max_fds; i++) {
90023+ struct inode *inode = NULL;
90024+ file = fcheck_files(files, i);
90025+ if (file)
90026+ inode = d_backing_inode(file->f_path.dentry);
90027+ if (inode && S_ISCHR(inode->i_mode) && inode->i_rdev == our_inode->i_rdev) {
90028+ p3 = task;
90029+ while (task_pid_nr(p3) > 0) {
90030+ if (p3 == p)
90031+ break;
90032+ p3 = p3->real_parent;
90033+ }
90034+ if (p3 == p)
90035+ break;
90036+ gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
90037+ gr_handle_alertkill(p);
90038+ rcu_read_unlock();
90039+ put_files_struct(files);
90040+ read_unlock(&tasklist_lock);
90041+ fput(our_file);
90042+ return 0;
90043+ }
90044+ }
90045+ rcu_read_unlock();
90046+ put_files_struct(files);
90047+ } while_each_thread(p2, p);
90048+ read_unlock(&tasklist_lock);
90049+
90050+ fput(our_file);
90051+ return 1;
90052+}
90053+
90054+ssize_t
90055+write_grsec_handler(struct file *file, const char __user * buf, size_t count, loff_t *ppos)
90056+{
90057+ struct gr_arg_wrapper uwrap;
90058+ unsigned char *sprole_salt = NULL;
90059+ unsigned char *sprole_sum = NULL;
90060+ int error = 0;
90061+ int error2 = 0;
90062+ size_t req_count = 0;
90063+ unsigned char oldmode = 0;
90064+
90065+ mutex_lock(&gr_dev_mutex);
90066+
90067+ if (gr_acl_is_enabled() && !(current->acl->mode & GR_KERNELAUTH)) {
90068+ error = -EPERM;
90069+ goto out;
90070+ }
90071+
90072+#ifdef CONFIG_COMPAT
90073+ pax_open_kernel();
90074+ if (is_compat_task()) {
90075+ copy_gr_arg_wrapper = &copy_gr_arg_wrapper_compat;
90076+ copy_gr_arg = &copy_gr_arg_compat;
90077+ copy_acl_object_label = &copy_acl_object_label_compat;
90078+ copy_acl_subject_label = &copy_acl_subject_label_compat;
90079+ copy_acl_role_label = &copy_acl_role_label_compat;
90080+ copy_acl_ip_label = &copy_acl_ip_label_compat;
90081+ copy_role_allowed_ip = &copy_role_allowed_ip_compat;
90082+ copy_role_transition = &copy_role_transition_compat;
90083+ copy_sprole_pw = &copy_sprole_pw_compat;
90084+ copy_gr_hash_struct = &copy_gr_hash_struct_compat;
90085+ copy_pointer_from_array = &copy_pointer_from_array_compat;
90086+ get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_compat;
90087+ } else {
90088+ copy_gr_arg_wrapper = &copy_gr_arg_wrapper_normal;
90089+ copy_gr_arg = &copy_gr_arg_normal;
90090+ copy_acl_object_label = &copy_acl_object_label_normal;
90091+ copy_acl_subject_label = &copy_acl_subject_label_normal;
90092+ copy_acl_role_label = &copy_acl_role_label_normal;
90093+ copy_acl_ip_label = &copy_acl_ip_label_normal;
90094+ copy_role_allowed_ip = &copy_role_allowed_ip_normal;
90095+ copy_role_transition = &copy_role_transition_normal;
90096+ copy_sprole_pw = &copy_sprole_pw_normal;
90097+ copy_gr_hash_struct = &copy_gr_hash_struct_normal;
90098+ copy_pointer_from_array = &copy_pointer_from_array_normal;
90099+ get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_normal;
90100+ }
90101+ pax_close_kernel();
90102+#endif
90103+
90104+ req_count = get_gr_arg_wrapper_size();
90105+
90106+ if (count != req_count) {
90107+ gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)req_count);
90108+ error = -EINVAL;
90109+ goto out;
90110+ }
90111+
90112+
90113+ if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
90114+ gr_auth_expires = 0;
90115+ gr_auth_attempts = 0;
90116+ }
90117+
90118+ error = copy_gr_arg_wrapper(buf, &uwrap);
90119+ if (error)
90120+ goto out;
90121+
90122+ error = copy_gr_arg(uwrap.arg, gr_usermode);
90123+ if (error)
90124+ goto out;
90125+
90126+ if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
90127+ gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
90128+ time_after(gr_auth_expires, get_seconds())) {
90129+ error = -EBUSY;
90130+ goto out;
90131+ }
90132+
90133+ /* if non-root trying to do anything other than use a special role,
90134+ do not attempt authentication, do not count towards authentication
90135+ locking
90136+ */
90137+
90138+ if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
90139+ gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
90140+ gr_is_global_nonroot(current_uid())) {
90141+ error = -EPERM;
90142+ goto out;
90143+ }
90144+
90145+ /* ensure pw and special role name are null terminated */
90146+
90147+ gr_usermode->pw[GR_PW_LEN - 1] = '\0';
90148+ gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
90149+
90150+ /* Okay.
90151+ * We have our enough of the argument structure..(we have yet
90152+ * to copy_from_user the tables themselves) . Copy the tables
90153+ * only if we need them, i.e. for loading operations. */
90154+
90155+ switch (gr_usermode->mode) {
90156+ case GR_STATUS:
90157+ if (gr_acl_is_enabled()) {
90158+ error = 1;
90159+ if (!gr_check_secure_terminal(current))
90160+ error = 3;
90161+ } else
90162+ error = 2;
90163+ goto out;
90164+ case GR_SHUTDOWN:
90165+ if (gr_acl_is_enabled() && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
90166+ stop_machine(gr_rbac_disable, NULL, NULL);
90167+ free_variables(false);
90168+ memset(gr_usermode, 0, sizeof(struct gr_arg));
90169+ memset(gr_system_salt, 0, GR_SALT_LEN);
90170+ memset(gr_system_sum, 0, GR_SHA_LEN);
90171+ gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
90172+ } else if (gr_acl_is_enabled()) {
90173+ gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
90174+ error = -EPERM;
90175+ } else {
90176+ gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
90177+ error = -EAGAIN;
90178+ }
90179+ break;
90180+ case GR_ENABLE:
90181+ if (!gr_acl_is_enabled() && !(error2 = gracl_init(gr_usermode)))
90182+ gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
90183+ else {
90184+ if (gr_acl_is_enabled())
90185+ error = -EAGAIN;
90186+ else
90187+ error = error2;
90188+ gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
90189+ }
90190+ break;
90191+ case GR_OLDRELOAD:
90192+ oldmode = 1;
90193+ case GR_RELOAD:
90194+ if (!gr_acl_is_enabled()) {
90195+ gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
90196+ error = -EAGAIN;
90197+ } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
90198+ error2 = gracl_reload(gr_usermode, oldmode);
90199+ if (!error2)
90200+ gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
90201+ else {
90202+ gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
90203+ error = error2;
90204+ }
90205+ } else {
90206+ gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
90207+ error = -EPERM;
90208+ }
90209+ break;
90210+ case GR_SEGVMOD:
90211+ if (unlikely(!gr_acl_is_enabled())) {
90212+ gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
90213+ error = -EAGAIN;
90214+ break;
90215+ }
90216+
90217+ if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
90218+ gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
90219+ if (gr_usermode->segv_device && gr_usermode->segv_inode) {
90220+ struct acl_subject_label *segvacl;
90221+ segvacl =
90222+ lookup_acl_subj_label(gr_usermode->segv_inode,
90223+ gr_usermode->segv_device,
90224+ current->role);
90225+ if (segvacl) {
90226+ segvacl->crashes = 0;
90227+ segvacl->expires = 0;
90228+ }
90229+ } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
90230+ gr_remove_uid(gr_usermode->segv_uid);
90231+ }
90232+ } else {
90233+ gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
90234+ error = -EPERM;
90235+ }
90236+ break;
90237+ case GR_SPROLE:
90238+ case GR_SPROLEPAM:
90239+ if (unlikely(!gr_acl_is_enabled())) {
90240+ gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
90241+ error = -EAGAIN;
90242+ break;
90243+ }
90244+
90245+ if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
90246+ current->role->expires = 0;
90247+ current->role->auth_attempts = 0;
90248+ }
90249+
90250+ if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
90251+ time_after(current->role->expires, get_seconds())) {
90252+ error = -EBUSY;
90253+ goto out;
90254+ }
90255+
90256+ if (lookup_special_role_auth
90257+ (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
90258+ && ((!sprole_salt && !sprole_sum)
90259+ || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
90260+ char *p = "";
90261+ assign_special_role(gr_usermode->sp_role);
90262+ read_lock(&tasklist_lock);
90263+ if (current->real_parent)
90264+ p = current->real_parent->role->rolename;
90265+ read_unlock(&tasklist_lock);
90266+ gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
90267+ p, acl_sp_role_value);
90268+ } else {
90269+ gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
90270+ error = -EPERM;
90271+ if(!(current->role->auth_attempts++))
90272+ current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
90273+
90274+ goto out;
90275+ }
90276+ break;
90277+ case GR_UNSPROLE:
90278+ if (unlikely(!gr_acl_is_enabled())) {
90279+ gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
90280+ error = -EAGAIN;
90281+ break;
90282+ }
90283+
90284+ if (current->role->roletype & GR_ROLE_SPECIAL) {
90285+ char *p = "";
90286+ int i = 0;
90287+
90288+ read_lock(&tasklist_lock);
90289+ if (current->real_parent) {
90290+ p = current->real_parent->role->rolename;
90291+ i = current->real_parent->acl_role_id;
90292+ }
90293+ read_unlock(&tasklist_lock);
90294+
90295+ gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
90296+ gr_set_acls(1);
90297+ } else {
90298+ error = -EPERM;
90299+ goto out;
90300+ }
90301+ break;
90302+ default:
90303+ gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
90304+ error = -EINVAL;
90305+ break;
90306+ }
90307+
90308+ if (error != -EPERM)
90309+ goto out;
90310+
90311+ if(!(gr_auth_attempts++))
90312+ gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
90313+
90314+ out:
90315+ mutex_unlock(&gr_dev_mutex);
90316+
90317+ if (!error)
90318+ error = req_count;
90319+
90320+ return error;
90321+}
90322+
90323+int
90324+gr_set_acls(const int type)
90325+{
90326+ struct task_struct *task, *task2;
90327+ struct acl_role_label *role = current->role;
90328+ struct acl_subject_label *subj;
90329+ __u16 acl_role_id = current->acl_role_id;
90330+ const struct cred *cred;
90331+ int ret;
90332+
90333+ rcu_read_lock();
90334+ read_lock(&tasklist_lock);
90335+ read_lock(&grsec_exec_file_lock);
90336+ do_each_thread(task2, task) {
90337+ /* check to see if we're called from the exit handler,
90338+ if so, only replace ACLs that have inherited the admin
90339+ ACL */
90340+
90341+ if (type && (task->role != role ||
90342+ task->acl_role_id != acl_role_id))
90343+ continue;
90344+
90345+ task->acl_role_id = 0;
90346+ task->acl_sp_role = 0;
90347+ task->inherited = 0;
90348+
90349+ if (task->exec_file) {
90350+ cred = __task_cred(task);
90351+ task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
90352+ subj = __gr_get_subject_for_task(polstate, task, NULL, 1);
90353+ if (subj == NULL) {
90354+ ret = -EINVAL;
90355+ read_unlock(&grsec_exec_file_lock);
90356+ read_unlock(&tasklist_lock);
90357+ rcu_read_unlock();
90358+ gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
90359+ return ret;
90360+ }
90361+ __gr_apply_subject_to_task(polstate, task, subj);
90362+ } else {
90363+ // it's a kernel process
90364+ task->role = polstate->kernel_role;
90365+ task->acl = polstate->kernel_role->root_label;
90366+#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
90367+ task->acl->mode &= ~GR_PROCFIND;
90368+#endif
90369+ }
90370+ } while_each_thread(task2, task);
90371+ read_unlock(&grsec_exec_file_lock);
90372+ read_unlock(&tasklist_lock);
90373+ rcu_read_unlock();
90374+
90375+ return 0;
90376+}
90377diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
90378new file mode 100644
90379index 0000000..39645c9
90380--- /dev/null
90381+++ b/grsecurity/gracl_res.c
90382@@ -0,0 +1,68 @@
90383+#include <linux/kernel.h>
90384+#include <linux/sched.h>
90385+#include <linux/gracl.h>
90386+#include <linux/grinternal.h>
90387+
90388+static const char *restab_log[] = {
90389+ [RLIMIT_CPU] = "RLIMIT_CPU",
90390+ [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
90391+ [RLIMIT_DATA] = "RLIMIT_DATA",
90392+ [RLIMIT_STACK] = "RLIMIT_STACK",
90393+ [RLIMIT_CORE] = "RLIMIT_CORE",
90394+ [RLIMIT_RSS] = "RLIMIT_RSS",
90395+ [RLIMIT_NPROC] = "RLIMIT_NPROC",
90396+ [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
90397+ [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
90398+ [RLIMIT_AS] = "RLIMIT_AS",
90399+ [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
90400+ [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
90401+ [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
90402+ [RLIMIT_NICE] = "RLIMIT_NICE",
90403+ [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
90404+ [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
90405+ [GR_CRASH_RES] = "RLIMIT_CRASH"
90406+};
90407+
90408+void
90409+gr_log_resource(const struct task_struct *task,
90410+ const int res, const unsigned long wanted, const int gt)
90411+{
90412+ const struct cred *cred;
90413+ unsigned long rlim;
90414+
90415+ if (!gr_acl_is_enabled() && !grsec_resource_logging)
90416+ return;
90417+
90418+ // not yet supported resource
90419+ if (unlikely(!restab_log[res]))
90420+ return;
90421+
90422+ if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
90423+ rlim = task_rlimit_max(task, res);
90424+ else
90425+ rlim = task_rlimit(task, res);
90426+
90427+ if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
90428+ return;
90429+
90430+ rcu_read_lock();
90431+ cred = __task_cred(task);
90432+
90433+ if (res == RLIMIT_NPROC &&
90434+ (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
90435+ cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
90436+ goto out_rcu_unlock;
90437+ else if (res == RLIMIT_MEMLOCK &&
90438+ cap_raised(cred->cap_effective, CAP_IPC_LOCK))
90439+ goto out_rcu_unlock;
90440+ else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
90441+ goto out_rcu_unlock;
90442+ rcu_read_unlock();
90443+
90444+ gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
90445+
90446+ return;
90447+out_rcu_unlock:
90448+ rcu_read_unlock();
90449+ return;
90450+}
90451diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
90452new file mode 100644
90453index 0000000..21646aa
90454--- /dev/null
90455+++ b/grsecurity/gracl_segv.c
90456@@ -0,0 +1,304 @@
90457+#include <linux/kernel.h>
90458+#include <linux/mm.h>
90459+#include <asm/uaccess.h>
90460+#include <asm/errno.h>
90461+#include <asm/mman.h>
90462+#include <net/sock.h>
90463+#include <linux/file.h>
90464+#include <linux/fs.h>
90465+#include <linux/net.h>
90466+#include <linux/in.h>
90467+#include <linux/slab.h>
90468+#include <linux/types.h>
90469+#include <linux/sched.h>
90470+#include <linux/timer.h>
90471+#include <linux/gracl.h>
90472+#include <linux/grsecurity.h>
90473+#include <linux/grinternal.h>
90474+#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
90475+#include <linux/magic.h>
90476+#include <linux/pagemap.h>
90477+#include "../fs/btrfs/async-thread.h"
90478+#include "../fs/btrfs/ctree.h"
90479+#include "../fs/btrfs/btrfs_inode.h"
90480+#endif
90481+
90482+static struct crash_uid *uid_set;
90483+static unsigned short uid_used;
90484+static DEFINE_SPINLOCK(gr_uid_lock);
90485+extern rwlock_t gr_inode_lock;
90486+extern struct acl_subject_label *
90487+ lookup_acl_subj_label(const u64 inode, const dev_t dev,
90488+ struct acl_role_label *role);
90489+
90490+int
90491+gr_init_uidset(void)
90492+{
90493+ uid_set =
90494+ kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
90495+ uid_used = 0;
90496+
90497+ return uid_set ? 1 : 0;
90498+}
90499+
90500+void
90501+gr_free_uidset(void)
90502+{
90503+ if (uid_set) {
90504+ struct crash_uid *tmpset;
90505+ spin_lock(&gr_uid_lock);
90506+ tmpset = uid_set;
90507+ uid_set = NULL;
90508+ uid_used = 0;
90509+ spin_unlock(&gr_uid_lock);
90510+ if (tmpset)
90511+ kfree(tmpset);
90512+ }
90513+
90514+ return;
90515+}
90516+
90517+int
90518+gr_find_uid(const uid_t uid)
90519+{
90520+ struct crash_uid *tmp = uid_set;
90521+ uid_t buid;
90522+ int low = 0, high = uid_used - 1, mid;
90523+
90524+ while (high >= low) {
90525+ mid = (low + high) >> 1;
90526+ buid = tmp[mid].uid;
90527+ if (buid == uid)
90528+ return mid;
90529+ if (buid > uid)
90530+ high = mid - 1;
90531+ if (buid < uid)
90532+ low = mid + 1;
90533+ }
90534+
90535+ return -1;
90536+}
90537+
90538+static void
90539+gr_insertsort(void)
90540+{
90541+ unsigned short i, j;
90542+ struct crash_uid index;
90543+
90544+ for (i = 1; i < uid_used; i++) {
90545+ index = uid_set[i];
90546+ j = i;
90547+ while ((j > 0) && uid_set[j - 1].uid > index.uid) {
90548+ uid_set[j] = uid_set[j - 1];
90549+ j--;
90550+ }
90551+ uid_set[j] = index;
90552+ }
90553+
90554+ return;
90555+}
90556+
90557+static void
90558+gr_insert_uid(const kuid_t kuid, const unsigned long expires)
90559+{
90560+ int loc;
90561+ uid_t uid = GR_GLOBAL_UID(kuid);
90562+
90563+ if (uid_used == GR_UIDTABLE_MAX)
90564+ return;
90565+
90566+ loc = gr_find_uid(uid);
90567+
90568+ if (loc >= 0) {
90569+ uid_set[loc].expires = expires;
90570+ return;
90571+ }
90572+
90573+ uid_set[uid_used].uid = uid;
90574+ uid_set[uid_used].expires = expires;
90575+ uid_used++;
90576+
90577+ gr_insertsort();
90578+
90579+ return;
90580+}
90581+
90582+void
90583+gr_remove_uid(const unsigned short loc)
90584+{
90585+ unsigned short i;
90586+
90587+ for (i = loc + 1; i < uid_used; i++)
90588+ uid_set[i - 1] = uid_set[i];
90589+
90590+ uid_used--;
90591+
90592+ return;
90593+}
90594+
90595+int
90596+gr_check_crash_uid(const kuid_t kuid)
90597+{
90598+ int loc;
90599+ int ret = 0;
90600+ uid_t uid;
90601+
90602+ if (unlikely(!gr_acl_is_enabled()))
90603+ return 0;
90604+
90605+ uid = GR_GLOBAL_UID(kuid);
90606+
90607+ spin_lock(&gr_uid_lock);
90608+ loc = gr_find_uid(uid);
90609+
90610+ if (loc < 0)
90611+ goto out_unlock;
90612+
90613+ if (time_before_eq(uid_set[loc].expires, get_seconds()))
90614+ gr_remove_uid(loc);
90615+ else
90616+ ret = 1;
90617+
90618+out_unlock:
90619+ spin_unlock(&gr_uid_lock);
90620+ return ret;
90621+}
90622+
90623+static int
90624+proc_is_setxid(const struct cred *cred)
90625+{
90626+ if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
90627+ !uid_eq(cred->uid, cred->fsuid))
90628+ return 1;
90629+ if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
90630+ !gid_eq(cred->gid, cred->fsgid))
90631+ return 1;
90632+
90633+ return 0;
90634+}
90635+
90636+extern int gr_fake_force_sig(int sig, struct task_struct *t);
90637+
90638+void
90639+gr_handle_crash(struct task_struct *task, const int sig)
90640+{
90641+ struct acl_subject_label *curr;
90642+ struct task_struct *tsk, *tsk2;
90643+ const struct cred *cred;
90644+ const struct cred *cred2;
90645+
90646+ if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
90647+ return;
90648+
90649+ if (unlikely(!gr_acl_is_enabled()))
90650+ return;
90651+
90652+ curr = task->acl;
90653+
90654+ if (!(curr->resmask & (1U << GR_CRASH_RES)))
90655+ return;
90656+
90657+ if (time_before_eq(curr->expires, get_seconds())) {
90658+ curr->expires = 0;
90659+ curr->crashes = 0;
90660+ }
90661+
90662+ curr->crashes++;
90663+
90664+ if (!curr->expires)
90665+ curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
90666+
90667+ if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
90668+ time_after(curr->expires, get_seconds())) {
90669+ rcu_read_lock();
90670+ cred = __task_cred(task);
90671+ if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
90672+ gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
90673+ spin_lock(&gr_uid_lock);
90674+ gr_insert_uid(cred->uid, curr->expires);
90675+ spin_unlock(&gr_uid_lock);
90676+ curr->expires = 0;
90677+ curr->crashes = 0;
90678+ read_lock(&tasklist_lock);
90679+ do_each_thread(tsk2, tsk) {
90680+ cred2 = __task_cred(tsk);
90681+ if (tsk != task && uid_eq(cred2->uid, cred->uid))
90682+ gr_fake_force_sig(SIGKILL, tsk);
90683+ } while_each_thread(tsk2, tsk);
90684+ read_unlock(&tasklist_lock);
90685+ } else {
90686+ gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
90687+ read_lock(&tasklist_lock);
90688+ read_lock(&grsec_exec_file_lock);
90689+ do_each_thread(tsk2, tsk) {
90690+ if (likely(tsk != task)) {
90691+ // if this thread has the same subject as the one that triggered
90692+ // RES_CRASH and it's the same binary, kill it
90693+ if (tsk->acl == task->acl && gr_is_same_file(tsk->exec_file, task->exec_file))
90694+ gr_fake_force_sig(SIGKILL, tsk);
90695+ }
90696+ } while_each_thread(tsk2, tsk);
90697+ read_unlock(&grsec_exec_file_lock);
90698+ read_unlock(&tasklist_lock);
90699+ }
90700+ rcu_read_unlock();
90701+ }
90702+
90703+ return;
90704+}
90705+
90706+int
90707+gr_check_crash_exec(const struct file *filp)
90708+{
90709+ struct acl_subject_label *curr;
90710+ struct dentry *dentry;
90711+
90712+ if (unlikely(!gr_acl_is_enabled()))
90713+ return 0;
90714+
90715+ read_lock(&gr_inode_lock);
90716+ dentry = filp->f_path.dentry;
90717+ curr = lookup_acl_subj_label(gr_get_ino_from_dentry(dentry), gr_get_dev_from_dentry(dentry),
90718+ current->role);
90719+ read_unlock(&gr_inode_lock);
90720+
90721+ if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
90722+ (!curr->crashes && !curr->expires))
90723+ return 0;
90724+
90725+ if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
90726+ time_after(curr->expires, get_seconds()))
90727+ return 1;
90728+ else if (time_before_eq(curr->expires, get_seconds())) {
90729+ curr->crashes = 0;
90730+ curr->expires = 0;
90731+ }
90732+
90733+ return 0;
90734+}
90735+
90736+void
90737+gr_handle_alertkill(struct task_struct *task)
90738+{
90739+ struct acl_subject_label *curracl;
90740+ __u32 curr_ip;
90741+ struct task_struct *p, *p2;
90742+
90743+ if (unlikely(!gr_acl_is_enabled()))
90744+ return;
90745+
90746+ curracl = task->acl;
90747+ curr_ip = task->signal->curr_ip;
90748+
90749+ if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
90750+ read_lock(&tasklist_lock);
90751+ do_each_thread(p2, p) {
90752+ if (p->signal->curr_ip == curr_ip)
90753+ gr_fake_force_sig(SIGKILL, p);
90754+ } while_each_thread(p2, p);
90755+ read_unlock(&tasklist_lock);
90756+ } else if (curracl->mode & GR_KILLPROC)
90757+ gr_fake_force_sig(SIGKILL, task);
90758+
90759+ return;
90760+}
90761diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
90762new file mode 100644
90763index 0000000..6b0c9cc
90764--- /dev/null
90765+++ b/grsecurity/gracl_shm.c
90766@@ -0,0 +1,40 @@
90767+#include <linux/kernel.h>
90768+#include <linux/mm.h>
90769+#include <linux/sched.h>
90770+#include <linux/file.h>
90771+#include <linux/ipc.h>
90772+#include <linux/gracl.h>
90773+#include <linux/grsecurity.h>
90774+#include <linux/grinternal.h>
90775+
90776+int
90777+gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
90778+ const u64 shm_createtime, const kuid_t cuid, const int shmid)
90779+{
90780+ struct task_struct *task;
90781+
90782+ if (!gr_acl_is_enabled())
90783+ return 1;
90784+
90785+ rcu_read_lock();
90786+ read_lock(&tasklist_lock);
90787+
90788+ task = find_task_by_vpid(shm_cprid);
90789+
90790+ if (unlikely(!task))
90791+ task = find_task_by_vpid(shm_lapid);
90792+
90793+ if (unlikely(task && (time_before_eq64(task->start_time, shm_createtime) ||
90794+ (task_pid_nr(task) == shm_lapid)) &&
90795+ (task->acl->mode & GR_PROTSHM) &&
90796+ (task->acl != current->acl))) {
90797+ read_unlock(&tasklist_lock);
90798+ rcu_read_unlock();
90799+ gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
90800+ return 0;
90801+ }
90802+ read_unlock(&tasklist_lock);
90803+ rcu_read_unlock();
90804+
90805+ return 1;
90806+}
90807diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
90808new file mode 100644
90809index 0000000..bc0be01
90810--- /dev/null
90811+++ b/grsecurity/grsec_chdir.c
90812@@ -0,0 +1,19 @@
90813+#include <linux/kernel.h>
90814+#include <linux/sched.h>
90815+#include <linux/fs.h>
90816+#include <linux/file.h>
90817+#include <linux/grsecurity.h>
90818+#include <linux/grinternal.h>
90819+
90820+void
90821+gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
90822+{
90823+#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
90824+ if ((grsec_enable_chdir && grsec_enable_group &&
90825+ in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
90826+ !grsec_enable_group)) {
90827+ gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
90828+ }
90829+#endif
90830+ return;
90831+}
90832diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
90833new file mode 100644
90834index 0000000..652ab45
90835--- /dev/null
90836+++ b/grsecurity/grsec_chroot.c
90837@@ -0,0 +1,467 @@
90838+#include <linux/kernel.h>
90839+#include <linux/module.h>
90840+#include <linux/sched.h>
90841+#include <linux/file.h>
90842+#include <linux/fs.h>
90843+#include <linux/mount.h>
90844+#include <linux/types.h>
90845+#include "../fs/mount.h"
90846+#include <linux/grsecurity.h>
90847+#include <linux/grinternal.h>
90848+
90849+#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
90850+int gr_init_ran;
90851+#endif
90852+
90853+void gr_inc_chroot_refcnts(struct dentry *dentry, struct vfsmount *mnt)
90854+{
90855+#ifdef CONFIG_GRKERNSEC_CHROOT_RENAME
90856+ struct dentry *tmpd = dentry;
90857+
90858+ read_seqlock_excl(&mount_lock);
90859+ write_seqlock(&rename_lock);
90860+
90861+ while (tmpd != mnt->mnt_root) {
90862+ atomic_inc(&tmpd->chroot_refcnt);
90863+ tmpd = tmpd->d_parent;
90864+ }
90865+ atomic_inc(&tmpd->chroot_refcnt);
90866+
90867+ write_sequnlock(&rename_lock);
90868+ read_sequnlock_excl(&mount_lock);
90869+#endif
90870+}
90871+
90872+void gr_dec_chroot_refcnts(struct dentry *dentry, struct vfsmount *mnt)
90873+{
90874+#ifdef CONFIG_GRKERNSEC_CHROOT_RENAME
90875+ struct dentry *tmpd = dentry;
90876+
90877+ read_seqlock_excl(&mount_lock);
90878+ write_seqlock(&rename_lock);
90879+
90880+ while (tmpd != mnt->mnt_root) {
90881+ atomic_dec(&tmpd->chroot_refcnt);
90882+ tmpd = tmpd->d_parent;
90883+ }
90884+ atomic_dec(&tmpd->chroot_refcnt);
90885+
90886+ write_sequnlock(&rename_lock);
90887+ read_sequnlock_excl(&mount_lock);
90888+#endif
90889+}
90890+
90891+#ifdef CONFIG_GRKERNSEC_CHROOT_RENAME
90892+static struct dentry *get_closest_chroot(struct dentry *dentry)
90893+{
90894+ write_seqlock(&rename_lock);
90895+ do {
90896+ if (atomic_read(&dentry->chroot_refcnt)) {
90897+ write_sequnlock(&rename_lock);
90898+ return dentry;
90899+ }
90900+ dentry = dentry->d_parent;
90901+ } while (!IS_ROOT(dentry));
90902+ write_sequnlock(&rename_lock);
90903+ return NULL;
90904+}
90905+#endif
90906+
90907+int gr_bad_chroot_rename(struct dentry *olddentry, struct vfsmount *oldmnt,
90908+ struct dentry *newdentry, struct vfsmount *newmnt)
90909+{
90910+#ifdef CONFIG_GRKERNSEC_CHROOT_RENAME
90911+ struct dentry *chroot;
90912+
90913+ if (unlikely(!grsec_enable_chroot_rename))
90914+ return 0;
90915+
90916+ if (likely(!proc_is_chrooted(current) && gr_is_global_root(current_uid())))
90917+ return 0;
90918+
90919+ chroot = get_closest_chroot(olddentry);
90920+
90921+ if (chroot == NULL)
90922+ return 0;
90923+
90924+ if (is_subdir(newdentry, chroot))
90925+ return 0;
90926+
90927+ gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_RENAME_MSG, olddentry, oldmnt);
90928+
90929+ return 1;
90930+#else
90931+ return 0;
90932+#endif
90933+}
90934+
90935+void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
90936+{
90937+#ifdef CONFIG_GRKERNSEC
90938+ if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
90939+ path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
90940+#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
90941+ && gr_init_ran
90942+#endif
90943+ )
90944+ task->gr_is_chrooted = 1;
90945+ else {
90946+#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
90947+ if (task_pid_nr(task) == 1 && !gr_init_ran)
90948+ gr_init_ran = 1;
90949+#endif
90950+ task->gr_is_chrooted = 0;
90951+ }
90952+
90953+ task->gr_chroot_dentry = path->dentry;
90954+#endif
90955+ return;
90956+}
90957+
90958+void gr_clear_chroot_entries(struct task_struct *task)
90959+{
90960+#ifdef CONFIG_GRKERNSEC
90961+ task->gr_is_chrooted = 0;
90962+ task->gr_chroot_dentry = NULL;
90963+#endif
90964+ return;
90965+}
90966+
90967+int
90968+gr_handle_chroot_unix(const pid_t pid)
90969+{
90970+#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
90971+ struct task_struct *p;
90972+
90973+ if (unlikely(!grsec_enable_chroot_unix))
90974+ return 1;
90975+
90976+ if (likely(!proc_is_chrooted(current)))
90977+ return 1;
90978+
90979+ rcu_read_lock();
90980+ read_lock(&tasklist_lock);
90981+ p = find_task_by_vpid_unrestricted(pid);
90982+ if (unlikely(p && !have_same_root(current, p))) {
90983+ read_unlock(&tasklist_lock);
90984+ rcu_read_unlock();
90985+ gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
90986+ return 0;
90987+ }
90988+ read_unlock(&tasklist_lock);
90989+ rcu_read_unlock();
90990+#endif
90991+ return 1;
90992+}
90993+
90994+int
90995+gr_handle_chroot_nice(void)
90996+{
90997+#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
90998+ if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
90999+ gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
91000+ return -EPERM;
91001+ }
91002+#endif
91003+ return 0;
91004+}
91005+
91006+int
91007+gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
91008+{
91009+#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
91010+ if (grsec_enable_chroot_nice && (niceval < task_nice(p))
91011+ && proc_is_chrooted(current)) {
91012+ gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
91013+ return -EACCES;
91014+ }
91015+#endif
91016+ return 0;
91017+}
91018+
91019+int
91020+gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
91021+{
91022+#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
91023+ struct task_struct *p;
91024+ int ret = 0;
91025+ if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
91026+ return ret;
91027+
91028+ read_lock(&tasklist_lock);
91029+ do_each_pid_task(pid, type, p) {
91030+ if (!have_same_root(current, p)) {
91031+ ret = 1;
91032+ goto out;
91033+ }
91034+ } while_each_pid_task(pid, type, p);
91035+out:
91036+ read_unlock(&tasklist_lock);
91037+ return ret;
91038+#endif
91039+ return 0;
91040+}
91041+
91042+int
91043+gr_pid_is_chrooted(struct task_struct *p)
91044+{
91045+#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
91046+ if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
91047+ return 0;
91048+
91049+ if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
91050+ !have_same_root(current, p)) {
91051+ return 1;
91052+ }
91053+#endif
91054+ return 0;
91055+}
91056+
91057+EXPORT_SYMBOL_GPL(gr_pid_is_chrooted);
91058+
91059+#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
91060+int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
91061+{
91062+ struct path path, currentroot;
91063+ int ret = 0;
91064+
91065+ path.dentry = (struct dentry *)u_dentry;
91066+ path.mnt = (struct vfsmount *)u_mnt;
91067+ get_fs_root(current->fs, &currentroot);
91068+ if (path_is_under(&path, &currentroot))
91069+ ret = 1;
91070+ path_put(&currentroot);
91071+
91072+ return ret;
91073+}
91074+#endif
91075+
91076+int
91077+gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
91078+{
91079+#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
91080+ if (!grsec_enable_chroot_fchdir)
91081+ return 1;
91082+
91083+ if (!proc_is_chrooted(current))
91084+ return 1;
91085+ else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
91086+ gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
91087+ return 0;
91088+ }
91089+#endif
91090+ return 1;
91091+}
91092+
91093+int
91094+gr_chroot_fhandle(void)
91095+{
91096+#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
91097+ if (!grsec_enable_chroot_fchdir)
91098+ return 1;
91099+
91100+ if (!proc_is_chrooted(current))
91101+ return 1;
91102+ else {
91103+ gr_log_noargs(GR_DONT_AUDIT, GR_CHROOT_FHANDLE_MSG);
91104+ return 0;
91105+ }
91106+#endif
91107+ return 1;
91108+}
91109+
91110+int
91111+gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
91112+ const u64 shm_createtime)
91113+{
91114+#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
91115+ struct task_struct *p;
91116+
91117+ if (unlikely(!grsec_enable_chroot_shmat))
91118+ return 1;
91119+
91120+ if (likely(!proc_is_chrooted(current)))
91121+ return 1;
91122+
91123+ rcu_read_lock();
91124+ read_lock(&tasklist_lock);
91125+
91126+ if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
91127+ if (time_before_eq64(p->start_time, shm_createtime)) {
91128+ if (have_same_root(current, p)) {
91129+ goto allow;
91130+ } else {
91131+ read_unlock(&tasklist_lock);
91132+ rcu_read_unlock();
91133+ gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
91134+ return 0;
91135+ }
91136+ }
91137+ /* creator exited, pid reuse, fall through to next check */
91138+ }
91139+ if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
91140+ if (unlikely(!have_same_root(current, p))) {
91141+ read_unlock(&tasklist_lock);
91142+ rcu_read_unlock();
91143+ gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
91144+ return 0;
91145+ }
91146+ }
91147+
91148+allow:
91149+ read_unlock(&tasklist_lock);
91150+ rcu_read_unlock();
91151+#endif
91152+ return 1;
91153+}
91154+
91155+void
91156+gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
91157+{
91158+#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
91159+ if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
91160+ gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
91161+#endif
91162+ return;
91163+}
91164+
91165+int
91166+gr_handle_chroot_mknod(const struct dentry *dentry,
91167+ const struct vfsmount *mnt, const int mode)
91168+{
91169+#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
91170+ if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
91171+ proc_is_chrooted(current)) {
91172+ gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
91173+ return -EPERM;
91174+ }
91175+#endif
91176+ return 0;
91177+}
91178+
91179+int
91180+gr_handle_chroot_mount(const struct dentry *dentry,
91181+ const struct vfsmount *mnt, const char *dev_name)
91182+{
91183+#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
91184+ if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
91185+ gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
91186+ return -EPERM;
91187+ }
91188+#endif
91189+ return 0;
91190+}
91191+
91192+int
91193+gr_handle_chroot_pivot(void)
91194+{
91195+#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
91196+ if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
91197+ gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
91198+ return -EPERM;
91199+ }
91200+#endif
91201+ return 0;
91202+}
91203+
91204+int
91205+gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
91206+{
91207+#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
91208+ if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
91209+ !gr_is_outside_chroot(dentry, mnt)) {
91210+ gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
91211+ return -EPERM;
91212+ }
91213+#endif
91214+ return 0;
91215+}
91216+
91217+extern const char *captab_log[];
91218+extern int captab_log_entries;
91219+
91220+int
91221+gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
91222+{
91223+#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
91224+ if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
91225+ kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
91226+ if (cap_raised(chroot_caps, cap)) {
91227+ if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
91228+ gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
91229+ }
91230+ return 0;
91231+ }
91232+ }
91233+#endif
91234+ return 1;
91235+}
91236+
91237+int
91238+gr_chroot_is_capable(const int cap)
91239+{
91240+#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
91241+ return gr_task_chroot_is_capable(current, current_cred(), cap);
91242+#endif
91243+ return 1;
91244+}
91245+
91246+int
91247+gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
91248+{
91249+#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
91250+ if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
91251+ kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
91252+ if (cap_raised(chroot_caps, cap)) {
91253+ return 0;
91254+ }
91255+ }
91256+#endif
91257+ return 1;
91258+}
91259+
91260+int
91261+gr_chroot_is_capable_nolog(const int cap)
91262+{
91263+#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
91264+ return gr_task_chroot_is_capable_nolog(current, cap);
91265+#endif
91266+ return 1;
91267+}
91268+
91269+int
91270+gr_handle_chroot_sysctl(const int op)
91271+{
91272+#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
91273+ if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
91274+ proc_is_chrooted(current))
91275+ return -EACCES;
91276+#endif
91277+ return 0;
91278+}
91279+
91280+void
91281+gr_handle_chroot_chdir(const struct path *path)
91282+{
91283+#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
91284+ if (grsec_enable_chroot_chdir)
91285+ set_fs_pwd(current->fs, path);
91286+#endif
91287+ return;
91288+}
91289+
91290+int
91291+gr_handle_chroot_chmod(const struct dentry *dentry,
91292+ const struct vfsmount *mnt, const int mode)
91293+{
91294+#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
91295+ /* allow chmod +s on directories, but not files */
91296+ if (grsec_enable_chroot_chmod && !d_is_dir(dentry) &&
91297+ ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
91298+ proc_is_chrooted(current)) {
91299+ gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
91300+ return -EPERM;
91301+ }
91302+#endif
91303+ return 0;
91304+}
91305diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
91306new file mode 100644
91307index 0000000..e723c08
91308--- /dev/null
91309+++ b/grsecurity/grsec_disabled.c
91310@@ -0,0 +1,445 @@
91311+#include <linux/kernel.h>
91312+#include <linux/module.h>
91313+#include <linux/sched.h>
91314+#include <linux/file.h>
91315+#include <linux/fs.h>
91316+#include <linux/kdev_t.h>
91317+#include <linux/net.h>
91318+#include <linux/in.h>
91319+#include <linux/ip.h>
91320+#include <linux/skbuff.h>
91321+#include <linux/sysctl.h>
91322+
91323+#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
91324+void
91325+pax_set_initial_flags(struct linux_binprm *bprm)
91326+{
91327+ return;
91328+}
91329+#endif
91330+
91331+#ifdef CONFIG_SYSCTL
91332+__u32
91333+gr_handle_sysctl(const struct ctl_table * table, const int op)
91334+{
91335+ return 0;
91336+}
91337+#endif
91338+
91339+#ifdef CONFIG_TASKSTATS
91340+int gr_is_taskstats_denied(int pid)
91341+{
91342+ return 0;
91343+}
91344+#endif
91345+
91346+int
91347+gr_acl_is_enabled(void)
91348+{
91349+ return 0;
91350+}
91351+
91352+int
91353+gr_learn_cap(const struct task_struct *task, const struct cred *cred, const int cap)
91354+{
91355+ return 0;
91356+}
91357+
91358+void
91359+gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
91360+{
91361+ return;
91362+}
91363+
91364+int
91365+gr_handle_rawio(const struct inode *inode)
91366+{
91367+ return 0;
91368+}
91369+
91370+void
91371+gr_acl_handle_psacct(struct task_struct *task, const long code)
91372+{
91373+ return;
91374+}
91375+
91376+int
91377+gr_handle_ptrace(struct task_struct *task, const long request)
91378+{
91379+ return 0;
91380+}
91381+
91382+int
91383+gr_handle_proc_ptrace(struct task_struct *task)
91384+{
91385+ return 0;
91386+}
91387+
91388+int
91389+gr_set_acls(const int type)
91390+{
91391+ return 0;
91392+}
91393+
91394+int
91395+gr_check_hidden_task(const struct task_struct *tsk)
91396+{
91397+ return 0;
91398+}
91399+
91400+int
91401+gr_check_protected_task(const struct task_struct *task)
91402+{
91403+ return 0;
91404+}
91405+
91406+int
91407+gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
91408+{
91409+ return 0;
91410+}
91411+
91412+void
91413+gr_copy_label(struct task_struct *tsk)
91414+{
91415+ return;
91416+}
91417+
91418+void
91419+gr_set_pax_flags(struct task_struct *task)
91420+{
91421+ return;
91422+}
91423+
91424+int
91425+gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
91426+ const int unsafe_share)
91427+{
91428+ return 0;
91429+}
91430+
91431+void
91432+gr_handle_delete(const u64 ino, const dev_t dev)
91433+{
91434+ return;
91435+}
91436+
91437+void
91438+gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
91439+{
91440+ return;
91441+}
91442+
91443+void
91444+gr_handle_crash(struct task_struct *task, const int sig)
91445+{
91446+ return;
91447+}
91448+
91449+int
91450+gr_check_crash_exec(const struct file *filp)
91451+{
91452+ return 0;
91453+}
91454+
91455+int
91456+gr_check_crash_uid(const kuid_t uid)
91457+{
91458+ return 0;
91459+}
91460+
91461+void
91462+gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
91463+ struct dentry *old_dentry,
91464+ struct dentry *new_dentry,
91465+ struct vfsmount *mnt, const __u8 replace, unsigned int flags)
91466+{
91467+ return;
91468+}
91469+
91470+int
91471+gr_search_socket(const int family, const int type, const int protocol)
91472+{
91473+ return 1;
91474+}
91475+
91476+int
91477+gr_search_connectbind(const int mode, const struct socket *sock,
91478+ const struct sockaddr_in *addr)
91479+{
91480+ return 0;
91481+}
91482+
91483+void
91484+gr_handle_alertkill(struct task_struct *task)
91485+{
91486+ return;
91487+}
91488+
91489+__u32
91490+gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
91491+{
91492+ return 1;
91493+}
91494+
91495+__u32
91496+gr_acl_handle_hidden_file(const struct dentry * dentry,
91497+ const struct vfsmount * mnt)
91498+{
91499+ return 1;
91500+}
91501+
91502+__u32
91503+gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
91504+ int acc_mode)
91505+{
91506+ return 1;
91507+}
91508+
91509+__u32
91510+gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
91511+{
91512+ return 1;
91513+}
91514+
91515+__u32
91516+gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
91517+{
91518+ return 1;
91519+}
91520+
91521+int
91522+gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
91523+ unsigned int *vm_flags)
91524+{
91525+ return 1;
91526+}
91527+
91528+__u32
91529+gr_acl_handle_truncate(const struct dentry * dentry,
91530+ const struct vfsmount * mnt)
91531+{
91532+ return 1;
91533+}
91534+
91535+__u32
91536+gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
91537+{
91538+ return 1;
91539+}
91540+
91541+__u32
91542+gr_acl_handle_access(const struct dentry * dentry,
91543+ const struct vfsmount * mnt, const int fmode)
91544+{
91545+ return 1;
91546+}
91547+
91548+__u32
91549+gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
91550+ umode_t *mode)
91551+{
91552+ return 1;
91553+}
91554+
91555+__u32
91556+gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
91557+{
91558+ return 1;
91559+}
91560+
91561+__u32
91562+gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
91563+{
91564+ return 1;
91565+}
91566+
91567+__u32
91568+gr_acl_handle_removexattr(const struct dentry * dentry, const struct vfsmount * mnt)
91569+{
91570+ return 1;
91571+}
91572+
91573+void
91574+grsecurity_init(void)
91575+{
91576+ return;
91577+}
91578+
91579+umode_t gr_acl_umask(void)
91580+{
91581+ return 0;
91582+}
91583+
91584+__u32
91585+gr_acl_handle_mknod(const struct dentry * new_dentry,
91586+ const struct dentry * parent_dentry,
91587+ const struct vfsmount * parent_mnt,
91588+ const int mode)
91589+{
91590+ return 1;
91591+}
91592+
91593+__u32
91594+gr_acl_handle_mkdir(const struct dentry * new_dentry,
91595+ const struct dentry * parent_dentry,
91596+ const struct vfsmount * parent_mnt)
91597+{
91598+ return 1;
91599+}
91600+
91601+__u32
91602+gr_acl_handle_symlink(const struct dentry * new_dentry,
91603+ const struct dentry * parent_dentry,
91604+ const struct vfsmount * parent_mnt, const struct filename *from)
91605+{
91606+ return 1;
91607+}
91608+
91609+__u32
91610+gr_acl_handle_link(const struct dentry * new_dentry,
91611+ const struct dentry * parent_dentry,
91612+ const struct vfsmount * parent_mnt,
91613+ const struct dentry * old_dentry,
91614+ const struct vfsmount * old_mnt, const struct filename *to)
91615+{
91616+ return 1;
91617+}
91618+
91619+int
91620+gr_acl_handle_rename(const struct dentry *new_dentry,
91621+ const struct dentry *parent_dentry,
91622+ const struct vfsmount *parent_mnt,
91623+ const struct dentry *old_dentry,
91624+ const struct inode *old_parent_inode,
91625+ const struct vfsmount *old_mnt, const struct filename *newname,
91626+ unsigned int flags)
91627+{
91628+ return 0;
91629+}
91630+
91631+int
91632+gr_acl_handle_filldir(const struct file *file, const char *name,
91633+ const int namelen, const u64 ino)
91634+{
91635+ return 1;
91636+}
91637+
91638+int
91639+gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
91640+ const u64 shm_createtime, const kuid_t cuid, const int shmid)
91641+{
91642+ return 1;
91643+}
91644+
91645+int
91646+gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
91647+{
91648+ return 0;
91649+}
91650+
91651+int
91652+gr_search_accept(const struct socket *sock)
91653+{
91654+ return 0;
91655+}
91656+
91657+int
91658+gr_search_listen(const struct socket *sock)
91659+{
91660+ return 0;
91661+}
91662+
91663+int
91664+gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
91665+{
91666+ return 0;
91667+}
91668+
91669+__u32
91670+gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
91671+{
91672+ return 1;
91673+}
91674+
91675+__u32
91676+gr_acl_handle_creat(const struct dentry * dentry,
91677+ const struct dentry * p_dentry,
91678+ const struct vfsmount * p_mnt, int open_flags, int acc_mode,
91679+ const int imode)
91680+{
91681+ return 1;
91682+}
91683+
91684+void
91685+gr_acl_handle_exit(void)
91686+{
91687+ return;
91688+}
91689+
91690+int
91691+gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
91692+{
91693+ return 1;
91694+}
91695+
91696+void
91697+gr_set_role_label(const kuid_t uid, const kgid_t gid)
91698+{
91699+ return;
91700+}
91701+
91702+int
91703+gr_acl_handle_procpidmem(const struct task_struct *task)
91704+{
91705+ return 0;
91706+}
91707+
91708+int
91709+gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
91710+{
91711+ return 0;
91712+}
91713+
91714+int
91715+gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
91716+{
91717+ return 0;
91718+}
91719+
91720+int
91721+gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
91722+{
91723+ return 0;
91724+}
91725+
91726+int
91727+gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
91728+{
91729+ return 0;
91730+}
91731+
91732+int gr_acl_enable_at_secure(void)
91733+{
91734+ return 0;
91735+}
91736+
91737+dev_t gr_get_dev_from_dentry(struct dentry *dentry)
91738+{
91739+ return d_backing_inode(dentry)->i_sb->s_dev;
91740+}
91741+
91742+u64 gr_get_ino_from_dentry(struct dentry *dentry)
91743+{
91744+ return d_backing_inode(dentry)->i_ino;
91745+}
91746+
91747+void gr_put_exec_file(struct task_struct *task)
91748+{
91749+ return;
91750+}
91751+
91752+#ifdef CONFIG_SECURITY
91753+EXPORT_SYMBOL_GPL(gr_check_user_change);
91754+EXPORT_SYMBOL_GPL(gr_check_group_change);
91755+#endif
91756diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
91757new file mode 100644
91758index 0000000..fb7531e
91759--- /dev/null
91760+++ b/grsecurity/grsec_exec.c
91761@@ -0,0 +1,189 @@
91762+#include <linux/kernel.h>
91763+#include <linux/sched.h>
91764+#include <linux/file.h>
91765+#include <linux/binfmts.h>
91766+#include <linux/fs.h>
91767+#include <linux/types.h>
91768+#include <linux/grdefs.h>
91769+#include <linux/grsecurity.h>
91770+#include <linux/grinternal.h>
91771+#include <linux/capability.h>
91772+#include <linux/module.h>
91773+#include <linux/compat.h>
91774+
91775+#include <asm/uaccess.h>
91776+
91777+#ifdef CONFIG_GRKERNSEC_EXECLOG
91778+static char gr_exec_arg_buf[132];
91779+static DEFINE_MUTEX(gr_exec_arg_mutex);
91780+#endif
91781+
91782+struct user_arg_ptr {
91783+#ifdef CONFIG_COMPAT
91784+ bool is_compat;
91785+#endif
91786+ union {
91787+ const char __user *const __user *native;
91788+#ifdef CONFIG_COMPAT
91789+ const compat_uptr_t __user *compat;
91790+#endif
91791+ } ptr;
91792+};
91793+
91794+extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
91795+
91796+void
91797+gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
91798+{
91799+#ifdef CONFIG_GRKERNSEC_EXECLOG
91800+ char *grarg = gr_exec_arg_buf;
91801+ unsigned int i, x, execlen = 0;
91802+ char c;
91803+
91804+ if (!((grsec_enable_execlog && grsec_enable_group &&
91805+ in_group_p(grsec_audit_gid))
91806+ || (grsec_enable_execlog && !grsec_enable_group)))
91807+ return;
91808+
91809+ mutex_lock(&gr_exec_arg_mutex);
91810+ memset(grarg, 0, sizeof(gr_exec_arg_buf));
91811+
91812+ for (i = 0; i < bprm->argc && execlen < 128; i++) {
91813+ const char __user *p;
91814+ unsigned int len;
91815+
91816+ p = get_user_arg_ptr(argv, i);
91817+ if (IS_ERR(p))
91818+ goto log;
91819+
91820+ len = strnlen_user(p, 128 - execlen);
91821+ if (len > 128 - execlen)
91822+ len = 128 - execlen;
91823+ else if (len > 0)
91824+ len--;
91825+ if (copy_from_user(grarg + execlen, p, len))
91826+ goto log;
91827+
91828+ /* rewrite unprintable characters */
91829+ for (x = 0; x < len; x++) {
91830+ c = *(grarg + execlen + x);
91831+ if (c < 32 || c > 126)
91832+ *(grarg + execlen + x) = ' ';
91833+ }
91834+
91835+ execlen += len;
91836+ *(grarg + execlen) = ' ';
91837+ *(grarg + execlen + 1) = '\0';
91838+ execlen++;
91839+ }
91840+
91841+ log:
91842+ gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
91843+ bprm->file->f_path.mnt, grarg);
91844+ mutex_unlock(&gr_exec_arg_mutex);
91845+#endif
91846+ return;
91847+}
91848+
91849+#ifdef CONFIG_GRKERNSEC
91850+extern int gr_acl_is_capable(const int cap);
91851+extern int gr_acl_is_capable_nolog(const int cap);
91852+extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
91853+extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
91854+extern int gr_chroot_is_capable(const int cap);
91855+extern int gr_chroot_is_capable_nolog(const int cap);
91856+extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
91857+extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
91858+#endif
91859+
91860+const char *captab_log[] = {
91861+ "CAP_CHOWN",
91862+ "CAP_DAC_OVERRIDE",
91863+ "CAP_DAC_READ_SEARCH",
91864+ "CAP_FOWNER",
91865+ "CAP_FSETID",
91866+ "CAP_KILL",
91867+ "CAP_SETGID",
91868+ "CAP_SETUID",
91869+ "CAP_SETPCAP",
91870+ "CAP_LINUX_IMMUTABLE",
91871+ "CAP_NET_BIND_SERVICE",
91872+ "CAP_NET_BROADCAST",
91873+ "CAP_NET_ADMIN",
91874+ "CAP_NET_RAW",
91875+ "CAP_IPC_LOCK",
91876+ "CAP_IPC_OWNER",
91877+ "CAP_SYS_MODULE",
91878+ "CAP_SYS_RAWIO",
91879+ "CAP_SYS_CHROOT",
91880+ "CAP_SYS_PTRACE",
91881+ "CAP_SYS_PACCT",
91882+ "CAP_SYS_ADMIN",
91883+ "CAP_SYS_BOOT",
91884+ "CAP_SYS_NICE",
91885+ "CAP_SYS_RESOURCE",
91886+ "CAP_SYS_TIME",
91887+ "CAP_SYS_TTY_CONFIG",
91888+ "CAP_MKNOD",
91889+ "CAP_LEASE",
91890+ "CAP_AUDIT_WRITE",
91891+ "CAP_AUDIT_CONTROL",
91892+ "CAP_SETFCAP",
91893+ "CAP_MAC_OVERRIDE",
91894+ "CAP_MAC_ADMIN",
91895+ "CAP_SYSLOG",
91896+ "CAP_WAKE_ALARM",
91897+ "CAP_BLOCK_SUSPEND",
91898+ "CAP_AUDIT_READ"
91899+};
91900+
91901+int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
91902+
91903+int gr_is_capable(const int cap)
91904+{
91905+#ifdef CONFIG_GRKERNSEC
91906+ if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
91907+ return 1;
91908+ return 0;
91909+#else
91910+ return 1;
91911+#endif
91912+}
91913+
91914+int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
91915+{
91916+#ifdef CONFIG_GRKERNSEC
91917+ if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
91918+ return 1;
91919+ return 0;
91920+#else
91921+ return 1;
91922+#endif
91923+}
91924+
91925+int gr_is_capable_nolog(const int cap)
91926+{
91927+#ifdef CONFIG_GRKERNSEC
91928+ if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
91929+ return 1;
91930+ return 0;
91931+#else
91932+ return 1;
91933+#endif
91934+}
91935+
91936+int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
91937+{
91938+#ifdef CONFIG_GRKERNSEC
91939+ if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
91940+ return 1;
91941+ return 0;
91942+#else
91943+ return 1;
91944+#endif
91945+}
91946+
91947+EXPORT_SYMBOL_GPL(gr_is_capable);
91948+EXPORT_SYMBOL_GPL(gr_is_capable_nolog);
91949+EXPORT_SYMBOL_GPL(gr_task_is_capable);
91950+EXPORT_SYMBOL_GPL(gr_task_is_capable_nolog);
91951diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
91952new file mode 100644
91953index 0000000..cdec49b
91954--- /dev/null
91955+++ b/grsecurity/grsec_fifo.c
91956@@ -0,0 +1,26 @@
91957+#include <linux/kernel.h>
91958+#include <linux/sched.h>
91959+#include <linux/fs.h>
91960+#include <linux/file.h>
91961+#include <linux/grinternal.h>
91962+
91963+int
91964+gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
91965+ const struct dentry *dir, const int flag, const int acc_mode)
91966+{
91967+#ifdef CONFIG_GRKERNSEC_FIFO
91968+ const struct cred *cred = current_cred();
91969+ struct inode *inode = d_backing_inode(dentry);
91970+ struct inode *dir_inode = d_backing_inode(dir);
91971+
91972+ if (grsec_enable_fifo && S_ISFIFO(inode->i_mode) &&
91973+ !(flag & O_EXCL) && (dir_inode->i_mode & S_ISVTX) &&
91974+ !uid_eq(inode->i_uid, dir_inode->i_uid) &&
91975+ !uid_eq(cred->fsuid, inode->i_uid)) {
91976+ if (!inode_permission(inode, acc_mode))
91977+ gr_log_fs_int2(GR_DONT_AUDIT, GR_FIFO_MSG, dentry, mnt, GR_GLOBAL_UID(inode->i_uid), GR_GLOBAL_GID(inode->i_gid));
91978+ return -EACCES;
91979+ }
91980+#endif
91981+ return 0;
91982+}
91983diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
91984new file mode 100644
91985index 0000000..8ca18bf
91986--- /dev/null
91987+++ b/grsecurity/grsec_fork.c
91988@@ -0,0 +1,23 @@
91989+#include <linux/kernel.h>
91990+#include <linux/sched.h>
91991+#include <linux/grsecurity.h>
91992+#include <linux/grinternal.h>
91993+#include <linux/errno.h>
91994+
91995+void
91996+gr_log_forkfail(const int retval)
91997+{
91998+#ifdef CONFIG_GRKERNSEC_FORKFAIL
91999+ if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
92000+ switch (retval) {
92001+ case -EAGAIN:
92002+ gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
92003+ break;
92004+ case -ENOMEM:
92005+ gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
92006+ break;
92007+ }
92008+ }
92009+#endif
92010+ return;
92011+}
92012diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
92013new file mode 100644
92014index 0000000..a364c58
92015--- /dev/null
92016+++ b/grsecurity/grsec_init.c
92017@@ -0,0 +1,290 @@
92018+#include <linux/kernel.h>
92019+#include <linux/sched.h>
92020+#include <linux/mm.h>
92021+#include <linux/gracl.h>
92022+#include <linux/slab.h>
92023+#include <linux/vmalloc.h>
92024+#include <linux/percpu.h>
92025+#include <linux/module.h>
92026+
92027+int grsec_enable_ptrace_readexec __read_only;
92028+int grsec_enable_setxid __read_only;
92029+int grsec_enable_symlinkown __read_only;
92030+kgid_t grsec_symlinkown_gid __read_only;
92031+int grsec_enable_brute __read_only;
92032+int grsec_enable_link __read_only;
92033+int grsec_enable_dmesg __read_only;
92034+int grsec_enable_harden_ptrace __read_only;
92035+int grsec_enable_harden_ipc __read_only;
92036+int grsec_enable_fifo __read_only;
92037+int grsec_enable_execlog __read_only;
92038+int grsec_enable_signal __read_only;
92039+int grsec_enable_forkfail __read_only;
92040+int grsec_enable_audit_ptrace __read_only;
92041+int grsec_enable_time __read_only;
92042+int grsec_enable_group __read_only;
92043+kgid_t grsec_audit_gid __read_only;
92044+int grsec_enable_chdir __read_only;
92045+int grsec_enable_mount __read_only;
92046+int grsec_enable_rofs __read_only;
92047+int grsec_deny_new_usb __read_only;
92048+int grsec_enable_chroot_findtask __read_only;
92049+int grsec_enable_chroot_mount __read_only;
92050+int grsec_enable_chroot_shmat __read_only;
92051+int grsec_enable_chroot_fchdir __read_only;
92052+int grsec_enable_chroot_double __read_only;
92053+int grsec_enable_chroot_pivot __read_only;
92054+int grsec_enable_chroot_chdir __read_only;
92055+int grsec_enable_chroot_chmod __read_only;
92056+int grsec_enable_chroot_mknod __read_only;
92057+int grsec_enable_chroot_nice __read_only;
92058+int grsec_enable_chroot_execlog __read_only;
92059+int grsec_enable_chroot_caps __read_only;
92060+int grsec_enable_chroot_rename __read_only;
92061+int grsec_enable_chroot_sysctl __read_only;
92062+int grsec_enable_chroot_unix __read_only;
92063+int grsec_enable_tpe __read_only;
92064+kgid_t grsec_tpe_gid __read_only;
92065+int grsec_enable_blackhole __read_only;
92066+#ifdef CONFIG_IPV6_MODULE
92067+EXPORT_SYMBOL_GPL(grsec_enable_blackhole);
92068+#endif
92069+int grsec_lastack_retries __read_only;
92070+int grsec_enable_tpe_all __read_only;
92071+int grsec_enable_tpe_invert __read_only;
92072+int grsec_enable_socket_all __read_only;
92073+kgid_t grsec_socket_all_gid __read_only;
92074+int grsec_enable_socket_client __read_only;
92075+kgid_t grsec_socket_client_gid __read_only;
92076+int grsec_enable_socket_server __read_only;
92077+kgid_t grsec_socket_server_gid __read_only;
92078+int grsec_resource_logging __read_only;
92079+int grsec_disable_privio __read_only;
92080+int grsec_enable_log_rwxmaps __read_only;
92081+int grsec_lock __read_only;
92082+
92083+DEFINE_SPINLOCK(grsec_alert_lock);
92084+unsigned long grsec_alert_wtime = 0;
92085+unsigned long grsec_alert_fyet = 0;
92086+
92087+DEFINE_SPINLOCK(grsec_audit_lock);
92088+
92089+DEFINE_RWLOCK(grsec_exec_file_lock);
92090+
92091+char *gr_shared_page[4];
92092+
92093+char *gr_alert_log_fmt;
92094+char *gr_audit_log_fmt;
92095+char *gr_alert_log_buf;
92096+char *gr_audit_log_buf;
92097+
92098+extern struct gr_arg *gr_usermode;
92099+extern unsigned char *gr_system_salt;
92100+extern unsigned char *gr_system_sum;
92101+
92102+void __init
92103+grsecurity_init(void)
92104+{
92105+ int j;
92106+ /* create the per-cpu shared pages */
92107+
92108+#ifdef CONFIG_X86
92109+ memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
92110+#endif
92111+
92112+ for (j = 0; j < 4; j++) {
92113+ gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
92114+ if (gr_shared_page[j] == NULL) {
92115+ panic("Unable to allocate grsecurity shared page");
92116+ return;
92117+ }
92118+ }
92119+
92120+ /* allocate log buffers */
92121+ gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
92122+ if (!gr_alert_log_fmt) {
92123+ panic("Unable to allocate grsecurity alert log format buffer");
92124+ return;
92125+ }
92126+ gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
92127+ if (!gr_audit_log_fmt) {
92128+ panic("Unable to allocate grsecurity audit log format buffer");
92129+ return;
92130+ }
92131+ gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
92132+ if (!gr_alert_log_buf) {
92133+ panic("Unable to allocate grsecurity alert log buffer");
92134+ return;
92135+ }
92136+ gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
92137+ if (!gr_audit_log_buf) {
92138+ panic("Unable to allocate grsecurity audit log buffer");
92139+ return;
92140+ }
92141+
92142+ /* allocate memory for authentication structure */
92143+ gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
92144+ gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
92145+ gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
92146+
92147+ if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
92148+ panic("Unable to allocate grsecurity authentication structure");
92149+ return;
92150+ }
92151+
92152+#ifdef CONFIG_GRKERNSEC_IO
92153+#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
92154+ grsec_disable_privio = 1;
92155+#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
92156+ grsec_disable_privio = 1;
92157+#else
92158+ grsec_disable_privio = 0;
92159+#endif
92160+#endif
92161+
92162+#ifdef CONFIG_GRKERNSEC_TPE_INVERT
92163+ /* for backward compatibility, tpe_invert always defaults to on if
92164+ enabled in the kernel
92165+ */
92166+ grsec_enable_tpe_invert = 1;
92167+#endif
92168+
92169+#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
92170+#ifndef CONFIG_GRKERNSEC_SYSCTL
92171+ grsec_lock = 1;
92172+#endif
92173+
92174+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
92175+ grsec_enable_log_rwxmaps = 1;
92176+#endif
92177+#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
92178+ grsec_enable_group = 1;
92179+ grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
92180+#endif
92181+#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
92182+ grsec_enable_ptrace_readexec = 1;
92183+#endif
92184+#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
92185+ grsec_enable_chdir = 1;
92186+#endif
92187+#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
92188+ grsec_enable_harden_ptrace = 1;
92189+#endif
92190+#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
92191+ grsec_enable_harden_ipc = 1;
92192+#endif
92193+#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
92194+ grsec_enable_mount = 1;
92195+#endif
92196+#ifdef CONFIG_GRKERNSEC_LINK
92197+ grsec_enable_link = 1;
92198+#endif
92199+#ifdef CONFIG_GRKERNSEC_BRUTE
92200+ grsec_enable_brute = 1;
92201+#endif
92202+#ifdef CONFIG_GRKERNSEC_DMESG
92203+ grsec_enable_dmesg = 1;
92204+#endif
92205+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92206+ grsec_enable_blackhole = 1;
92207+ grsec_lastack_retries = 4;
92208+#endif
92209+#ifdef CONFIG_GRKERNSEC_FIFO
92210+ grsec_enable_fifo = 1;
92211+#endif
92212+#ifdef CONFIG_GRKERNSEC_EXECLOG
92213+ grsec_enable_execlog = 1;
92214+#endif
92215+#ifdef CONFIG_GRKERNSEC_SETXID
92216+ grsec_enable_setxid = 1;
92217+#endif
92218+#ifdef CONFIG_GRKERNSEC_SIGNAL
92219+ grsec_enable_signal = 1;
92220+#endif
92221+#ifdef CONFIG_GRKERNSEC_FORKFAIL
92222+ grsec_enable_forkfail = 1;
92223+#endif
92224+#ifdef CONFIG_GRKERNSEC_TIME
92225+ grsec_enable_time = 1;
92226+#endif
92227+#ifdef CONFIG_GRKERNSEC_RESLOG
92228+ grsec_resource_logging = 1;
92229+#endif
92230+#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
92231+ grsec_enable_chroot_findtask = 1;
92232+#endif
92233+#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
92234+ grsec_enable_chroot_unix = 1;
92235+#endif
92236+#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
92237+ grsec_enable_chroot_mount = 1;
92238+#endif
92239+#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
92240+ grsec_enable_chroot_fchdir = 1;
92241+#endif
92242+#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
92243+ grsec_enable_chroot_shmat = 1;
92244+#endif
92245+#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
92246+ grsec_enable_audit_ptrace = 1;
92247+#endif
92248+#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
92249+ grsec_enable_chroot_double = 1;
92250+#endif
92251+#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
92252+ grsec_enable_chroot_pivot = 1;
92253+#endif
92254+#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
92255+ grsec_enable_chroot_chdir = 1;
92256+#endif
92257+#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
92258+ grsec_enable_chroot_chmod = 1;
92259+#endif
92260+#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
92261+ grsec_enable_chroot_mknod = 1;
92262+#endif
92263+#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
92264+ grsec_enable_chroot_nice = 1;
92265+#endif
92266+#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
92267+ grsec_enable_chroot_execlog = 1;
92268+#endif
92269+#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
92270+ grsec_enable_chroot_caps = 1;
92271+#endif
92272+#ifdef CONFIG_GRKERNSEC_CHROOT_RENAME
92273+ grsec_enable_chroot_rename = 1;
92274+#endif
92275+#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
92276+ grsec_enable_chroot_sysctl = 1;
92277+#endif
92278+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
92279+ grsec_enable_symlinkown = 1;
92280+ grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
92281+#endif
92282+#ifdef CONFIG_GRKERNSEC_TPE
92283+ grsec_enable_tpe = 1;
92284+ grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
92285+#ifdef CONFIG_GRKERNSEC_TPE_ALL
92286+ grsec_enable_tpe_all = 1;
92287+#endif
92288+#endif
92289+#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
92290+ grsec_enable_socket_all = 1;
92291+ grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
92292+#endif
92293+#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
92294+ grsec_enable_socket_client = 1;
92295+ grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
92296+#endif
92297+#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
92298+ grsec_enable_socket_server = 1;
92299+ grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
92300+#endif
92301+#endif
92302+#ifdef CONFIG_GRKERNSEC_DENYUSB_FORCE
92303+ grsec_deny_new_usb = 1;
92304+#endif
92305+
92306+ return;
92307+}
92308diff --git a/grsecurity/grsec_ipc.c b/grsecurity/grsec_ipc.c
92309new file mode 100644
92310index 0000000..1773300
92311--- /dev/null
92312+++ b/grsecurity/grsec_ipc.c
92313@@ -0,0 +1,48 @@
92314+#include <linux/kernel.h>
92315+#include <linux/mm.h>
92316+#include <linux/sched.h>
92317+#include <linux/file.h>
92318+#include <linux/ipc.h>
92319+#include <linux/ipc_namespace.h>
92320+#include <linux/grsecurity.h>
92321+#include <linux/grinternal.h>
92322+
92323+int
92324+gr_ipc_permitted(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, int requested_mode, int granted_mode)
92325+{
92326+#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
92327+ int write;
92328+ int orig_granted_mode;
92329+ kuid_t euid;
92330+ kgid_t egid;
92331+
92332+ if (!grsec_enable_harden_ipc)
92333+ return 1;
92334+
92335+ euid = current_euid();
92336+ egid = current_egid();
92337+
92338+ write = requested_mode & 00002;
92339+ orig_granted_mode = ipcp->mode;
92340+
92341+ if (uid_eq(euid, ipcp->cuid) || uid_eq(euid, ipcp->uid))
92342+ orig_granted_mode >>= 6;
92343+ else {
92344+ /* if likely wrong permissions, lock to user */
92345+ if (orig_granted_mode & 0007)
92346+ orig_granted_mode = 0;
92347+ /* otherwise do a egid-only check */
92348+ else if (gid_eq(egid, ipcp->cgid) || gid_eq(egid, ipcp->gid))
92349+ orig_granted_mode >>= 3;
92350+ /* otherwise, no access */
92351+ else
92352+ orig_granted_mode = 0;
92353+ }
92354+ if (!(requested_mode & ~granted_mode & 0007) && (requested_mode & ~orig_granted_mode & 0007) &&
92355+ !ns_capable_nolog(ns->user_ns, CAP_IPC_OWNER)) {
92356+ gr_log_str_int(GR_DONT_AUDIT, GR_IPC_DENIED_MSG, write ? "write" : "read", GR_GLOBAL_UID(ipcp->cuid));
92357+ return 0;
92358+ }
92359+#endif
92360+ return 1;
92361+}
92362diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
92363new file mode 100644
92364index 0000000..8ef2b75
92365--- /dev/null
92366+++ b/grsecurity/grsec_link.c
92367@@ -0,0 +1,59 @@
92368+#include <linux/kernel.h>
92369+#include <linux/sched.h>
92370+#include <linux/fs.h>
92371+#include <linux/file.h>
92372+#include <linux/grinternal.h>
92373+
92374+int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
92375+{
92376+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
92377+ const struct inode *link_inode = d_backing_inode(link->dentry);
92378+
92379+ if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
92380+ /* ignore root-owned links, e.g. /proc/self */
92381+ gr_is_global_nonroot(link_inode->i_uid) && target &&
92382+ !uid_eq(link_inode->i_uid, target->i_uid)) {
92383+ gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
92384+ return 1;
92385+ }
92386+#endif
92387+ return 0;
92388+}
92389+
92390+int
92391+gr_handle_follow_link(const struct dentry *dentry, const struct vfsmount *mnt)
92392+{
92393+#ifdef CONFIG_GRKERNSEC_LINK
92394+ struct inode *inode = d_backing_inode(dentry);
92395+ struct inode *parent = d_backing_inode(dentry->d_parent);
92396+ const struct cred *cred = current_cred();
92397+
92398+ if (grsec_enable_link && d_is_symlink(dentry) &&
92399+ (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
92400+ (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
92401+ gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
92402+ return -EACCES;
92403+ }
92404+#endif
92405+ return 0;
92406+}
92407+
92408+int
92409+gr_handle_hardlink(const struct dentry *dentry,
92410+ const struct vfsmount *mnt,
92411+ const struct filename *to)
92412+{
92413+#ifdef CONFIG_GRKERNSEC_LINK
92414+ struct inode *inode = d_backing_inode(dentry);
92415+ const struct cred *cred = current_cred();
92416+
92417+ if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
92418+ (!d_is_reg(dentry) || is_privileged_binary(dentry) ||
92419+ (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
92420+ !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
92421+ gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
92422+ return -EPERM;
92423+ }
92424+#endif
92425+ return 0;
92426+}
92427diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
92428new file mode 100644
92429index 0000000..dbe0a6b
92430--- /dev/null
92431+++ b/grsecurity/grsec_log.c
92432@@ -0,0 +1,341 @@
92433+#include <linux/kernel.h>
92434+#include <linux/sched.h>
92435+#include <linux/file.h>
92436+#include <linux/tty.h>
92437+#include <linux/fs.h>
92438+#include <linux/mm.h>
92439+#include <linux/grinternal.h>
92440+
92441+#ifdef CONFIG_TREE_PREEMPT_RCU
92442+#define DISABLE_PREEMPT() preempt_disable()
92443+#define ENABLE_PREEMPT() preempt_enable()
92444+#else
92445+#define DISABLE_PREEMPT()
92446+#define ENABLE_PREEMPT()
92447+#endif
92448+
92449+#define BEGIN_LOCKS(x) \
92450+ DISABLE_PREEMPT(); \
92451+ rcu_read_lock(); \
92452+ read_lock(&tasklist_lock); \
92453+ read_lock(&grsec_exec_file_lock); \
92454+ if (x != GR_DO_AUDIT) \
92455+ spin_lock(&grsec_alert_lock); \
92456+ else \
92457+ spin_lock(&grsec_audit_lock)
92458+
92459+#define END_LOCKS(x) \
92460+ if (x != GR_DO_AUDIT) \
92461+ spin_unlock(&grsec_alert_lock); \
92462+ else \
92463+ spin_unlock(&grsec_audit_lock); \
92464+ read_unlock(&grsec_exec_file_lock); \
92465+ read_unlock(&tasklist_lock); \
92466+ rcu_read_unlock(); \
92467+ ENABLE_PREEMPT(); \
92468+ if (x == GR_DONT_AUDIT) \
92469+ gr_handle_alertkill(current)
92470+
92471+enum {
92472+ FLOODING,
92473+ NO_FLOODING
92474+};
92475+
92476+extern char *gr_alert_log_fmt;
92477+extern char *gr_audit_log_fmt;
92478+extern char *gr_alert_log_buf;
92479+extern char *gr_audit_log_buf;
92480+
92481+static int gr_log_start(int audit)
92482+{
92483+ char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
92484+ char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
92485+ char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
92486+#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
92487+ unsigned long curr_secs = get_seconds();
92488+
92489+ if (audit == GR_DO_AUDIT)
92490+ goto set_fmt;
92491+
92492+ if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
92493+ grsec_alert_wtime = curr_secs;
92494+ grsec_alert_fyet = 0;
92495+ } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
92496+ && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
92497+ grsec_alert_fyet++;
92498+ } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
92499+ grsec_alert_wtime = curr_secs;
92500+ grsec_alert_fyet++;
92501+ printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
92502+ return FLOODING;
92503+ }
92504+ else return FLOODING;
92505+
92506+set_fmt:
92507+#endif
92508+ memset(buf, 0, PAGE_SIZE);
92509+ if (current->signal->curr_ip && gr_acl_is_enabled()) {
92510+ sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
92511+ snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
92512+ } else if (current->signal->curr_ip) {
92513+ sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
92514+ snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
92515+ } else if (gr_acl_is_enabled()) {
92516+ sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
92517+ snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
92518+ } else {
92519+ sprintf(fmt, "%s%s", loglevel, "grsec: ");
92520+ strcpy(buf, fmt);
92521+ }
92522+
92523+ return NO_FLOODING;
92524+}
92525+
92526+static void gr_log_middle(int audit, const char *msg, va_list ap)
92527+ __attribute__ ((format (printf, 2, 0)));
92528+
92529+static void gr_log_middle(int audit, const char *msg, va_list ap)
92530+{
92531+ char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
92532+ unsigned int len = strlen(buf);
92533+
92534+ vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
92535+
92536+ return;
92537+}
92538+
92539+static void gr_log_middle_varargs(int audit, const char *msg, ...)
92540+ __attribute__ ((format (printf, 2, 3)));
92541+
92542+static void gr_log_middle_varargs(int audit, const char *msg, ...)
92543+{
92544+ char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
92545+ unsigned int len = strlen(buf);
92546+ va_list ap;
92547+
92548+ va_start(ap, msg);
92549+ vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
92550+ va_end(ap);
92551+
92552+ return;
92553+}
92554+
92555+static void gr_log_end(int audit, int append_default)
92556+{
92557+ char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
92558+ if (append_default) {
92559+ struct task_struct *task = current;
92560+ struct task_struct *parent = task->real_parent;
92561+ const struct cred *cred = __task_cred(task);
92562+ const struct cred *pcred = __task_cred(parent);
92563+ unsigned int len = strlen(buf);
92564+
92565+ 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));
92566+ }
92567+
92568+ printk("%s\n", buf);
92569+
92570+ return;
92571+}
92572+
92573+void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
92574+{
92575+ int logtype;
92576+ char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
92577+ char *str1 = NULL, *str2 = NULL, *str3 = NULL;
92578+ void *voidptr = NULL;
92579+ int num1 = 0, num2 = 0;
92580+ unsigned long ulong1 = 0, ulong2 = 0;
92581+ struct dentry *dentry = NULL;
92582+ struct vfsmount *mnt = NULL;
92583+ struct file *file = NULL;
92584+ struct task_struct *task = NULL;
92585+ struct vm_area_struct *vma = NULL;
92586+ const struct cred *cred, *pcred;
92587+ va_list ap;
92588+
92589+ BEGIN_LOCKS(audit);
92590+ logtype = gr_log_start(audit);
92591+ if (logtype == FLOODING) {
92592+ END_LOCKS(audit);
92593+ return;
92594+ }
92595+ va_start(ap, argtypes);
92596+ switch (argtypes) {
92597+ case GR_TTYSNIFF:
92598+ task = va_arg(ap, struct task_struct *);
92599+ 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));
92600+ break;
92601+ case GR_SYSCTL_HIDDEN:
92602+ str1 = va_arg(ap, char *);
92603+ gr_log_middle_varargs(audit, msg, result, str1);
92604+ break;
92605+ case GR_RBAC:
92606+ dentry = va_arg(ap, struct dentry *);
92607+ mnt = va_arg(ap, struct vfsmount *);
92608+ gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
92609+ break;
92610+ case GR_RBAC_STR:
92611+ dentry = va_arg(ap, struct dentry *);
92612+ mnt = va_arg(ap, struct vfsmount *);
92613+ str1 = va_arg(ap, char *);
92614+ gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
92615+ break;
92616+ case GR_STR_RBAC:
92617+ str1 = va_arg(ap, char *);
92618+ dentry = va_arg(ap, struct dentry *);
92619+ mnt = va_arg(ap, struct vfsmount *);
92620+ gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
92621+ break;
92622+ case GR_RBAC_MODE2:
92623+ dentry = va_arg(ap, struct dentry *);
92624+ mnt = va_arg(ap, struct vfsmount *);
92625+ str1 = va_arg(ap, char *);
92626+ str2 = va_arg(ap, char *);
92627+ gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
92628+ break;
92629+ case GR_RBAC_MODE3:
92630+ dentry = va_arg(ap, struct dentry *);
92631+ mnt = va_arg(ap, struct vfsmount *);
92632+ str1 = va_arg(ap, char *);
92633+ str2 = va_arg(ap, char *);
92634+ str3 = va_arg(ap, char *);
92635+ gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
92636+ break;
92637+ case GR_FILENAME:
92638+ dentry = va_arg(ap, struct dentry *);
92639+ mnt = va_arg(ap, struct vfsmount *);
92640+ gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
92641+ break;
92642+ case GR_STR_FILENAME:
92643+ str1 = va_arg(ap, char *);
92644+ dentry = va_arg(ap, struct dentry *);
92645+ mnt = va_arg(ap, struct vfsmount *);
92646+ gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
92647+ break;
92648+ case GR_FILENAME_STR:
92649+ dentry = va_arg(ap, struct dentry *);
92650+ mnt = va_arg(ap, struct vfsmount *);
92651+ str1 = va_arg(ap, char *);
92652+ gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
92653+ break;
92654+ case GR_FILENAME_TWO_INT:
92655+ dentry = va_arg(ap, struct dentry *);
92656+ mnt = va_arg(ap, struct vfsmount *);
92657+ num1 = va_arg(ap, int);
92658+ num2 = va_arg(ap, int);
92659+ gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
92660+ break;
92661+ case GR_FILENAME_TWO_INT_STR:
92662+ dentry = va_arg(ap, struct dentry *);
92663+ mnt = va_arg(ap, struct vfsmount *);
92664+ num1 = va_arg(ap, int);
92665+ num2 = va_arg(ap, int);
92666+ str1 = va_arg(ap, char *);
92667+ gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
92668+ break;
92669+ case GR_TEXTREL:
92670+ file = va_arg(ap, struct file *);
92671+ ulong1 = va_arg(ap, unsigned long);
92672+ ulong2 = va_arg(ap, unsigned long);
92673+ gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
92674+ break;
92675+ case GR_PTRACE:
92676+ task = va_arg(ap, struct task_struct *);
92677+ 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));
92678+ break;
92679+ case GR_RESOURCE:
92680+ task = va_arg(ap, struct task_struct *);
92681+ cred = __task_cred(task);
92682+ pcred = __task_cred(task->real_parent);
92683+ ulong1 = va_arg(ap, unsigned long);
92684+ str1 = va_arg(ap, char *);
92685+ ulong2 = va_arg(ap, unsigned long);
92686+ 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));
92687+ break;
92688+ case GR_CAP:
92689+ task = va_arg(ap, struct task_struct *);
92690+ cred = __task_cred(task);
92691+ pcred = __task_cred(task->real_parent);
92692+ str1 = va_arg(ap, char *);
92693+ 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));
92694+ break;
92695+ case GR_SIG:
92696+ str1 = va_arg(ap, char *);
92697+ voidptr = va_arg(ap, void *);
92698+ gr_log_middle_varargs(audit, msg, str1, voidptr);
92699+ break;
92700+ case GR_SIG2:
92701+ task = va_arg(ap, struct task_struct *);
92702+ cred = __task_cred(task);
92703+ pcred = __task_cred(task->real_parent);
92704+ num1 = va_arg(ap, int);
92705+ 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));
92706+ break;
92707+ case GR_CRASH1:
92708+ task = va_arg(ap, struct task_struct *);
92709+ cred = __task_cred(task);
92710+ pcred = __task_cred(task->real_parent);
92711+ ulong1 = va_arg(ap, unsigned long);
92712+ 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);
92713+ break;
92714+ case GR_CRASH2:
92715+ task = va_arg(ap, struct task_struct *);
92716+ cred = __task_cred(task);
92717+ pcred = __task_cred(task->real_parent);
92718+ ulong1 = va_arg(ap, unsigned long);
92719+ 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);
92720+ break;
92721+ case GR_RWXMAP:
92722+ file = va_arg(ap, struct file *);
92723+ gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
92724+ break;
92725+ case GR_RWXMAPVMA:
92726+ vma = va_arg(ap, struct vm_area_struct *);
92727+ if (vma->vm_file)
92728+ str1 = gr_to_filename(vma->vm_file->f_path.dentry, vma->vm_file->f_path.mnt);
92729+ else if (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
92730+ str1 = "<stack>";
92731+ else if (vma->vm_start <= current->mm->brk &&
92732+ vma->vm_end >= current->mm->start_brk)
92733+ str1 = "<heap>";
92734+ else
92735+ str1 = "<anonymous mapping>";
92736+ gr_log_middle_varargs(audit, msg, str1);
92737+ break;
92738+ case GR_PSACCT:
92739+ {
92740+ unsigned int wday, cday;
92741+ __u8 whr, chr;
92742+ __u8 wmin, cmin;
92743+ __u8 wsec, csec;
92744+ char cur_tty[64] = { 0 };
92745+ char parent_tty[64] = { 0 };
92746+
92747+ task = va_arg(ap, struct task_struct *);
92748+ wday = va_arg(ap, unsigned int);
92749+ cday = va_arg(ap, unsigned int);
92750+ whr = va_arg(ap, int);
92751+ chr = va_arg(ap, int);
92752+ wmin = va_arg(ap, int);
92753+ cmin = va_arg(ap, int);
92754+ wsec = va_arg(ap, int);
92755+ csec = va_arg(ap, int);
92756+ ulong1 = va_arg(ap, unsigned long);
92757+ cred = __task_cred(task);
92758+ pcred = __task_cred(task->real_parent);
92759+
92760+ 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));
92761+ }
92762+ break;
92763+ default:
92764+ gr_log_middle(audit, msg, ap);
92765+ }
92766+ va_end(ap);
92767+ // these don't need DEFAULTSECARGS printed on the end
92768+ if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
92769+ gr_log_end(audit, 0);
92770+ else
92771+ gr_log_end(audit, 1);
92772+ END_LOCKS(audit);
92773+}
92774diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
92775new file mode 100644
92776index 0000000..0e39d8c
92777--- /dev/null
92778+++ b/grsecurity/grsec_mem.c
92779@@ -0,0 +1,48 @@
92780+#include <linux/kernel.h>
92781+#include <linux/sched.h>
92782+#include <linux/mm.h>
92783+#include <linux/mman.h>
92784+#include <linux/module.h>
92785+#include <linux/grinternal.h>
92786+
92787+void gr_handle_msr_write(void)
92788+{
92789+ gr_log_noargs(GR_DONT_AUDIT, GR_MSRWRITE_MSG);
92790+ return;
92791+}
92792+EXPORT_SYMBOL_GPL(gr_handle_msr_write);
92793+
92794+void
92795+gr_handle_ioperm(void)
92796+{
92797+ gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
92798+ return;
92799+}
92800+
92801+void
92802+gr_handle_iopl(void)
92803+{
92804+ gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
92805+ return;
92806+}
92807+
92808+void
92809+gr_handle_mem_readwrite(u64 from, u64 to)
92810+{
92811+ gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
92812+ return;
92813+}
92814+
92815+void
92816+gr_handle_vm86(void)
92817+{
92818+ gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
92819+ return;
92820+}
92821+
92822+void
92823+gr_log_badprocpid(const char *entry)
92824+{
92825+ gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
92826+ return;
92827+}
92828diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
92829new file mode 100644
92830index 0000000..fe02bf4
92831--- /dev/null
92832+++ b/grsecurity/grsec_mount.c
92833@@ -0,0 +1,65 @@
92834+#include <linux/kernel.h>
92835+#include <linux/sched.h>
92836+#include <linux/mount.h>
92837+#include <linux/major.h>
92838+#include <linux/grsecurity.h>
92839+#include <linux/grinternal.h>
92840+
92841+void
92842+gr_log_remount(const char *devname, const int retval)
92843+{
92844+#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
92845+ if (grsec_enable_mount && (retval >= 0))
92846+ gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
92847+#endif
92848+ return;
92849+}
92850+
92851+void
92852+gr_log_unmount(const char *devname, const int retval)
92853+{
92854+#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
92855+ if (grsec_enable_mount && (retval >= 0))
92856+ gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
92857+#endif
92858+ return;
92859+}
92860+
92861+void
92862+gr_log_mount(const char *from, struct path *to, const int retval)
92863+{
92864+#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
92865+ if (grsec_enable_mount && (retval >= 0))
92866+ gr_log_str_fs(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to->dentry, to->mnt);
92867+#endif
92868+ return;
92869+}
92870+
92871+int
92872+gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
92873+{
92874+#ifdef CONFIG_GRKERNSEC_ROFS
92875+ if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
92876+ gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
92877+ return -EPERM;
92878+ } else
92879+ return 0;
92880+#endif
92881+ return 0;
92882+}
92883+
92884+int
92885+gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
92886+{
92887+#ifdef CONFIG_GRKERNSEC_ROFS
92888+ struct inode *inode = d_backing_inode(dentry);
92889+
92890+ if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
92891+ inode && (S_ISBLK(inode->i_mode) || (S_ISCHR(inode->i_mode) && imajor(inode) == RAW_MAJOR))) {
92892+ gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
92893+ return -EPERM;
92894+ } else
92895+ return 0;
92896+#endif
92897+ return 0;
92898+}
92899diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
92900new file mode 100644
92901index 0000000..6ee9d50
92902--- /dev/null
92903+++ b/grsecurity/grsec_pax.c
92904@@ -0,0 +1,45 @@
92905+#include <linux/kernel.h>
92906+#include <linux/sched.h>
92907+#include <linux/mm.h>
92908+#include <linux/file.h>
92909+#include <linux/grinternal.h>
92910+#include <linux/grsecurity.h>
92911+
92912+void
92913+gr_log_textrel(struct vm_area_struct * vma)
92914+{
92915+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
92916+ if (grsec_enable_log_rwxmaps)
92917+ gr_log_textrel_ulong_ulong(GR_DONT_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
92918+#endif
92919+ return;
92920+}
92921+
92922+void gr_log_ptgnustack(struct file *file)
92923+{
92924+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
92925+ if (grsec_enable_log_rwxmaps)
92926+ gr_log_rwxmap(GR_DONT_AUDIT, GR_PTGNUSTACK_MSG, file);
92927+#endif
92928+ return;
92929+}
92930+
92931+void
92932+gr_log_rwxmmap(struct file *file)
92933+{
92934+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
92935+ if (grsec_enable_log_rwxmaps)
92936+ gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
92937+#endif
92938+ return;
92939+}
92940+
92941+void
92942+gr_log_rwxmprotect(struct vm_area_struct *vma)
92943+{
92944+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
92945+ if (grsec_enable_log_rwxmaps)
92946+ gr_log_rwxmap_vma(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, vma);
92947+#endif
92948+ return;
92949+}
92950diff --git a/grsecurity/grsec_proc.c b/grsecurity/grsec_proc.c
92951new file mode 100644
92952index 0000000..2005a3a
92953--- /dev/null
92954+++ b/grsecurity/grsec_proc.c
92955@@ -0,0 +1,20 @@
92956+#include <linux/kernel.h>
92957+#include <linux/sched.h>
92958+#include <linux/grsecurity.h>
92959+#include <linux/grinternal.h>
92960+
92961+int gr_proc_is_restricted(void)
92962+{
92963+#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
92964+ const struct cred *cred = current_cred();
92965+#endif
92966+
92967+#ifdef CONFIG_GRKERNSEC_PROC_USER
92968+ if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
92969+ return -EACCES;
92970+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
92971+ if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
92972+ return -EACCES;
92973+#endif
92974+ return 0;
92975+}
92976diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
92977new file mode 100644
92978index 0000000..304c518
92979--- /dev/null
92980+++ b/grsecurity/grsec_ptrace.c
92981@@ -0,0 +1,30 @@
92982+#include <linux/kernel.h>
92983+#include <linux/sched.h>
92984+#include <linux/grinternal.h>
92985+#include <linux/security.h>
92986+
92987+void
92988+gr_audit_ptrace(struct task_struct *task)
92989+{
92990+#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
92991+ if (grsec_enable_audit_ptrace)
92992+ gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
92993+#endif
92994+ return;
92995+}
92996+
92997+int
92998+gr_ptrace_readexec(struct file *file, int unsafe_flags)
92999+{
93000+#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
93001+ const struct dentry *dentry = file->f_path.dentry;
93002+ const struct vfsmount *mnt = file->f_path.mnt;
93003+
93004+ if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
93005+ (inode_permission(d_backing_inode(dentry), MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
93006+ gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
93007+ return -EACCES;
93008+ }
93009+#endif
93010+ return 0;
93011+}
93012diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
93013new file mode 100644
93014index 0000000..3860c7e
93015--- /dev/null
93016+++ b/grsecurity/grsec_sig.c
93017@@ -0,0 +1,236 @@
93018+#include <linux/kernel.h>
93019+#include <linux/sched.h>
93020+#include <linux/fs.h>
93021+#include <linux/delay.h>
93022+#include <linux/grsecurity.h>
93023+#include <linux/grinternal.h>
93024+#include <linux/hardirq.h>
93025+
93026+char *signames[] = {
93027+ [SIGSEGV] = "Segmentation fault",
93028+ [SIGILL] = "Illegal instruction",
93029+ [SIGABRT] = "Abort",
93030+ [SIGBUS] = "Invalid alignment/Bus error"
93031+};
93032+
93033+void
93034+gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
93035+{
93036+#ifdef CONFIG_GRKERNSEC_SIGNAL
93037+ if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
93038+ (sig == SIGABRT) || (sig == SIGBUS))) {
93039+ if (task_pid_nr(t) == task_pid_nr(current)) {
93040+ gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
93041+ } else {
93042+ gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
93043+ }
93044+ }
93045+#endif
93046+ return;
93047+}
93048+
93049+int
93050+gr_handle_signal(const struct task_struct *p, const int sig)
93051+{
93052+#ifdef CONFIG_GRKERNSEC
93053+ /* ignore the 0 signal for protected task checks */
93054+ if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
93055+ gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
93056+ return -EPERM;
93057+ } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
93058+ return -EPERM;
93059+ }
93060+#endif
93061+ return 0;
93062+}
93063+
93064+#ifdef CONFIG_GRKERNSEC
93065+extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
93066+
93067+int gr_fake_force_sig(int sig, struct task_struct *t)
93068+{
93069+ unsigned long int flags;
93070+ int ret, blocked, ignored;
93071+ struct k_sigaction *action;
93072+
93073+ spin_lock_irqsave(&t->sighand->siglock, flags);
93074+ action = &t->sighand->action[sig-1];
93075+ ignored = action->sa.sa_handler == SIG_IGN;
93076+ blocked = sigismember(&t->blocked, sig);
93077+ if (blocked || ignored) {
93078+ action->sa.sa_handler = SIG_DFL;
93079+ if (blocked) {
93080+ sigdelset(&t->blocked, sig);
93081+ recalc_sigpending_and_wake(t);
93082+ }
93083+ }
93084+ if (action->sa.sa_handler == SIG_DFL)
93085+ t->signal->flags &= ~SIGNAL_UNKILLABLE;
93086+ ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
93087+
93088+ spin_unlock_irqrestore(&t->sighand->siglock, flags);
93089+
93090+ return ret;
93091+}
93092+#endif
93093+
93094+#define GR_USER_BAN_TIME (15 * 60)
93095+#define GR_DAEMON_BRUTE_TIME (30 * 60)
93096+
93097+void gr_handle_brute_attach(int dumpable)
93098+{
93099+#ifdef CONFIG_GRKERNSEC_BRUTE
93100+ struct task_struct *p = current;
93101+ kuid_t uid = GLOBAL_ROOT_UID;
93102+ int daemon = 0;
93103+
93104+ if (!grsec_enable_brute)
93105+ return;
93106+
93107+ rcu_read_lock();
93108+ read_lock(&tasklist_lock);
93109+ read_lock(&grsec_exec_file_lock);
93110+ if (p->real_parent && gr_is_same_file(p->real_parent->exec_file, p->exec_file)) {
93111+ p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
93112+ p->real_parent->brute = 1;
93113+ daemon = 1;
93114+ } else {
93115+ const struct cred *cred = __task_cred(p), *cred2;
93116+ struct task_struct *tsk, *tsk2;
93117+
93118+ if (dumpable != SUID_DUMP_USER && gr_is_global_nonroot(cred->uid)) {
93119+ struct user_struct *user;
93120+
93121+ uid = cred->uid;
93122+
93123+ /* this is put upon execution past expiration */
93124+ user = find_user(uid);
93125+ if (user == NULL)
93126+ goto unlock;
93127+ user->suid_banned = 1;
93128+ user->suid_ban_expires = get_seconds() + GR_USER_BAN_TIME;
93129+ if (user->suid_ban_expires == ~0UL)
93130+ user->suid_ban_expires--;
93131+
93132+ /* only kill other threads of the same binary, from the same user */
93133+ do_each_thread(tsk2, tsk) {
93134+ cred2 = __task_cred(tsk);
93135+ if (tsk != p && uid_eq(cred2->uid, uid) && gr_is_same_file(tsk->exec_file, p->exec_file))
93136+ gr_fake_force_sig(SIGKILL, tsk);
93137+ } while_each_thread(tsk2, tsk);
93138+ }
93139+ }
93140+unlock:
93141+ read_unlock(&grsec_exec_file_lock);
93142+ read_unlock(&tasklist_lock);
93143+ rcu_read_unlock();
93144+
93145+ if (gr_is_global_nonroot(uid))
93146+ 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);
93147+ else if (daemon)
93148+ gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
93149+
93150+#endif
93151+ return;
93152+}
93153+
93154+void gr_handle_brute_check(void)
93155+{
93156+#ifdef CONFIG_GRKERNSEC_BRUTE
93157+ struct task_struct *p = current;
93158+
93159+ if (unlikely(p->brute)) {
93160+ if (!grsec_enable_brute)
93161+ p->brute = 0;
93162+ else if (time_before(get_seconds(), p->brute_expires))
93163+ msleep(30 * 1000);
93164+ }
93165+#endif
93166+ return;
93167+}
93168+
93169+void gr_handle_kernel_exploit(void)
93170+{
93171+#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
93172+ const struct cred *cred;
93173+ struct task_struct *tsk, *tsk2;
93174+ struct user_struct *user;
93175+ kuid_t uid;
93176+
93177+ if (in_irq() || in_serving_softirq() || in_nmi())
93178+ panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
93179+
93180+ uid = current_uid();
93181+
93182+ if (gr_is_global_root(uid))
93183+ panic("grsec: halting the system due to suspicious kernel crash caused by root");
93184+ else {
93185+ /* kill all the processes of this user, hold a reference
93186+ to their creds struct, and prevent them from creating
93187+ another process until system reset
93188+ */
93189+ printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
93190+ GR_GLOBAL_UID(uid));
93191+ /* we intentionally leak this ref */
93192+ user = get_uid(current->cred->user);
93193+ if (user)
93194+ user->kernel_banned = 1;
93195+
93196+ /* kill all processes of this user */
93197+ read_lock(&tasklist_lock);
93198+ do_each_thread(tsk2, tsk) {
93199+ cred = __task_cred(tsk);
93200+ if (uid_eq(cred->uid, uid))
93201+ gr_fake_force_sig(SIGKILL, tsk);
93202+ } while_each_thread(tsk2, tsk);
93203+ read_unlock(&tasklist_lock);
93204+ }
93205+#endif
93206+}
93207+
93208+#ifdef CONFIG_GRKERNSEC_BRUTE
93209+static bool suid_ban_expired(struct user_struct *user)
93210+{
93211+ if (user->suid_ban_expires != ~0UL && time_after_eq(get_seconds(), user->suid_ban_expires)) {
93212+ user->suid_banned = 0;
93213+ user->suid_ban_expires = 0;
93214+ free_uid(user);
93215+ return true;
93216+ }
93217+
93218+ return false;
93219+}
93220+#endif
93221+
93222+int gr_process_kernel_exec_ban(void)
93223+{
93224+#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
93225+ if (unlikely(current->cred->user->kernel_banned))
93226+ return -EPERM;
93227+#endif
93228+ return 0;
93229+}
93230+
93231+int gr_process_kernel_setuid_ban(struct user_struct *user)
93232+{
93233+#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
93234+ if (unlikely(user->kernel_banned))
93235+ gr_fake_force_sig(SIGKILL, current);
93236+#endif
93237+ return 0;
93238+}
93239+
93240+int gr_process_suid_exec_ban(const struct linux_binprm *bprm)
93241+{
93242+#ifdef CONFIG_GRKERNSEC_BRUTE
93243+ struct user_struct *user = current->cred->user;
93244+ if (unlikely(user->suid_banned)) {
93245+ if (suid_ban_expired(user))
93246+ return 0;
93247+ /* disallow execution of suid binaries only */
93248+ else if (!uid_eq(bprm->cred->euid, current->cred->uid))
93249+ return -EPERM;
93250+ }
93251+#endif
93252+ return 0;
93253+}
93254diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
93255new file mode 100644
93256index 0000000..a523bd2
93257--- /dev/null
93258+++ b/grsecurity/grsec_sock.c
93259@@ -0,0 +1,244 @@
93260+#include <linux/kernel.h>
93261+#include <linux/module.h>
93262+#include <linux/sched.h>
93263+#include <linux/file.h>
93264+#include <linux/net.h>
93265+#include <linux/in.h>
93266+#include <linux/ip.h>
93267+#include <net/sock.h>
93268+#include <net/inet_sock.h>
93269+#include <linux/grsecurity.h>
93270+#include <linux/grinternal.h>
93271+#include <linux/gracl.h>
93272+
93273+extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
93274+extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
93275+
93276+EXPORT_SYMBOL_GPL(gr_search_udp_recvmsg);
93277+EXPORT_SYMBOL_GPL(gr_search_udp_sendmsg);
93278+
93279+#ifdef CONFIG_UNIX_MODULE
93280+EXPORT_SYMBOL_GPL(gr_acl_handle_unix);
93281+EXPORT_SYMBOL_GPL(gr_acl_handle_mknod);
93282+EXPORT_SYMBOL_GPL(gr_handle_chroot_unix);
93283+EXPORT_SYMBOL_GPL(gr_handle_create);
93284+#endif
93285+
93286+#ifdef CONFIG_GRKERNSEC
93287+#define gr_conn_table_size 32749
93288+struct conn_table_entry {
93289+ struct conn_table_entry *next;
93290+ struct signal_struct *sig;
93291+};
93292+
93293+struct conn_table_entry *gr_conn_table[gr_conn_table_size];
93294+DEFINE_SPINLOCK(gr_conn_table_lock);
93295+
93296+extern const char * gr_socktype_to_name(unsigned char type);
93297+extern const char * gr_proto_to_name(unsigned char proto);
93298+extern const char * gr_sockfamily_to_name(unsigned char family);
93299+
93300+static int
93301+conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
93302+{
93303+ return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
93304+}
93305+
93306+static int
93307+conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
93308+ __u16 sport, __u16 dport)
93309+{
93310+ if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
93311+ sig->gr_sport == sport && sig->gr_dport == dport))
93312+ return 1;
93313+ else
93314+ return 0;
93315+}
93316+
93317+static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
93318+{
93319+ struct conn_table_entry **match;
93320+ unsigned int index;
93321+
93322+ index = conn_hash(sig->gr_saddr, sig->gr_daddr,
93323+ sig->gr_sport, sig->gr_dport,
93324+ gr_conn_table_size);
93325+
93326+ newent->sig = sig;
93327+
93328+ match = &gr_conn_table[index];
93329+ newent->next = *match;
93330+ *match = newent;
93331+
93332+ return;
93333+}
93334+
93335+static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
93336+{
93337+ struct conn_table_entry *match, *last = NULL;
93338+ unsigned int index;
93339+
93340+ index = conn_hash(sig->gr_saddr, sig->gr_daddr,
93341+ sig->gr_sport, sig->gr_dport,
93342+ gr_conn_table_size);
93343+
93344+ match = gr_conn_table[index];
93345+ while (match && !conn_match(match->sig,
93346+ sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
93347+ sig->gr_dport)) {
93348+ last = match;
93349+ match = match->next;
93350+ }
93351+
93352+ if (match) {
93353+ if (last)
93354+ last->next = match->next;
93355+ else
93356+ gr_conn_table[index] = NULL;
93357+ kfree(match);
93358+ }
93359+
93360+ return;
93361+}
93362+
93363+static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
93364+ __u16 sport, __u16 dport)
93365+{
93366+ struct conn_table_entry *match;
93367+ unsigned int index;
93368+
93369+ index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
93370+
93371+ match = gr_conn_table[index];
93372+ while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
93373+ match = match->next;
93374+
93375+ if (match)
93376+ return match->sig;
93377+ else
93378+ return NULL;
93379+}
93380+
93381+#endif
93382+
93383+void gr_update_task_in_ip_table(const struct inet_sock *inet)
93384+{
93385+#ifdef CONFIG_GRKERNSEC
93386+ struct signal_struct *sig = current->signal;
93387+ struct conn_table_entry *newent;
93388+
93389+ newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
93390+ if (newent == NULL)
93391+ return;
93392+ /* no bh lock needed since we are called with bh disabled */
93393+ spin_lock(&gr_conn_table_lock);
93394+ gr_del_task_from_ip_table_nolock(sig);
93395+ sig->gr_saddr = inet->inet_rcv_saddr;
93396+ sig->gr_daddr = inet->inet_daddr;
93397+ sig->gr_sport = inet->inet_sport;
93398+ sig->gr_dport = inet->inet_dport;
93399+ gr_add_to_task_ip_table_nolock(sig, newent);
93400+ spin_unlock(&gr_conn_table_lock);
93401+#endif
93402+ return;
93403+}
93404+
93405+void gr_del_task_from_ip_table(struct task_struct *task)
93406+{
93407+#ifdef CONFIG_GRKERNSEC
93408+ spin_lock_bh(&gr_conn_table_lock);
93409+ gr_del_task_from_ip_table_nolock(task->signal);
93410+ spin_unlock_bh(&gr_conn_table_lock);
93411+#endif
93412+ return;
93413+}
93414+
93415+void
93416+gr_attach_curr_ip(const struct sock *sk)
93417+{
93418+#ifdef CONFIG_GRKERNSEC
93419+ struct signal_struct *p, *set;
93420+ const struct inet_sock *inet = inet_sk(sk);
93421+
93422+ if (unlikely(sk->sk_protocol != IPPROTO_TCP))
93423+ return;
93424+
93425+ set = current->signal;
93426+
93427+ spin_lock_bh(&gr_conn_table_lock);
93428+ p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
93429+ inet->inet_dport, inet->inet_sport);
93430+ if (unlikely(p != NULL)) {
93431+ set->curr_ip = p->curr_ip;
93432+ set->used_accept = 1;
93433+ gr_del_task_from_ip_table_nolock(p);
93434+ spin_unlock_bh(&gr_conn_table_lock);
93435+ return;
93436+ }
93437+ spin_unlock_bh(&gr_conn_table_lock);
93438+
93439+ set->curr_ip = inet->inet_daddr;
93440+ set->used_accept = 1;
93441+#endif
93442+ return;
93443+}
93444+
93445+int
93446+gr_handle_sock_all(const int family, const int type, const int protocol)
93447+{
93448+#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
93449+ if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
93450+ (family != AF_UNIX)) {
93451+ if (family == AF_INET)
93452+ gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
93453+ else
93454+ gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
93455+ return -EACCES;
93456+ }
93457+#endif
93458+ return 0;
93459+}
93460+
93461+int
93462+gr_handle_sock_server(const struct sockaddr *sck)
93463+{
93464+#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
93465+ if (grsec_enable_socket_server &&
93466+ in_group_p(grsec_socket_server_gid) &&
93467+ sck && (sck->sa_family != AF_UNIX) &&
93468+ (sck->sa_family != AF_LOCAL)) {
93469+ gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
93470+ return -EACCES;
93471+ }
93472+#endif
93473+ return 0;
93474+}
93475+
93476+int
93477+gr_handle_sock_server_other(const struct sock *sck)
93478+{
93479+#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
93480+ if (grsec_enable_socket_server &&
93481+ in_group_p(grsec_socket_server_gid) &&
93482+ sck && (sck->sk_family != AF_UNIX) &&
93483+ (sck->sk_family != AF_LOCAL)) {
93484+ gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
93485+ return -EACCES;
93486+ }
93487+#endif
93488+ return 0;
93489+}
93490+
93491+int
93492+gr_handle_sock_client(const struct sockaddr *sck)
93493+{
93494+#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
93495+ if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
93496+ sck && (sck->sa_family != AF_UNIX) &&
93497+ (sck->sa_family != AF_LOCAL)) {
93498+ gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
93499+ return -EACCES;
93500+ }
93501+#endif
93502+ return 0;
93503+}
93504diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
93505new file mode 100644
93506index 0000000..aaec43c
93507--- /dev/null
93508+++ b/grsecurity/grsec_sysctl.c
93509@@ -0,0 +1,488 @@
93510+#include <linux/kernel.h>
93511+#include <linux/sched.h>
93512+#include <linux/sysctl.h>
93513+#include <linux/grsecurity.h>
93514+#include <linux/grinternal.h>
93515+
93516+int
93517+gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
93518+{
93519+#ifdef CONFIG_GRKERNSEC_SYSCTL
93520+ if (dirname == NULL || name == NULL)
93521+ return 0;
93522+ if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
93523+ gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
93524+ return -EACCES;
93525+ }
93526+#endif
93527+ return 0;
93528+}
93529+
93530+#if defined(CONFIG_GRKERNSEC_ROFS) || defined(CONFIG_GRKERNSEC_DENYUSB)
93531+static int __maybe_unused __read_only one = 1;
93532+#endif
93533+
93534+#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS) || \
93535+ defined(CONFIG_GRKERNSEC_DENYUSB)
93536+struct ctl_table grsecurity_table[] = {
93537+#ifdef CONFIG_GRKERNSEC_SYSCTL
93538+#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
93539+#ifdef CONFIG_GRKERNSEC_IO
93540+ {
93541+ .procname = "disable_priv_io",
93542+ .data = &grsec_disable_privio,
93543+ .maxlen = sizeof(int),
93544+ .mode = 0600,
93545+ .proc_handler = &proc_dointvec_secure,
93546+ },
93547+#endif
93548+#endif
93549+#ifdef CONFIG_GRKERNSEC_LINK
93550+ {
93551+ .procname = "linking_restrictions",
93552+ .data = &grsec_enable_link,
93553+ .maxlen = sizeof(int),
93554+ .mode = 0600,
93555+ .proc_handler = &proc_dointvec_secure,
93556+ },
93557+#endif
93558+#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
93559+ {
93560+ .procname = "enforce_symlinksifowner",
93561+ .data = &grsec_enable_symlinkown,
93562+ .maxlen = sizeof(int),
93563+ .mode = 0600,
93564+ .proc_handler = &proc_dointvec_secure,
93565+ },
93566+ {
93567+ .procname = "symlinkown_gid",
93568+ .data = &grsec_symlinkown_gid,
93569+ .maxlen = sizeof(int),
93570+ .mode = 0600,
93571+ .proc_handler = &proc_dointvec_secure,
93572+ },
93573+#endif
93574+#ifdef CONFIG_GRKERNSEC_BRUTE
93575+ {
93576+ .procname = "deter_bruteforce",
93577+ .data = &grsec_enable_brute,
93578+ .maxlen = sizeof(int),
93579+ .mode = 0600,
93580+ .proc_handler = &proc_dointvec_secure,
93581+ },
93582+#endif
93583+#ifdef CONFIG_GRKERNSEC_FIFO
93584+ {
93585+ .procname = "fifo_restrictions",
93586+ .data = &grsec_enable_fifo,
93587+ .maxlen = sizeof(int),
93588+ .mode = 0600,
93589+ .proc_handler = &proc_dointvec_secure,
93590+ },
93591+#endif
93592+#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
93593+ {
93594+ .procname = "ptrace_readexec",
93595+ .data = &grsec_enable_ptrace_readexec,
93596+ .maxlen = sizeof(int),
93597+ .mode = 0600,
93598+ .proc_handler = &proc_dointvec_secure,
93599+ },
93600+#endif
93601+#ifdef CONFIG_GRKERNSEC_SETXID
93602+ {
93603+ .procname = "consistent_setxid",
93604+ .data = &grsec_enable_setxid,
93605+ .maxlen = sizeof(int),
93606+ .mode = 0600,
93607+ .proc_handler = &proc_dointvec_secure,
93608+ },
93609+#endif
93610+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93611+ {
93612+ .procname = "ip_blackhole",
93613+ .data = &grsec_enable_blackhole,
93614+ .maxlen = sizeof(int),
93615+ .mode = 0600,
93616+ .proc_handler = &proc_dointvec_secure,
93617+ },
93618+ {
93619+ .procname = "lastack_retries",
93620+ .data = &grsec_lastack_retries,
93621+ .maxlen = sizeof(int),
93622+ .mode = 0600,
93623+ .proc_handler = &proc_dointvec_secure,
93624+ },
93625+#endif
93626+#ifdef CONFIG_GRKERNSEC_EXECLOG
93627+ {
93628+ .procname = "exec_logging",
93629+ .data = &grsec_enable_execlog,
93630+ .maxlen = sizeof(int),
93631+ .mode = 0600,
93632+ .proc_handler = &proc_dointvec_secure,
93633+ },
93634+#endif
93635+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
93636+ {
93637+ .procname = "rwxmap_logging",
93638+ .data = &grsec_enable_log_rwxmaps,
93639+ .maxlen = sizeof(int),
93640+ .mode = 0600,
93641+ .proc_handler = &proc_dointvec_secure,
93642+ },
93643+#endif
93644+#ifdef CONFIG_GRKERNSEC_SIGNAL
93645+ {
93646+ .procname = "signal_logging",
93647+ .data = &grsec_enable_signal,
93648+ .maxlen = sizeof(int),
93649+ .mode = 0600,
93650+ .proc_handler = &proc_dointvec_secure,
93651+ },
93652+#endif
93653+#ifdef CONFIG_GRKERNSEC_FORKFAIL
93654+ {
93655+ .procname = "forkfail_logging",
93656+ .data = &grsec_enable_forkfail,
93657+ .maxlen = sizeof(int),
93658+ .mode = 0600,
93659+ .proc_handler = &proc_dointvec_secure,
93660+ },
93661+#endif
93662+#ifdef CONFIG_GRKERNSEC_TIME
93663+ {
93664+ .procname = "timechange_logging",
93665+ .data = &grsec_enable_time,
93666+ .maxlen = sizeof(int),
93667+ .mode = 0600,
93668+ .proc_handler = &proc_dointvec_secure,
93669+ },
93670+#endif
93671+#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
93672+ {
93673+ .procname = "chroot_deny_shmat",
93674+ .data = &grsec_enable_chroot_shmat,
93675+ .maxlen = sizeof(int),
93676+ .mode = 0600,
93677+ .proc_handler = &proc_dointvec_secure,
93678+ },
93679+#endif
93680+#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
93681+ {
93682+ .procname = "chroot_deny_unix",
93683+ .data = &grsec_enable_chroot_unix,
93684+ .maxlen = sizeof(int),
93685+ .mode = 0600,
93686+ .proc_handler = &proc_dointvec_secure,
93687+ },
93688+#endif
93689+#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
93690+ {
93691+ .procname = "chroot_deny_mount",
93692+ .data = &grsec_enable_chroot_mount,
93693+ .maxlen = sizeof(int),
93694+ .mode = 0600,
93695+ .proc_handler = &proc_dointvec_secure,
93696+ },
93697+#endif
93698+#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
93699+ {
93700+ .procname = "chroot_deny_fchdir",
93701+ .data = &grsec_enable_chroot_fchdir,
93702+ .maxlen = sizeof(int),
93703+ .mode = 0600,
93704+ .proc_handler = &proc_dointvec_secure,
93705+ },
93706+#endif
93707+#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
93708+ {
93709+ .procname = "chroot_deny_chroot",
93710+ .data = &grsec_enable_chroot_double,
93711+ .maxlen = sizeof(int),
93712+ .mode = 0600,
93713+ .proc_handler = &proc_dointvec_secure,
93714+ },
93715+#endif
93716+#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
93717+ {
93718+ .procname = "chroot_deny_pivot",
93719+ .data = &grsec_enable_chroot_pivot,
93720+ .maxlen = sizeof(int),
93721+ .mode = 0600,
93722+ .proc_handler = &proc_dointvec_secure,
93723+ },
93724+#endif
93725+#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
93726+ {
93727+ .procname = "chroot_enforce_chdir",
93728+ .data = &grsec_enable_chroot_chdir,
93729+ .maxlen = sizeof(int),
93730+ .mode = 0600,
93731+ .proc_handler = &proc_dointvec_secure,
93732+ },
93733+#endif
93734+#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
93735+ {
93736+ .procname = "chroot_deny_chmod",
93737+ .data = &grsec_enable_chroot_chmod,
93738+ .maxlen = sizeof(int),
93739+ .mode = 0600,
93740+ .proc_handler = &proc_dointvec_secure,
93741+ },
93742+#endif
93743+#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
93744+ {
93745+ .procname = "chroot_deny_mknod",
93746+ .data = &grsec_enable_chroot_mknod,
93747+ .maxlen = sizeof(int),
93748+ .mode = 0600,
93749+ .proc_handler = &proc_dointvec_secure,
93750+ },
93751+#endif
93752+#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
93753+ {
93754+ .procname = "chroot_restrict_nice",
93755+ .data = &grsec_enable_chroot_nice,
93756+ .maxlen = sizeof(int),
93757+ .mode = 0600,
93758+ .proc_handler = &proc_dointvec_secure,
93759+ },
93760+#endif
93761+#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
93762+ {
93763+ .procname = "chroot_execlog",
93764+ .data = &grsec_enable_chroot_execlog,
93765+ .maxlen = sizeof(int),
93766+ .mode = 0600,
93767+ .proc_handler = &proc_dointvec_secure,
93768+ },
93769+#endif
93770+#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
93771+ {
93772+ .procname = "chroot_caps",
93773+ .data = &grsec_enable_chroot_caps,
93774+ .maxlen = sizeof(int),
93775+ .mode = 0600,
93776+ .proc_handler = &proc_dointvec_secure,
93777+ },
93778+#endif
93779+#ifdef CONFIG_GRKERNSEC_CHROOT_RENAME
93780+ {
93781+ .procname = "chroot_deny_bad_rename",
93782+ .data = &grsec_enable_chroot_rename,
93783+ .maxlen = sizeof(int),
93784+ .mode = 0600,
93785+ .proc_handler = &proc_dointvec_secure,
93786+ },
93787+#endif
93788+#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
93789+ {
93790+ .procname = "chroot_deny_sysctl",
93791+ .data = &grsec_enable_chroot_sysctl,
93792+ .maxlen = sizeof(int),
93793+ .mode = 0600,
93794+ .proc_handler = &proc_dointvec_secure,
93795+ },
93796+#endif
93797+#ifdef CONFIG_GRKERNSEC_TPE
93798+ {
93799+ .procname = "tpe",
93800+ .data = &grsec_enable_tpe,
93801+ .maxlen = sizeof(int),
93802+ .mode = 0600,
93803+ .proc_handler = &proc_dointvec_secure,
93804+ },
93805+ {
93806+ .procname = "tpe_gid",
93807+ .data = &grsec_tpe_gid,
93808+ .maxlen = sizeof(int),
93809+ .mode = 0600,
93810+ .proc_handler = &proc_dointvec_secure,
93811+ },
93812+#endif
93813+#ifdef CONFIG_GRKERNSEC_TPE_INVERT
93814+ {
93815+ .procname = "tpe_invert",
93816+ .data = &grsec_enable_tpe_invert,
93817+ .maxlen = sizeof(int),
93818+ .mode = 0600,
93819+ .proc_handler = &proc_dointvec_secure,
93820+ },
93821+#endif
93822+#ifdef CONFIG_GRKERNSEC_TPE_ALL
93823+ {
93824+ .procname = "tpe_restrict_all",
93825+ .data = &grsec_enable_tpe_all,
93826+ .maxlen = sizeof(int),
93827+ .mode = 0600,
93828+ .proc_handler = &proc_dointvec_secure,
93829+ },
93830+#endif
93831+#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
93832+ {
93833+ .procname = "socket_all",
93834+ .data = &grsec_enable_socket_all,
93835+ .maxlen = sizeof(int),
93836+ .mode = 0600,
93837+ .proc_handler = &proc_dointvec_secure,
93838+ },
93839+ {
93840+ .procname = "socket_all_gid",
93841+ .data = &grsec_socket_all_gid,
93842+ .maxlen = sizeof(int),
93843+ .mode = 0600,
93844+ .proc_handler = &proc_dointvec_secure,
93845+ },
93846+#endif
93847+#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
93848+ {
93849+ .procname = "socket_client",
93850+ .data = &grsec_enable_socket_client,
93851+ .maxlen = sizeof(int),
93852+ .mode = 0600,
93853+ .proc_handler = &proc_dointvec_secure,
93854+ },
93855+ {
93856+ .procname = "socket_client_gid",
93857+ .data = &grsec_socket_client_gid,
93858+ .maxlen = sizeof(int),
93859+ .mode = 0600,
93860+ .proc_handler = &proc_dointvec_secure,
93861+ },
93862+#endif
93863+#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
93864+ {
93865+ .procname = "socket_server",
93866+ .data = &grsec_enable_socket_server,
93867+ .maxlen = sizeof(int),
93868+ .mode = 0600,
93869+ .proc_handler = &proc_dointvec_secure,
93870+ },
93871+ {
93872+ .procname = "socket_server_gid",
93873+ .data = &grsec_socket_server_gid,
93874+ .maxlen = sizeof(int),
93875+ .mode = 0600,
93876+ .proc_handler = &proc_dointvec_secure,
93877+ },
93878+#endif
93879+#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
93880+ {
93881+ .procname = "audit_group",
93882+ .data = &grsec_enable_group,
93883+ .maxlen = sizeof(int),
93884+ .mode = 0600,
93885+ .proc_handler = &proc_dointvec_secure,
93886+ },
93887+ {
93888+ .procname = "audit_gid",
93889+ .data = &grsec_audit_gid,
93890+ .maxlen = sizeof(int),
93891+ .mode = 0600,
93892+ .proc_handler = &proc_dointvec_secure,
93893+ },
93894+#endif
93895+#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
93896+ {
93897+ .procname = "audit_chdir",
93898+ .data = &grsec_enable_chdir,
93899+ .maxlen = sizeof(int),
93900+ .mode = 0600,
93901+ .proc_handler = &proc_dointvec_secure,
93902+ },
93903+#endif
93904+#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
93905+ {
93906+ .procname = "audit_mount",
93907+ .data = &grsec_enable_mount,
93908+ .maxlen = sizeof(int),
93909+ .mode = 0600,
93910+ .proc_handler = &proc_dointvec_secure,
93911+ },
93912+#endif
93913+#ifdef CONFIG_GRKERNSEC_DMESG
93914+ {
93915+ .procname = "dmesg",
93916+ .data = &grsec_enable_dmesg,
93917+ .maxlen = sizeof(int),
93918+ .mode = 0600,
93919+ .proc_handler = &proc_dointvec_secure,
93920+ },
93921+#endif
93922+#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
93923+ {
93924+ .procname = "chroot_findtask",
93925+ .data = &grsec_enable_chroot_findtask,
93926+ .maxlen = sizeof(int),
93927+ .mode = 0600,
93928+ .proc_handler = &proc_dointvec_secure,
93929+ },
93930+#endif
93931+#ifdef CONFIG_GRKERNSEC_RESLOG
93932+ {
93933+ .procname = "resource_logging",
93934+ .data = &grsec_resource_logging,
93935+ .maxlen = sizeof(int),
93936+ .mode = 0600,
93937+ .proc_handler = &proc_dointvec_secure,
93938+ },
93939+#endif
93940+#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
93941+ {
93942+ .procname = "audit_ptrace",
93943+ .data = &grsec_enable_audit_ptrace,
93944+ .maxlen = sizeof(int),
93945+ .mode = 0600,
93946+ .proc_handler = &proc_dointvec_secure,
93947+ },
93948+#endif
93949+#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
93950+ {
93951+ .procname = "harden_ptrace",
93952+ .data = &grsec_enable_harden_ptrace,
93953+ .maxlen = sizeof(int),
93954+ .mode = 0600,
93955+ .proc_handler = &proc_dointvec_secure,
93956+ },
93957+#endif
93958+#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
93959+ {
93960+ .procname = "harden_ipc",
93961+ .data = &grsec_enable_harden_ipc,
93962+ .maxlen = sizeof(int),
93963+ .mode = 0600,
93964+ .proc_handler = &proc_dointvec_secure,
93965+ },
93966+#endif
93967+ {
93968+ .procname = "grsec_lock",
93969+ .data = &grsec_lock,
93970+ .maxlen = sizeof(int),
93971+ .mode = 0600,
93972+ .proc_handler = &proc_dointvec_secure,
93973+ },
93974+#endif
93975+#ifdef CONFIG_GRKERNSEC_ROFS
93976+ {
93977+ .procname = "romount_protect",
93978+ .data = &grsec_enable_rofs,
93979+ .maxlen = sizeof(int),
93980+ .mode = 0600,
93981+ .proc_handler = &proc_dointvec_minmax_secure,
93982+ .extra1 = &one,
93983+ .extra2 = &one,
93984+ },
93985+#endif
93986+#if defined(CONFIG_GRKERNSEC_DENYUSB) && !defined(CONFIG_GRKERNSEC_DENYUSB_FORCE)
93987+ {
93988+ .procname = "deny_new_usb",
93989+ .data = &grsec_deny_new_usb,
93990+ .maxlen = sizeof(int),
93991+ .mode = 0600,
93992+ .proc_handler = &proc_dointvec_secure,
93993+ },
93994+#endif
93995+ { }
93996+};
93997+#endif
93998diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
93999new file mode 100644
94000index 0000000..61b514e
94001--- /dev/null
94002+++ b/grsecurity/grsec_time.c
94003@@ -0,0 +1,16 @@
94004+#include <linux/kernel.h>
94005+#include <linux/sched.h>
94006+#include <linux/grinternal.h>
94007+#include <linux/module.h>
94008+
94009+void
94010+gr_log_timechange(void)
94011+{
94012+#ifdef CONFIG_GRKERNSEC_TIME
94013+ if (grsec_enable_time)
94014+ gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
94015+#endif
94016+ return;
94017+}
94018+
94019+EXPORT_SYMBOL_GPL(gr_log_timechange);
94020diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
94021new file mode 100644
94022index 0000000..9786671
94023--- /dev/null
94024+++ b/grsecurity/grsec_tpe.c
94025@@ -0,0 +1,78 @@
94026+#include <linux/kernel.h>
94027+#include <linux/sched.h>
94028+#include <linux/file.h>
94029+#include <linux/fs.h>
94030+#include <linux/grinternal.h>
94031+
94032+extern int gr_acl_tpe_check(void);
94033+
94034+int
94035+gr_tpe_allow(const struct file *file)
94036+{
94037+#ifdef CONFIG_GRKERNSEC
94038+ struct inode *inode = d_backing_inode(file->f_path.dentry->d_parent);
94039+ struct inode *file_inode = d_backing_inode(file->f_path.dentry);
94040+ const struct cred *cred = current_cred();
94041+ char *msg = NULL;
94042+ char *msg2 = NULL;
94043+
94044+ // never restrict root
94045+ if (gr_is_global_root(cred->uid))
94046+ return 1;
94047+
94048+ if (grsec_enable_tpe) {
94049+#ifdef CONFIG_GRKERNSEC_TPE_INVERT
94050+ if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
94051+ msg = "not being in trusted group";
94052+ else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
94053+ msg = "being in untrusted group";
94054+#else
94055+ if (in_group_p(grsec_tpe_gid))
94056+ msg = "being in untrusted group";
94057+#endif
94058+ }
94059+ if (!msg && gr_acl_tpe_check())
94060+ msg = "being in untrusted role";
94061+
94062+ // not in any affected group/role
94063+ if (!msg)
94064+ goto next_check;
94065+
94066+ if (gr_is_global_nonroot(inode->i_uid))
94067+ msg2 = "file in non-root-owned directory";
94068+ else if (inode->i_mode & S_IWOTH)
94069+ msg2 = "file in world-writable directory";
94070+ else if (inode->i_mode & S_IWGRP)
94071+ msg2 = "file in group-writable directory";
94072+ else if (file_inode->i_mode & S_IWOTH)
94073+ msg2 = "file is world-writable";
94074+
94075+ if (msg && msg2) {
94076+ char fullmsg[70] = {0};
94077+ snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
94078+ gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
94079+ return 0;
94080+ }
94081+ msg = NULL;
94082+next_check:
94083+#ifdef CONFIG_GRKERNSEC_TPE_ALL
94084+ if (!grsec_enable_tpe || !grsec_enable_tpe_all)
94085+ return 1;
94086+
94087+ if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
94088+ msg = "directory not owned by user";
94089+ else if (inode->i_mode & S_IWOTH)
94090+ msg = "file in world-writable directory";
94091+ else if (inode->i_mode & S_IWGRP)
94092+ msg = "file in group-writable directory";
94093+ else if (file_inode->i_mode & S_IWOTH)
94094+ msg = "file is world-writable";
94095+
94096+ if (msg) {
94097+ gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
94098+ return 0;
94099+ }
94100+#endif
94101+#endif
94102+ return 1;
94103+}
94104diff --git a/grsecurity/grsec_usb.c b/grsecurity/grsec_usb.c
94105new file mode 100644
94106index 0000000..ae02d8e
94107--- /dev/null
94108+++ b/grsecurity/grsec_usb.c
94109@@ -0,0 +1,15 @@
94110+#include <linux/kernel.h>
94111+#include <linux/grinternal.h>
94112+#include <linux/module.h>
94113+
94114+int gr_handle_new_usb(void)
94115+{
94116+#ifdef CONFIG_GRKERNSEC_DENYUSB
94117+ if (grsec_deny_new_usb) {
94118+ printk(KERN_ALERT "grsec: denied insert of new USB device\n");
94119+ return 1;
94120+ }
94121+#endif
94122+ return 0;
94123+}
94124+EXPORT_SYMBOL_GPL(gr_handle_new_usb);
94125diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
94126new file mode 100644
94127index 0000000..158b330
94128--- /dev/null
94129+++ b/grsecurity/grsum.c
94130@@ -0,0 +1,64 @@
94131+#include <linux/err.h>
94132+#include <linux/kernel.h>
94133+#include <linux/sched.h>
94134+#include <linux/mm.h>
94135+#include <linux/scatterlist.h>
94136+#include <linux/crypto.h>
94137+#include <linux/gracl.h>
94138+
94139+
94140+#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
94141+#error "crypto and sha256 must be built into the kernel"
94142+#endif
94143+
94144+int
94145+chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
94146+{
94147+ struct crypto_hash *tfm;
94148+ struct hash_desc desc;
94149+ struct scatterlist sg[2];
94150+ unsigned char temp_sum[GR_SHA_LEN] __attribute__((aligned(__alignof__(unsigned long))));
94151+ unsigned long *tmpsumptr = (unsigned long *)temp_sum;
94152+ unsigned long *sumptr = (unsigned long *)sum;
94153+ int cryptres;
94154+ int retval = 1;
94155+ volatile int mismatched = 0;
94156+ volatile int dummy = 0;
94157+ unsigned int i;
94158+
94159+ tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
94160+ if (IS_ERR(tfm)) {
94161+ /* should never happen, since sha256 should be built in */
94162+ memset(entry->pw, 0, GR_PW_LEN);
94163+ return 1;
94164+ }
94165+
94166+ sg_init_table(sg, 2);
94167+ sg_set_buf(&sg[0], salt, GR_SALT_LEN);
94168+ sg_set_buf(&sg[1], entry->pw, strlen(entry->pw));
94169+
94170+ desc.tfm = tfm;
94171+ desc.flags = 0;
94172+
94173+ cryptres = crypto_hash_digest(&desc, sg, GR_SALT_LEN + strlen(entry->pw),
94174+ temp_sum);
94175+
94176+ memset(entry->pw, 0, GR_PW_LEN);
94177+
94178+ if (cryptres)
94179+ goto out;
94180+
94181+ for (i = 0; i < GR_SHA_LEN/sizeof(tmpsumptr[0]); i++)
94182+ if (sumptr[i] != tmpsumptr[i])
94183+ mismatched = 1;
94184+ else
94185+ dummy = 1; // waste a cycle
94186+
94187+ if (!mismatched)
94188+ retval = dummy - 1;
94189+
94190+out:
94191+ crypto_free_hash(tfm);
94192+
94193+ return retval;
94194+}
94195diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
94196index 5bdab6b..9ae82fe 100644
94197--- a/include/asm-generic/4level-fixup.h
94198+++ b/include/asm-generic/4level-fixup.h
94199@@ -14,8 +14,10 @@
94200 #define pmd_alloc(mm, pud, address) \
94201 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
94202 NULL: pmd_offset(pud, address))
94203+#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
94204
94205 #define pud_alloc(mm, pgd, address) (pgd)
94206+#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
94207 #define pud_offset(pgd, start) (pgd)
94208 #define pud_none(pud) 0
94209 #define pud_bad(pud) 0
94210diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
94211index b7babf0..1e4b4f1 100644
94212--- a/include/asm-generic/atomic-long.h
94213+++ b/include/asm-generic/atomic-long.h
94214@@ -22,6 +22,12 @@
94215
94216 typedef atomic64_t atomic_long_t;
94217
94218+#ifdef CONFIG_PAX_REFCOUNT
94219+typedef atomic64_unchecked_t atomic_long_unchecked_t;
94220+#else
94221+typedef atomic64_t atomic_long_unchecked_t;
94222+#endif
94223+
94224 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
94225
94226 static inline long atomic_long_read(atomic_long_t *l)
94227@@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
94228 return (long)atomic64_read(v);
94229 }
94230
94231+#ifdef CONFIG_PAX_REFCOUNT
94232+static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
94233+{
94234+ atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
94235+
94236+ return (long)atomic64_read_unchecked(v);
94237+}
94238+#endif
94239+
94240 static inline void atomic_long_set(atomic_long_t *l, long i)
94241 {
94242 atomic64_t *v = (atomic64_t *)l;
94243@@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
94244 atomic64_set(v, i);
94245 }
94246
94247+#ifdef CONFIG_PAX_REFCOUNT
94248+static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
94249+{
94250+ atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
94251+
94252+ atomic64_set_unchecked(v, i);
94253+}
94254+#endif
94255+
94256 static inline void atomic_long_inc(atomic_long_t *l)
94257 {
94258 atomic64_t *v = (atomic64_t *)l;
94259@@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
94260 atomic64_inc(v);
94261 }
94262
94263+#ifdef CONFIG_PAX_REFCOUNT
94264+static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
94265+{
94266+ atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
94267+
94268+ atomic64_inc_unchecked(v);
94269+}
94270+#endif
94271+
94272 static inline void atomic_long_dec(atomic_long_t *l)
94273 {
94274 atomic64_t *v = (atomic64_t *)l;
94275@@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
94276 atomic64_dec(v);
94277 }
94278
94279+#ifdef CONFIG_PAX_REFCOUNT
94280+static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
94281+{
94282+ atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
94283+
94284+ atomic64_dec_unchecked(v);
94285+}
94286+#endif
94287+
94288 static inline void atomic_long_add(long i, atomic_long_t *l)
94289 {
94290 atomic64_t *v = (atomic64_t *)l;
94291@@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
94292 atomic64_add(i, v);
94293 }
94294
94295+#ifdef CONFIG_PAX_REFCOUNT
94296+static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
94297+{
94298+ atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
94299+
94300+ atomic64_add_unchecked(i, v);
94301+}
94302+#endif
94303+
94304 static inline void atomic_long_sub(long i, atomic_long_t *l)
94305 {
94306 atomic64_t *v = (atomic64_t *)l;
94307@@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
94308 atomic64_sub(i, v);
94309 }
94310
94311+#ifdef CONFIG_PAX_REFCOUNT
94312+static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
94313+{
94314+ atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
94315+
94316+ atomic64_sub_unchecked(i, v);
94317+}
94318+#endif
94319+
94320 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
94321 {
94322 atomic64_t *v = (atomic64_t *)l;
94323@@ -94,13 +154,22 @@ static inline int atomic_long_add_negative(long i, atomic_long_t *l)
94324 return atomic64_add_negative(i, v);
94325 }
94326
94327-static inline long atomic_long_add_return(long i, atomic_long_t *l)
94328+static inline long __intentional_overflow(-1) atomic_long_add_return(long i, atomic_long_t *l)
94329 {
94330 atomic64_t *v = (atomic64_t *)l;
94331
94332 return (long)atomic64_add_return(i, v);
94333 }
94334
94335+#ifdef CONFIG_PAX_REFCOUNT
94336+static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
94337+{
94338+ atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
94339+
94340+ return (long)atomic64_add_return_unchecked(i, v);
94341+}
94342+#endif
94343+
94344 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
94345 {
94346 atomic64_t *v = (atomic64_t *)l;
94347@@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
94348 return (long)atomic64_inc_return(v);
94349 }
94350
94351+#ifdef CONFIG_PAX_REFCOUNT
94352+static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
94353+{
94354+ atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
94355+
94356+ return (long)atomic64_inc_return_unchecked(v);
94357+}
94358+#endif
94359+
94360 static inline long atomic_long_dec_return(atomic_long_t *l)
94361 {
94362 atomic64_t *v = (atomic64_t *)l;
94363@@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
94364
94365 typedef atomic_t atomic_long_t;
94366
94367+#ifdef CONFIG_PAX_REFCOUNT
94368+typedef atomic_unchecked_t atomic_long_unchecked_t;
94369+#else
94370+typedef atomic_t atomic_long_unchecked_t;
94371+#endif
94372+
94373 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
94374 static inline long atomic_long_read(atomic_long_t *l)
94375 {
94376@@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
94377 return (long)atomic_read(v);
94378 }
94379
94380+#ifdef CONFIG_PAX_REFCOUNT
94381+static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
94382+{
94383+ atomic_unchecked_t *v = (atomic_unchecked_t *)l;
94384+
94385+ return (long)atomic_read_unchecked(v);
94386+}
94387+#endif
94388+
94389 static inline void atomic_long_set(atomic_long_t *l, long i)
94390 {
94391 atomic_t *v = (atomic_t *)l;
94392@@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
94393 atomic_set(v, i);
94394 }
94395
94396+#ifdef CONFIG_PAX_REFCOUNT
94397+static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
94398+{
94399+ atomic_unchecked_t *v = (atomic_unchecked_t *)l;
94400+
94401+ atomic_set_unchecked(v, i);
94402+}
94403+#endif
94404+
94405 static inline void atomic_long_inc(atomic_long_t *l)
94406 {
94407 atomic_t *v = (atomic_t *)l;
94408@@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
94409 atomic_inc(v);
94410 }
94411
94412+#ifdef CONFIG_PAX_REFCOUNT
94413+static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
94414+{
94415+ atomic_unchecked_t *v = (atomic_unchecked_t *)l;
94416+
94417+ atomic_inc_unchecked(v);
94418+}
94419+#endif
94420+
94421 static inline void atomic_long_dec(atomic_long_t *l)
94422 {
94423 atomic_t *v = (atomic_t *)l;
94424@@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
94425 atomic_dec(v);
94426 }
94427
94428+#ifdef CONFIG_PAX_REFCOUNT
94429+static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
94430+{
94431+ atomic_unchecked_t *v = (atomic_unchecked_t *)l;
94432+
94433+ atomic_dec_unchecked(v);
94434+}
94435+#endif
94436+
94437 static inline void atomic_long_add(long i, atomic_long_t *l)
94438 {
94439 atomic_t *v = (atomic_t *)l;
94440@@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
94441 atomic_add(i, v);
94442 }
94443
94444+#ifdef CONFIG_PAX_REFCOUNT
94445+static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
94446+{
94447+ atomic_unchecked_t *v = (atomic_unchecked_t *)l;
94448+
94449+ atomic_add_unchecked(i, v);
94450+}
94451+#endif
94452+
94453 static inline void atomic_long_sub(long i, atomic_long_t *l)
94454 {
94455 atomic_t *v = (atomic_t *)l;
94456@@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
94457 atomic_sub(i, v);
94458 }
94459
94460+#ifdef CONFIG_PAX_REFCOUNT
94461+static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
94462+{
94463+ atomic_unchecked_t *v = (atomic_unchecked_t *)l;
94464+
94465+ atomic_sub_unchecked(i, v);
94466+}
94467+#endif
94468+
94469 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
94470 {
94471 atomic_t *v = (atomic_t *)l;
94472@@ -211,13 +349,23 @@ static inline int atomic_long_add_negative(long i, atomic_long_t *l)
94473 return atomic_add_negative(i, v);
94474 }
94475
94476-static inline long atomic_long_add_return(long i, atomic_long_t *l)
94477+static inline long __intentional_overflow(-1) atomic_long_add_return(long i, atomic_long_t *l)
94478 {
94479 atomic_t *v = (atomic_t *)l;
94480
94481 return (long)atomic_add_return(i, v);
94482 }
94483
94484+#ifdef CONFIG_PAX_REFCOUNT
94485+static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
94486+{
94487+ atomic_unchecked_t *v = (atomic_unchecked_t *)l;
94488+
94489+ return (long)atomic_add_return_unchecked(i, v);
94490+}
94491+
94492+#endif
94493+
94494 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
94495 {
94496 atomic_t *v = (atomic_t *)l;
94497@@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
94498 return (long)atomic_inc_return(v);
94499 }
94500
94501+#ifdef CONFIG_PAX_REFCOUNT
94502+static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
94503+{
94504+ atomic_unchecked_t *v = (atomic_unchecked_t *)l;
94505+
94506+ return (long)atomic_inc_return_unchecked(v);
94507+}
94508+#endif
94509+
94510 static inline long atomic_long_dec_return(atomic_long_t *l)
94511 {
94512 atomic_t *v = (atomic_t *)l;
94513@@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
94514
94515 #endif /* BITS_PER_LONG == 64 */
94516
94517+#ifdef CONFIG_PAX_REFCOUNT
94518+static inline void pax_refcount_needs_these_functions(void)
94519+{
94520+ atomic_read_unchecked((atomic_unchecked_t *)NULL);
94521+ atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
94522+ atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
94523+ atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
94524+ atomic_inc_unchecked((atomic_unchecked_t *)NULL);
94525+ (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
94526+ atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
94527+ atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
94528+ atomic_dec_unchecked((atomic_unchecked_t *)NULL);
94529+ atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
94530+ (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
94531+#ifdef CONFIG_X86
94532+ atomic_clear_mask_unchecked(0, NULL);
94533+ atomic_set_mask_unchecked(0, NULL);
94534+#endif
94535+
94536+ atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
94537+ atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
94538+ atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
94539+ atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
94540+ atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
94541+ atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
94542+ atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
94543+ atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
94544+}
94545+#else
94546+#define atomic_read_unchecked(v) atomic_read(v)
94547+#define atomic_set_unchecked(v, i) atomic_set((v), (i))
94548+#define atomic_add_unchecked(i, v) atomic_add((i), (v))
94549+#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
94550+#define atomic_inc_unchecked(v) atomic_inc(v)
94551+#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
94552+#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
94553+#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
94554+#define atomic_dec_unchecked(v) atomic_dec(v)
94555+#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
94556+#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
94557+#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
94558+#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
94559+
94560+#define atomic_long_read_unchecked(v) atomic_long_read(v)
94561+#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
94562+#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
94563+#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
94564+#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
94565+#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
94566+#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
94567+#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
94568+#endif
94569+
94570 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
94571diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
94572index 30ad9c8..c70c170 100644
94573--- a/include/asm-generic/atomic64.h
94574+++ b/include/asm-generic/atomic64.h
94575@@ -16,6 +16,8 @@ typedef struct {
94576 long long counter;
94577 } atomic64_t;
94578
94579+typedef atomic64_t atomic64_unchecked_t;
94580+
94581 #define ATOMIC64_INIT(i) { (i) }
94582
94583 extern long long atomic64_read(const atomic64_t *v);
94584@@ -51,4 +53,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
94585 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
94586 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
94587
94588+#define atomic64_read_unchecked(v) atomic64_read(v)
94589+#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
94590+#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
94591+#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
94592+#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
94593+#define atomic64_inc_unchecked(v) atomic64_inc(v)
94594+#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
94595+#define atomic64_dec_unchecked(v) atomic64_dec(v)
94596+#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
94597+
94598 #endif /* _ASM_GENERIC_ATOMIC64_H */
94599diff --git a/include/asm-generic/barrier.h b/include/asm-generic/barrier.h
94600index f5c40b0..e902f9d 100644
94601--- a/include/asm-generic/barrier.h
94602+++ b/include/asm-generic/barrier.h
94603@@ -82,7 +82,7 @@
94604 do { \
94605 compiletime_assert_atomic_type(*p); \
94606 smp_mb(); \
94607- ACCESS_ONCE(*p) = (v); \
94608+ ACCESS_ONCE_RW(*p) = (v); \
94609 } while (0)
94610
94611 #define smp_load_acquire(p) \
94612diff --git a/include/asm-generic/bitops/__fls.h b/include/asm-generic/bitops/__fls.h
94613index a60a7cc..0fe12f2 100644
94614--- a/include/asm-generic/bitops/__fls.h
94615+++ b/include/asm-generic/bitops/__fls.h
94616@@ -9,7 +9,7 @@
94617 *
94618 * Undefined if no set bit exists, so code should check against 0 first.
94619 */
94620-static __always_inline unsigned long __fls(unsigned long word)
94621+static __always_inline unsigned long __intentional_overflow(-1) __fls(unsigned long word)
94622 {
94623 int num = BITS_PER_LONG - 1;
94624
94625diff --git a/include/asm-generic/bitops/fls.h b/include/asm-generic/bitops/fls.h
94626index 0576d1f..dad6c71 100644
94627--- a/include/asm-generic/bitops/fls.h
94628+++ b/include/asm-generic/bitops/fls.h
94629@@ -9,7 +9,7 @@
94630 * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
94631 */
94632
94633-static __always_inline int fls(int x)
94634+static __always_inline int __intentional_overflow(-1) fls(int x)
94635 {
94636 int r = 32;
94637
94638diff --git a/include/asm-generic/bitops/fls64.h b/include/asm-generic/bitops/fls64.h
94639index b097cf8..3d40e14 100644
94640--- a/include/asm-generic/bitops/fls64.h
94641+++ b/include/asm-generic/bitops/fls64.h
94642@@ -15,7 +15,7 @@
94643 * at position 64.
94644 */
94645 #if BITS_PER_LONG == 32
94646-static __always_inline int fls64(__u64 x)
94647+static __always_inline int __intentional_overflow(-1) fls64(__u64 x)
94648 {
94649 __u32 h = x >> 32;
94650 if (h)
94651@@ -23,7 +23,7 @@ static __always_inline int fls64(__u64 x)
94652 return fls(x);
94653 }
94654 #elif BITS_PER_LONG == 64
94655-static __always_inline int fls64(__u64 x)
94656+static __always_inline int __intentional_overflow(-1) fls64(__u64 x)
94657 {
94658 if (x == 0)
94659 return 0;
94660diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
94661index 630dd23..8c1dcb6b 100644
94662--- a/include/asm-generic/bug.h
94663+++ b/include/asm-generic/bug.h
94664@@ -62,13 +62,13 @@ struct bug_entry {
94665 * to provide better diagnostics.
94666 */
94667 #ifndef __WARN_TAINT
94668-extern __printf(3, 4)
94669+extern __printf(3, 4) __nocapture(1, 3, 4)
94670 void warn_slowpath_fmt(const char *file, const int line,
94671 const char *fmt, ...);
94672-extern __printf(4, 5)
94673+extern __printf(4, 5) __nocapture(1, 4, 5)
94674 void warn_slowpath_fmt_taint(const char *file, const int line, unsigned taint,
94675 const char *fmt, ...);
94676-extern void warn_slowpath_null(const char *file, const int line);
94677+extern __nocapture(1) void warn_slowpath_null(const char *file, const int line);
94678 #define WANT_WARN_ON_SLOWPATH
94679 #define __WARN() warn_slowpath_null(__FILE__, __LINE__)
94680 #define __WARN_printf(arg...) warn_slowpath_fmt(__FILE__, __LINE__, arg)
94681diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
94682index 1bfcfe5..e04c5c9 100644
94683--- a/include/asm-generic/cache.h
94684+++ b/include/asm-generic/cache.h
94685@@ -6,7 +6,7 @@
94686 * cache lines need to provide their own cache.h.
94687 */
94688
94689-#define L1_CACHE_SHIFT 5
94690-#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
94691+#define L1_CACHE_SHIFT 5UL
94692+#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
94693
94694 #endif /* __ASM_GENERIC_CACHE_H */
94695diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
94696index 0d68a1e..b74a761 100644
94697--- a/include/asm-generic/emergency-restart.h
94698+++ b/include/asm-generic/emergency-restart.h
94699@@ -1,7 +1,7 @@
94700 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
94701 #define _ASM_GENERIC_EMERGENCY_RESTART_H
94702
94703-static inline void machine_emergency_restart(void)
94704+static inline __noreturn void machine_emergency_restart(void)
94705 {
94706 machine_restart(NULL);
94707 }
94708diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
94709index 90f99c7..00ce236 100644
94710--- a/include/asm-generic/kmap_types.h
94711+++ b/include/asm-generic/kmap_types.h
94712@@ -2,9 +2,9 @@
94713 #define _ASM_GENERIC_KMAP_TYPES_H
94714
94715 #ifdef __WITH_KM_FENCE
94716-# define KM_TYPE_NR 41
94717+# define KM_TYPE_NR 42
94718 #else
94719-# define KM_TYPE_NR 20
94720+# define KM_TYPE_NR 21
94721 #endif
94722
94723 #endif
94724diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
94725index 9ceb03b..62b0b8f 100644
94726--- a/include/asm-generic/local.h
94727+++ b/include/asm-generic/local.h
94728@@ -23,24 +23,37 @@ typedef struct
94729 atomic_long_t a;
94730 } local_t;
94731
94732+typedef struct {
94733+ atomic_long_unchecked_t a;
94734+} local_unchecked_t;
94735+
94736 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
94737
94738 #define local_read(l) atomic_long_read(&(l)->a)
94739+#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
94740 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
94741+#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
94742 #define local_inc(l) atomic_long_inc(&(l)->a)
94743+#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
94744 #define local_dec(l) atomic_long_dec(&(l)->a)
94745+#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
94746 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
94747+#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
94748 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
94749+#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
94750
94751 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
94752 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
94753 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
94754 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
94755 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
94756+#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
94757 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
94758 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
94759+#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
94760
94761 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
94762+#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
94763 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
94764 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
94765 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
94766diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
94767index 725612b..9cc513a 100644
94768--- a/include/asm-generic/pgtable-nopmd.h
94769+++ b/include/asm-generic/pgtable-nopmd.h
94770@@ -1,14 +1,19 @@
94771 #ifndef _PGTABLE_NOPMD_H
94772 #define _PGTABLE_NOPMD_H
94773
94774-#ifndef __ASSEMBLY__
94775-
94776 #include <asm-generic/pgtable-nopud.h>
94777
94778-struct mm_struct;
94779-
94780 #define __PAGETABLE_PMD_FOLDED
94781
94782+#define PMD_SHIFT PUD_SHIFT
94783+#define PTRS_PER_PMD 1
94784+#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
94785+#define PMD_MASK (~(PMD_SIZE-1))
94786+
94787+#ifndef __ASSEMBLY__
94788+
94789+struct mm_struct;
94790+
94791 /*
94792 * Having the pmd type consist of a pud gets the size right, and allows
94793 * us to conceptually access the pud entry that this pmd is folded into
94794@@ -16,11 +21,6 @@ struct mm_struct;
94795 */
94796 typedef struct { pud_t pud; } pmd_t;
94797
94798-#define PMD_SHIFT PUD_SHIFT
94799-#define PTRS_PER_PMD 1
94800-#define PMD_SIZE (1UL << PMD_SHIFT)
94801-#define PMD_MASK (~(PMD_SIZE-1))
94802-
94803 /*
94804 * The "pud_xxx()" functions here are trivial for a folded two-level
94805 * setup: the pmd is never bad, and a pmd always exists (as it's folded
94806diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
94807index 810431d..0ec4804f 100644
94808--- a/include/asm-generic/pgtable-nopud.h
94809+++ b/include/asm-generic/pgtable-nopud.h
94810@@ -1,10 +1,15 @@
94811 #ifndef _PGTABLE_NOPUD_H
94812 #define _PGTABLE_NOPUD_H
94813
94814-#ifndef __ASSEMBLY__
94815-
94816 #define __PAGETABLE_PUD_FOLDED
94817
94818+#define PUD_SHIFT PGDIR_SHIFT
94819+#define PTRS_PER_PUD 1
94820+#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
94821+#define PUD_MASK (~(PUD_SIZE-1))
94822+
94823+#ifndef __ASSEMBLY__
94824+
94825 /*
94826 * Having the pud type consist of a pgd gets the size right, and allows
94827 * us to conceptually access the pgd entry that this pud is folded into
94828@@ -12,11 +17,6 @@
94829 */
94830 typedef struct { pgd_t pgd; } pud_t;
94831
94832-#define PUD_SHIFT PGDIR_SHIFT
94833-#define PTRS_PER_PUD 1
94834-#define PUD_SIZE (1UL << PUD_SHIFT)
94835-#define PUD_MASK (~(PUD_SIZE-1))
94836-
94837 /*
94838 * The "pgd_xxx()" functions here are trivial for a folded two-level
94839 * setup: the pud is never bad, and a pud always exists (as it's folded
94840@@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
94841 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
94842
94843 #define pgd_populate(mm, pgd, pud) do { } while (0)
94844+#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
94845 /*
94846 * (puds are folded into pgds so this doesn't get actually called,
94847 * but the define is needed for a generic inline function.)
94848diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
94849index 39f1d6a..7dae6fb 100644
94850--- a/include/asm-generic/pgtable.h
94851+++ b/include/asm-generic/pgtable.h
94852@@ -695,6 +695,22 @@ static inline int pmd_protnone(pmd_t pmd)
94853 }
94854 #endif /* CONFIG_NUMA_BALANCING */
94855
94856+#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
94857+#ifdef CONFIG_PAX_KERNEXEC
94858+#error KERNEXEC requires pax_open_kernel
94859+#else
94860+static inline unsigned long pax_open_kernel(void) { return 0; }
94861+#endif
94862+#endif
94863+
94864+#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
94865+#ifdef CONFIG_PAX_KERNEXEC
94866+#error KERNEXEC requires pax_close_kernel
94867+#else
94868+static inline unsigned long pax_close_kernel(void) { return 0; }
94869+#endif
94870+#endif
94871+
94872 #endif /* CONFIG_MMU */
94873
94874 #ifdef CONFIG_HAVE_ARCH_HUGE_VMAP
94875diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
94876index 72d8803..cb9749c 100644
94877--- a/include/asm-generic/uaccess.h
94878+++ b/include/asm-generic/uaccess.h
94879@@ -343,4 +343,20 @@ clear_user(void __user *to, unsigned long n)
94880 return __clear_user(to, n);
94881 }
94882
94883+#ifndef __HAVE_ARCH_PAX_OPEN_USERLAND
94884+#ifdef CONFIG_PAX_MEMORY_UDEREF
94885+#error UDEREF requires pax_open_userland
94886+#else
94887+static inline unsigned long pax_open_userland(void) { return 0; }
94888+#endif
94889+#endif
94890+
94891+#ifndef __HAVE_ARCH_PAX_CLOSE_USERLAND
94892+#ifdef CONFIG_PAX_MEMORY_UDEREF
94893+#error UDEREF requires pax_close_userland
94894+#else
94895+static inline unsigned long pax_close_userland(void) { return 0; }
94896+#endif
94897+#endif
94898+
94899 #endif /* __ASM_GENERIC_UACCESS_H */
94900diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
94901index 8bd374d..9590e70 100644
94902--- a/include/asm-generic/vmlinux.lds.h
94903+++ b/include/asm-generic/vmlinux.lds.h
94904@@ -246,6 +246,7 @@
94905 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
94906 VMLINUX_SYMBOL(__start_rodata) = .; \
94907 *(.rodata) *(.rodata.*) \
94908+ *(.data..read_only) \
94909 *(__vermagic) /* Kernel version magic */ \
94910 . = ALIGN(8); \
94911 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
94912@@ -504,6 +505,7 @@
94913 KERNEL_CTORS() \
94914 MCOUNT_REC() \
94915 *(.init.rodata) \
94916+ *(.init.rodata.*) \
94917 FTRACE_EVENTS() \
94918 TRACE_SYSCALLS() \
94919 KPROBE_BLACKLIST() \
94920@@ -525,6 +527,8 @@
94921
94922 #define EXIT_DATA \
94923 *(.exit.data) \
94924+ *(.exit.rodata) \
94925+ *(.exit.rodata.*) \
94926 MEM_DISCARD(exit.data) \
94927 MEM_DISCARD(exit.rodata)
94928
94929@@ -741,17 +745,18 @@
94930 * section in the linker script will go there too. @phdr should have
94931 * a leading colon.
94932 *
94933- * Note that this macros defines __per_cpu_load as an absolute symbol.
94934+ * Note that this macros defines per_cpu_load as an absolute symbol.
94935 * If there is no need to put the percpu section at a predetermined
94936 * address, use PERCPU_SECTION.
94937 */
94938 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
94939- VMLINUX_SYMBOL(__per_cpu_load) = .; \
94940- .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
94941+ per_cpu_load = .; \
94942+ .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
94943 - LOAD_OFFSET) { \
94944+ VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
94945 PERCPU_INPUT(cacheline) \
94946 } phdr \
94947- . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
94948+ . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
94949
94950 /**
94951 * PERCPU_SECTION - define output section for percpu area, simple version
94952diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
94953index 0ecb768..f910132 100644
94954--- a/include/crypto/algapi.h
94955+++ b/include/crypto/algapi.h
94956@@ -34,7 +34,7 @@ struct crypto_type {
94957 unsigned int maskclear;
94958 unsigned int maskset;
94959 unsigned int tfmsize;
94960-};
94961+} __do_const;
94962
94963 struct crypto_instance {
94964 struct crypto_alg alg;
94965diff --git a/include/drm/drmP.h b/include/drm/drmP.h
94966index 62c40777..f980496 100644
94967--- a/include/drm/drmP.h
94968+++ b/include/drm/drmP.h
94969@@ -59,6 +59,7 @@
94970
94971 #include <asm/mman.h>
94972 #include <asm/pgalloc.h>
94973+#include <asm/local.h>
94974 #include <asm/uaccess.h>
94975
94976 #include <uapi/drm/drm.h>
94977@@ -137,17 +138,18 @@ void drm_err(const char *format, ...);
94978 /*@{*/
94979
94980 /* driver capabilities and requirements mask */
94981-#define DRIVER_USE_AGP 0x1
94982-#define DRIVER_PCI_DMA 0x8
94983-#define DRIVER_SG 0x10
94984-#define DRIVER_HAVE_DMA 0x20
94985-#define DRIVER_HAVE_IRQ 0x40
94986-#define DRIVER_IRQ_SHARED 0x80
94987-#define DRIVER_GEM 0x1000
94988-#define DRIVER_MODESET 0x2000
94989-#define DRIVER_PRIME 0x4000
94990-#define DRIVER_RENDER 0x8000
94991-#define DRIVER_ATOMIC 0x10000
94992+#define DRIVER_USE_AGP 0x1
94993+#define DRIVER_PCI_DMA 0x8
94994+#define DRIVER_SG 0x10
94995+#define DRIVER_HAVE_DMA 0x20
94996+#define DRIVER_HAVE_IRQ 0x40
94997+#define DRIVER_IRQ_SHARED 0x80
94998+#define DRIVER_GEM 0x1000
94999+#define DRIVER_MODESET 0x2000
95000+#define DRIVER_PRIME 0x4000
95001+#define DRIVER_RENDER 0x8000
95002+#define DRIVER_ATOMIC 0x10000
95003+#define DRIVER_KMS_LEGACY_CONTEXT 0x20000
95004
95005 /***********************************************************************/
95006 /** \name Macros to make printk easier */
95007@@ -233,10 +235,12 @@ void drm_err(const char *format, ...);
95008 * \param cmd command.
95009 * \param arg argument.
95010 */
95011-typedef int drm_ioctl_t(struct drm_device *dev, void *data,
95012+typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
95013+ struct drm_file *file_priv);
95014+typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
95015 struct drm_file *file_priv);
95016
95017-typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
95018+typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
95019 unsigned long arg);
95020
95021 #define DRM_IOCTL_NR(n) _IOC_NR(n)
95022@@ -252,9 +256,9 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
95023 struct drm_ioctl_desc {
95024 unsigned int cmd;
95025 int flags;
95026- drm_ioctl_t *func;
95027+ drm_ioctl_t func;
95028 const char *name;
95029-};
95030+} __do_const;
95031
95032 /**
95033 * Creates a driver or general drm_ioctl_desc array entry for the given
95034@@ -645,7 +649,8 @@ struct drm_info_list {
95035 int (*show)(struct seq_file*, void*); /** show callback */
95036 u32 driver_features; /**< Required driver features for this entry */
95037 void *data;
95038-};
95039+} __do_const;
95040+typedef struct drm_info_list __no_const drm_info_list_no_const;
95041
95042 /**
95043 * debugfs node structure. This structure represents a debugfs file.
95044@@ -729,7 +734,7 @@ struct drm_device {
95045
95046 /** \name Usage Counters */
95047 /*@{ */
95048- int open_count; /**< Outstanding files open, protected by drm_global_mutex. */
95049+ local_t open_count; /**< Outstanding files open, protected by drm_global_mutex. */
95050 spinlock_t buf_lock; /**< For drm_device::buf_use and a few other things. */
95051 int buf_use; /**< Buffers in use -- cannot alloc */
95052 atomic_t buf_alloc; /**< Buffer allocation in progress */
95053diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
95054index c8fc187..079d4c2 100644
95055--- a/include/drm/drm_crtc_helper.h
95056+++ b/include/drm/drm_crtc_helper.h
95057@@ -161,7 +161,7 @@ struct drm_encoder_helper_funcs {
95058 int (*atomic_check)(struct drm_encoder *encoder,
95059 struct drm_crtc_state *crtc_state,
95060 struct drm_connector_state *conn_state);
95061-};
95062+} __no_const;
95063
95064 /**
95065 * struct drm_connector_helper_funcs - helper operations for connectors
95066diff --git a/include/drm/i915_pciids.h b/include/drm/i915_pciids.h
95067index 6133723..4c1fccb 100644
95068--- a/include/drm/i915_pciids.h
95069+++ b/include/drm/i915_pciids.h
95070@@ -37,7 +37,7 @@
95071 */
95072 #define INTEL_VGA_DEVICE(id, info) { \
95073 0x8086, id, \
95074- ~0, ~0, \
95075+ PCI_ANY_ID, PCI_ANY_ID, \
95076 0x030000, 0xff0000, \
95077 (unsigned long) info }
95078
95079diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
95080index 72dcbe8..8db58d7 100644
95081--- a/include/drm/ttm/ttm_memory.h
95082+++ b/include/drm/ttm/ttm_memory.h
95083@@ -48,7 +48,7 @@
95084
95085 struct ttm_mem_shrink {
95086 int (*do_shrink) (struct ttm_mem_shrink *);
95087-};
95088+} __no_const;
95089
95090 /**
95091 * struct ttm_mem_global - Global memory accounting structure.
95092diff --git a/include/drm/ttm/ttm_page_alloc.h b/include/drm/ttm/ttm_page_alloc.h
95093index 49a8284..9643967 100644
95094--- a/include/drm/ttm/ttm_page_alloc.h
95095+++ b/include/drm/ttm/ttm_page_alloc.h
95096@@ -80,6 +80,7 @@ void ttm_dma_page_alloc_fini(void);
95097 */
95098 extern int ttm_dma_page_alloc_debugfs(struct seq_file *m, void *data);
95099
95100+struct device;
95101 extern int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev);
95102 extern void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev);
95103
95104diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
95105index 4b840e8..155d235 100644
95106--- a/include/keys/asymmetric-subtype.h
95107+++ b/include/keys/asymmetric-subtype.h
95108@@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
95109 /* Verify the signature on a key of this subtype (optional) */
95110 int (*verify_signature)(const struct key *key,
95111 const struct public_key_signature *sig);
95112-};
95113+} __do_const;
95114
95115 /**
95116 * asymmetric_key_subtype - Get the subtype from an asymmetric key
95117diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
95118index c1da539..1dcec55 100644
95119--- a/include/linux/atmdev.h
95120+++ b/include/linux/atmdev.h
95121@@ -28,7 +28,7 @@ struct compat_atm_iobuf {
95122 #endif
95123
95124 struct k_atm_aal_stats {
95125-#define __HANDLE_ITEM(i) atomic_t i
95126+#define __HANDLE_ITEM(i) atomic_unchecked_t i
95127 __AAL_STAT_ITEMS
95128 #undef __HANDLE_ITEM
95129 };
95130@@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
95131 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
95132 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
95133 struct module *owner;
95134-};
95135+} __do_const ;
95136
95137 struct atmphy_ops {
95138 int (*start)(struct atm_dev *dev);
95139diff --git a/include/linux/atomic.h b/include/linux/atomic.h
95140index 5b08a85..60922fb 100644
95141--- a/include/linux/atomic.h
95142+++ b/include/linux/atomic.h
95143@@ -12,7 +12,7 @@
95144 * Atomically adds @a to @v, so long as @v was not already @u.
95145 * Returns non-zero if @v was not @u, and zero otherwise.
95146 */
95147-static inline int atomic_add_unless(atomic_t *v, int a, int u)
95148+static inline int __intentional_overflow(-1) atomic_add_unless(atomic_t *v, int a, int u)
95149 {
95150 return __atomic_add_unless(v, a, u) != u;
95151 }
95152diff --git a/include/linux/audit.h b/include/linux/audit.h
95153index c2e7e3a..8bfc0e1 100644
95154--- a/include/linux/audit.h
95155+++ b/include/linux/audit.h
95156@@ -223,7 +223,7 @@ static inline void audit_ptrace(struct task_struct *t)
95157 extern unsigned int audit_serial(void);
95158 extern int auditsc_get_stamp(struct audit_context *ctx,
95159 struct timespec *t, unsigned int *serial);
95160-extern int audit_set_loginuid(kuid_t loginuid);
95161+extern int __intentional_overflow(-1) audit_set_loginuid(kuid_t loginuid);
95162
95163 static inline kuid_t audit_get_loginuid(struct task_struct *tsk)
95164 {
95165diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
95166index 576e463..28fd926 100644
95167--- a/include/linux/binfmts.h
95168+++ b/include/linux/binfmts.h
95169@@ -44,7 +44,7 @@ struct linux_binprm {
95170 unsigned interp_flags;
95171 unsigned interp_data;
95172 unsigned long loader, exec;
95173-};
95174+} __randomize_layout;
95175
95176 #define BINPRM_FLAGS_ENFORCE_NONDUMP_BIT 0
95177 #define BINPRM_FLAGS_ENFORCE_NONDUMP (1 << BINPRM_FLAGS_ENFORCE_NONDUMP_BIT)
95178@@ -77,8 +77,10 @@ struct linux_binfmt {
95179 int (*load_binary)(struct linux_binprm *);
95180 int (*load_shlib)(struct file *);
95181 int (*core_dump)(struct coredump_params *cprm);
95182+ void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
95183+ void (*handle_mmap)(struct file *);
95184 unsigned long min_coredump; /* minimal dump size */
95185-};
95186+} __do_const __randomize_layout;
95187
95188 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
95189
95190diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
95191index ea17cca..dd56e56 100644
95192--- a/include/linux/bitmap.h
95193+++ b/include/linux/bitmap.h
95194@@ -295,7 +295,7 @@ static inline int bitmap_full(const unsigned long *src, unsigned int nbits)
95195 return find_first_zero_bit(src, nbits) == nbits;
95196 }
95197
95198-static inline int bitmap_weight(const unsigned long *src, unsigned int nbits)
95199+static inline int __intentional_overflow(-1) bitmap_weight(const unsigned long *src, unsigned int nbits)
95200 {
95201 if (small_const_nbits(nbits))
95202 return hweight_long(*src & BITMAP_LAST_WORD_MASK(nbits));
95203diff --git a/include/linux/bitops.h b/include/linux/bitops.h
95204index 297f5bd..0b6d1e8 100644
95205--- a/include/linux/bitops.h
95206+++ b/include/linux/bitops.h
95207@@ -105,7 +105,7 @@ static inline __u64 ror64(__u64 word, unsigned int shift)
95208 * @word: value to rotate
95209 * @shift: bits to roll
95210 */
95211-static inline __u32 rol32(__u32 word, unsigned int shift)
95212+static inline __u32 __intentional_overflow(-1) rol32(__u32 word, unsigned int shift)
95213 {
95214 return (word << shift) | (word >> (32 - shift));
95215 }
95216@@ -115,7 +115,7 @@ static inline __u32 rol32(__u32 word, unsigned int shift)
95217 * @word: value to rotate
95218 * @shift: bits to roll
95219 */
95220-static inline __u32 ror32(__u32 word, unsigned int shift)
95221+static inline __u32 __intentional_overflow(-1) ror32(__u32 word, unsigned int shift)
95222 {
95223 return (word >> shift) | (word << (32 - shift));
95224 }
95225@@ -171,7 +171,7 @@ static inline __s32 sign_extend32(__u32 value, int index)
95226 return (__s32)(value << shift) >> shift;
95227 }
95228
95229-static inline unsigned fls_long(unsigned long l)
95230+static inline unsigned __intentional_overflow(-1) fls_long(unsigned long l)
95231 {
95232 if (sizeof(l) == 4)
95233 return fls(l);
95234diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
95235index 5d93a66..978c4a0 100644
95236--- a/include/linux/blkdev.h
95237+++ b/include/linux/blkdev.h
95238@@ -1614,7 +1614,7 @@ struct block_device_operations {
95239 /* this callback is with swap_lock and sometimes page table lock held */
95240 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
95241 struct module *owner;
95242-};
95243+} __do_const;
95244
95245 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
95246 unsigned long);
95247diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
95248index afc1343..9735539 100644
95249--- a/include/linux/blktrace_api.h
95250+++ b/include/linux/blktrace_api.h
95251@@ -25,7 +25,7 @@ struct blk_trace {
95252 struct dentry *dropped_file;
95253 struct dentry *msg_file;
95254 struct list_head running_list;
95255- atomic_t dropped;
95256+ atomic_unchecked_t dropped;
95257 };
95258
95259 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
95260diff --git a/include/linux/cache.h b/include/linux/cache.h
95261index 17e7e82..1d7da26 100644
95262--- a/include/linux/cache.h
95263+++ b/include/linux/cache.h
95264@@ -16,6 +16,14 @@
95265 #define __read_mostly
95266 #endif
95267
95268+#ifndef __read_only
95269+#ifdef CONFIG_PAX_KERNEXEC
95270+#error KERNEXEC requires __read_only
95271+#else
95272+#define __read_only __read_mostly
95273+#endif
95274+#endif
95275+
95276 #ifndef ____cacheline_aligned
95277 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
95278 #endif
95279diff --git a/include/linux/capability.h b/include/linux/capability.h
95280index af9f0b9..71a5e5c 100644
95281--- a/include/linux/capability.h
95282+++ b/include/linux/capability.h
95283@@ -237,15 +237,28 @@ static inline bool capable(int cap)
95284 {
95285 return true;
95286 }
95287+static inline bool capable_nolog(int cap)
95288+{
95289+ return true;
95290+}
95291 static inline bool ns_capable(struct user_namespace *ns, int cap)
95292 {
95293 return true;
95294 }
95295+static inline bool ns_capable_nolog(struct user_namespace *ns, int cap)
95296+{
95297+ return true;
95298+}
95299 #endif /* CONFIG_MULTIUSER */
95300 extern bool capable_wrt_inode_uidgid(const struct inode *inode, int cap);
95301+extern bool capable_wrt_inode_uidgid_nolog(const struct inode *inode, int cap);
95302 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
95303+extern bool capable_nolog(int cap);
95304+extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
95305
95306 /* audit system wants to get cap info from files as well */
95307 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
95308
95309+extern int is_privileged_binary(const struct dentry *dentry);
95310+
95311 #endif /* !_LINUX_CAPABILITY_H */
95312diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
95313index 8609d57..86e4d79 100644
95314--- a/include/linux/cdrom.h
95315+++ b/include/linux/cdrom.h
95316@@ -87,7 +87,6 @@ struct cdrom_device_ops {
95317
95318 /* driver specifications */
95319 const int capability; /* capability flags */
95320- int n_minors; /* number of active minor devices */
95321 /* handle uniform packets for scsi type devices (scsi,atapi) */
95322 int (*generic_packet) (struct cdrom_device_info *,
95323 struct packet_command *);
95324diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
95325index bda5ec0b4..51d8ea1 100644
95326--- a/include/linux/cleancache.h
95327+++ b/include/linux/cleancache.h
95328@@ -35,7 +35,7 @@ struct cleancache_ops {
95329 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
95330 void (*invalidate_inode)(int, struct cleancache_filekey);
95331 void (*invalidate_fs)(int);
95332-};
95333+} __no_const;
95334
95335 extern int cleancache_register_ops(struct cleancache_ops *ops);
95336 extern void __cleancache_init_fs(struct super_block *);
95337diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
95338index df69531..0180e68 100644
95339--- a/include/linux/clk-provider.h
95340+++ b/include/linux/clk-provider.h
95341@@ -195,6 +195,7 @@ struct clk_ops {
95342 void (*init)(struct clk_hw *hw);
95343 int (*debug_init)(struct clk_hw *hw, struct dentry *dentry);
95344 };
95345+typedef struct clk_ops __no_const clk_ops_no_const;
95346
95347 /**
95348 * struct clk_init_data - holds init data that's common to all clocks and is
95349@@ -209,7 +210,7 @@ struct clk_ops {
95350 struct clk_init_data {
95351 const char *name;
95352 const struct clk_ops *ops;
95353- const char **parent_names;
95354+ const char * const *parent_names;
95355 u8 num_parents;
95356 unsigned long flags;
95357 };
95358@@ -426,12 +427,12 @@ extern const struct clk_ops clk_mux_ops;
95359 extern const struct clk_ops clk_mux_ro_ops;
95360
95361 struct clk *clk_register_mux(struct device *dev, const char *name,
95362- const char **parent_names, u8 num_parents, unsigned long flags,
95363+ const char * const *parent_names, u8 num_parents, unsigned long flags,
95364 void __iomem *reg, u8 shift, u8 width,
95365 u8 clk_mux_flags, spinlock_t *lock);
95366
95367 struct clk *clk_register_mux_table(struct device *dev, const char *name,
95368- const char **parent_names, u8 num_parents, unsigned long flags,
95369+ const char * const *parent_names, u8 num_parents, unsigned long flags,
95370 void __iomem *reg, u8 shift, u32 mask,
95371 u8 clk_mux_flags, u32 *table, spinlock_t *lock);
95372
95373diff --git a/include/linux/clkdev.h b/include/linux/clkdev.h
95374index 94bad77..a39e810 100644
95375--- a/include/linux/clkdev.h
95376+++ b/include/linux/clkdev.h
95377@@ -32,7 +32,7 @@ struct clk_lookup {
95378 }
95379
95380 struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
95381- const char *dev_fmt, ...);
95382+ const char *dev_fmt, ...) __printf(3, 4);
95383
95384 void clkdev_add(struct clk_lookup *cl);
95385 void clkdev_drop(struct clk_lookup *cl);
95386@@ -40,7 +40,8 @@ void clkdev_drop(struct clk_lookup *cl);
95387 void clkdev_add_table(struct clk_lookup *, size_t);
95388 int clk_add_alias(const char *, const char *, char *, struct device *);
95389
95390-int clk_register_clkdev(struct clk *, const char *, const char *, ...);
95391+int clk_register_clkdev(struct clk *, const char *, const char *, ...)
95392+ __printf(3, 4);
95393 int clk_register_clkdevs(struct clk *, struct clk_lookup *, size_t);
95394
95395 #ifdef CONFIG_COMMON_CLK
95396diff --git a/include/linux/compat.h b/include/linux/compat.h
95397index ab25814..63b52db 100644
95398--- a/include/linux/compat.h
95399+++ b/include/linux/compat.h
95400@@ -316,7 +316,7 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
95401 compat_size_t __user *len_ptr);
95402
95403 asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32);
95404-asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
95405+asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
95406 asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
95407 asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp,
95408 compat_ssize_t msgsz, int msgflg);
95409@@ -325,7 +325,7 @@ asmlinkage long compat_sys_msgrcv(int msqid, compat_uptr_t msgp,
95410 long compat_sys_msgctl(int first, int second, void __user *uptr);
95411 long compat_sys_shmctl(int first, int second, void __user *uptr);
95412 long compat_sys_semtimedop(int semid, struct sembuf __user *tsems,
95413- unsigned nsems, const struct compat_timespec __user *timeout);
95414+ compat_long_t nsems, const struct compat_timespec __user *timeout);
95415 asmlinkage long compat_sys_keyctl(u32 option,
95416 u32 arg2, u32 arg3, u32 arg4, u32 arg5);
95417 asmlinkage long compat_sys_ustat(unsigned dev, struct compat_ustat __user *u32);
95418@@ -424,7 +424,7 @@ asmlinkage long compat_sys_settimeofday(struct compat_timeval __user *tv,
95419
95420 asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp);
95421
95422-extern int compat_printk(const char *fmt, ...);
95423+extern __printf(1, 2) int compat_printk(const char *fmt, ...);
95424 extern void sigset_from_compat(sigset_t *set, const compat_sigset_t *compat);
95425 extern void sigset_to_compat(compat_sigset_t *compat, const sigset_t *set);
95426
95427@@ -439,7 +439,7 @@ extern int compat_ptrace_request(struct task_struct *child,
95428 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
95429 compat_ulong_t addr, compat_ulong_t data);
95430 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
95431- compat_long_t addr, compat_long_t data);
95432+ compat_ulong_t addr, compat_ulong_t data);
95433
95434 asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, compat_size_t);
95435 /*
95436diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
95437index 371e560..e2e4e3e 100644
95438--- a/include/linux/compiler-gcc.h
95439+++ b/include/linux/compiler-gcc.h
95440@@ -108,8 +108,8 @@
95441 */
95442 #define __pure __attribute__((pure))
95443 #define __aligned(x) __attribute__((aligned(x)))
95444-#define __printf(a, b) __attribute__((format(printf, a, b)))
95445-#define __scanf(a, b) __attribute__((format(scanf, a, b)))
95446+#define __printf(a, b) __attribute__((format(printf, a, b))) __nocapture(a, b)
95447+#define __scanf(a, b) __attribute__((format(scanf, a, b))) __nocapture(a, b)
95448 #define noinline __attribute__((noinline))
95449 #define __attribute_const__ __attribute__((__const__))
95450 #define __maybe_unused __attribute__((unused))
95451diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
95452index 769e198..7ee7cb5 100644
95453--- a/include/linux/compiler-gcc4.h
95454+++ b/include/linux/compiler-gcc4.h
95455@@ -39,9 +39,38 @@
95456 # define __compiletime_warning(message) __attribute__((warning(message)))
95457 # define __compiletime_error(message) __attribute__((error(message)))
95458 #endif /* __CHECKER__ */
95459+
95460+#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
95461+#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
95462+#define __bos0(ptr) __bos((ptr), 0)
95463+#define __bos1(ptr) __bos((ptr), 1)
95464 #endif /* GCC_VERSION >= 40300 */
95465
95466 #if GCC_VERSION >= 40500
95467+
95468+#ifdef RANDSTRUCT_PLUGIN
95469+#define __randomize_layout __attribute__((randomize_layout))
95470+#define __no_randomize_layout __attribute__((no_randomize_layout))
95471+#endif
95472+
95473+#ifdef CONSTIFY_PLUGIN
95474+#define __no_const __attribute__((no_const))
95475+#define __do_const __attribute__((do_const))
95476+#endif
95477+
95478+#ifdef SIZE_OVERFLOW_PLUGIN
95479+#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
95480+#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
95481+#endif
95482+
95483+#ifdef LATENT_ENTROPY_PLUGIN
95484+#define __latent_entropy __attribute__((latent_entropy))
95485+#endif
95486+
95487+#ifdef INITIFY_PLUGIN
95488+#define __nocapture(...) __attribute__((nocapture(__VA_ARGS__)))
95489+#endif
95490+
95491 /*
95492 * Mark a position in code as unreachable. This can be used to
95493 * suppress control flow warnings after asm blocks that transfer
95494diff --git a/include/linux/compiler-gcc5.h b/include/linux/compiler-gcc5.h
95495index efee493..8aa8f6b 100644
95496--- a/include/linux/compiler-gcc5.h
95497+++ b/include/linux/compiler-gcc5.h
95498@@ -28,6 +28,34 @@
95499 # define __compiletime_error(message) __attribute__((error(message)))
95500 #endif /* __CHECKER__ */
95501
95502+#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
95503+#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
95504+#define __bos0(ptr) __bos((ptr), 0)
95505+#define __bos1(ptr) __bos((ptr), 1)
95506+
95507+#ifdef RANDSTRUCT_PLUGIN
95508+#define __randomize_layout __attribute__((randomize_layout))
95509+#define __no_randomize_layout __attribute__((no_randomize_layout))
95510+#endif
95511+
95512+#ifdef CONSTIFY_PLUGIN
95513+#define __no_const __attribute__((no_const))
95514+#define __do_const __attribute__((do_const))
95515+#endif
95516+
95517+#ifdef SIZE_OVERFLOW_PLUGIN
95518+#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
95519+#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
95520+#endif
95521+
95522+#ifdef LATENT_ENTROPY_PLUGIN
95523+#define __latent_entropy __attribute__((latent_entropy))
95524+#endif
95525+
95526+#ifdef INITIFY_PLUGIN
95527+#define __nocapture(...) __attribute__((nocapture(__VA_ARGS__)))
95528+#endif
95529+
95530 /*
95531 * Mark a position in code as unreachable. This can be used to
95532 * suppress control flow warnings after asm blocks that transfer
95533diff --git a/include/linux/compiler.h b/include/linux/compiler.h
95534index 8677225..2d49df1 100644
95535--- a/include/linux/compiler.h
95536+++ b/include/linux/compiler.h
95537@@ -5,11 +5,14 @@
95538
95539 #ifdef __CHECKER__
95540 # define __user __attribute__((noderef, address_space(1)))
95541+# define __force_user __force __user
95542 # define __kernel __attribute__((address_space(0)))
95543+# define __force_kernel __force __kernel
95544 # define __safe __attribute__((safe))
95545 # define __force __attribute__((force))
95546 # define __nocast __attribute__((nocast))
95547 # define __iomem __attribute__((noderef, address_space(2)))
95548+# define __force_iomem __force __iomem
95549 # define __must_hold(x) __attribute__((context(x,1,1)))
95550 # define __acquires(x) __attribute__((context(x,0,1)))
95551 # define __releases(x) __attribute__((context(x,1,0)))
95552@@ -17,20 +20,37 @@
95553 # define __release(x) __context__(x,-1)
95554 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
95555 # define __percpu __attribute__((noderef, address_space(3)))
95556+# define __force_percpu __force __percpu
95557 #ifdef CONFIG_SPARSE_RCU_POINTER
95558 # define __rcu __attribute__((noderef, address_space(4)))
95559+# define __force_rcu __force __rcu
95560 #else
95561 # define __rcu
95562+# define __force_rcu
95563 #endif
95564 extern void __chk_user_ptr(const volatile void __user *);
95565 extern void __chk_io_ptr(const volatile void __iomem *);
95566 #else
95567-# define __user
95568-# define __kernel
95569+# ifdef CHECKER_PLUGIN
95570+//# define __user
95571+//# define __force_user
95572+//# define __kernel
95573+//# define __force_kernel
95574+# else
95575+# ifdef STRUCTLEAK_PLUGIN
95576+# define __user __attribute__((user))
95577+# else
95578+# define __user
95579+# endif
95580+# define __force_user
95581+# define __kernel
95582+# define __force_kernel
95583+# endif
95584 # define __safe
95585 # define __force
95586 # define __nocast
95587 # define __iomem
95588+# define __force_iomem
95589 # define __chk_user_ptr(x) (void)0
95590 # define __chk_io_ptr(x) (void)0
95591 # define __builtin_warning(x, y...) (1)
95592@@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
95593 # define __release(x) (void)0
95594 # define __cond_lock(x,c) (c)
95595 # define __percpu
95596+# define __force_percpu
95597 # define __rcu
95598+# define __force_rcu
95599 #endif
95600
95601 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
95602@@ -199,27 +221,27 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
95603 static __always_inline void __read_once_size(const volatile void *p, void *res, int size)
95604 {
95605 switch (size) {
95606- case 1: *(__u8 *)res = *(volatile __u8 *)p; break;
95607- case 2: *(__u16 *)res = *(volatile __u16 *)p; break;
95608- case 4: *(__u32 *)res = *(volatile __u32 *)p; break;
95609- case 8: *(__u64 *)res = *(volatile __u64 *)p; break;
95610+ case 1: *(__u8 *)res = *(const volatile __u8 *)p; break;
95611+ case 2: *(__u16 *)res = *(const volatile __u16 *)p; break;
95612+ case 4: *(__u32 *)res = *(const volatile __u32 *)p; break;
95613+ case 8: *(__u64 *)res = *(const volatile __u64 *)p; break;
95614 default:
95615 barrier();
95616- __builtin_memcpy((void *)res, (const void *)p, size);
95617+ __builtin_memcpy(res, (const void *)p, size);
95618 barrier();
95619 }
95620 }
95621
95622-static __always_inline void __write_once_size(volatile void *p, void *res, int size)
95623+static __always_inline void __write_once_size(volatile void *p, const void *res, int size)
95624 {
95625 switch (size) {
95626- case 1: *(volatile __u8 *)p = *(__u8 *)res; break;
95627- case 2: *(volatile __u16 *)p = *(__u16 *)res; break;
95628- case 4: *(volatile __u32 *)p = *(__u32 *)res; break;
95629- case 8: *(volatile __u64 *)p = *(__u64 *)res; break;
95630+ case 1: *(volatile __u8 *)p = *(const __u8 *)res; break;
95631+ case 2: *(volatile __u16 *)p = *(const __u16 *)res; break;
95632+ case 4: *(volatile __u32 *)p = *(const __u32 *)res; break;
95633+ case 8: *(volatile __u64 *)p = *(const __u64 *)res; break;
95634 default:
95635 barrier();
95636- __builtin_memcpy((void *)p, (const void *)res, size);
95637+ __builtin_memcpy((void *)p, res, size);
95638 barrier();
95639 }
95640 }
95641@@ -352,6 +374,38 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
95642 # define __attribute_const__ /* unimplemented */
95643 #endif
95644
95645+#ifndef __randomize_layout
95646+# define __randomize_layout
95647+#endif
95648+
95649+#ifndef __no_randomize_layout
95650+# define __no_randomize_layout
95651+#endif
95652+
95653+#ifndef __no_const
95654+# define __no_const
95655+#endif
95656+
95657+#ifndef __do_const
95658+# define __do_const
95659+#endif
95660+
95661+#ifndef __size_overflow
95662+# define __size_overflow(...)
95663+#endif
95664+
95665+#ifndef __intentional_overflow
95666+# define __intentional_overflow(...)
95667+#endif
95668+
95669+#ifndef __latent_entropy
95670+# define __latent_entropy
95671+#endif
95672+
95673+#ifndef __nocapture
95674+# define __nocapture(...)
95675+#endif
95676+
95677 /*
95678 * Tell gcc if a function is cold. The compiler will assume any path
95679 * directly leading to the call is unlikely.
95680@@ -361,6 +415,22 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
95681 #define __cold
95682 #endif
95683
95684+#ifndef __alloc_size
95685+#define __alloc_size(...)
95686+#endif
95687+
95688+#ifndef __bos
95689+#define __bos(ptr, arg)
95690+#endif
95691+
95692+#ifndef __bos0
95693+#define __bos0(ptr)
95694+#endif
95695+
95696+#ifndef __bos1
95697+#define __bos1(ptr)
95698+#endif
95699+
95700 /* Simple shorthand for a section definition */
95701 #ifndef __section
95702 # define __section(S) __attribute__ ((__section__(#S)))
95703@@ -375,6 +445,8 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
95704 # define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
95705 #endif
95706
95707+#define __type_is_unsigned(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))
95708+
95709 /* Is this type a native word size -- useful for atomic operations */
95710 #ifndef __native_word
95711 # define __native_word(t) (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || sizeof(t) == sizeof(int) || sizeof(t) == sizeof(long))
95712@@ -454,8 +526,9 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
95713 */
95714 #define __ACCESS_ONCE(x) ({ \
95715 __maybe_unused typeof(x) __var = (__force typeof(x)) 0; \
95716- (volatile typeof(x) *)&(x); })
95717+ (volatile const typeof(x) *)&(x); })
95718 #define ACCESS_ONCE(x) (*__ACCESS_ONCE(x))
95719+#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
95720
95721 /* Ignore/forbid kprobes attach on very low level functions marked by this attribute: */
95722 #ifdef CONFIG_KPROBES
95723diff --git a/include/linux/completion.h b/include/linux/completion.h
95724index 5d5aaae..0ea9b84 100644
95725--- a/include/linux/completion.h
95726+++ b/include/linux/completion.h
95727@@ -90,16 +90,16 @@ static inline void reinit_completion(struct completion *x)
95728
95729 extern void wait_for_completion(struct completion *);
95730 extern void wait_for_completion_io(struct completion *);
95731-extern int wait_for_completion_interruptible(struct completion *x);
95732-extern int wait_for_completion_killable(struct completion *x);
95733+extern int wait_for_completion_interruptible(struct completion *x) __intentional_overflow(-1);
95734+extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
95735 extern unsigned long wait_for_completion_timeout(struct completion *x,
95736- unsigned long timeout);
95737+ unsigned long timeout) __intentional_overflow(-1);
95738 extern unsigned long wait_for_completion_io_timeout(struct completion *x,
95739- unsigned long timeout);
95740+ unsigned long timeout) __intentional_overflow(-1);
95741 extern long wait_for_completion_interruptible_timeout(
95742- struct completion *x, unsigned long timeout);
95743+ struct completion *x, unsigned long timeout) __intentional_overflow(-1);
95744 extern long wait_for_completion_killable_timeout(
95745- struct completion *x, unsigned long timeout);
95746+ struct completion *x, unsigned long timeout) __intentional_overflow(-1);
95747 extern bool try_wait_for_completion(struct completion *x);
95748 extern bool completion_done(struct completion *x);
95749
95750diff --git a/include/linux/configfs.h b/include/linux/configfs.h
95751index 34025df..9c263df 100644
95752--- a/include/linux/configfs.h
95753+++ b/include/linux/configfs.h
95754@@ -64,7 +64,8 @@ struct config_item {
95755 struct dentry *ci_dentry;
95756 };
95757
95758-extern int config_item_set_name(struct config_item *, const char *, ...);
95759+extern __printf(2, 3)
95760+int config_item_set_name(struct config_item *, const char *, ...);
95761
95762 static inline char *config_item_name(struct config_item * item)
95763 {
95764@@ -125,7 +126,7 @@ struct configfs_attribute {
95765 const char *ca_name;
95766 struct module *ca_owner;
95767 umode_t ca_mode;
95768-};
95769+} __do_const;
95770
95771 /*
95772 * Users often need to create attribute structures for their configurable
95773diff --git a/include/linux/cpu.h b/include/linux/cpu.h
95774index c0fb6b1..23c30bd 100644
95775--- a/include/linux/cpu.h
95776+++ b/include/linux/cpu.h
95777@@ -40,9 +40,10 @@ extern void cpu_remove_dev_attr(struct device_attribute *attr);
95778 extern int cpu_add_dev_attr_group(struct attribute_group *attrs);
95779 extern void cpu_remove_dev_attr_group(struct attribute_group *attrs);
95780
95781-extern struct device *cpu_device_create(struct device *parent, void *drvdata,
95782- const struct attribute_group **groups,
95783- const char *fmt, ...);
95784+extern __printf(4, 5)
95785+struct device *cpu_device_create(struct device *parent, void *drvdata,
95786+ const struct attribute_group **groups,
95787+ const char *fmt, ...);
95788 #ifdef CONFIG_HOTPLUG_CPU
95789 extern void unregister_cpu(struct cpu *cpu);
95790 extern ssize_t arch_cpu_probe(const char *, size_t);
95791diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
95792index 2ee4888..0451f5e 100644
95793--- a/include/linux/cpufreq.h
95794+++ b/include/linux/cpufreq.h
95795@@ -207,6 +207,7 @@ struct global_attr {
95796 ssize_t (*store)(struct kobject *a, struct attribute *b,
95797 const char *c, size_t count);
95798 };
95799+typedef struct global_attr __no_const global_attr_no_const;
95800
95801 #define define_one_global_ro(_name) \
95802 static struct global_attr _name = \
95803@@ -278,7 +279,7 @@ struct cpufreq_driver {
95804 bool boost_supported;
95805 bool boost_enabled;
95806 int (*set_boost)(int state);
95807-};
95808+} __do_const;
95809
95810 /* flags */
95811 #define CPUFREQ_STICKY (1 << 0) /* driver isn't removed even if
95812diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
95813index 9c5e892..feb34e0 100644
95814--- a/include/linux/cpuidle.h
95815+++ b/include/linux/cpuidle.h
95816@@ -59,7 +59,8 @@ struct cpuidle_state {
95817 void (*enter_freeze) (struct cpuidle_device *dev,
95818 struct cpuidle_driver *drv,
95819 int index);
95820-};
95821+} __do_const;
95822+typedef struct cpuidle_state __no_const cpuidle_state_no_const;
95823
95824 /* Idle State Flags */
95825 #define CPUIDLE_FLAG_COUPLED (0x02) /* state applies to multiple cpus */
95826@@ -227,7 +228,7 @@ struct cpuidle_governor {
95827 void (*reflect) (struct cpuidle_device *dev, int index);
95828
95829 struct module *owner;
95830-};
95831+} __do_const;
95832
95833 #ifdef CONFIG_CPU_IDLE
95834 extern int cpuidle_register_governor(struct cpuidle_governor *gov);
95835diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
95836index 59915ea..81ebec0 100644
95837--- a/include/linux/cpumask.h
95838+++ b/include/linux/cpumask.h
95839@@ -127,17 +127,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
95840 }
95841
95842 /* Valid inputs for n are -1 and 0. */
95843-static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
95844+static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
95845 {
95846 return n+1;
95847 }
95848
95849-static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
95850+static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
95851 {
95852 return n+1;
95853 }
95854
95855-static inline unsigned int cpumask_next_and(int n,
95856+static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
95857 const struct cpumask *srcp,
95858 const struct cpumask *andp)
95859 {
95860@@ -181,7 +181,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
95861 *
95862 * Returns >= nr_cpu_ids if no further cpus set.
95863 */
95864-static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
95865+static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
95866 {
95867 /* -1 is a legal arg here. */
95868 if (n != -1)
95869@@ -196,7 +196,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
95870 *
95871 * Returns >= nr_cpu_ids if no further cpus unset.
95872 */
95873-static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
95874+static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
95875 {
95876 /* -1 is a legal arg here. */
95877 if (n != -1)
95878@@ -204,7 +204,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
95879 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
95880 }
95881
95882-int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
95883+int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
95884 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
95885 unsigned int cpumask_local_spread(unsigned int i, int node);
95886
95887@@ -471,7 +471,7 @@ static inline bool cpumask_full(const struct cpumask *srcp)
95888 * cpumask_weight - Count of bits in *srcp
95889 * @srcp: the cpumask to count bits (< nr_cpu_ids) in.
95890 */
95891-static inline unsigned int cpumask_weight(const struct cpumask *srcp)
95892+static inline unsigned int __intentional_overflow(-1) cpumask_weight(const struct cpumask *srcp)
95893 {
95894 return bitmap_weight(cpumask_bits(srcp), nr_cpumask_bits);
95895 }
95896diff --git a/include/linux/cred.h b/include/linux/cred.h
95897index 8b6c083..51cb9f5 100644
95898--- a/include/linux/cred.h
95899+++ b/include/linux/cred.h
95900@@ -35,7 +35,7 @@ struct group_info {
95901 int nblocks;
95902 kgid_t small_block[NGROUPS_SMALL];
95903 kgid_t *blocks[0];
95904-};
95905+} __randomize_layout;
95906
95907 /**
95908 * get_group_info - Get a reference to a group info structure
95909@@ -152,7 +152,7 @@ struct cred {
95910 struct user_namespace *user_ns; /* user_ns the caps and keyrings are relative to. */
95911 struct group_info *group_info; /* supplementary groups for euid/fsgid */
95912 struct rcu_head rcu; /* RCU deletion hook */
95913-};
95914+} __randomize_layout;
95915
95916 extern void __put_cred(struct cred *);
95917 extern void exit_creds(struct task_struct *);
95918@@ -210,6 +210,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
95919 static inline void validate_process_creds(void)
95920 {
95921 }
95922+static inline void validate_task_creds(struct task_struct *task)
95923+{
95924+}
95925 #endif
95926
95927 /**
95928@@ -347,6 +350,7 @@ static inline void put_cred(const struct cred *_cred)
95929
95930 #define task_uid(task) (task_cred_xxx((task), uid))
95931 #define task_euid(task) (task_cred_xxx((task), euid))
95932+#define task_securebits(task) (task_cred_xxx((task), securebits))
95933
95934 #define current_cred_xxx(xxx) \
95935 ({ \
95936diff --git a/include/linux/crypto.h b/include/linux/crypto.h
95937index 10df5d2..503d678 100644
95938--- a/include/linux/crypto.h
95939+++ b/include/linux/crypto.h
95940@@ -632,7 +632,7 @@ struct cipher_tfm {
95941 const u8 *key, unsigned int keylen);
95942 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
95943 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
95944-};
95945+} __no_const;
95946
95947 struct hash_tfm {
95948 int (*init)(struct hash_desc *desc);
95949@@ -653,13 +653,13 @@ struct compress_tfm {
95950 int (*cot_decompress)(struct crypto_tfm *tfm,
95951 const u8 *src, unsigned int slen,
95952 u8 *dst, unsigned int *dlen);
95953-};
95954+} __no_const;
95955
95956 struct rng_tfm {
95957 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
95958 unsigned int dlen);
95959 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
95960-};
95961+} __no_const;
95962
95963 #define crt_ablkcipher crt_u.ablkcipher
95964 #define crt_aead crt_u.aead
95965diff --git a/include/linux/ctype.h b/include/linux/ctype.h
95966index 653589e..4ef254a 100644
95967--- a/include/linux/ctype.h
95968+++ b/include/linux/ctype.h
95969@@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
95970 * Fast implementation of tolower() for internal usage. Do not use in your
95971 * code.
95972 */
95973-static inline char _tolower(const char c)
95974+static inline unsigned char _tolower(const unsigned char c)
95975 {
95976 return c | 0x20;
95977 }
95978diff --git a/include/linux/dcache.h b/include/linux/dcache.h
95979index df334cb..e730faa 100644
95980--- a/include/linux/dcache.h
95981+++ b/include/linux/dcache.h
95982@@ -123,6 +123,9 @@ struct dentry {
95983 unsigned long d_time; /* used by d_revalidate */
95984 void *d_fsdata; /* fs-specific data */
95985
95986+#ifdef CONFIG_GRKERNSEC_CHROOT_RENAME
95987+ atomic_t chroot_refcnt; /* tracks use of directory in chroot */
95988+#endif
95989 struct list_head d_lru; /* LRU list */
95990 struct list_head d_child; /* child of parent list */
95991 struct list_head d_subdirs; /* our children */
95992@@ -133,7 +136,7 @@ struct dentry {
95993 struct hlist_node d_alias; /* inode alias list */
95994 struct rcu_head d_rcu;
95995 } d_u;
95996-};
95997+} __randomize_layout;
95998
95999 /*
96000 * dentry->d_lock spinlock nesting subclasses:
96001@@ -319,13 +322,14 @@ extern struct dentry *__d_lookup_rcu(const struct dentry *parent,
96002
96003 static inline unsigned d_count(const struct dentry *dentry)
96004 {
96005- return dentry->d_lockref.count;
96006+ return __lockref_read(&dentry->d_lockref);
96007 }
96008
96009 /*
96010 * helper function for dentry_operations.d_dname() members
96011 */
96012-extern char *dynamic_dname(struct dentry *, char *, int, const char *, ...);
96013+extern __printf(4, 5)
96014+char *dynamic_dname(struct dentry *, char *, int, const char *, ...);
96015 extern char *simple_dname(struct dentry *, char *, int);
96016
96017 extern char *__d_path(const struct path *, const struct path *, char *, int);
96018@@ -347,7 +351,7 @@ extern char *dentry_path(struct dentry *, char *, int);
96019 static inline struct dentry *dget_dlock(struct dentry *dentry)
96020 {
96021 if (dentry)
96022- dentry->d_lockref.count++;
96023+ __lockref_inc(&dentry->d_lockref);
96024 return dentry;
96025 }
96026
96027diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
96028index 7925bf0..d5143d2 100644
96029--- a/include/linux/decompress/mm.h
96030+++ b/include/linux/decompress/mm.h
96031@@ -77,7 +77,7 @@ static void free(void *where)
96032 * warnings when not needed (indeed large_malloc / large_free are not
96033 * needed by inflate */
96034
96035-#define malloc(a) kmalloc(a, GFP_KERNEL)
96036+#define malloc(a) kmalloc((a), GFP_KERNEL)
96037 #define free(a) kfree(a)
96038
96039 #define large_malloc(a) vmalloc(a)
96040diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
96041index ce447f0..83c66bd 100644
96042--- a/include/linux/devfreq.h
96043+++ b/include/linux/devfreq.h
96044@@ -114,7 +114,7 @@ struct devfreq_governor {
96045 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
96046 int (*event_handler)(struct devfreq *devfreq,
96047 unsigned int event, void *data);
96048-};
96049+} __do_const;
96050
96051 /**
96052 * struct devfreq - Device devfreq structure
96053diff --git a/include/linux/device.h b/include/linux/device.h
96054index 6558af9..48bce1a 100644
96055--- a/include/linux/device.h
96056+++ b/include/linux/device.h
96057@@ -312,7 +312,7 @@ struct subsys_interface {
96058 struct list_head node;
96059 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
96060 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
96061-};
96062+} __do_const;
96063
96064 int subsys_interface_register(struct subsys_interface *sif);
96065 void subsys_interface_unregister(struct subsys_interface *sif);
96066@@ -508,7 +508,7 @@ struct device_type {
96067 void (*release)(struct device *dev);
96068
96069 const struct dev_pm_ops *pm;
96070-};
96071+} __do_const;
96072
96073 /* interface for exporting device attributes */
96074 struct device_attribute {
96075@@ -518,11 +518,12 @@ struct device_attribute {
96076 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
96077 const char *buf, size_t count);
96078 };
96079+typedef struct device_attribute __no_const device_attribute_no_const;
96080
96081 struct dev_ext_attribute {
96082 struct device_attribute attr;
96083 void *var;
96084-};
96085+} __do_const;
96086
96087 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
96088 char *buf);
96089@@ -607,8 +608,9 @@ extern int devres_release_group(struct device *dev, void *id);
96090
96091 /* managed devm_k.alloc/kfree for device drivers */
96092 extern void *devm_kmalloc(struct device *dev, size_t size, gfp_t gfp);
96093-extern char *devm_kvasprintf(struct device *dev, gfp_t gfp, const char *fmt,
96094- va_list ap);
96095+extern __printf(3, 0)
96096+char *devm_kvasprintf(struct device *dev, gfp_t gfp, const char *fmt,
96097+ va_list ap);
96098 extern __printf(3, 4)
96099 char *devm_kasprintf(struct device *dev, gfp_t gfp, const char *fmt, ...);
96100 static inline void *devm_kzalloc(struct device *dev, size_t size, gfp_t gfp)
96101@@ -980,12 +982,10 @@ extern int __must_check device_reprobe(struct device *dev);
96102 /*
96103 * Easy functions for dynamically creating devices on the fly
96104 */
96105-extern struct device *device_create_vargs(struct class *cls,
96106- struct device *parent,
96107- dev_t devt,
96108- void *drvdata,
96109- const char *fmt,
96110- va_list vargs);
96111+extern __printf(5, 0)
96112+struct device *device_create_vargs(struct class *cls, struct device *parent,
96113+ dev_t devt, void *drvdata,
96114+ const char *fmt, va_list vargs);
96115 extern __printf(5, 6)
96116 struct device *device_create(struct class *cls, struct device *parent,
96117 dev_t devt, void *drvdata,
96118diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
96119index ac07ff0..edff186 100644
96120--- a/include/linux/dma-mapping.h
96121+++ b/include/linux/dma-mapping.h
96122@@ -64,7 +64,7 @@ struct dma_map_ops {
96123 u64 (*get_required_mask)(struct device *dev);
96124 #endif
96125 int is_phys;
96126-};
96127+} __do_const;
96128
96129 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
96130
96131diff --git a/include/linux/efi.h b/include/linux/efi.h
96132index af5be03..d8a6ae2 100644
96133--- a/include/linux/efi.h
96134+++ b/include/linux/efi.h
96135@@ -1057,6 +1057,7 @@ struct efivar_operations {
96136 efi_set_variable_nonblocking_t *set_variable_nonblocking;
96137 efi_query_variable_store_t *query_variable_store;
96138 };
96139+typedef struct efivar_operations __no_const efivar_operations_no_const;
96140
96141 struct efivars {
96142 /*
96143diff --git a/include/linux/elf.h b/include/linux/elf.h
96144index 20fa8d8..3d0dd18 100644
96145--- a/include/linux/elf.h
96146+++ b/include/linux/elf.h
96147@@ -29,6 +29,7 @@ extern Elf32_Dyn _DYNAMIC [];
96148 #define elf_note elf32_note
96149 #define elf_addr_t Elf32_Off
96150 #define Elf_Half Elf32_Half
96151+#define elf_dyn Elf32_Dyn
96152
96153 #else
96154
96155@@ -39,6 +40,7 @@ extern Elf64_Dyn _DYNAMIC [];
96156 #define elf_note elf64_note
96157 #define elf_addr_t Elf64_Off
96158 #define Elf_Half Elf64_Half
96159+#define elf_dyn Elf64_Dyn
96160
96161 #endif
96162
96163diff --git a/include/linux/err.h b/include/linux/err.h
96164index a729120..6ede2c9 100644
96165--- a/include/linux/err.h
96166+++ b/include/linux/err.h
96167@@ -20,12 +20,12 @@
96168
96169 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
96170
96171-static inline void * __must_check ERR_PTR(long error)
96172+static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
96173 {
96174 return (void *) error;
96175 }
96176
96177-static inline long __must_check PTR_ERR(__force const void *ptr)
96178+static inline long __must_check __intentional_overflow(-1) PTR_ERR(__force const void *ptr)
96179 {
96180 return (long) ptr;
96181 }
96182diff --git a/include/linux/extcon.h b/include/linux/extcon.h
96183index 36f49c4..a2a1f4c 100644
96184--- a/include/linux/extcon.h
96185+++ b/include/linux/extcon.h
96186@@ -135,7 +135,7 @@ struct extcon_dev {
96187 /* /sys/class/extcon/.../mutually_exclusive/... */
96188 struct attribute_group attr_g_muex;
96189 struct attribute **attrs_muex;
96190- struct device_attribute *d_attrs_muex;
96191+ device_attribute_no_const *d_attrs_muex;
96192 };
96193
96194 /**
96195diff --git a/include/linux/fb.h b/include/linux/fb.h
96196index 043f328..180ccbf 100644
96197--- a/include/linux/fb.h
96198+++ b/include/linux/fb.h
96199@@ -305,7 +305,8 @@ struct fb_ops {
96200 /* called at KDB enter and leave time to prepare the console */
96201 int (*fb_debug_enter)(struct fb_info *info);
96202 int (*fb_debug_leave)(struct fb_info *info);
96203-};
96204+} __do_const;
96205+typedef struct fb_ops __no_const fb_ops_no_const;
96206
96207 #ifdef CONFIG_FB_TILEBLITTING
96208 #define FB_TILE_CURSOR_NONE 0
96209diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
96210index 230f87b..1fd0485 100644
96211--- a/include/linux/fdtable.h
96212+++ b/include/linux/fdtable.h
96213@@ -100,7 +100,7 @@ struct files_struct *get_files_struct(struct task_struct *);
96214 void put_files_struct(struct files_struct *fs);
96215 void reset_files_struct(struct files_struct *);
96216 int unshare_files(struct files_struct **);
96217-struct files_struct *dup_fd(struct files_struct *, int *);
96218+struct files_struct *dup_fd(struct files_struct *, int *) __latent_entropy;
96219 void do_close_on_exec(struct files_struct *);
96220 int iterate_fd(struct files_struct *, unsigned,
96221 int (*)(const void *, struct file *, unsigned),
96222diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
96223index 8293262..2b3b8bd 100644
96224--- a/include/linux/frontswap.h
96225+++ b/include/linux/frontswap.h
96226@@ -11,7 +11,7 @@ struct frontswap_ops {
96227 int (*load)(unsigned, pgoff_t, struct page *);
96228 void (*invalidate_page)(unsigned, pgoff_t);
96229 void (*invalidate_area)(unsigned);
96230-};
96231+} __no_const;
96232
96233 extern bool frontswap_enabled;
96234 extern struct frontswap_ops *
96235diff --git a/include/linux/fs.h b/include/linux/fs.h
96236index 571aab9..03a5b06 100644
96237--- a/include/linux/fs.h
96238+++ b/include/linux/fs.h
96239@@ -437,7 +437,7 @@ struct address_space {
96240 spinlock_t private_lock; /* for use by the address_space */
96241 struct list_head private_list; /* ditto */
96242 void *private_data; /* ditto */
96243-} __attribute__((aligned(sizeof(long))));
96244+} __attribute__((aligned(sizeof(long)))) __randomize_layout;
96245 /*
96246 * On most architectures that alignment is already the case; but
96247 * must be enforced here for CRIS, to let the least significant bit
96248@@ -480,7 +480,7 @@ struct block_device {
96249 int bd_fsfreeze_count;
96250 /* Mutex for freeze */
96251 struct mutex bd_fsfreeze_mutex;
96252-};
96253+} __randomize_layout;
96254
96255 /*
96256 * Radix-tree tags, for tagging dirty and writeback pages within the pagecache
96257@@ -666,7 +666,7 @@ struct inode {
96258 #endif
96259
96260 void *i_private; /* fs or device private pointer */
96261-};
96262+} __randomize_layout;
96263
96264 static inline int inode_unhashed(struct inode *inode)
96265 {
96266@@ -861,7 +861,7 @@ struct file {
96267 struct list_head f_tfile_llink;
96268 #endif /* #ifdef CONFIG_EPOLL */
96269 struct address_space *f_mapping;
96270-} __attribute__((aligned(4))); /* lest something weird decides that 2 is OK */
96271+} __attribute__((aligned(4))) __randomize_layout; /* lest something weird decides that 2 is OK */
96272
96273 struct file_handle {
96274 __u32 handle_bytes;
96275@@ -990,7 +990,7 @@ struct file_lock {
96276 int state; /* state of grant or error if -ve */
96277 } afs;
96278 } fl_u;
96279-};
96280+} __randomize_layout;
96281
96282 struct file_lock_context {
96283 spinlock_t flc_lock;
96284@@ -1351,7 +1351,7 @@ struct super_block {
96285 * Indicates how deep in a filesystem stack this SB is
96286 */
96287 int s_stack_depth;
96288-};
96289+} __randomize_layout;
96290
96291 extern struct timespec current_fs_time(struct super_block *sb);
96292
96293@@ -1603,7 +1603,8 @@ struct file_operations {
96294 #ifndef CONFIG_MMU
96295 unsigned (*mmap_capabilities)(struct file *);
96296 #endif
96297-};
96298+} __do_const __randomize_layout;
96299+typedef struct file_operations __no_const file_operations_no_const;
96300
96301 struct inode_operations {
96302 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
96303@@ -2303,7 +2304,7 @@ extern int register_chrdev_region(dev_t, unsigned, const char *);
96304 extern int __register_chrdev(unsigned int major, unsigned int baseminor,
96305 unsigned int count, const char *name,
96306 const struct file_operations *fops);
96307-extern void __unregister_chrdev(unsigned int major, unsigned int baseminor,
96308+extern __nocapture(4) void __unregister_chrdev(unsigned int major, unsigned int baseminor,
96309 unsigned int count, const char *name);
96310 extern void unregister_chrdev_region(dev_t, unsigned);
96311 extern void chrdev_show(struct seq_file *,off_t);
96312@@ -2989,4 +2990,14 @@ static inline bool dir_relax(struct inode *inode)
96313 return !IS_DEADDIR(inode);
96314 }
96315
96316+static inline bool is_sidechannel_device(const struct inode *inode)
96317+{
96318+#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
96319+ umode_t mode = inode->i_mode;
96320+ return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
96321+#else
96322+ return false;
96323+#endif
96324+}
96325+
96326 #endif /* _LINUX_FS_H */
96327diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
96328index 0efc3e6..fd23610 100644
96329--- a/include/linux/fs_struct.h
96330+++ b/include/linux/fs_struct.h
96331@@ -6,13 +6,13 @@
96332 #include <linux/seqlock.h>
96333
96334 struct fs_struct {
96335- int users;
96336+ atomic_t users;
96337 spinlock_t lock;
96338 seqcount_t seq;
96339 int umask;
96340 int in_exec;
96341 struct path root, pwd;
96342-};
96343+} __randomize_layout;
96344
96345 extern struct kmem_cache *fs_cachep;
96346
96347diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
96348index 7714849..a4a5c7a 100644
96349--- a/include/linux/fscache-cache.h
96350+++ b/include/linux/fscache-cache.h
96351@@ -113,7 +113,7 @@ struct fscache_operation {
96352 fscache_operation_release_t release;
96353 };
96354
96355-extern atomic_t fscache_op_debug_id;
96356+extern atomic_unchecked_t fscache_op_debug_id;
96357 extern void fscache_op_work_func(struct work_struct *work);
96358
96359 extern void fscache_enqueue_operation(struct fscache_operation *);
96360@@ -135,7 +135,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
96361 INIT_WORK(&op->work, fscache_op_work_func);
96362 atomic_set(&op->usage, 1);
96363 op->state = FSCACHE_OP_ST_INITIALISED;
96364- op->debug_id = atomic_inc_return(&fscache_op_debug_id);
96365+ op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
96366 op->processor = processor;
96367 op->release = release;
96368 INIT_LIST_HEAD(&op->pend_link);
96369diff --git a/include/linux/fscache.h b/include/linux/fscache.h
96370index 115bb81..e7b812b 100644
96371--- a/include/linux/fscache.h
96372+++ b/include/linux/fscache.h
96373@@ -152,7 +152,7 @@ struct fscache_cookie_def {
96374 * - this is mandatory for any object that may have data
96375 */
96376 void (*now_uncached)(void *cookie_netfs_data);
96377-};
96378+} __do_const;
96379
96380 /*
96381 * fscache cached network filesystem type
96382diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
96383index 7ee1774..72505b8 100644
96384--- a/include/linux/fsnotify.h
96385+++ b/include/linux/fsnotify.h
96386@@ -197,6 +197,9 @@ static inline void fsnotify_access(struct file *file)
96387 struct inode *inode = file_inode(file);
96388 __u32 mask = FS_ACCESS;
96389
96390+ if (is_sidechannel_device(inode))
96391+ return;
96392+
96393 if (S_ISDIR(inode->i_mode))
96394 mask |= FS_ISDIR;
96395
96396@@ -215,6 +218,9 @@ static inline void fsnotify_modify(struct file *file)
96397 struct inode *inode = file_inode(file);
96398 __u32 mask = FS_MODIFY;
96399
96400+ if (is_sidechannel_device(inode))
96401+ return;
96402+
96403 if (S_ISDIR(inode->i_mode))
96404 mask |= FS_ISDIR;
96405
96406@@ -317,7 +323,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
96407 */
96408 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
96409 {
96410- return kstrdup(name, GFP_KERNEL);
96411+ return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
96412 }
96413
96414 /*
96415diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
96416index 1da6029..6cd8c0e 100644
96417--- a/include/linux/ftrace.h
96418+++ b/include/linux/ftrace.h
96419@@ -116,6 +116,7 @@ ftrace_func_t ftrace_ops_get_func(struct ftrace_ops *ops);
96420 * SAVE_REGS. If another ops with this flag set is already registered
96421 * for any of the functions that this ops will be registered for, then
96422 * this ops will fail to register or set_filter_ip.
96423+ * PID - Is affected by set_ftrace_pid (allows filtering on those pids)
96424 */
96425 enum {
96426 FTRACE_OPS_FL_ENABLED = 1 << 0,
96427@@ -132,6 +133,7 @@ enum {
96428 FTRACE_OPS_FL_MODIFYING = 1 << 11,
96429 FTRACE_OPS_FL_ALLOC_TRAMP = 1 << 12,
96430 FTRACE_OPS_FL_IPMODIFY = 1 << 13,
96431+ FTRACE_OPS_FL_PID = 1 << 14,
96432 };
96433
96434 #ifdef CONFIG_DYNAMIC_FTRACE
96435@@ -159,6 +161,7 @@ struct ftrace_ops {
96436 struct ftrace_ops *next;
96437 unsigned long flags;
96438 void *private;
96439+ ftrace_func_t saved_func;
96440 int __percpu *disabled;
96441 #ifdef CONFIG_DYNAMIC_FTRACE
96442 int nr_trampolines;
96443diff --git a/include/linux/genhd.h b/include/linux/genhd.h
96444index ec274e0..e678159 100644
96445--- a/include/linux/genhd.h
96446+++ b/include/linux/genhd.h
96447@@ -194,7 +194,7 @@ struct gendisk {
96448 struct kobject *slave_dir;
96449
96450 struct timer_rand_state *random;
96451- atomic_t sync_io; /* RAID */
96452+ atomic_unchecked_t sync_io; /* RAID */
96453 struct disk_events *ev;
96454 #ifdef CONFIG_BLK_DEV_INTEGRITY
96455 struct blk_integrity *integrity;
96456@@ -435,7 +435,7 @@ extern void disk_flush_events(struct gendisk *disk, unsigned int mask);
96457 extern unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask);
96458
96459 /* drivers/char/random.c */
96460-extern void add_disk_randomness(struct gendisk *disk);
96461+extern void add_disk_randomness(struct gendisk *disk) __latent_entropy;
96462 extern void rand_initialize_disk(struct gendisk *disk);
96463
96464 static inline sector_t get_start_sect(struct block_device *bdev)
96465diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
96466index 667c311..abac2a7 100644
96467--- a/include/linux/genl_magic_func.h
96468+++ b/include/linux/genl_magic_func.h
96469@@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
96470 },
96471
96472 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
96473-static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
96474+static struct genl_ops ZZZ_genl_ops[] = {
96475 #include GENL_MAGIC_INCLUDE_FILE
96476 };
96477
96478diff --git a/include/linux/gfp.h b/include/linux/gfp.h
96479index 15928f0..90b31d7 100644
96480--- a/include/linux/gfp.h
96481+++ b/include/linux/gfp.h
96482@@ -35,6 +35,13 @@ struct vm_area_struct;
96483 #define ___GFP_NO_KSWAPD 0x400000u
96484 #define ___GFP_OTHER_NODE 0x800000u
96485 #define ___GFP_WRITE 0x1000000u
96486+
96487+#ifdef CONFIG_PAX_USERCOPY_SLABS
96488+#define ___GFP_USERCOPY 0x2000000u
96489+#else
96490+#define ___GFP_USERCOPY 0
96491+#endif
96492+
96493 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
96494
96495 /*
96496@@ -94,6 +101,7 @@ struct vm_area_struct;
96497 #define __GFP_NO_KSWAPD ((__force gfp_t)___GFP_NO_KSWAPD)
96498 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
96499 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
96500+#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
96501
96502 /*
96503 * This may seem redundant, but it's a way of annotating false positives vs.
96504@@ -101,7 +109,7 @@ struct vm_area_struct;
96505 */
96506 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
96507
96508-#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
96509+#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
96510 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
96511
96512 /* This equals 0, but use constants in case they ever change */
96513@@ -146,6 +154,8 @@ struct vm_area_struct;
96514 /* 4GB DMA on some platforms */
96515 #define GFP_DMA32 __GFP_DMA32
96516
96517+#define GFP_USERCOPY __GFP_USERCOPY
96518+
96519 /* Convert GFP flags to their corresponding migrate type */
96520 static inline int gfpflags_to_migratetype(const gfp_t gfp_flags)
96521 {
96522diff --git a/include/linux/gracl.h b/include/linux/gracl.h
96523new file mode 100644
96524index 0000000..91858e4
96525--- /dev/null
96526+++ b/include/linux/gracl.h
96527@@ -0,0 +1,342 @@
96528+#ifndef GR_ACL_H
96529+#define GR_ACL_H
96530+
96531+#include <linux/grdefs.h>
96532+#include <linux/resource.h>
96533+#include <linux/capability.h>
96534+#include <linux/dcache.h>
96535+#include <asm/resource.h>
96536+
96537+/* Major status information */
96538+
96539+#define GR_VERSION "grsecurity 3.1"
96540+#define GRSECURITY_VERSION 0x3100
96541+
96542+enum {
96543+ GR_SHUTDOWN = 0,
96544+ GR_ENABLE = 1,
96545+ GR_SPROLE = 2,
96546+ GR_OLDRELOAD = 3,
96547+ GR_SEGVMOD = 4,
96548+ GR_STATUS = 5,
96549+ GR_UNSPROLE = 6,
96550+ GR_PASSSET = 7,
96551+ GR_SPROLEPAM = 8,
96552+ GR_RELOAD = 9,
96553+};
96554+
96555+/* Password setup definitions
96556+ * kernel/grhash.c */
96557+enum {
96558+ GR_PW_LEN = 128,
96559+ GR_SALT_LEN = 16,
96560+ GR_SHA_LEN = 32,
96561+};
96562+
96563+enum {
96564+ GR_SPROLE_LEN = 64,
96565+};
96566+
96567+enum {
96568+ GR_NO_GLOB = 0,
96569+ GR_REG_GLOB,
96570+ GR_CREATE_GLOB
96571+};
96572+
96573+#define GR_NLIMITS 32
96574+
96575+/* Begin Data Structures */
96576+
96577+struct sprole_pw {
96578+ unsigned char *rolename;
96579+ unsigned char salt[GR_SALT_LEN];
96580+ unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
96581+};
96582+
96583+struct name_entry {
96584+ __u32 key;
96585+ u64 inode;
96586+ dev_t device;
96587+ char *name;
96588+ __u16 len;
96589+ __u8 deleted;
96590+ struct name_entry *prev;
96591+ struct name_entry *next;
96592+};
96593+
96594+struct inodev_entry {
96595+ struct name_entry *nentry;
96596+ struct inodev_entry *prev;
96597+ struct inodev_entry *next;
96598+};
96599+
96600+struct acl_role_db {
96601+ struct acl_role_label **r_hash;
96602+ __u32 r_size;
96603+};
96604+
96605+struct inodev_db {
96606+ struct inodev_entry **i_hash;
96607+ __u32 i_size;
96608+};
96609+
96610+struct name_db {
96611+ struct name_entry **n_hash;
96612+ __u32 n_size;
96613+};
96614+
96615+struct crash_uid {
96616+ uid_t uid;
96617+ unsigned long expires;
96618+};
96619+
96620+struct gr_hash_struct {
96621+ void **table;
96622+ void **nametable;
96623+ void *first;
96624+ __u32 table_size;
96625+ __u32 used_size;
96626+ int type;
96627+};
96628+
96629+/* Userspace Grsecurity ACL data structures */
96630+
96631+struct acl_subject_label {
96632+ char *filename;
96633+ u64 inode;
96634+ dev_t device;
96635+ __u32 mode;
96636+ kernel_cap_t cap_mask;
96637+ kernel_cap_t cap_lower;
96638+ kernel_cap_t cap_invert_audit;
96639+
96640+ struct rlimit res[GR_NLIMITS];
96641+ __u32 resmask;
96642+
96643+ __u8 user_trans_type;
96644+ __u8 group_trans_type;
96645+ uid_t *user_transitions;
96646+ gid_t *group_transitions;
96647+ __u16 user_trans_num;
96648+ __u16 group_trans_num;
96649+
96650+ __u32 sock_families[2];
96651+ __u32 ip_proto[8];
96652+ __u32 ip_type;
96653+ struct acl_ip_label **ips;
96654+ __u32 ip_num;
96655+ __u32 inaddr_any_override;
96656+
96657+ __u32 crashes;
96658+ unsigned long expires;
96659+
96660+ struct acl_subject_label *parent_subject;
96661+ struct gr_hash_struct *hash;
96662+ struct acl_subject_label *prev;
96663+ struct acl_subject_label *next;
96664+
96665+ struct acl_object_label **obj_hash;
96666+ __u32 obj_hash_size;
96667+ __u16 pax_flags;
96668+};
96669+
96670+struct role_allowed_ip {
96671+ __u32 addr;
96672+ __u32 netmask;
96673+
96674+ struct role_allowed_ip *prev;
96675+ struct role_allowed_ip *next;
96676+};
96677+
96678+struct role_transition {
96679+ char *rolename;
96680+
96681+ struct role_transition *prev;
96682+ struct role_transition *next;
96683+};
96684+
96685+struct acl_role_label {
96686+ char *rolename;
96687+ uid_t uidgid;
96688+ __u16 roletype;
96689+
96690+ __u16 auth_attempts;
96691+ unsigned long expires;
96692+
96693+ struct acl_subject_label *root_label;
96694+ struct gr_hash_struct *hash;
96695+
96696+ struct acl_role_label *prev;
96697+ struct acl_role_label *next;
96698+
96699+ struct role_transition *transitions;
96700+ struct role_allowed_ip *allowed_ips;
96701+ uid_t *domain_children;
96702+ __u16 domain_child_num;
96703+
96704+ umode_t umask;
96705+
96706+ struct acl_subject_label **subj_hash;
96707+ __u32 subj_hash_size;
96708+};
96709+
96710+struct user_acl_role_db {
96711+ struct acl_role_label **r_table;
96712+ __u32 num_pointers; /* Number of allocations to track */
96713+ __u32 num_roles; /* Number of roles */
96714+ __u32 num_domain_children; /* Number of domain children */
96715+ __u32 num_subjects; /* Number of subjects */
96716+ __u32 num_objects; /* Number of objects */
96717+};
96718+
96719+struct acl_object_label {
96720+ char *filename;
96721+ u64 inode;
96722+ dev_t device;
96723+ __u32 mode;
96724+
96725+ struct acl_subject_label *nested;
96726+ struct acl_object_label *globbed;
96727+
96728+ /* next two structures not used */
96729+
96730+ struct acl_object_label *prev;
96731+ struct acl_object_label *next;
96732+};
96733+
96734+struct acl_ip_label {
96735+ char *iface;
96736+ __u32 addr;
96737+ __u32 netmask;
96738+ __u16 low, high;
96739+ __u8 mode;
96740+ __u32 type;
96741+ __u32 proto[8];
96742+
96743+ /* next two structures not used */
96744+
96745+ struct acl_ip_label *prev;
96746+ struct acl_ip_label *next;
96747+};
96748+
96749+struct gr_arg {
96750+ struct user_acl_role_db role_db;
96751+ unsigned char pw[GR_PW_LEN];
96752+ unsigned char salt[GR_SALT_LEN];
96753+ unsigned char sum[GR_SHA_LEN];
96754+ unsigned char sp_role[GR_SPROLE_LEN];
96755+ struct sprole_pw *sprole_pws;
96756+ dev_t segv_device;
96757+ u64 segv_inode;
96758+ uid_t segv_uid;
96759+ __u16 num_sprole_pws;
96760+ __u16 mode;
96761+};
96762+
96763+struct gr_arg_wrapper {
96764+ struct gr_arg *arg;
96765+ __u32 version;
96766+ __u32 size;
96767+};
96768+
96769+struct subject_map {
96770+ struct acl_subject_label *user;
96771+ struct acl_subject_label *kernel;
96772+ struct subject_map *prev;
96773+ struct subject_map *next;
96774+};
96775+
96776+struct acl_subj_map_db {
96777+ struct subject_map **s_hash;
96778+ __u32 s_size;
96779+};
96780+
96781+struct gr_policy_state {
96782+ struct sprole_pw **acl_special_roles;
96783+ __u16 num_sprole_pws;
96784+ struct acl_role_label *kernel_role;
96785+ struct acl_role_label *role_list;
96786+ struct acl_role_label *default_role;
96787+ struct acl_role_db acl_role_set;
96788+ struct acl_subj_map_db subj_map_set;
96789+ struct name_db name_set;
96790+ struct inodev_db inodev_set;
96791+};
96792+
96793+struct gr_alloc_state {
96794+ unsigned long alloc_stack_next;
96795+ unsigned long alloc_stack_size;
96796+ void **alloc_stack;
96797+};
96798+
96799+struct gr_reload_state {
96800+ struct gr_policy_state oldpolicy;
96801+ struct gr_alloc_state oldalloc;
96802+ struct gr_policy_state newpolicy;
96803+ struct gr_alloc_state newalloc;
96804+ struct gr_policy_state *oldpolicy_ptr;
96805+ struct gr_alloc_state *oldalloc_ptr;
96806+ unsigned char oldmode;
96807+};
96808+
96809+/* End Data Structures Section */
96810+
96811+/* Hash functions generated by empirical testing by Brad Spengler
96812+ Makes good use of the low bits of the inode. Generally 0-1 times
96813+ in loop for successful match. 0-3 for unsuccessful match.
96814+ Shift/add algorithm with modulus of table size and an XOR*/
96815+
96816+static __inline__ unsigned int
96817+gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
96818+{
96819+ return ((((uid + type) << (16 + type)) ^ uid) % sz);
96820+}
96821+
96822+ static __inline__ unsigned int
96823+gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
96824+{
96825+ return ((const unsigned long)userp % sz);
96826+}
96827+
96828+static __inline__ unsigned int
96829+gr_fhash(const u64 ino, const dev_t dev, const unsigned int sz)
96830+{
96831+ unsigned int rem;
96832+ div_u64_rem((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9)), sz, &rem);
96833+ return rem;
96834+}
96835+
96836+static __inline__ unsigned int
96837+gr_nhash(const char *name, const __u16 len, const unsigned int sz)
96838+{
96839+ return full_name_hash((const unsigned char *)name, len) % sz;
96840+}
96841+
96842+#define FOR_EACH_SUBJECT_START(role,subj,iter) \
96843+ subj = NULL; \
96844+ iter = 0; \
96845+ while (iter < role->subj_hash_size) { \
96846+ if (subj == NULL) \
96847+ subj = role->subj_hash[iter]; \
96848+ if (subj == NULL) { \
96849+ iter++; \
96850+ continue; \
96851+ }
96852+
96853+#define FOR_EACH_SUBJECT_END(subj,iter) \
96854+ subj = subj->next; \
96855+ if (subj == NULL) \
96856+ iter++; \
96857+ }
96858+
96859+
96860+#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
96861+ subj = role->hash->first; \
96862+ while (subj != NULL) {
96863+
96864+#define FOR_EACH_NESTED_SUBJECT_END(subj) \
96865+ subj = subj->next; \
96866+ }
96867+
96868+#endif
96869+
96870diff --git a/include/linux/gracl_compat.h b/include/linux/gracl_compat.h
96871new file mode 100644
96872index 0000000..af64092
96873--- /dev/null
96874+++ b/include/linux/gracl_compat.h
96875@@ -0,0 +1,156 @@
96876+#ifndef GR_ACL_COMPAT_H
96877+#define GR_ACL_COMPAT_H
96878+
96879+#include <linux/resource.h>
96880+#include <asm/resource.h>
96881+
96882+struct sprole_pw_compat {
96883+ compat_uptr_t rolename;
96884+ unsigned char salt[GR_SALT_LEN];
96885+ unsigned char sum[GR_SHA_LEN];
96886+};
96887+
96888+struct gr_hash_struct_compat {
96889+ compat_uptr_t table;
96890+ compat_uptr_t nametable;
96891+ compat_uptr_t first;
96892+ __u32 table_size;
96893+ __u32 used_size;
96894+ int type;
96895+};
96896+
96897+struct acl_subject_label_compat {
96898+ compat_uptr_t filename;
96899+ compat_u64 inode;
96900+ __u32 device;
96901+ __u32 mode;
96902+ kernel_cap_t cap_mask;
96903+ kernel_cap_t cap_lower;
96904+ kernel_cap_t cap_invert_audit;
96905+
96906+ struct compat_rlimit res[GR_NLIMITS];
96907+ __u32 resmask;
96908+
96909+ __u8 user_trans_type;
96910+ __u8 group_trans_type;
96911+ compat_uptr_t user_transitions;
96912+ compat_uptr_t group_transitions;
96913+ __u16 user_trans_num;
96914+ __u16 group_trans_num;
96915+
96916+ __u32 sock_families[2];
96917+ __u32 ip_proto[8];
96918+ __u32 ip_type;
96919+ compat_uptr_t ips;
96920+ __u32 ip_num;
96921+ __u32 inaddr_any_override;
96922+
96923+ __u32 crashes;
96924+ compat_ulong_t expires;
96925+
96926+ compat_uptr_t parent_subject;
96927+ compat_uptr_t hash;
96928+ compat_uptr_t prev;
96929+ compat_uptr_t next;
96930+
96931+ compat_uptr_t obj_hash;
96932+ __u32 obj_hash_size;
96933+ __u16 pax_flags;
96934+};
96935+
96936+struct role_allowed_ip_compat {
96937+ __u32 addr;
96938+ __u32 netmask;
96939+
96940+ compat_uptr_t prev;
96941+ compat_uptr_t next;
96942+};
96943+
96944+struct role_transition_compat {
96945+ compat_uptr_t rolename;
96946+
96947+ compat_uptr_t prev;
96948+ compat_uptr_t next;
96949+};
96950+
96951+struct acl_role_label_compat {
96952+ compat_uptr_t rolename;
96953+ uid_t uidgid;
96954+ __u16 roletype;
96955+
96956+ __u16 auth_attempts;
96957+ compat_ulong_t expires;
96958+
96959+ compat_uptr_t root_label;
96960+ compat_uptr_t hash;
96961+
96962+ compat_uptr_t prev;
96963+ compat_uptr_t next;
96964+
96965+ compat_uptr_t transitions;
96966+ compat_uptr_t allowed_ips;
96967+ compat_uptr_t domain_children;
96968+ __u16 domain_child_num;
96969+
96970+ umode_t umask;
96971+
96972+ compat_uptr_t subj_hash;
96973+ __u32 subj_hash_size;
96974+};
96975+
96976+struct user_acl_role_db_compat {
96977+ compat_uptr_t r_table;
96978+ __u32 num_pointers;
96979+ __u32 num_roles;
96980+ __u32 num_domain_children;
96981+ __u32 num_subjects;
96982+ __u32 num_objects;
96983+};
96984+
96985+struct acl_object_label_compat {
96986+ compat_uptr_t filename;
96987+ compat_u64 inode;
96988+ __u32 device;
96989+ __u32 mode;
96990+
96991+ compat_uptr_t nested;
96992+ compat_uptr_t globbed;
96993+
96994+ compat_uptr_t prev;
96995+ compat_uptr_t next;
96996+};
96997+
96998+struct acl_ip_label_compat {
96999+ compat_uptr_t iface;
97000+ __u32 addr;
97001+ __u32 netmask;
97002+ __u16 low, high;
97003+ __u8 mode;
97004+ __u32 type;
97005+ __u32 proto[8];
97006+
97007+ compat_uptr_t prev;
97008+ compat_uptr_t next;
97009+};
97010+
97011+struct gr_arg_compat {
97012+ struct user_acl_role_db_compat role_db;
97013+ unsigned char pw[GR_PW_LEN];
97014+ unsigned char salt[GR_SALT_LEN];
97015+ unsigned char sum[GR_SHA_LEN];
97016+ unsigned char sp_role[GR_SPROLE_LEN];
97017+ compat_uptr_t sprole_pws;
97018+ __u32 segv_device;
97019+ compat_u64 segv_inode;
97020+ uid_t segv_uid;
97021+ __u16 num_sprole_pws;
97022+ __u16 mode;
97023+};
97024+
97025+struct gr_arg_wrapper_compat {
97026+ compat_uptr_t arg;
97027+ __u32 version;
97028+ __u32 size;
97029+};
97030+
97031+#endif
97032diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
97033new file mode 100644
97034index 0000000..323ecf2
97035--- /dev/null
97036+++ b/include/linux/gralloc.h
97037@@ -0,0 +1,9 @@
97038+#ifndef __GRALLOC_H
97039+#define __GRALLOC_H
97040+
97041+void acl_free_all(void);
97042+int acl_alloc_stack_init(unsigned long size);
97043+void *acl_alloc(unsigned long len);
97044+void *acl_alloc_num(unsigned long num, unsigned long len);
97045+
97046+#endif
97047diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
97048new file mode 100644
97049index 0000000..be66033
97050--- /dev/null
97051+++ b/include/linux/grdefs.h
97052@@ -0,0 +1,140 @@
97053+#ifndef GRDEFS_H
97054+#define GRDEFS_H
97055+
97056+/* Begin grsecurity status declarations */
97057+
97058+enum {
97059+ GR_READY = 0x01,
97060+ GR_STATUS_INIT = 0x00 // disabled state
97061+};
97062+
97063+/* Begin ACL declarations */
97064+
97065+/* Role flags */
97066+
97067+enum {
97068+ GR_ROLE_USER = 0x0001,
97069+ GR_ROLE_GROUP = 0x0002,
97070+ GR_ROLE_DEFAULT = 0x0004,
97071+ GR_ROLE_SPECIAL = 0x0008,
97072+ GR_ROLE_AUTH = 0x0010,
97073+ GR_ROLE_NOPW = 0x0020,
97074+ GR_ROLE_GOD = 0x0040,
97075+ GR_ROLE_LEARN = 0x0080,
97076+ GR_ROLE_TPE = 0x0100,
97077+ GR_ROLE_DOMAIN = 0x0200,
97078+ GR_ROLE_PAM = 0x0400,
97079+ GR_ROLE_PERSIST = 0x0800
97080+};
97081+
97082+/* ACL Subject and Object mode flags */
97083+enum {
97084+ GR_DELETED = 0x80000000
97085+};
97086+
97087+/* ACL Object-only mode flags */
97088+enum {
97089+ GR_READ = 0x00000001,
97090+ GR_APPEND = 0x00000002,
97091+ GR_WRITE = 0x00000004,
97092+ GR_EXEC = 0x00000008,
97093+ GR_FIND = 0x00000010,
97094+ GR_INHERIT = 0x00000020,
97095+ GR_SETID = 0x00000040,
97096+ GR_CREATE = 0x00000080,
97097+ GR_DELETE = 0x00000100,
97098+ GR_LINK = 0x00000200,
97099+ GR_AUDIT_READ = 0x00000400,
97100+ GR_AUDIT_APPEND = 0x00000800,
97101+ GR_AUDIT_WRITE = 0x00001000,
97102+ GR_AUDIT_EXEC = 0x00002000,
97103+ GR_AUDIT_FIND = 0x00004000,
97104+ GR_AUDIT_INHERIT= 0x00008000,
97105+ GR_AUDIT_SETID = 0x00010000,
97106+ GR_AUDIT_CREATE = 0x00020000,
97107+ GR_AUDIT_DELETE = 0x00040000,
97108+ GR_AUDIT_LINK = 0x00080000,
97109+ GR_PTRACERD = 0x00100000,
97110+ GR_NOPTRACE = 0x00200000,
97111+ GR_SUPPRESS = 0x00400000,
97112+ GR_NOLEARN = 0x00800000,
97113+ GR_INIT_TRANSFER= 0x01000000
97114+};
97115+
97116+#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
97117+ GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
97118+ GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
97119+
97120+/* ACL subject-only mode flags */
97121+enum {
97122+ GR_KILL = 0x00000001,
97123+ GR_VIEW = 0x00000002,
97124+ GR_PROTECTED = 0x00000004,
97125+ GR_LEARN = 0x00000008,
97126+ GR_OVERRIDE = 0x00000010,
97127+ /* just a placeholder, this mode is only used in userspace */
97128+ GR_DUMMY = 0x00000020,
97129+ GR_PROTSHM = 0x00000040,
97130+ GR_KILLPROC = 0x00000080,
97131+ GR_KILLIPPROC = 0x00000100,
97132+ /* just a placeholder, this mode is only used in userspace */
97133+ GR_NOTROJAN = 0x00000200,
97134+ GR_PROTPROCFD = 0x00000400,
97135+ GR_PROCACCT = 0x00000800,
97136+ GR_RELAXPTRACE = 0x00001000,
97137+ //GR_NESTED = 0x00002000,
97138+ GR_INHERITLEARN = 0x00004000,
97139+ GR_PROCFIND = 0x00008000,
97140+ GR_POVERRIDE = 0x00010000,
97141+ GR_KERNELAUTH = 0x00020000,
97142+ GR_ATSECURE = 0x00040000,
97143+ GR_SHMEXEC = 0x00080000
97144+};
97145+
97146+enum {
97147+ GR_PAX_ENABLE_SEGMEXEC = 0x0001,
97148+ GR_PAX_ENABLE_PAGEEXEC = 0x0002,
97149+ GR_PAX_ENABLE_MPROTECT = 0x0004,
97150+ GR_PAX_ENABLE_RANDMMAP = 0x0008,
97151+ GR_PAX_ENABLE_EMUTRAMP = 0x0010,
97152+ GR_PAX_DISABLE_SEGMEXEC = 0x0100,
97153+ GR_PAX_DISABLE_PAGEEXEC = 0x0200,
97154+ GR_PAX_DISABLE_MPROTECT = 0x0400,
97155+ GR_PAX_DISABLE_RANDMMAP = 0x0800,
97156+ GR_PAX_DISABLE_EMUTRAMP = 0x1000,
97157+};
97158+
97159+enum {
97160+ GR_ID_USER = 0x01,
97161+ GR_ID_GROUP = 0x02,
97162+};
97163+
97164+enum {
97165+ GR_ID_ALLOW = 0x01,
97166+ GR_ID_DENY = 0x02,
97167+};
97168+
97169+#define GR_CRASH_RES 31
97170+#define GR_UIDTABLE_MAX 500
97171+
97172+/* begin resource learning section */
97173+enum {
97174+ GR_RLIM_CPU_BUMP = 60,
97175+ GR_RLIM_FSIZE_BUMP = 50000,
97176+ GR_RLIM_DATA_BUMP = 10000,
97177+ GR_RLIM_STACK_BUMP = 1000,
97178+ GR_RLIM_CORE_BUMP = 10000,
97179+ GR_RLIM_RSS_BUMP = 500000,
97180+ GR_RLIM_NPROC_BUMP = 1,
97181+ GR_RLIM_NOFILE_BUMP = 5,
97182+ GR_RLIM_MEMLOCK_BUMP = 50000,
97183+ GR_RLIM_AS_BUMP = 500000,
97184+ GR_RLIM_LOCKS_BUMP = 2,
97185+ GR_RLIM_SIGPENDING_BUMP = 5,
97186+ GR_RLIM_MSGQUEUE_BUMP = 10000,
97187+ GR_RLIM_NICE_BUMP = 1,
97188+ GR_RLIM_RTPRIO_BUMP = 1,
97189+ GR_RLIM_RTTIME_BUMP = 1000000
97190+};
97191+
97192+#endif
97193diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
97194new file mode 100644
97195index 0000000..fb1de5d
97196--- /dev/null
97197+++ b/include/linux/grinternal.h
97198@@ -0,0 +1,230 @@
97199+#ifndef __GRINTERNAL_H
97200+#define __GRINTERNAL_H
97201+
97202+#ifdef CONFIG_GRKERNSEC
97203+
97204+#include <linux/fs.h>
97205+#include <linux/mnt_namespace.h>
97206+#include <linux/nsproxy.h>
97207+#include <linux/gracl.h>
97208+#include <linux/grdefs.h>
97209+#include <linux/grmsg.h>
97210+
97211+void gr_add_learn_entry(const char *fmt, ...)
97212+ __attribute__ ((format (printf, 1, 2)));
97213+__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
97214+ const struct vfsmount *mnt);
97215+__u32 gr_check_create(const struct dentry *new_dentry,
97216+ const struct dentry *parent,
97217+ const struct vfsmount *mnt, const __u32 mode);
97218+int gr_check_protected_task(const struct task_struct *task);
97219+__u32 to_gr_audit(const __u32 reqmode);
97220+int gr_set_acls(const int type);
97221+int gr_acl_is_enabled(void);
97222+char gr_roletype_to_char(void);
97223+
97224+void gr_handle_alertkill(struct task_struct *task);
97225+char *gr_to_filename(const struct dentry *dentry,
97226+ const struct vfsmount *mnt);
97227+char *gr_to_filename1(const struct dentry *dentry,
97228+ const struct vfsmount *mnt);
97229+char *gr_to_filename2(const struct dentry *dentry,
97230+ const struct vfsmount *mnt);
97231+char *gr_to_filename3(const struct dentry *dentry,
97232+ const struct vfsmount *mnt);
97233+
97234+extern int grsec_enable_ptrace_readexec;
97235+extern int grsec_enable_harden_ptrace;
97236+extern int grsec_enable_link;
97237+extern int grsec_enable_fifo;
97238+extern int grsec_enable_execve;
97239+extern int grsec_enable_shm;
97240+extern int grsec_enable_execlog;
97241+extern int grsec_enable_signal;
97242+extern int grsec_enable_audit_ptrace;
97243+extern int grsec_enable_forkfail;
97244+extern int grsec_enable_time;
97245+extern int grsec_enable_rofs;
97246+extern int grsec_deny_new_usb;
97247+extern int grsec_enable_chroot_shmat;
97248+extern int grsec_enable_chroot_mount;
97249+extern int grsec_enable_chroot_double;
97250+extern int grsec_enable_chroot_pivot;
97251+extern int grsec_enable_chroot_chdir;
97252+extern int grsec_enable_chroot_chmod;
97253+extern int grsec_enable_chroot_mknod;
97254+extern int grsec_enable_chroot_fchdir;
97255+extern int grsec_enable_chroot_nice;
97256+extern int grsec_enable_chroot_execlog;
97257+extern int grsec_enable_chroot_caps;
97258+extern int grsec_enable_chroot_rename;
97259+extern int grsec_enable_chroot_sysctl;
97260+extern int grsec_enable_chroot_unix;
97261+extern int grsec_enable_symlinkown;
97262+extern kgid_t grsec_symlinkown_gid;
97263+extern int grsec_enable_tpe;
97264+extern kgid_t grsec_tpe_gid;
97265+extern int grsec_enable_tpe_all;
97266+extern int grsec_enable_tpe_invert;
97267+extern int grsec_enable_socket_all;
97268+extern kgid_t grsec_socket_all_gid;
97269+extern int grsec_enable_socket_client;
97270+extern kgid_t grsec_socket_client_gid;
97271+extern int grsec_enable_socket_server;
97272+extern kgid_t grsec_socket_server_gid;
97273+extern kgid_t grsec_audit_gid;
97274+extern int grsec_enable_group;
97275+extern int grsec_enable_log_rwxmaps;
97276+extern int grsec_enable_mount;
97277+extern int grsec_enable_chdir;
97278+extern int grsec_resource_logging;
97279+extern int grsec_enable_blackhole;
97280+extern int grsec_lastack_retries;
97281+extern int grsec_enable_brute;
97282+extern int grsec_enable_harden_ipc;
97283+extern int grsec_lock;
97284+
97285+extern spinlock_t grsec_alert_lock;
97286+extern unsigned long grsec_alert_wtime;
97287+extern unsigned long grsec_alert_fyet;
97288+
97289+extern spinlock_t grsec_audit_lock;
97290+
97291+extern rwlock_t grsec_exec_file_lock;
97292+
97293+#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
97294+ gr_to_filename2((tsk)->exec_file->f_path.dentry, \
97295+ (tsk)->exec_file->f_path.mnt) : "/")
97296+
97297+#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
97298+ gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
97299+ (tsk)->real_parent->exec_file->f_path.mnt) : "/")
97300+
97301+#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
97302+ gr_to_filename((tsk)->exec_file->f_path.dentry, \
97303+ (tsk)->exec_file->f_path.mnt) : "/")
97304+
97305+#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
97306+ gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
97307+ (tsk)->real_parent->exec_file->f_path.mnt) : "/")
97308+
97309+#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
97310+
97311+#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
97312+
97313+static inline bool gr_is_same_file(const struct file *file1, const struct file *file2)
97314+{
97315+ if (file1 && file2) {
97316+ const struct inode *inode1 = file1->f_path.dentry->d_inode;
97317+ const struct inode *inode2 = file2->f_path.dentry->d_inode;
97318+ if (inode1->i_ino == inode2->i_ino && inode1->i_sb->s_dev == inode2->i_sb->s_dev)
97319+ return true;
97320+ }
97321+
97322+ return false;
97323+}
97324+
97325+#define GR_CHROOT_CAPS {{ \
97326+ CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
97327+ CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
97328+ CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
97329+ CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
97330+ CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
97331+ CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
97332+ CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
97333+
97334+#define security_learn(normal_msg,args...) \
97335+({ \
97336+ read_lock(&grsec_exec_file_lock); \
97337+ gr_add_learn_entry(normal_msg "\n", ## args); \
97338+ read_unlock(&grsec_exec_file_lock); \
97339+})
97340+
97341+enum {
97342+ GR_DO_AUDIT,
97343+ GR_DONT_AUDIT,
97344+ /* used for non-audit messages that we shouldn't kill the task on */
97345+ GR_DONT_AUDIT_GOOD
97346+};
97347+
97348+enum {
97349+ GR_TTYSNIFF,
97350+ GR_RBAC,
97351+ GR_RBAC_STR,
97352+ GR_STR_RBAC,
97353+ GR_RBAC_MODE2,
97354+ GR_RBAC_MODE3,
97355+ GR_FILENAME,
97356+ GR_SYSCTL_HIDDEN,
97357+ GR_NOARGS,
97358+ GR_ONE_INT,
97359+ GR_ONE_INT_TWO_STR,
97360+ GR_ONE_STR,
97361+ GR_STR_INT,
97362+ GR_TWO_STR_INT,
97363+ GR_TWO_INT,
97364+ GR_TWO_U64,
97365+ GR_THREE_INT,
97366+ GR_FIVE_INT_TWO_STR,
97367+ GR_TWO_STR,
97368+ GR_THREE_STR,
97369+ GR_FOUR_STR,
97370+ GR_STR_FILENAME,
97371+ GR_FILENAME_STR,
97372+ GR_FILENAME_TWO_INT,
97373+ GR_FILENAME_TWO_INT_STR,
97374+ GR_TEXTREL,
97375+ GR_PTRACE,
97376+ GR_RESOURCE,
97377+ GR_CAP,
97378+ GR_SIG,
97379+ GR_SIG2,
97380+ GR_CRASH1,
97381+ GR_CRASH2,
97382+ GR_PSACCT,
97383+ GR_RWXMAP,
97384+ GR_RWXMAPVMA
97385+};
97386+
97387+#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
97388+#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
97389+#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
97390+#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
97391+#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
97392+#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
97393+#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)
97394+#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
97395+#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
97396+#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
97397+#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
97398+#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
97399+#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
97400+#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
97401+#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
97402+#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
97403+#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)
97404+#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
97405+#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
97406+#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
97407+#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
97408+#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
97409+#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
97410+#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
97411+#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)
97412+#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
97413+#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
97414+#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
97415+#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
97416+#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
97417+#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
97418+#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
97419+#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
97420+#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)
97421+#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
97422+#define gr_log_rwxmap_vma(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAPVMA, str)
97423+
97424+void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
97425+
97426+#endif
97427+
97428+#endif
97429diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
97430new file mode 100644
97431index 0000000..26ef560
97432--- /dev/null
97433+++ b/include/linux/grmsg.h
97434@@ -0,0 +1,118 @@
97435+#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"
97436+#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"
97437+#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
97438+#define GR_STOPMOD_MSG "denied modification of module state by "
97439+#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
97440+#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
97441+#define GR_IOPERM_MSG "denied use of ioperm() by "
97442+#define GR_IOPL_MSG "denied use of iopl() by "
97443+#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
97444+#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
97445+#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
97446+#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
97447+#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
97448+#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"
97449+#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"
97450+#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
97451+#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
97452+#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
97453+#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
97454+#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
97455+#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
97456+#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
97457+#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
97458+#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
97459+#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
97460+#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
97461+#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
97462+#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
97463+#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
97464+#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
97465+#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
97466+#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
97467+#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
97468+#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
97469+#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
97470+#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
97471+#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
97472+#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
97473+#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
97474+#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
97475+#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
97476+#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
97477+#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
97478+#define GR_CHROOT_RENAME_MSG "denied bad rename of %.950s out of a chroot by "
97479+#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
97480+#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
97481+#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
97482+#define GR_CHROOT_FHANDLE_MSG "denied use of file handles inside chroot by "
97483+#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
97484+#define GR_SETXATTR_ACL_MSG "%s setting extended attribute of %.950s by "
97485+#define GR_REMOVEXATTR_ACL_MSG "%s removing extended attribute of %.950s by "
97486+#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
97487+#define GR_INITF_ACL_MSG "init_variables() failed %s by "
97488+#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"
97489+#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
97490+#define GR_SHUTS_ACL_MSG "shutdown auth success for "
97491+#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
97492+#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
97493+#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
97494+#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
97495+#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
97496+#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
97497+#define GR_ENABLEF_ACL_MSG "unable to load %s for "
97498+#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
97499+#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
97500+#define GR_RELOADF_ACL_MSG "failed reload of %s for "
97501+#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
97502+#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
97503+#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
97504+#define GR_SPROLEF_ACL_MSG "special role %s failure for "
97505+#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
97506+#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
97507+#define GR_INVMODE_ACL_MSG "invalid mode %d by "
97508+#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
97509+#define GR_FAILFORK_MSG "failed fork with errno %s by "
97510+#define GR_NICE_CHROOT_MSG "denied priority change by "
97511+#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
97512+#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
97513+#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
97514+#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
97515+#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
97516+#define GR_TIME_MSG "time set by "
97517+#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
97518+#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
97519+#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
97520+#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
97521+#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
97522+#define GR_BIND_MSG "denied bind() by "
97523+#define GR_CONNECT_MSG "denied connect() by "
97524+#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
97525+#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
97526+#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"
97527+#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
97528+#define GR_CAP_ACL_MSG "use of %s denied for "
97529+#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
97530+#define GR_CAP_ACL_MSG2 "use of %s permitted for "
97531+#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
97532+#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
97533+#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
97534+#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
97535+#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
97536+#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
97537+#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
97538+#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
97539+#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
97540+#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
97541+#define GR_TEXTREL_AUDIT_MSG "denied text relocation in %.950s, VMA:0x%08lx 0x%08lx by "
97542+#define GR_PTGNUSTACK_MSG "denied marking stack executable as requested by PT_GNU_STACK marking in %.950s by "
97543+#define GR_VM86_MSG "denied use of vm86 by "
97544+#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
97545+#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
97546+#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
97547+#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
97548+#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
97549+#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 "
97550+#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 "
97551+#define GR_IPC_DENIED_MSG "denied %s of overly-permissive IPC object with creator uid %u by "
97552+#define GR_MSRWRITE_MSG "denied write to CPU MSR by "
97553diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
97554new file mode 100644
97555index 0000000..085a746
97556--- /dev/null
97557+++ b/include/linux/grsecurity.h
97558@@ -0,0 +1,247 @@
97559+#ifndef GR_SECURITY_H
97560+#define GR_SECURITY_H
97561+#include <linux/fs.h>
97562+#include <linux/fs_struct.h>
97563+#include <linux/binfmts.h>
97564+#include <linux/gracl.h>
97565+
97566+/* notify of brain-dead configs */
97567+#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
97568+#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
97569+#endif
97570+#if defined(CONFIG_GRKERNSEC_PROC) && !defined(CONFIG_GRKERNSEC_PROC_USER) && !defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
97571+#error "CONFIG_GRKERNSEC_PROC enabled, but neither CONFIG_GRKERNSEC_PROC_USER nor CONFIG_GRKERNSEC_PROC_USERGROUP enabled"
97572+#endif
97573+#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
97574+#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
97575+#endif
97576+#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
97577+#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
97578+#endif
97579+#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
97580+#error "CONFIG_PAX enabled, but no PaX options are enabled."
97581+#endif
97582+
97583+int gr_handle_new_usb(void);
97584+
97585+void gr_handle_brute_attach(int dumpable);
97586+void gr_handle_brute_check(void);
97587+void gr_handle_kernel_exploit(void);
97588+
97589+char gr_roletype_to_char(void);
97590+
97591+int gr_proc_is_restricted(void);
97592+
97593+int gr_acl_enable_at_secure(void);
97594+
97595+int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
97596+int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
97597+
97598+int gr_learn_cap(const struct task_struct *task, const struct cred *cred, const int cap);
97599+
97600+void gr_del_task_from_ip_table(struct task_struct *p);
97601+
97602+int gr_pid_is_chrooted(struct task_struct *p);
97603+int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
97604+int gr_handle_chroot_nice(void);
97605+int gr_handle_chroot_sysctl(const int op);
97606+int gr_handle_chroot_setpriority(struct task_struct *p,
97607+ const int niceval);
97608+int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
97609+int gr_chroot_fhandle(void);
97610+int gr_handle_chroot_chroot(const struct dentry *dentry,
97611+ const struct vfsmount *mnt);
97612+void gr_handle_chroot_chdir(const struct path *path);
97613+int gr_handle_chroot_chmod(const struct dentry *dentry,
97614+ const struct vfsmount *mnt, const int mode);
97615+int gr_handle_chroot_mknod(const struct dentry *dentry,
97616+ const struct vfsmount *mnt, const int mode);
97617+int gr_handle_chroot_mount(const struct dentry *dentry,
97618+ const struct vfsmount *mnt,
97619+ const char *dev_name);
97620+int gr_handle_chroot_pivot(void);
97621+int gr_handle_chroot_unix(const pid_t pid);
97622+
97623+int gr_handle_rawio(const struct inode *inode);
97624+
97625+void gr_handle_ioperm(void);
97626+void gr_handle_iopl(void);
97627+void gr_handle_msr_write(void);
97628+
97629+umode_t gr_acl_umask(void);
97630+
97631+int gr_tpe_allow(const struct file *file);
97632+
97633+void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
97634+void gr_clear_chroot_entries(struct task_struct *task);
97635+
97636+void gr_log_forkfail(const int retval);
97637+void gr_log_timechange(void);
97638+void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
97639+void gr_log_chdir(const struct dentry *dentry,
97640+ const struct vfsmount *mnt);
97641+void gr_log_chroot_exec(const struct dentry *dentry,
97642+ const struct vfsmount *mnt);
97643+void gr_log_remount(const char *devname, const int retval);
97644+void gr_log_unmount(const char *devname, const int retval);
97645+void gr_log_mount(const char *from, struct path *to, const int retval);
97646+void gr_log_textrel(struct vm_area_struct *vma);
97647+void gr_log_ptgnustack(struct file *file);
97648+void gr_log_rwxmmap(struct file *file);
97649+void gr_log_rwxmprotect(struct vm_area_struct *vma);
97650+
97651+int gr_handle_follow_link(const struct dentry *dentry,
97652+ const struct vfsmount *mnt);
97653+int gr_handle_fifo(const struct dentry *dentry,
97654+ const struct vfsmount *mnt,
97655+ const struct dentry *dir, const int flag,
97656+ const int acc_mode);
97657+int gr_handle_hardlink(const struct dentry *dentry,
97658+ const struct vfsmount *mnt,
97659+ const struct filename *to);
97660+
97661+int gr_is_capable(const int cap);
97662+int gr_is_capable_nolog(const int cap);
97663+int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
97664+int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
97665+
97666+void gr_copy_label(struct task_struct *tsk);
97667+void gr_handle_crash(struct task_struct *task, const int sig);
97668+int gr_handle_signal(const struct task_struct *p, const int sig);
97669+int gr_check_crash_uid(const kuid_t uid);
97670+int gr_check_protected_task(const struct task_struct *task);
97671+int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
97672+int gr_acl_handle_mmap(const struct file *file,
97673+ const unsigned long prot);
97674+int gr_acl_handle_mprotect(const struct file *file,
97675+ const unsigned long prot);
97676+int gr_check_hidden_task(const struct task_struct *tsk);
97677+__u32 gr_acl_handle_truncate(const struct dentry *dentry,
97678+ const struct vfsmount *mnt);
97679+__u32 gr_acl_handle_utime(const struct dentry *dentry,
97680+ const struct vfsmount *mnt);
97681+__u32 gr_acl_handle_access(const struct dentry *dentry,
97682+ const struct vfsmount *mnt, const int fmode);
97683+__u32 gr_acl_handle_chmod(const struct dentry *dentry,
97684+ const struct vfsmount *mnt, umode_t *mode);
97685+__u32 gr_acl_handle_chown(const struct dentry *dentry,
97686+ const struct vfsmount *mnt);
97687+__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
97688+ const struct vfsmount *mnt);
97689+__u32 gr_acl_handle_removexattr(const struct dentry *dentry,
97690+ const struct vfsmount *mnt);
97691+int gr_handle_ptrace(struct task_struct *task, const long request);
97692+int gr_handle_proc_ptrace(struct task_struct *task);
97693+__u32 gr_acl_handle_execve(const struct dentry *dentry,
97694+ const struct vfsmount *mnt);
97695+int gr_check_crash_exec(const struct file *filp);
97696+int gr_acl_is_enabled(void);
97697+void gr_set_role_label(struct task_struct *task, const kuid_t uid,
97698+ const kgid_t gid);
97699+int gr_set_proc_label(const struct dentry *dentry,
97700+ const struct vfsmount *mnt,
97701+ const int unsafe_flags);
97702+__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
97703+ const struct vfsmount *mnt);
97704+__u32 gr_acl_handle_open(const struct dentry *dentry,
97705+ const struct vfsmount *mnt, int acc_mode);
97706+__u32 gr_acl_handle_creat(const struct dentry *dentry,
97707+ const struct dentry *p_dentry,
97708+ const struct vfsmount *p_mnt,
97709+ int open_flags, int acc_mode, const int imode);
97710+void gr_handle_create(const struct dentry *dentry,
97711+ const struct vfsmount *mnt);
97712+void gr_handle_proc_create(const struct dentry *dentry,
97713+ const struct inode *inode);
97714+__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
97715+ const struct dentry *parent_dentry,
97716+ const struct vfsmount *parent_mnt,
97717+ const int mode);
97718+__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
97719+ const struct dentry *parent_dentry,
97720+ const struct vfsmount *parent_mnt);
97721+__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
97722+ const struct vfsmount *mnt);
97723+void gr_handle_delete(const u64 ino, const dev_t dev);
97724+__u32 gr_acl_handle_unlink(const struct dentry *dentry,
97725+ const struct vfsmount *mnt);
97726+__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
97727+ const struct dentry *parent_dentry,
97728+ const struct vfsmount *parent_mnt,
97729+ const struct filename *from);
97730+__u32 gr_acl_handle_link(const struct dentry *new_dentry,
97731+ const struct dentry *parent_dentry,
97732+ const struct vfsmount *parent_mnt,
97733+ const struct dentry *old_dentry,
97734+ const struct vfsmount *old_mnt, const struct filename *to);
97735+int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
97736+int gr_acl_handle_rename(struct dentry *new_dentry,
97737+ struct dentry *parent_dentry,
97738+ const struct vfsmount *parent_mnt,
97739+ struct dentry *old_dentry,
97740+ struct inode *old_parent_inode,
97741+ struct vfsmount *old_mnt, const struct filename *newname, unsigned int flags);
97742+void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
97743+ struct dentry *old_dentry,
97744+ struct dentry *new_dentry,
97745+ struct vfsmount *mnt, const __u8 replace, unsigned int flags);
97746+__u32 gr_check_link(const struct dentry *new_dentry,
97747+ const struct dentry *parent_dentry,
97748+ const struct vfsmount *parent_mnt,
97749+ const struct dentry *old_dentry,
97750+ const struct vfsmount *old_mnt);
97751+int gr_acl_handle_filldir(const struct file *file, const char *name,
97752+ const unsigned int namelen, const u64 ino);
97753+
97754+__u32 gr_acl_handle_unix(const struct dentry *dentry,
97755+ const struct vfsmount *mnt);
97756+void gr_acl_handle_exit(void);
97757+void gr_acl_handle_psacct(struct task_struct *task, const long code);
97758+int gr_acl_handle_procpidmem(const struct task_struct *task);
97759+int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
97760+int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
97761+void gr_audit_ptrace(struct task_struct *task);
97762+dev_t gr_get_dev_from_dentry(struct dentry *dentry);
97763+u64 gr_get_ino_from_dentry(struct dentry *dentry);
97764+void gr_put_exec_file(struct task_struct *task);
97765+
97766+int gr_ptrace_readexec(struct file *file, int unsafe_flags);
97767+
97768+void gr_inc_chroot_refcnts(struct dentry *dentry, struct vfsmount *mnt);
97769+void gr_dec_chroot_refcnts(struct dentry *dentry, struct vfsmount *mnt);
97770+int gr_bad_chroot_rename(struct dentry *olddentry, struct vfsmount *oldmnt,
97771+ struct dentry *newdentry, struct vfsmount *newmnt);
97772+
97773+#ifdef CONFIG_GRKERNSEC_RESLOG
97774+extern void gr_log_resource(const struct task_struct *task, const int res,
97775+ const unsigned long wanted, const int gt);
97776+#else
97777+static inline void gr_log_resource(const struct task_struct *task, const int res,
97778+ const unsigned long wanted, const int gt)
97779+{
97780+}
97781+#endif
97782+
97783+#ifdef CONFIG_GRKERNSEC
97784+void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
97785+void gr_handle_vm86(void);
97786+void gr_handle_mem_readwrite(u64 from, u64 to);
97787+
97788+void gr_log_badprocpid(const char *entry);
97789+
97790+extern int grsec_enable_dmesg;
97791+extern int grsec_disable_privio;
97792+
97793+#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
97794+extern kgid_t grsec_proc_gid;
97795+#endif
97796+
97797+#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
97798+extern int grsec_enable_chroot_findtask;
97799+#endif
97800+#ifdef CONFIG_GRKERNSEC_SETXID
97801+extern int grsec_enable_setxid;
97802+#endif
97803+#endif
97804+
97805+#endif
97806diff --git a/include/linux/grsock.h b/include/linux/grsock.h
97807new file mode 100644
97808index 0000000..e7ffaaf
97809--- /dev/null
97810+++ b/include/linux/grsock.h
97811@@ -0,0 +1,19 @@
97812+#ifndef __GRSOCK_H
97813+#define __GRSOCK_H
97814+
97815+extern void gr_attach_curr_ip(const struct sock *sk);
97816+extern int gr_handle_sock_all(const int family, const int type,
97817+ const int protocol);
97818+extern int gr_handle_sock_server(const struct sockaddr *sck);
97819+extern int gr_handle_sock_server_other(const struct sock *sck);
97820+extern int gr_handle_sock_client(const struct sockaddr *sck);
97821+extern int gr_search_connect(struct socket * sock,
97822+ struct sockaddr_in * addr);
97823+extern int gr_search_bind(struct socket * sock,
97824+ struct sockaddr_in * addr);
97825+extern int gr_search_listen(struct socket * sock);
97826+extern int gr_search_accept(struct socket * sock);
97827+extern int gr_search_socket(const int domain, const int type,
97828+ const int protocol);
97829+
97830+#endif
97831diff --git a/include/linux/highmem.h b/include/linux/highmem.h
97832index 9286a46..373f27f 100644
97833--- a/include/linux/highmem.h
97834+++ b/include/linux/highmem.h
97835@@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
97836 kunmap_atomic(kaddr);
97837 }
97838
97839+static inline void sanitize_highpage(struct page *page)
97840+{
97841+ void *kaddr;
97842+ unsigned long flags;
97843+
97844+ local_irq_save(flags);
97845+ kaddr = kmap_atomic(page);
97846+ clear_page(kaddr);
97847+ kunmap_atomic(kaddr);
97848+ local_irq_restore(flags);
97849+}
97850+
97851 static inline void zero_user_segments(struct page *page,
97852 unsigned start1, unsigned end1,
97853 unsigned start2, unsigned end2)
97854diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
97855index 1c7b89a..7dda400 100644
97856--- a/include/linux/hwmon-sysfs.h
97857+++ b/include/linux/hwmon-sysfs.h
97858@@ -25,7 +25,8 @@
97859 struct sensor_device_attribute{
97860 struct device_attribute dev_attr;
97861 int index;
97862-};
97863+} __do_const;
97864+typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
97865 #define to_sensor_dev_attr(_dev_attr) \
97866 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
97867
97868@@ -41,7 +42,8 @@ struct sensor_device_attribute_2 {
97869 struct device_attribute dev_attr;
97870 u8 index;
97871 u8 nr;
97872-};
97873+} __do_const;
97874+typedef struct sensor_device_attribute_2 __no_const sensor_device_attribute_2_no_const;
97875 #define to_sensor_dev_attr_2(_dev_attr) \
97876 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
97877
97878diff --git a/include/linux/i2c.h b/include/linux/i2c.h
97879index e83a738..8b323fa 100644
97880--- a/include/linux/i2c.h
97881+++ b/include/linux/i2c.h
97882@@ -409,6 +409,7 @@ struct i2c_algorithm {
97883 int (*unreg_slave)(struct i2c_client *client);
97884 #endif
97885 };
97886+typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
97887
97888 /**
97889 * struct i2c_bus_recovery_info - I2C bus recovery information
97890diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
97891index 66a7d76..5e68d20 100644
97892--- a/include/linux/if_pppox.h
97893+++ b/include/linux/if_pppox.h
97894@@ -78,7 +78,7 @@ struct pppox_proto {
97895 int (*ioctl)(struct socket *sock, unsigned int cmd,
97896 unsigned long arg);
97897 struct module *owner;
97898-};
97899+} __do_const;
97900
97901 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
97902 extern void unregister_pppox_proto(int proto_num);
97903diff --git a/include/linux/init.h b/include/linux/init.h
97904index 21b6d76..4a6775c 100644
97905--- a/include/linux/init.h
97906+++ b/include/linux/init.h
97907@@ -37,9 +37,17 @@
97908 * section.
97909 */
97910
97911+#define add_init_latent_entropy __latent_entropy
97912+
97913+#ifdef CONFIG_MEMORY_HOTPLUG
97914+#define add_meminit_latent_entropy
97915+#else
97916+#define add_meminit_latent_entropy __latent_entropy
97917+#endif
97918+
97919 /* These are for everybody (although not all archs will actually
97920 discard it in modules) */
97921-#define __init __section(.init.text) __cold notrace
97922+#define __init __section(.init.text) __cold notrace add_init_latent_entropy
97923 #define __initdata __section(.init.data)
97924 #define __initconst __constsection(.init.rodata)
97925 #define __exitdata __section(.exit.data)
97926@@ -100,7 +108,7 @@
97927 #define __cpuexitconst
97928
97929 /* Used for MEMORY_HOTPLUG */
97930-#define __meminit __section(.meminit.text) __cold notrace
97931+#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
97932 #define __meminitdata __section(.meminit.data)
97933 #define __meminitconst __constsection(.meminit.rodata)
97934 #define __memexit __section(.memexit.text) __exitused __cold notrace
97935diff --git a/include/linux/init_task.h b/include/linux/init_task.h
97936index 696d223..6d6b39f 100644
97937--- a/include/linux/init_task.h
97938+++ b/include/linux/init_task.h
97939@@ -158,6 +158,12 @@ extern struct task_group root_task_group;
97940
97941 #define INIT_TASK_COMM "swapper"
97942
97943+#ifdef CONFIG_X86
97944+#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
97945+#else
97946+#define INIT_TASK_THREAD_INFO
97947+#endif
97948+
97949 #ifdef CONFIG_RT_MUTEXES
97950 # define INIT_RT_MUTEXES(tsk) \
97951 .pi_waiters = RB_ROOT, \
97952@@ -224,6 +230,7 @@ extern struct task_group root_task_group;
97953 RCU_POINTER_INITIALIZER(cred, &init_cred), \
97954 .comm = INIT_TASK_COMM, \
97955 .thread = INIT_THREAD, \
97956+ INIT_TASK_THREAD_INFO \
97957 .fs = &init_fs, \
97958 .files = &init_files, \
97959 .signal = &init_signals, \
97960diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
97961index 950ae45..df6ac60 100644
97962--- a/include/linux/interrupt.h
97963+++ b/include/linux/interrupt.h
97964@@ -432,8 +432,8 @@ extern const char * const softirq_to_name[NR_SOFTIRQS];
97965
97966 struct softirq_action
97967 {
97968- void (*action)(struct softirq_action *);
97969-};
97970+ void (*action)(void);
97971+} __no_const;
97972
97973 asmlinkage void do_softirq(void);
97974 asmlinkage void __do_softirq(void);
97975@@ -447,7 +447,7 @@ static inline void do_softirq_own_stack(void)
97976 }
97977 #endif
97978
97979-extern void open_softirq(int nr, void (*action)(struct softirq_action *));
97980+extern void open_softirq(int nr, void (*action)(void));
97981 extern void softirq_init(void);
97982 extern void __raise_softirq_irqoff(unsigned int nr);
97983
97984diff --git a/include/linux/iommu.h b/include/linux/iommu.h
97985index 0546b87..46fd5b6 100644
97986--- a/include/linux/iommu.h
97987+++ b/include/linux/iommu.h
97988@@ -174,7 +174,7 @@ struct iommu_ops {
97989
97990 unsigned long pgsize_bitmap;
97991 void *priv;
97992-};
97993+} __do_const;
97994
97995 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
97996 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
97997@@ -234,7 +234,7 @@ extern int iommu_domain_set_attr(struct iommu_domain *domain, enum iommu_attr,
97998 void *data);
97999 struct device *iommu_device_create(struct device *parent, void *drvdata,
98000 const struct attribute_group **groups,
98001- const char *fmt, ...);
98002+ const char *fmt, ...) __printf(4, 5);
98003 void iommu_device_destroy(struct device *dev);
98004 int iommu_device_link(struct device *dev, struct device *link);
98005 void iommu_device_unlink(struct device *dev, struct device *link);
98006diff --git a/include/linux/ioport.h b/include/linux/ioport.h
98007index 388e3ae..d7e45a1 100644
98008--- a/include/linux/ioport.h
98009+++ b/include/linux/ioport.h
98010@@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
98011 int adjust_resource(struct resource *res, resource_size_t start,
98012 resource_size_t size);
98013 resource_size_t resource_alignment(struct resource *res);
98014-static inline resource_size_t resource_size(const struct resource *res)
98015+static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
98016 {
98017 return res->end - res->start + 1;
98018 }
98019diff --git a/include/linux/ipc_namespace.h b/include/linux/ipc_namespace.h
98020index 1eee6bc..9cf4912 100644
98021--- a/include/linux/ipc_namespace.h
98022+++ b/include/linux/ipc_namespace.h
98023@@ -60,7 +60,7 @@ struct ipc_namespace {
98024 struct user_namespace *user_ns;
98025
98026 struct ns_common ns;
98027-};
98028+} __randomize_layout;
98029
98030 extern struct ipc_namespace init_ipc_ns;
98031 extern atomic_t nr_ipc_ns;
98032diff --git a/include/linux/irq.h b/include/linux/irq.h
98033index 62c6901..827f8f6 100644
98034--- a/include/linux/irq.h
98035+++ b/include/linux/irq.h
98036@@ -370,7 +370,8 @@ struct irq_chip {
98037 int (*irq_set_irqchip_state)(struct irq_data *data, enum irqchip_irq_state which, bool state);
98038
98039 unsigned long flags;
98040-};
98041+} __do_const;
98042+typedef struct irq_chip __no_const irq_chip_no_const;
98043
98044 /*
98045 * irq_chip specific flags
98046diff --git a/include/linux/irqdesc.h b/include/linux/irqdesc.h
98047index dd1109f..4f4fdda 100644
98048--- a/include/linux/irqdesc.h
98049+++ b/include/linux/irqdesc.h
98050@@ -61,7 +61,7 @@ struct irq_desc {
98051 unsigned int irq_count; /* For detecting broken IRQs */
98052 unsigned long last_unhandled; /* Aging timer for unhandled count */
98053 unsigned int irqs_unhandled;
98054- atomic_t threads_handled;
98055+ atomic_unchecked_t threads_handled;
98056 int threads_handled_last;
98057 raw_spinlock_t lock;
98058 struct cpumask *percpu_enabled;
98059diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
98060index 676d730..8d3a1ad 100644
98061--- a/include/linux/irqdomain.h
98062+++ b/include/linux/irqdomain.h
98063@@ -40,6 +40,7 @@ struct device_node;
98064 struct irq_domain;
98065 struct of_device_id;
98066 struct irq_chip;
98067+typedef struct irq_chip __no_const irq_chip_no_const;
98068 struct irq_data;
98069
98070 /* Number of irqs reserved for a legacy isa controller */
98071diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
98072index c367cbd..c9b79e6 100644
98073--- a/include/linux/jiffies.h
98074+++ b/include/linux/jiffies.h
98075@@ -280,20 +280,20 @@ extern unsigned long preset_lpj;
98076 /*
98077 * Convert various time units to each other:
98078 */
98079-extern unsigned int jiffies_to_msecs(const unsigned long j);
98080-extern unsigned int jiffies_to_usecs(const unsigned long j);
98081+extern unsigned int jiffies_to_msecs(const unsigned long j) __intentional_overflow(-1);
98082+extern unsigned int jiffies_to_usecs(const unsigned long j) __intentional_overflow(-1);
98083
98084-static inline u64 jiffies_to_nsecs(const unsigned long j)
98085+static inline u64 __intentional_overflow(-1) jiffies_to_nsecs(const unsigned long j)
98086 {
98087 return (u64)jiffies_to_usecs(j) * NSEC_PER_USEC;
98088 }
98089
98090-extern unsigned long msecs_to_jiffies(const unsigned int m);
98091-extern unsigned long usecs_to_jiffies(const unsigned int u);
98092+extern unsigned long msecs_to_jiffies(const unsigned int m) __intentional_overflow(-1);
98093+extern unsigned long usecs_to_jiffies(const unsigned int u) __intentional_overflow(-1);
98094 extern unsigned long timespec_to_jiffies(const struct timespec *value);
98095 extern void jiffies_to_timespec(const unsigned long jiffies,
98096- struct timespec *value);
98097-extern unsigned long timeval_to_jiffies(const struct timeval *value);
98098+ struct timespec *value) __intentional_overflow(-1);
98099+extern unsigned long timeval_to_jiffies(const struct timeval *value) __intentional_overflow(-1);
98100 extern void jiffies_to_timeval(const unsigned long jiffies,
98101 struct timeval *value);
98102
98103diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
98104index 6883e19..e854fcb 100644
98105--- a/include/linux/kallsyms.h
98106+++ b/include/linux/kallsyms.h
98107@@ -15,7 +15,8 @@
98108
98109 struct module;
98110
98111-#ifdef CONFIG_KALLSYMS
98112+#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
98113+#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
98114 /* Lookup the address for a symbol. Returns 0 if not found. */
98115 unsigned long kallsyms_lookup_name(const char *name);
98116
98117@@ -106,6 +107,21 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
98118 /* Stupid that this does nothing, but I didn't create this mess. */
98119 #define __print_symbol(fmt, addr)
98120 #endif /*CONFIG_KALLSYMS*/
98121+#else /* when included by kallsyms.c, vsnprintf.c, kprobes.c, or
98122+ arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
98123+extern unsigned long kallsyms_lookup_name(const char *name);
98124+extern void __print_symbol(const char *fmt, unsigned long address);
98125+extern int sprint_backtrace(char *buffer, unsigned long address);
98126+extern int sprint_symbol(char *buffer, unsigned long address);
98127+extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
98128+const char *kallsyms_lookup(unsigned long addr,
98129+ unsigned long *symbolsize,
98130+ unsigned long *offset,
98131+ char **modname, char *namebuf);
98132+extern int kallsyms_lookup_size_offset(unsigned long addr,
98133+ unsigned long *symbolsize,
98134+ unsigned long *offset);
98135+#endif
98136
98137 /* This macro allows us to keep printk typechecking */
98138 static __printf(1, 2)
98139diff --git a/include/linux/kernel.h b/include/linux/kernel.h
98140index 3a5b48e..240107b 100644
98141--- a/include/linux/kernel.h
98142+++ b/include/linux/kernel.h
98143@@ -390,7 +390,7 @@ static inline int __must_check kstrtos32_from_user(const char __user *s, size_t
98144 /* Obsolete, do not use. Use kstrto<foo> instead */
98145
98146 extern unsigned long simple_strtoul(const char *,char **,unsigned int);
98147-extern long simple_strtol(const char *,char **,unsigned int);
98148+extern long simple_strtol(const char *,char **,unsigned int) __intentional_overflow(-1);
98149 extern unsigned long long simple_strtoull(const char *,char **,unsigned int);
98150 extern long long simple_strtoll(const char *,char **,unsigned int);
98151
98152@@ -410,7 +410,8 @@ extern __printf(3, 0)
98153 int vscnprintf(char *buf, size_t size, const char *fmt, va_list args);
98154 extern __printf(2, 3)
98155 char *kasprintf(gfp_t gfp, const char *fmt, ...);
98156-extern char *kvasprintf(gfp_t gfp, const char *fmt, va_list args);
98157+extern __printf(2, 0)
98158+char *kvasprintf(gfp_t gfp, const char *fmt, va_list args);
98159
98160 extern __scanf(2, 3)
98161 int sscanf(const char *, const char *, ...);
98162@@ -681,10 +682,10 @@ do { \
98163 __ftrace_vprintk(_THIS_IP_, fmt, vargs); \
98164 } while (0)
98165
98166-extern int
98167+extern __printf(2, 0) int
98168 __ftrace_vbprintk(unsigned long ip, const char *fmt, va_list ap);
98169
98170-extern int
98171+extern __printf(2, 0) int
98172 __ftrace_vprintk(unsigned long ip, const char *fmt, va_list ap);
98173
98174 extern void ftrace_dump(enum ftrace_dump_mode oops_dump_mode);
98175@@ -704,7 +705,7 @@ int trace_printk(const char *fmt, ...)
98176 {
98177 return 0;
98178 }
98179-static inline int
98180+static __printf(1, 0) inline int
98181 ftrace_vprintk(const char *fmt, va_list ap)
98182 {
98183 return 0;
98184diff --git a/include/linux/key-type.h b/include/linux/key-type.h
98185index ff9f1d3..6712be5 100644
98186--- a/include/linux/key-type.h
98187+++ b/include/linux/key-type.h
98188@@ -152,7 +152,7 @@ struct key_type {
98189 /* internal fields */
98190 struct list_head link; /* link in types list */
98191 struct lock_class_key lock_class; /* key->sem lock class */
98192-};
98193+} __do_const;
98194
98195 extern struct key_type key_type_keyring;
98196
98197diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
98198index e465bb1..19f605fd 100644
98199--- a/include/linux/kgdb.h
98200+++ b/include/linux/kgdb.h
98201@@ -52,7 +52,7 @@ extern int kgdb_connected;
98202 extern int kgdb_io_module_registered;
98203
98204 extern atomic_t kgdb_setting_breakpoint;
98205-extern atomic_t kgdb_cpu_doing_single_step;
98206+extern atomic_unchecked_t kgdb_cpu_doing_single_step;
98207
98208 extern struct task_struct *kgdb_usethread;
98209 extern struct task_struct *kgdb_contthread;
98210@@ -254,7 +254,7 @@ struct kgdb_arch {
98211 void (*correct_hw_break)(void);
98212
98213 void (*enable_nmi)(bool on);
98214-};
98215+} __do_const;
98216
98217 /**
98218 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
98219@@ -279,7 +279,7 @@ struct kgdb_io {
98220 void (*pre_exception) (void);
98221 void (*post_exception) (void);
98222 int is_console;
98223-};
98224+} __do_const;
98225
98226 extern struct kgdb_arch arch_kgdb_ops;
98227
98228diff --git a/include/linux/kmemleak.h b/include/linux/kmemleak.h
98229index d0a1f99..0bd8b7c 100644
98230--- a/include/linux/kmemleak.h
98231+++ b/include/linux/kmemleak.h
98232@@ -27,7 +27,7 @@
98233
98234 extern void kmemleak_init(void) __ref;
98235 extern void kmemleak_alloc(const void *ptr, size_t size, int min_count,
98236- gfp_t gfp) __ref;
98237+ gfp_t gfp) __ref __size_overflow(2);
98238 extern void kmemleak_alloc_percpu(const void __percpu *ptr, size_t size,
98239 gfp_t gfp) __ref;
98240 extern void kmemleak_free(const void *ptr) __ref;
98241@@ -63,7 +63,7 @@ static inline void kmemleak_erase(void **ptr)
98242 static inline void kmemleak_init(void)
98243 {
98244 }
98245-static inline void kmemleak_alloc(const void *ptr, size_t size, int min_count,
98246+static inline void __size_overflow(2) kmemleak_alloc(const void *ptr, size_t size, int min_count,
98247 gfp_t gfp)
98248 {
98249 }
98250diff --git a/include/linux/kmod.h b/include/linux/kmod.h
98251index 0555cc6..40116ce 100644
98252--- a/include/linux/kmod.h
98253+++ b/include/linux/kmod.h
98254@@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
98255 * usually useless though. */
98256 extern __printf(2, 3)
98257 int __request_module(bool wait, const char *name, ...);
98258+extern __printf(3, 4)
98259+int ___request_module(bool wait, char *param_name, const char *name, ...);
98260 #define request_module(mod...) __request_module(true, mod)
98261 #define request_module_nowait(mod...) __request_module(false, mod)
98262 #define try_then_request_module(x, mod...) \
98263@@ -57,6 +59,9 @@ struct subprocess_info {
98264 struct work_struct work;
98265 struct completion *complete;
98266 char *path;
98267+#ifdef CONFIG_GRKERNSEC
98268+ char *origpath;
98269+#endif
98270 char **argv;
98271 char **envp;
98272 int wait;
98273diff --git a/include/linux/kobject.h b/include/linux/kobject.h
98274index 2d61b90..3d69945 100644
98275--- a/include/linux/kobject.h
98276+++ b/include/linux/kobject.h
98277@@ -80,8 +80,9 @@ struct kobject {
98278
98279 extern __printf(2, 3)
98280 int kobject_set_name(struct kobject *kobj, const char *name, ...);
98281-extern int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
98282- va_list vargs);
98283+extern __printf(2, 0)
98284+int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
98285+ va_list vargs);
98286
98287 static inline const char *kobject_name(const struct kobject *kobj)
98288 {
98289@@ -118,7 +119,7 @@ struct kobj_type {
98290 struct attribute **default_attrs;
98291 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
98292 const void *(*namespace)(struct kobject *kobj);
98293-};
98294+} __do_const;
98295
98296 struct kobj_uevent_env {
98297 char *argv[3];
98298@@ -142,6 +143,7 @@ struct kobj_attribute {
98299 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
98300 const char *buf, size_t count);
98301 };
98302+typedef struct kobj_attribute __no_const kobj_attribute_no_const;
98303
98304 extern const struct sysfs_ops kobj_sysfs_ops;
98305
98306@@ -169,7 +171,7 @@ struct kset {
98307 spinlock_t list_lock;
98308 struct kobject kobj;
98309 const struct kset_uevent_ops *uevent_ops;
98310-};
98311+} __randomize_layout;
98312
98313 extern void kset_init(struct kset *kset);
98314 extern int __must_check kset_register(struct kset *kset);
98315diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
98316index df32d25..fb52e27 100644
98317--- a/include/linux/kobject_ns.h
98318+++ b/include/linux/kobject_ns.h
98319@@ -44,7 +44,7 @@ struct kobj_ns_type_operations {
98320 const void *(*netlink_ns)(struct sock *sk);
98321 const void *(*initial_ns)(void);
98322 void (*drop_ns)(void *);
98323-};
98324+} __do_const;
98325
98326 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
98327 int kobj_ns_type_registered(enum kobj_ns_type type);
98328diff --git a/include/linux/kref.h b/include/linux/kref.h
98329index 484604d..0f6c5b6 100644
98330--- a/include/linux/kref.h
98331+++ b/include/linux/kref.h
98332@@ -68,7 +68,7 @@ static inline void kref_get(struct kref *kref)
98333 static inline int kref_sub(struct kref *kref, unsigned int count,
98334 void (*release)(struct kref *kref))
98335 {
98336- WARN_ON(release == NULL);
98337+ BUG_ON(release == NULL);
98338
98339 if (atomic_sub_and_test((int) count, &kref->refcount)) {
98340 release(kref);
98341diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
98342index ad45054..7c54663 100644
98343--- a/include/linux/kvm_host.h
98344+++ b/include/linux/kvm_host.h
98345@@ -455,7 +455,7 @@ static inline void kvm_irqfd_exit(void)
98346 {
98347 }
98348 #endif
98349-int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
98350+int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
98351 struct module *module);
98352 void kvm_exit(void);
98353
98354@@ -633,7 +633,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
98355 struct kvm_guest_debug *dbg);
98356 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
98357
98358-int kvm_arch_init(void *opaque);
98359+int kvm_arch_init(const void *opaque);
98360 void kvm_arch_exit(void);
98361
98362 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
98363diff --git a/include/linux/libata.h b/include/linux/libata.h
98364index 28aeae4..320b3bf6 100644
98365--- a/include/linux/libata.h
98366+++ b/include/linux/libata.h
98367@@ -988,7 +988,7 @@ struct ata_port_operations {
98368 * fields must be pointers.
98369 */
98370 const struct ata_port_operations *inherits;
98371-};
98372+} __do_const;
98373
98374 struct ata_port_info {
98375 unsigned long flags;
98376diff --git a/include/linux/linkage.h b/include/linux/linkage.h
98377index a6a42dd..6c5ebce 100644
98378--- a/include/linux/linkage.h
98379+++ b/include/linux/linkage.h
98380@@ -36,6 +36,7 @@
98381 #endif
98382
98383 #define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE)
98384+#define __page_aligned_rodata __read_only __aligned(PAGE_SIZE)
98385 #define __page_aligned_bss __section(.bss..page_aligned) __aligned(PAGE_SIZE)
98386
98387 /*
98388diff --git a/include/linux/list.h b/include/linux/list.h
98389index feb773c..98f3075 100644
98390--- a/include/linux/list.h
98391+++ b/include/linux/list.h
98392@@ -113,6 +113,19 @@ extern void __list_del_entry(struct list_head *entry);
98393 extern void list_del(struct list_head *entry);
98394 #endif
98395
98396+extern void __pax_list_add(struct list_head *new,
98397+ struct list_head *prev,
98398+ struct list_head *next);
98399+static inline void pax_list_add(struct list_head *new, struct list_head *head)
98400+{
98401+ __pax_list_add(new, head, head->next);
98402+}
98403+static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
98404+{
98405+ __pax_list_add(new, head->prev, head);
98406+}
98407+extern void pax_list_del(struct list_head *entry);
98408+
98409 /**
98410 * list_replace - replace old entry by new one
98411 * @old : the element to be replaced
98412@@ -146,6 +159,8 @@ static inline void list_del_init(struct list_head *entry)
98413 INIT_LIST_HEAD(entry);
98414 }
98415
98416+extern void pax_list_del_init(struct list_head *entry);
98417+
98418 /**
98419 * list_move - delete from one list and add as another's head
98420 * @list: the entry to move
98421diff --git a/include/linux/lockref.h b/include/linux/lockref.h
98422index b10b122..d37b3de 100644
98423--- a/include/linux/lockref.h
98424+++ b/include/linux/lockref.h
98425@@ -28,7 +28,7 @@ struct lockref {
98426 #endif
98427 struct {
98428 spinlock_t lock;
98429- int count;
98430+ atomic_t count;
98431 };
98432 };
98433 };
98434@@ -43,9 +43,29 @@ extern void lockref_mark_dead(struct lockref *);
98435 extern int lockref_get_not_dead(struct lockref *);
98436
98437 /* Must be called under spinlock for reliable results */
98438-static inline int __lockref_is_dead(const struct lockref *l)
98439+static inline int __lockref_is_dead(const struct lockref *lockref)
98440 {
98441- return ((int)l->count < 0);
98442+ return atomic_read(&lockref->count) < 0;
98443+}
98444+
98445+static inline int __lockref_read(const struct lockref *lockref)
98446+{
98447+ return atomic_read(&lockref->count);
98448+}
98449+
98450+static inline void __lockref_set(struct lockref *lockref, int count)
98451+{
98452+ atomic_set(&lockref->count, count);
98453+}
98454+
98455+static inline void __lockref_inc(struct lockref *lockref)
98456+{
98457+ atomic_inc(&lockref->count);
98458+}
98459+
98460+static inline void __lockref_dec(struct lockref *lockref)
98461+{
98462+ atomic_dec(&lockref->count);
98463 }
98464
98465 #endif /* __LINUX_LOCKREF_H */
98466diff --git a/include/linux/math64.h b/include/linux/math64.h
98467index c45c089..298841c 100644
98468--- a/include/linux/math64.h
98469+++ b/include/linux/math64.h
98470@@ -15,7 +15,7 @@
98471 * This is commonly provided by 32bit archs to provide an optimized 64bit
98472 * divide.
98473 */
98474-static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
98475+static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
98476 {
98477 *remainder = dividend % divisor;
98478 return dividend / divisor;
98479@@ -42,7 +42,7 @@ static inline u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder)
98480 /**
98481 * div64_u64 - unsigned 64bit divide with 64bit divisor
98482 */
98483-static inline u64 div64_u64(u64 dividend, u64 divisor)
98484+static inline u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
98485 {
98486 return dividend / divisor;
98487 }
98488@@ -61,7 +61,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
98489 #define div64_ul(x, y) div_u64((x), (y))
98490
98491 #ifndef div_u64_rem
98492-static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
98493+static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
98494 {
98495 *remainder = do_div(dividend, divisor);
98496 return dividend;
98497@@ -77,7 +77,7 @@ extern u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder);
98498 #endif
98499
98500 #ifndef div64_u64
98501-extern u64 div64_u64(u64 dividend, u64 divisor);
98502+extern u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor);
98503 #endif
98504
98505 #ifndef div64_s64
98506@@ -94,7 +94,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
98507 * divide.
98508 */
98509 #ifndef div_u64
98510-static inline u64 div_u64(u64 dividend, u32 divisor)
98511+static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
98512 {
98513 u32 remainder;
98514 return div_u64_rem(dividend, divisor, &remainder);
98515diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h
98516index 3d385c8..deacb6a 100644
98517--- a/include/linux/mempolicy.h
98518+++ b/include/linux/mempolicy.h
98519@@ -91,6 +91,10 @@ static inline struct mempolicy *mpol_dup(struct mempolicy *pol)
98520 }
98521
98522 #define vma_policy(vma) ((vma)->vm_policy)
98523+static inline void set_vma_policy(struct vm_area_struct *vma, struct mempolicy *pol)
98524+{
98525+ vma->vm_policy = pol;
98526+}
98527
98528 static inline void mpol_get(struct mempolicy *pol)
98529 {
98530@@ -229,6 +233,9 @@ static inline void mpol_free_shared_policy(struct shared_policy *p)
98531 }
98532
98533 #define vma_policy(vma) NULL
98534+static inline void set_vma_policy(struct vm_area_struct *vma, struct mempolicy *pol)
98535+{
98536+}
98537
98538 static inline int
98539 vma_dup_policy(struct vm_area_struct *src, struct vm_area_struct *dst)
98540diff --git a/include/linux/mm.h b/include/linux/mm.h
98541index 0755b9f..2960e96 100644
98542--- a/include/linux/mm.h
98543+++ b/include/linux/mm.h
98544@@ -135,6 +135,11 @@ extern unsigned int kobjsize(const void *objp);
98545
98546 #define VM_DONTCOPY 0x00020000 /* Do not copy this vma on fork */
98547 #define VM_DONTEXPAND 0x00040000 /* Cannot expand with mremap() */
98548+
98549+#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
98550+#define VM_PAGEEXEC 0x00080000 /* vma->vm_page_prot needs special handling */
98551+#endif
98552+
98553 #define VM_ACCOUNT 0x00100000 /* Is a VM accounted object */
98554 #define VM_NORESERVE 0x00200000 /* should the VM suppress accounting */
98555 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
98556@@ -257,8 +262,8 @@ struct vm_operations_struct {
98557 /* called by access_process_vm when get_user_pages() fails, typically
98558 * for use by special VMAs that can switch between memory and hardware
98559 */
98560- int (*access)(struct vm_area_struct *vma, unsigned long addr,
98561- void *buf, int len, int write);
98562+ ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
98563+ void *buf, size_t len, int write);
98564
98565 /* Called by the /proc/PID/maps code to ask the vma whether it
98566 * has a special name. Returning non-NULL will also cause this
98567@@ -296,6 +301,7 @@ struct vm_operations_struct {
98568 struct page *(*find_special_page)(struct vm_area_struct *vma,
98569 unsigned long addr);
98570 };
98571+typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
98572
98573 struct mmu_gather;
98574 struct inode;
98575@@ -1131,8 +1137,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
98576 unsigned long *pfn);
98577 int follow_phys(struct vm_area_struct *vma, unsigned long address,
98578 unsigned int flags, unsigned long *prot, resource_size_t *phys);
98579-int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
98580- void *buf, int len, int write);
98581+ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
98582+ void *buf, size_t len, int write);
98583
98584 static inline void unmap_shared_mapping_range(struct address_space *mapping,
98585 loff_t const holebegin, loff_t const holelen)
98586@@ -1172,9 +1178,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
98587 }
98588 #endif
98589
98590-extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
98591-extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
98592- void *buf, int len, int write);
98593+extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
98594+extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
98595+ void *buf, size_t len, int write);
98596
98597 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
98598 unsigned long start, unsigned long nr_pages,
98599@@ -1219,34 +1225,6 @@ int clear_page_dirty_for_io(struct page *page);
98600
98601 int get_cmdline(struct task_struct *task, char *buffer, int buflen);
98602
98603-/* Is the vma a continuation of the stack vma above it? */
98604-static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
98605-{
98606- return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
98607-}
98608-
98609-static inline int stack_guard_page_start(struct vm_area_struct *vma,
98610- unsigned long addr)
98611-{
98612- return (vma->vm_flags & VM_GROWSDOWN) &&
98613- (vma->vm_start == addr) &&
98614- !vma_growsdown(vma->vm_prev, addr);
98615-}
98616-
98617-/* Is the vma a continuation of the stack vma below it? */
98618-static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
98619-{
98620- return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
98621-}
98622-
98623-static inline int stack_guard_page_end(struct vm_area_struct *vma,
98624- unsigned long addr)
98625-{
98626- return (vma->vm_flags & VM_GROWSUP) &&
98627- (vma->vm_end == addr) &&
98628- !vma_growsup(vma->vm_next, addr);
98629-}
98630-
98631 extern struct task_struct *task_of_stack(struct task_struct *task,
98632 struct vm_area_struct *vma, bool in_group);
98633
98634@@ -1369,8 +1347,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
98635 {
98636 return 0;
98637 }
98638+
98639+static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
98640+ unsigned long address)
98641+{
98642+ return 0;
98643+}
98644 #else
98645 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
98646+int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
98647 #endif
98648
98649 #if defined(__PAGETABLE_PMD_FOLDED) || !defined(CONFIG_MMU)
98650@@ -1380,6 +1365,12 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
98651 return 0;
98652 }
98653
98654+static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
98655+ unsigned long address)
98656+{
98657+ return 0;
98658+}
98659+
98660 static inline void mm_nr_pmds_init(struct mm_struct *mm) {}
98661
98662 static inline unsigned long mm_nr_pmds(struct mm_struct *mm)
98663@@ -1392,6 +1383,7 @@ static inline void mm_dec_nr_pmds(struct mm_struct *mm) {}
98664
98665 #else
98666 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
98667+int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
98668
98669 static inline void mm_nr_pmds_init(struct mm_struct *mm)
98670 {
98671@@ -1429,11 +1421,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
98672 NULL: pud_offset(pgd, address);
98673 }
98674
98675+static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
98676+{
98677+ return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
98678+ NULL: pud_offset(pgd, address);
98679+}
98680+
98681 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
98682 {
98683 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
98684 NULL: pmd_offset(pud, address);
98685 }
98686+
98687+static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
98688+{
98689+ return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
98690+ NULL: pmd_offset(pud, address);
98691+}
98692 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
98693
98694 #if USE_SPLIT_PTE_PTLOCKS
98695@@ -1810,12 +1814,23 @@ extern struct vm_area_struct *copy_vma(struct vm_area_struct **,
98696 bool *need_rmap_locks);
98697 extern void exit_mmap(struct mm_struct *);
98698
98699+#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
98700+extern void gr_learn_resource(const struct task_struct *task, const int res,
98701+ const unsigned long wanted, const int gt);
98702+#else
98703+static inline void gr_learn_resource(const struct task_struct *task, const int res,
98704+ const unsigned long wanted, const int gt)
98705+{
98706+}
98707+#endif
98708+
98709 static inline int check_data_rlimit(unsigned long rlim,
98710 unsigned long new,
98711 unsigned long start,
98712 unsigned long end_data,
98713 unsigned long start_data)
98714 {
98715+ gr_learn_resource(current, RLIMIT_DATA, (new - start) + (end_data - start_data), 1);
98716 if (rlim < RLIM_INFINITY) {
98717 if (((new - start) + (end_data - start_data)) > rlim)
98718 return -ENOSPC;
98719@@ -1840,7 +1855,7 @@ extern int install_special_mapping(struct mm_struct *mm,
98720 unsigned long addr, unsigned long len,
98721 unsigned long flags, struct page **pages);
98722
98723-extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
98724+extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long) __intentional_overflow(-1);
98725
98726 extern unsigned long mmap_region(struct file *file, unsigned long addr,
98727 unsigned long len, vm_flags_t vm_flags, unsigned long pgoff);
98728@@ -1848,6 +1863,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
98729 unsigned long len, unsigned long prot, unsigned long flags,
98730 unsigned long pgoff, unsigned long *populate);
98731 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
98732+extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
98733
98734 #ifdef CONFIG_MMU
98735 extern int __mm_populate(unsigned long addr, unsigned long len,
98736@@ -1876,10 +1892,11 @@ struct vm_unmapped_area_info {
98737 unsigned long high_limit;
98738 unsigned long align_mask;
98739 unsigned long align_offset;
98740+ unsigned long threadstack_offset;
98741 };
98742
98743-extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
98744-extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
98745+extern unsigned long unmapped_area(const struct vm_unmapped_area_info *info);
98746+extern unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info);
98747
98748 /*
98749 * Search for an unmapped address range.
98750@@ -1891,7 +1908,7 @@ extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
98751 * - satisfies (begin_addr & align_mask) == (align_offset & align_mask)
98752 */
98753 static inline unsigned long
98754-vm_unmapped_area(struct vm_unmapped_area_info *info)
98755+vm_unmapped_area(const struct vm_unmapped_area_info *info)
98756 {
98757 if (info->flags & VM_UNMAPPED_AREA_TOPDOWN)
98758 return unmapped_area_topdown(info);
98759@@ -1953,6 +1970,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
98760 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
98761 struct vm_area_struct **pprev);
98762
98763+extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
98764+extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
98765+extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
98766+
98767 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
98768 NULL if none. Assume start_addr < end_addr. */
98769 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
98770@@ -1982,10 +2003,10 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
98771 }
98772
98773 #ifdef CONFIG_MMU
98774-pgprot_t vm_get_page_prot(unsigned long vm_flags);
98775+pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
98776 void vma_set_page_prot(struct vm_area_struct *vma);
98777 #else
98778-static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
98779+static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
98780 {
98781 return __pgprot(0);
98782 }
98783@@ -2047,6 +2068,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
98784 static inline void vm_stat_account(struct mm_struct *mm,
98785 unsigned long flags, struct file *file, long pages)
98786 {
98787+
98788+#ifdef CONFIG_PAX_RANDMMAP
98789+ if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
98790+#endif
98791+
98792 mm->total_vm += pages;
98793 }
98794 #endif /* CONFIG_PROC_FS */
98795@@ -2149,7 +2175,7 @@ extern int unpoison_memory(unsigned long pfn);
98796 extern int sysctl_memory_failure_early_kill;
98797 extern int sysctl_memory_failure_recovery;
98798 extern void shake_page(struct page *p, int access);
98799-extern atomic_long_t num_poisoned_pages;
98800+extern atomic_long_unchecked_t num_poisoned_pages;
98801 extern int soft_offline_page(struct page *page, int flags);
98802
98803 #if defined(CONFIG_TRANSPARENT_HUGEPAGE) || defined(CONFIG_HUGETLBFS)
98804@@ -2200,5 +2226,11 @@ void __init setup_nr_node_ids(void);
98805 static inline void setup_nr_node_ids(void) {}
98806 #endif
98807
98808+#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
98809+extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
98810+#else
98811+static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
98812+#endif
98813+
98814 #endif /* __KERNEL__ */
98815 #endif /* _LINUX_MM_H */
98816diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
98817index 8d37e26..6a6f55b 100644
98818--- a/include/linux/mm_types.h
98819+++ b/include/linux/mm_types.h
98820@@ -313,7 +313,9 @@ struct vm_area_struct {
98821 #ifdef CONFIG_NUMA
98822 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
98823 #endif
98824-};
98825+
98826+ struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
98827+} __randomize_layout;
98828
98829 struct core_thread {
98830 struct task_struct *task;
98831@@ -466,7 +468,25 @@ struct mm_struct {
98832 /* address of the bounds directory */
98833 void __user *bd_addr;
98834 #endif
98835-};
98836+
98837+#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
98838+ unsigned long pax_flags;
98839+#endif
98840+
98841+#ifdef CONFIG_PAX_DLRESOLVE
98842+ unsigned long call_dl_resolve;
98843+#endif
98844+
98845+#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
98846+ unsigned long call_syscall;
98847+#endif
98848+
98849+#ifdef CONFIG_PAX_ASLR
98850+ unsigned long delta_mmap; /* randomized offset */
98851+ unsigned long delta_stack; /* randomized offset */
98852+#endif
98853+
98854+} __randomize_layout;
98855
98856 static inline void mm_init_cpumask(struct mm_struct *mm)
98857 {
98858diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
98859index c5d5278..85cd5ce 100644
98860--- a/include/linux/mmiotrace.h
98861+++ b/include/linux/mmiotrace.h
98862@@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
98863 /* Called from ioremap.c */
98864 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
98865 void __iomem *addr);
98866-extern void mmiotrace_iounmap(volatile void __iomem *addr);
98867+extern void mmiotrace_iounmap(const volatile void __iomem *addr);
98868
98869 /* For anyone to insert markers. Remember trailing newline. */
98870 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
98871@@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
98872 {
98873 }
98874
98875-static inline void mmiotrace_iounmap(volatile void __iomem *addr)
98876+static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
98877 {
98878 }
98879
98880@@ -106,6 +106,6 @@ extern void enable_mmiotrace(void);
98881 extern void disable_mmiotrace(void);
98882 extern void mmio_trace_rw(struct mmiotrace_rw *rw);
98883 extern void mmio_trace_mapping(struct mmiotrace_map *map);
98884-extern int mmio_trace_printk(const char *fmt, va_list args);
98885+extern __printf(1, 0) int mmio_trace_printk(const char *fmt, va_list args);
98886
98887 #endif /* _LINUX_MMIOTRACE_H */
98888diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
98889index 54d74f6..0728424 100644
98890--- a/include/linux/mmzone.h
98891+++ b/include/linux/mmzone.h
98892@@ -526,7 +526,7 @@ struct zone {
98893
98894 ZONE_PADDING(_pad3_)
98895 /* Zone statistics */
98896- atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
98897+ atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
98898 } ____cacheline_internodealigned_in_smp;
98899
98900 enum zone_flags {
98901diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
98902index 3bfd567..72e7d8f 100644
98903--- a/include/linux/mod_devicetable.h
98904+++ b/include/linux/mod_devicetable.h
98905@@ -139,7 +139,7 @@ struct usb_device_id {
98906 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
98907 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
98908
98909-#define HID_ANY_ID (~0)
98910+#define HID_ANY_ID (~0U)
98911 #define HID_BUS_ANY 0xffff
98912 #define HID_GROUP_ANY 0x0000
98913
98914@@ -470,7 +470,7 @@ struct dmi_system_id {
98915 const char *ident;
98916 struct dmi_strmatch matches[4];
98917 void *driver_data;
98918-};
98919+} __do_const;
98920 /*
98921 * struct dmi_device_id appears during expansion of
98922 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
98923diff --git a/include/linux/module.h b/include/linux/module.h
98924index c883b86..516812e 100644
98925--- a/include/linux/module.h
98926+++ b/include/linux/module.h
98927@@ -17,9 +17,11 @@
98928 #include <linux/moduleparam.h>
98929 #include <linux/jump_label.h>
98930 #include <linux/export.h>
98931+#include <linux/fs.h>
98932
98933 #include <linux/percpu.h>
98934 #include <asm/module.h>
98935+#include <asm/pgtable.h>
98936
98937 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
98938 #define MODULE_SIG_STRING "~Module signature appended~\n"
98939@@ -42,7 +44,7 @@ struct module_kobject {
98940 struct kobject *drivers_dir;
98941 struct module_param_attrs *mp;
98942 struct completion *kobj_completion;
98943-};
98944+} __randomize_layout;
98945
98946 struct module_attribute {
98947 struct attribute attr;
98948@@ -54,12 +56,13 @@ struct module_attribute {
98949 int (*test)(struct module *);
98950 void (*free)(struct module *);
98951 };
98952+typedef struct module_attribute __no_const module_attribute_no_const;
98953
98954 struct module_version_attribute {
98955 struct module_attribute mattr;
98956 const char *module_name;
98957 const char *version;
98958-} __attribute__ ((__aligned__(sizeof(void *))));
98959+} __do_const __attribute__ ((__aligned__(sizeof(void *))));
98960
98961 extern ssize_t __modver_version_show(struct module_attribute *,
98962 struct module_kobject *, char *);
98963@@ -221,7 +224,7 @@ struct module {
98964
98965 /* Sysfs stuff. */
98966 struct module_kobject mkobj;
98967- struct module_attribute *modinfo_attrs;
98968+ module_attribute_no_const *modinfo_attrs;
98969 const char *version;
98970 const char *srcversion;
98971 struct kobject *holders_dir;
98972@@ -270,19 +273,16 @@ struct module {
98973 int (*init)(void);
98974
98975 /* If this is non-NULL, vfree after init() returns */
98976- void *module_init;
98977+ void *module_init_rx, *module_init_rw;
98978
98979 /* Here is the actual code + data, vfree'd on unload. */
98980- void *module_core;
98981+ void *module_core_rx, *module_core_rw;
98982
98983 /* Here are the sizes of the init and core sections */
98984- unsigned int init_size, core_size;
98985+ unsigned int init_size_rw, core_size_rw;
98986
98987 /* The size of the executable code in each section. */
98988- unsigned int init_text_size, core_text_size;
98989-
98990- /* Size of RO sections of the module (text+rodata) */
98991- unsigned int init_ro_size, core_ro_size;
98992+ unsigned int init_size_rx, core_size_rx;
98993
98994 /* Arch-specific module values */
98995 struct mod_arch_specific arch;
98996@@ -340,6 +340,10 @@ struct module {
98997 unsigned int num_trace_events;
98998 struct trace_enum_map **trace_enums;
98999 unsigned int num_trace_enums;
99000+ struct file_operations trace_id;
99001+ struct file_operations trace_enable;
99002+ struct file_operations trace_format;
99003+ struct file_operations trace_filter;
99004 #endif
99005 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
99006 unsigned int num_ftrace_callsites;
99007@@ -367,7 +371,7 @@ struct module {
99008 ctor_fn_t *ctors;
99009 unsigned int num_ctors;
99010 #endif
99011-};
99012+} __randomize_layout;
99013 #ifndef MODULE_ARCH_INIT
99014 #define MODULE_ARCH_INIT {}
99015 #endif
99016@@ -388,18 +392,48 @@ bool is_module_address(unsigned long addr);
99017 bool is_module_percpu_address(unsigned long addr);
99018 bool is_module_text_address(unsigned long addr);
99019
99020+static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
99021+{
99022+
99023+#ifdef CONFIG_PAX_KERNEXEC
99024+ if (ktla_ktva(addr) >= (unsigned long)start &&
99025+ ktla_ktva(addr) < (unsigned long)start + size)
99026+ return 1;
99027+#endif
99028+
99029+ return ((void *)addr >= start && (void *)addr < start + size);
99030+}
99031+
99032+static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
99033+{
99034+ return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
99035+}
99036+
99037+static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
99038+{
99039+ return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
99040+}
99041+
99042+static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
99043+{
99044+ return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
99045+}
99046+
99047+static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
99048+{
99049+ return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
99050+}
99051+
99052 static inline bool within_module_core(unsigned long addr,
99053 const struct module *mod)
99054 {
99055- return (unsigned long)mod->module_core <= addr &&
99056- addr < (unsigned long)mod->module_core + mod->core_size;
99057+ return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
99058 }
99059
99060 static inline bool within_module_init(unsigned long addr,
99061 const struct module *mod)
99062 {
99063- return (unsigned long)mod->module_init <= addr &&
99064- addr < (unsigned long)mod->module_init + mod->init_size;
99065+ return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
99066 }
99067
99068 static inline bool within_module(unsigned long addr, const struct module *mod)
99069diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
99070index 4d0cb9b..3169ac7 100644
99071--- a/include/linux/moduleloader.h
99072+++ b/include/linux/moduleloader.h
99073@@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
99074 sections. Returns NULL on failure. */
99075 void *module_alloc(unsigned long size);
99076
99077+#ifdef CONFIG_PAX_KERNEXEC
99078+void *module_alloc_exec(unsigned long size);
99079+#else
99080+#define module_alloc_exec(x) module_alloc(x)
99081+#endif
99082+
99083 /* Free memory returned from module_alloc. */
99084 void module_memfree(void *module_region);
99085
99086+#ifdef CONFIG_PAX_KERNEXEC
99087+void module_memfree_exec(void *module_region);
99088+#else
99089+#define module_memfree_exec(x) module_memfree((x))
99090+#endif
99091+
99092 /*
99093 * Apply the given relocation to the (simplified) ELF. Return -error
99094 * or 0.
99095@@ -45,8 +57,10 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
99096 unsigned int relsec,
99097 struct module *me)
99098 {
99099+#ifdef CONFIG_MODULES
99100 printk(KERN_ERR "module %s: REL relocation unsupported\n",
99101 module_name(me));
99102+#endif
99103 return -ENOEXEC;
99104 }
99105 #endif
99106@@ -68,8 +82,10 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
99107 unsigned int relsec,
99108 struct module *me)
99109 {
99110+#ifdef CONFIG_MODULES
99111 printk(KERN_ERR "module %s: REL relocation unsupported\n",
99112 module_name(me));
99113+#endif
99114 return -ENOEXEC;
99115 }
99116 #endif
99117diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
99118index 1c9effa..1160bdd 100644
99119--- a/include/linux/moduleparam.h
99120+++ b/include/linux/moduleparam.h
99121@@ -323,7 +323,7 @@ static inline void __kernel_param_unlock(void)
99122 * @len is usually just sizeof(string).
99123 */
99124 #define module_param_string(name, string, len, perm) \
99125- static const struct kparam_string __param_string_##name \
99126+ static const struct kparam_string __param_string_##name __used \
99127 = { len, string }; \
99128 __module_param_call(MODULE_PARAM_PREFIX, name, \
99129 &param_ops_string, \
99130@@ -467,7 +467,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
99131 */
99132 #define module_param_array_named(name, array, type, nump, perm) \
99133 param_check_##type(name, &(array)[0]); \
99134- static const struct kparam_array __param_arr_##name \
99135+ static const struct kparam_array __param_arr_##name __used \
99136 = { .max = ARRAY_SIZE(array), .num = nump, \
99137 .ops = &param_ops_##type, \
99138 .elemsize = sizeof(array[0]), .elem = array }; \
99139diff --git a/include/linux/mount.h b/include/linux/mount.h
99140index f822c3c..958ca0a 100644
99141--- a/include/linux/mount.h
99142+++ b/include/linux/mount.h
99143@@ -67,7 +67,7 @@ struct vfsmount {
99144 struct dentry *mnt_root; /* root of the mounted tree */
99145 struct super_block *mnt_sb; /* pointer to superblock */
99146 int mnt_flags;
99147-};
99148+} __randomize_layout;
99149
99150 struct file; /* forward dec */
99151 struct path;
99152diff --git a/include/linux/namei.h b/include/linux/namei.h
99153index c899077..b9a2010 100644
99154--- a/include/linux/namei.h
99155+++ b/include/linux/namei.h
99156@@ -71,8 +71,8 @@ extern struct dentry *lock_rename(struct dentry *, struct dentry *);
99157 extern void unlock_rename(struct dentry *, struct dentry *);
99158
99159 extern void nd_jump_link(struct nameidata *nd, struct path *path);
99160-extern void nd_set_link(struct nameidata *nd, char *path);
99161-extern char *nd_get_link(struct nameidata *nd);
99162+extern void nd_set_link(struct nameidata *nd, const char *path);
99163+extern const char *nd_get_link(const struct nameidata *nd);
99164
99165 static inline void nd_terminate_link(void *name, size_t len, size_t maxlen)
99166 {
99167diff --git a/include/linux/net.h b/include/linux/net.h
99168index 738ea48..409dc09 100644
99169--- a/include/linux/net.h
99170+++ b/include/linux/net.h
99171@@ -190,7 +190,7 @@ struct net_proto_family {
99172 int (*create)(struct net *net, struct socket *sock,
99173 int protocol, int kern);
99174 struct module *owner;
99175-};
99176+} __do_const;
99177
99178 struct iovec;
99179 struct kvec;
99180diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
99181index 05b9a69..4d7e300 100644
99182--- a/include/linux/netdevice.h
99183+++ b/include/linux/netdevice.h
99184@@ -1208,6 +1208,7 @@ struct net_device_ops {
99185 u32 maxrate);
99186 int (*ndo_get_iflink)(const struct net_device *dev);
99187 };
99188+typedef struct net_device_ops __no_const net_device_ops_no_const;
99189
99190 /**
99191 * enum net_device_priv_flags - &struct net_device priv_flags
99192@@ -1515,7 +1516,7 @@ struct net_device {
99193 unsigned long base_addr;
99194 int irq;
99195
99196- atomic_t carrier_changes;
99197+ atomic_unchecked_t carrier_changes;
99198
99199 /*
99200 * Some hardware also needs these fields (state,dev_list,
99201@@ -1554,8 +1555,8 @@ struct net_device {
99202
99203 struct net_device_stats stats;
99204
99205- atomic_long_t rx_dropped;
99206- atomic_long_t tx_dropped;
99207+ atomic_long_unchecked_t rx_dropped;
99208+ atomic_long_unchecked_t tx_dropped;
99209
99210 #ifdef CONFIG_WIRELESS_EXT
99211 const struct iw_handler_def * wireless_handlers;
99212diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
99213index 63560d0..64aba5c 100644
99214--- a/include/linux/netfilter.h
99215+++ b/include/linux/netfilter.h
99216@@ -113,7 +113,7 @@ struct nf_sockopt_ops {
99217 #endif
99218 /* Use the module struct to lock set/get code in place */
99219 struct module *owner;
99220-};
99221+} __do_const;
99222
99223 /* Function to register/unregister hook points. */
99224 int nf_register_hook(struct nf_hook_ops *reg);
99225diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
99226index e955d47..04a5338 100644
99227--- a/include/linux/netfilter/nfnetlink.h
99228+++ b/include/linux/netfilter/nfnetlink.h
99229@@ -19,7 +19,7 @@ struct nfnl_callback {
99230 const struct nlattr * const cda[]);
99231 const struct nla_policy *policy; /* netlink attribute policy */
99232 const u_int16_t attr_count; /* number of nlattr's */
99233-};
99234+} __do_const;
99235
99236 struct nfnetlink_subsystem {
99237 const char *name;
99238diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
99239new file mode 100644
99240index 0000000..33f4af8
99241--- /dev/null
99242+++ b/include/linux/netfilter/xt_gradm.h
99243@@ -0,0 +1,9 @@
99244+#ifndef _LINUX_NETFILTER_XT_GRADM_H
99245+#define _LINUX_NETFILTER_XT_GRADM_H 1
99246+
99247+struct xt_gradm_mtinfo {
99248+ __u16 flags;
99249+ __u16 invflags;
99250+};
99251+
99252+#endif
99253diff --git a/include/linux/nls.h b/include/linux/nls.h
99254index 520681b..2b7fabb 100644
99255--- a/include/linux/nls.h
99256+++ b/include/linux/nls.h
99257@@ -31,7 +31,7 @@ struct nls_table {
99258 const unsigned char *charset2upper;
99259 struct module *owner;
99260 struct nls_table *next;
99261-};
99262+} __do_const;
99263
99264 /* this value hold the maximum octet of charset */
99265 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
99266@@ -46,7 +46,7 @@ enum utf16_endian {
99267 /* nls_base.c */
99268 extern int __register_nls(struct nls_table *, struct module *);
99269 extern int unregister_nls(struct nls_table *);
99270-extern struct nls_table *load_nls(char *);
99271+extern struct nls_table *load_nls(const char *);
99272 extern void unload_nls(struct nls_table *);
99273 extern struct nls_table *load_nls_default(void);
99274 #define register_nls(nls) __register_nls((nls), THIS_MODULE)
99275diff --git a/include/linux/notifier.h b/include/linux/notifier.h
99276index d14a4c3..a078786 100644
99277--- a/include/linux/notifier.h
99278+++ b/include/linux/notifier.h
99279@@ -54,7 +54,8 @@ struct notifier_block {
99280 notifier_fn_t notifier_call;
99281 struct notifier_block __rcu *next;
99282 int priority;
99283-};
99284+} __do_const;
99285+typedef struct notifier_block __no_const notifier_block_no_const;
99286
99287 struct atomic_notifier_head {
99288 spinlock_t lock;
99289diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
99290index b2a0f15..4d7da32 100644
99291--- a/include/linux/oprofile.h
99292+++ b/include/linux/oprofile.h
99293@@ -138,9 +138,9 @@ int oprofilefs_create_ulong(struct dentry * root,
99294 int oprofilefs_create_ro_ulong(struct dentry * root,
99295 char const * name, ulong * val);
99296
99297-/** Create a file for read-only access to an atomic_t. */
99298+/** Create a file for read-only access to an atomic_unchecked_t. */
99299 int oprofilefs_create_ro_atomic(struct dentry * root,
99300- char const * name, atomic_t * val);
99301+ char const * name, atomic_unchecked_t * val);
99302
99303 /** create a directory */
99304 struct dentry *oprofilefs_mkdir(struct dentry *parent, char const *name);
99305diff --git a/include/linux/padata.h b/include/linux/padata.h
99306index 4386946..f50c615 100644
99307--- a/include/linux/padata.h
99308+++ b/include/linux/padata.h
99309@@ -129,7 +129,7 @@ struct parallel_data {
99310 struct padata_serial_queue __percpu *squeue;
99311 atomic_t reorder_objects;
99312 atomic_t refcnt;
99313- atomic_t seq_nr;
99314+ atomic_unchecked_t seq_nr;
99315 struct padata_cpumask cpumask;
99316 spinlock_t lock ____cacheline_aligned;
99317 unsigned int processed;
99318diff --git a/include/linux/path.h b/include/linux/path.h
99319index d137218..be0c176 100644
99320--- a/include/linux/path.h
99321+++ b/include/linux/path.h
99322@@ -1,13 +1,15 @@
99323 #ifndef _LINUX_PATH_H
99324 #define _LINUX_PATH_H
99325
99326+#include <linux/compiler.h>
99327+
99328 struct dentry;
99329 struct vfsmount;
99330
99331 struct path {
99332 struct vfsmount *mnt;
99333 struct dentry *dentry;
99334-};
99335+} __randomize_layout;
99336
99337 extern void path_get(const struct path *);
99338 extern void path_put(const struct path *);
99339diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
99340index 8c78950..0d74ed9 100644
99341--- a/include/linux/pci_hotplug.h
99342+++ b/include/linux/pci_hotplug.h
99343@@ -71,7 +71,8 @@ struct hotplug_slot_ops {
99344 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
99345 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
99346 int (*reset_slot) (struct hotplug_slot *slot, int probe);
99347-};
99348+} __do_const;
99349+typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
99350
99351 /**
99352 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
99353diff --git a/include/linux/percpu.h b/include/linux/percpu.h
99354index caebf2a..4c3ae9d 100644
99355--- a/include/linux/percpu.h
99356+++ b/include/linux/percpu.h
99357@@ -34,7 +34,7 @@
99358 * preallocate for this. Keep PERCPU_DYNAMIC_RESERVE equal to or
99359 * larger than PERCPU_DYNAMIC_EARLY_SIZE.
99360 */
99361-#define PERCPU_DYNAMIC_EARLY_SLOTS 128
99362+#define PERCPU_DYNAMIC_EARLY_SLOTS 256
99363 #define PERCPU_DYNAMIC_EARLY_SIZE (12 << 10)
99364
99365 /*
99366diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
99367index d8a82a8..8b580f0 100644
99368--- a/include/linux/perf_event.h
99369+++ b/include/linux/perf_event.h
99370@@ -379,8 +379,8 @@ struct perf_event {
99371
99372 enum perf_event_active_state state;
99373 unsigned int attach_state;
99374- local64_t count;
99375- atomic64_t child_count;
99376+ local64_t count; /* PaX: fix it one day */
99377+ atomic64_unchecked_t child_count;
99378
99379 /*
99380 * These are the total time in nanoseconds that the event
99381@@ -431,8 +431,8 @@ struct perf_event {
99382 * These accumulate total time (in nanoseconds) that children
99383 * events have been enabled and running, respectively.
99384 */
99385- atomic64_t child_total_time_enabled;
99386- atomic64_t child_total_time_running;
99387+ atomic64_unchecked_t child_total_time_enabled;
99388+ atomic64_unchecked_t child_total_time_running;
99389
99390 /*
99391 * Protect attach/detach and child_list:
99392@@ -812,7 +812,7 @@ static inline void perf_event_task_sched_out(struct task_struct *prev,
99393
99394 static inline u64 __perf_event_count(struct perf_event *event)
99395 {
99396- return local64_read(&event->count) + atomic64_read(&event->child_count);
99397+ return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
99398 }
99399
99400 extern void perf_event_mmap(struct vm_area_struct *vma);
99401@@ -836,7 +836,7 @@ static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64
99402 entry->ip[entry->nr++] = ip;
99403 }
99404
99405-extern int sysctl_perf_event_paranoid;
99406+extern int sysctl_perf_event_legitimately_concerned;
99407 extern int sysctl_perf_event_mlock;
99408 extern int sysctl_perf_event_sample_rate;
99409 extern int sysctl_perf_cpu_time_max_percent;
99410@@ -851,19 +851,24 @@ extern int perf_cpu_time_max_percent_handler(struct ctl_table *table, int write,
99411 loff_t *ppos);
99412
99413
99414+static inline bool perf_paranoid_any(void)
99415+{
99416+ return sysctl_perf_event_legitimately_concerned > 2;
99417+}
99418+
99419 static inline bool perf_paranoid_tracepoint_raw(void)
99420 {
99421- return sysctl_perf_event_paranoid > -1;
99422+ return sysctl_perf_event_legitimately_concerned > -1;
99423 }
99424
99425 static inline bool perf_paranoid_cpu(void)
99426 {
99427- return sysctl_perf_event_paranoid > 0;
99428+ return sysctl_perf_event_legitimately_concerned > 0;
99429 }
99430
99431 static inline bool perf_paranoid_kernel(void)
99432 {
99433- return sysctl_perf_event_paranoid > 1;
99434+ return sysctl_perf_event_legitimately_concerned > 1;
99435 }
99436
99437 extern void perf_event_init(void);
99438@@ -1017,7 +1022,7 @@ struct perf_pmu_events_attr {
99439 struct device_attribute attr;
99440 u64 id;
99441 const char *event_str;
99442-};
99443+} __do_const;
99444
99445 ssize_t perf_event_sysfs_show(struct device *dev, struct device_attribute *attr,
99446 char *page);
99447diff --git a/include/linux/pid_namespace.h b/include/linux/pid_namespace.h
99448index 918b117..7af374b7 100644
99449--- a/include/linux/pid_namespace.h
99450+++ b/include/linux/pid_namespace.h
99451@@ -45,7 +45,7 @@ struct pid_namespace {
99452 int hide_pid;
99453 int reboot; /* group exit code if this pidns was rebooted */
99454 struct ns_common ns;
99455-};
99456+} __randomize_layout;
99457
99458 extern struct pid_namespace init_pid_ns;
99459
99460diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
99461index eb8b8ac..62649e1 100644
99462--- a/include/linux/pipe_fs_i.h
99463+++ b/include/linux/pipe_fs_i.h
99464@@ -47,10 +47,10 @@ struct pipe_inode_info {
99465 struct mutex mutex;
99466 wait_queue_head_t wait;
99467 unsigned int nrbufs, curbuf, buffers;
99468- unsigned int readers;
99469- unsigned int writers;
99470- unsigned int files;
99471- unsigned int waiting_writers;
99472+ atomic_t readers;
99473+ atomic_t writers;
99474+ atomic_t files;
99475+ atomic_t waiting_writers;
99476 unsigned int r_counter;
99477 unsigned int w_counter;
99478 struct page *tmp_page;
99479diff --git a/include/linux/pm.h b/include/linux/pm.h
99480index 2d29c64..1b25b2a 100644
99481--- a/include/linux/pm.h
99482+++ b/include/linux/pm.h
99483@@ -616,6 +616,7 @@ struct dev_pm_domain {
99484 void (*sync)(struct device *dev);
99485 void (*dismiss)(struct device *dev);
99486 };
99487+typedef struct dev_pm_domain __no_const dev_pm_domain_no_const;
99488
99489 /*
99490 * The PM_EVENT_ messages are also used by drivers implementing the legacy
99491diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
99492index 681ccb0..a90e0b7 100644
99493--- a/include/linux/pm_domain.h
99494+++ b/include/linux/pm_domain.h
99495@@ -39,11 +39,11 @@ struct gpd_dev_ops {
99496 int (*save_state)(struct device *dev);
99497 int (*restore_state)(struct device *dev);
99498 bool (*active_wakeup)(struct device *dev);
99499-};
99500+} __no_const;
99501
99502 struct gpd_cpuidle_data {
99503 unsigned int saved_exit_latency;
99504- struct cpuidle_state *idle_state;
99505+ cpuidle_state_no_const *idle_state;
99506 };
99507
99508 struct generic_pm_domain {
99509diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
99510index 30e84d4..22278b4 100644
99511--- a/include/linux/pm_runtime.h
99512+++ b/include/linux/pm_runtime.h
99513@@ -115,7 +115,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
99514
99515 static inline void pm_runtime_mark_last_busy(struct device *dev)
99516 {
99517- ACCESS_ONCE(dev->power.last_busy) = jiffies;
99518+ ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
99519 }
99520
99521 static inline bool pm_runtime_is_irq_safe(struct device *dev)
99522diff --git a/include/linux/pnp.h b/include/linux/pnp.h
99523index 5df733b..d55f252 100644
99524--- a/include/linux/pnp.h
99525+++ b/include/linux/pnp.h
99526@@ -298,7 +298,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
99527 struct pnp_fixup {
99528 char id[7];
99529 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
99530-};
99531+} __do_const;
99532
99533 /* config parameters */
99534 #define PNP_CONFIG_NORMAL 0x0001
99535diff --git a/include/linux/poison.h b/include/linux/poison.h
99536index 2110a81..13a11bb 100644
99537--- a/include/linux/poison.h
99538+++ b/include/linux/poison.h
99539@@ -19,8 +19,8 @@
99540 * under normal circumstances, used to verify that nobody uses
99541 * non-initialized list entries.
99542 */
99543-#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
99544-#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
99545+#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
99546+#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
99547
99548 /********** include/linux/timer.h **********/
99549 /*
99550diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
99551index d8b187c3..9a9257a 100644
99552--- a/include/linux/power/smartreflex.h
99553+++ b/include/linux/power/smartreflex.h
99554@@ -238,7 +238,7 @@ struct omap_sr_class_data {
99555 int (*notify)(struct omap_sr *sr, u32 status);
99556 u8 notify_flags;
99557 u8 class_type;
99558-};
99559+} __do_const;
99560
99561 /**
99562 * struct omap_sr_nvalue_table - Smartreflex n-target value info
99563diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
99564index 4ea1d37..80f4b33 100644
99565--- a/include/linux/ppp-comp.h
99566+++ b/include/linux/ppp-comp.h
99567@@ -84,7 +84,7 @@ struct compressor {
99568 struct module *owner;
99569 /* Extra skb space needed by the compressor algorithm */
99570 unsigned int comp_extra;
99571-};
99572+} __do_const;
99573
99574 /*
99575 * The return value from decompress routine is the length of the
99576diff --git a/include/linux/preempt.h b/include/linux/preempt.h
99577index de83b4e..c4b997d 100644
99578--- a/include/linux/preempt.h
99579+++ b/include/linux/preempt.h
99580@@ -27,11 +27,16 @@ extern void preempt_count_sub(int val);
99581 #define preempt_count_dec_and_test() __preempt_count_dec_and_test()
99582 #endif
99583
99584+#define raw_preempt_count_add(val) __preempt_count_add(val)
99585+#define raw_preempt_count_sub(val) __preempt_count_sub(val)
99586+
99587 #define __preempt_count_inc() __preempt_count_add(1)
99588 #define __preempt_count_dec() __preempt_count_sub(1)
99589
99590 #define preempt_count_inc() preempt_count_add(1)
99591+#define raw_preempt_count_inc() raw_preempt_count_add(1)
99592 #define preempt_count_dec() preempt_count_sub(1)
99593+#define raw_preempt_count_dec() raw_preempt_count_sub(1)
99594
99595 #ifdef CONFIG_PREEMPT_COUNT
99596
99597@@ -41,6 +46,12 @@ do { \
99598 barrier(); \
99599 } while (0)
99600
99601+#define raw_preempt_disable() \
99602+do { \
99603+ raw_preempt_count_inc(); \
99604+ barrier(); \
99605+} while (0)
99606+
99607 #define sched_preempt_enable_no_resched() \
99608 do { \
99609 barrier(); \
99610@@ -49,6 +60,12 @@ do { \
99611
99612 #define preempt_enable_no_resched() sched_preempt_enable_no_resched()
99613
99614+#define raw_preempt_enable_no_resched() \
99615+do { \
99616+ barrier(); \
99617+ raw_preempt_count_dec(); \
99618+} while (0)
99619+
99620 #ifdef CONFIG_PREEMPT
99621 #define preempt_enable() \
99622 do { \
99623@@ -113,8 +130,10 @@ do { \
99624 * region.
99625 */
99626 #define preempt_disable() barrier()
99627+#define raw_preempt_disable() barrier()
99628 #define sched_preempt_enable_no_resched() barrier()
99629 #define preempt_enable_no_resched() barrier()
99630+#define raw_preempt_enable_no_resched() barrier()
99631 #define preempt_enable() barrier()
99632 #define preempt_check_resched() do { } while (0)
99633
99634@@ -128,11 +147,13 @@ do { \
99635 /*
99636 * Modules have no business playing preemption tricks.
99637 */
99638+#ifndef CONFIG_PAX_KERNEXEC
99639 #undef sched_preempt_enable_no_resched
99640 #undef preempt_enable_no_resched
99641 #undef preempt_enable_no_resched_notrace
99642 #undef preempt_check_resched
99643 #endif
99644+#endif
99645
99646 #define preempt_set_need_resched() \
99647 do { \
99648diff --git a/include/linux/printk.h b/include/linux/printk.h
99649index 9b30871..1aebc2d 100644
99650--- a/include/linux/printk.h
99651+++ b/include/linux/printk.h
99652@@ -120,7 +120,8 @@ static inline __printf(1, 2) __cold
99653 void early_printk(const char *s, ...) { }
99654 #endif
99655
99656-typedef int(*printk_func_t)(const char *fmt, va_list args);
99657+typedef __printf(1, 0) int (*printk_func_t)(const char *fmt, va_list args);
99658+extern int kptr_restrict;
99659
99660 #ifdef CONFIG_PRINTK
99661 asmlinkage __printf(5, 0)
99662@@ -156,7 +157,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
99663
99664 extern int printk_delay_msec;
99665 extern int dmesg_restrict;
99666-extern int kptr_restrict;
99667
99668 extern void wake_up_klogd(void);
99669
99670@@ -164,7 +164,7 @@ char *log_buf_addr_get(void);
99671 u32 log_buf_len_get(void);
99672 void log_buf_kexec_setup(void);
99673 void __init setup_log_buf(int early);
99674-void dump_stack_set_arch_desc(const char *fmt, ...);
99675+__printf(1, 2) void dump_stack_set_arch_desc(const char *fmt, ...);
99676 void dump_stack_print_info(const char *log_lvl);
99677 void show_regs_print_info(const char *log_lvl);
99678 #else
99679@@ -215,7 +215,7 @@ static inline void setup_log_buf(int early)
99680 {
99681 }
99682
99683-static inline void dump_stack_set_arch_desc(const char *fmt, ...)
99684+static inline __printf(1, 2) void dump_stack_set_arch_desc(const char *fmt, ...)
99685 {
99686 }
99687
99688diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
99689index b97bf2e..f14c92d4 100644
99690--- a/include/linux/proc_fs.h
99691+++ b/include/linux/proc_fs.h
99692@@ -17,8 +17,11 @@ extern void proc_flush_task(struct task_struct *);
99693 extern struct proc_dir_entry *proc_symlink(const char *,
99694 struct proc_dir_entry *, const char *);
99695 extern struct proc_dir_entry *proc_mkdir(const char *, struct proc_dir_entry *);
99696+extern struct proc_dir_entry *proc_mkdir_restrict(const char *, struct proc_dir_entry *);
99697 extern struct proc_dir_entry *proc_mkdir_data(const char *, umode_t,
99698 struct proc_dir_entry *, void *);
99699+extern struct proc_dir_entry *proc_mkdir_data_restrict(const char *, umode_t,
99700+ struct proc_dir_entry *, void *);
99701 extern struct proc_dir_entry *proc_mkdir_mode(const char *, umode_t,
99702 struct proc_dir_entry *);
99703
99704@@ -34,6 +37,19 @@ static inline struct proc_dir_entry *proc_create(
99705 return proc_create_data(name, mode, parent, proc_fops, NULL);
99706 }
99707
99708+static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
99709+ struct proc_dir_entry *parent, const struct file_operations *proc_fops)
99710+{
99711+#ifdef CONFIG_GRKERNSEC_PROC_USER
99712+ return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
99713+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
99714+ return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
99715+#else
99716+ return proc_create_data(name, mode, parent, proc_fops, NULL);
99717+#endif
99718+}
99719+
99720+
99721 extern void proc_set_size(struct proc_dir_entry *, loff_t);
99722 extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
99723 extern void *PDE_DATA(const struct inode *);
99724@@ -56,8 +72,12 @@ static inline struct proc_dir_entry *proc_symlink(const char *name,
99725 struct proc_dir_entry *parent,const char *dest) { return NULL;}
99726 static inline struct proc_dir_entry *proc_mkdir(const char *name,
99727 struct proc_dir_entry *parent) {return NULL;}
99728+static inline struct proc_dir_entry *proc_mkdir_restrict(const char *name,
99729+ struct proc_dir_entry *parent) { return NULL; }
99730 static inline struct proc_dir_entry *proc_mkdir_data(const char *name,
99731 umode_t mode, struct proc_dir_entry *parent, void *data) { return NULL; }
99732+static inline struct proc_dir_entry *proc_mkdir_data_restrict(const char *name,
99733+ umode_t mode, struct proc_dir_entry *parent, void *data) { return NULL; }
99734 static inline struct proc_dir_entry *proc_mkdir_mode(const char *name,
99735 umode_t mode, struct proc_dir_entry *parent) { return NULL; }
99736 #define proc_create(name, mode, parent, proc_fops) ({NULL;})
99737@@ -79,7 +99,7 @@ struct net;
99738 static inline struct proc_dir_entry *proc_net_mkdir(
99739 struct net *net, const char *name, struct proc_dir_entry *parent)
99740 {
99741- return proc_mkdir_data(name, 0, parent, net);
99742+ return proc_mkdir_data_restrict(name, 0, parent, net);
99743 }
99744
99745 #endif /* _LINUX_PROC_FS_H */
99746diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
99747index 42dfc61..8113a99 100644
99748--- a/include/linux/proc_ns.h
99749+++ b/include/linux/proc_ns.h
99750@@ -16,7 +16,7 @@ struct proc_ns_operations {
99751 struct ns_common *(*get)(struct task_struct *task);
99752 void (*put)(struct ns_common *ns);
99753 int (*install)(struct nsproxy *nsproxy, struct ns_common *ns);
99754-};
99755+} __do_const __randomize_layout;
99756
99757 extern const struct proc_ns_operations netns_operations;
99758 extern const struct proc_ns_operations utsns_operations;
99759diff --git a/include/linux/quota.h b/include/linux/quota.h
99760index b2505ac..5f7ab55 100644
99761--- a/include/linux/quota.h
99762+++ b/include/linux/quota.h
99763@@ -76,7 +76,7 @@ struct kqid { /* Type in which we store the quota identifier */
99764
99765 extern bool qid_eq(struct kqid left, struct kqid right);
99766 extern bool qid_lt(struct kqid left, struct kqid right);
99767-extern qid_t from_kqid(struct user_namespace *to, struct kqid qid);
99768+extern qid_t from_kqid(struct user_namespace *to, struct kqid qid) __intentional_overflow(-1);
99769 extern qid_t from_kqid_munged(struct user_namespace *to, struct kqid qid);
99770 extern bool qid_valid(struct kqid qid);
99771
99772diff --git a/include/linux/random.h b/include/linux/random.h
99773index b05856e..0a9f14e 100644
99774--- a/include/linux/random.h
99775+++ b/include/linux/random.h
99776@@ -9,9 +9,19 @@
99777 #include <uapi/linux/random.h>
99778
99779 extern void add_device_randomness(const void *, unsigned int);
99780+
99781+static inline void add_latent_entropy(void)
99782+{
99783+
99784+#ifdef LATENT_ENTROPY_PLUGIN
99785+ add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
99786+#endif
99787+
99788+}
99789+
99790 extern void add_input_randomness(unsigned int type, unsigned int code,
99791- unsigned int value);
99792-extern void add_interrupt_randomness(int irq, int irq_flags);
99793+ unsigned int value) __latent_entropy;
99794+extern void add_interrupt_randomness(int irq, int irq_flags) __latent_entropy;
99795
99796 extern void get_random_bytes(void *buf, int nbytes);
99797 extern void get_random_bytes_arch(void *buf, int nbytes);
99798@@ -22,10 +32,10 @@ extern int random_int_secret_init(void);
99799 extern const struct file_operations random_fops, urandom_fops;
99800 #endif
99801
99802-unsigned int get_random_int(void);
99803+unsigned int __intentional_overflow(-1) get_random_int(void);
99804 unsigned long randomize_range(unsigned long start, unsigned long end, unsigned long len);
99805
99806-u32 prandom_u32(void);
99807+u32 prandom_u32(void) __intentional_overflow(-1);
99808 void prandom_bytes(void *buf, size_t nbytes);
99809 void prandom_seed(u32 seed);
99810 void prandom_reseed_late(void);
99811@@ -37,6 +47,11 @@ struct rnd_state {
99812 u32 prandom_u32_state(struct rnd_state *state);
99813 void prandom_bytes_state(struct rnd_state *state, void *buf, size_t nbytes);
99814
99815+static inline unsigned long __intentional_overflow(-1) pax_get_random_long(void)
99816+{
99817+ return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
99818+}
99819+
99820 /**
99821 * prandom_u32_max - returns a pseudo-random number in interval [0, ep_ro)
99822 * @ep_ro: right open interval endpoint
99823@@ -49,7 +64,7 @@ void prandom_bytes_state(struct rnd_state *state, void *buf, size_t nbytes);
99824 *
99825 * Returns: pseudo-random number in interval [0, ep_ro)
99826 */
99827-static inline u32 prandom_u32_max(u32 ep_ro)
99828+static inline u32 __intentional_overflow(-1) prandom_u32_max(u32 ep_ro)
99829 {
99830 return (u32)(((u64) prandom_u32() * ep_ro) >> 32);
99831 }
99832diff --git a/include/linux/rbtree_augmented.h b/include/linux/rbtree_augmented.h
99833index 378c5ee..aa84a47 100644
99834--- a/include/linux/rbtree_augmented.h
99835+++ b/include/linux/rbtree_augmented.h
99836@@ -90,7 +90,9 @@ rbname ## _rotate(struct rb_node *rb_old, struct rb_node *rb_new) \
99837 old->rbaugmented = rbcompute(old); \
99838 } \
99839 rbstatic const struct rb_augment_callbacks rbname = { \
99840- rbname ## _propagate, rbname ## _copy, rbname ## _rotate \
99841+ .propagate = rbname ## _propagate, \
99842+ .copy = rbname ## _copy, \
99843+ .rotate = rbname ## _rotate \
99844 };
99845
99846
99847diff --git a/include/linux/rculist.h b/include/linux/rculist.h
99848index a18b16f..2683096 100644
99849--- a/include/linux/rculist.h
99850+++ b/include/linux/rculist.h
99851@@ -29,8 +29,8 @@
99852 */
99853 static inline void INIT_LIST_HEAD_RCU(struct list_head *list)
99854 {
99855- ACCESS_ONCE(list->next) = list;
99856- ACCESS_ONCE(list->prev) = list;
99857+ ACCESS_ONCE_RW(list->next) = list;
99858+ ACCESS_ONCE_RW(list->prev) = list;
99859 }
99860
99861 /*
99862@@ -59,6 +59,9 @@ void __list_add_rcu(struct list_head *new,
99863 struct list_head *prev, struct list_head *next);
99864 #endif
99865
99866+void __pax_list_add_rcu(struct list_head *new,
99867+ struct list_head *prev, struct list_head *next);
99868+
99869 /**
99870 * list_add_rcu - add a new entry to rcu-protected list
99871 * @new: new entry to be added
99872@@ -80,6 +83,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
99873 __list_add_rcu(new, head, head->next);
99874 }
99875
99876+static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
99877+{
99878+ __pax_list_add_rcu(new, head, head->next);
99879+}
99880+
99881 /**
99882 * list_add_tail_rcu - add a new entry to rcu-protected list
99883 * @new: new entry to be added
99884@@ -102,6 +110,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
99885 __list_add_rcu(new, head->prev, head);
99886 }
99887
99888+static inline void pax_list_add_tail_rcu(struct list_head *new,
99889+ struct list_head *head)
99890+{
99891+ __pax_list_add_rcu(new, head->prev, head);
99892+}
99893+
99894 /**
99895 * list_del_rcu - deletes entry from list without re-initialization
99896 * @entry: the element to delete from the list.
99897@@ -132,6 +146,8 @@ static inline void list_del_rcu(struct list_head *entry)
99898 entry->prev = LIST_POISON2;
99899 }
99900
99901+extern void pax_list_del_rcu(struct list_head *entry);
99902+
99903 /**
99904 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
99905 * @n: the element to delete from the hash list.
99906diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
99907index 573a5af..de97a14 100644
99908--- a/include/linux/rcupdate.h
99909+++ b/include/linux/rcupdate.h
99910@@ -365,7 +365,7 @@ extern struct srcu_struct tasks_rcu_exit_srcu;
99911 do { \
99912 rcu_all_qs(); \
99913 if (ACCESS_ONCE((t)->rcu_tasks_holdout)) \
99914- ACCESS_ONCE((t)->rcu_tasks_holdout) = false; \
99915+ ACCESS_ONCE_RW((t)->rcu_tasks_holdout) = false; \
99916 } while (0)
99917 #else /* #ifdef CONFIG_TASKS_RCU */
99918 #define TASKS_RCU(x) do { } while (0)
99919diff --git a/include/linux/reboot.h b/include/linux/reboot.h
99920index a7ff409..03e2fa8 100644
99921--- a/include/linux/reboot.h
99922+++ b/include/linux/reboot.h
99923@@ -47,9 +47,9 @@ extern void do_kernel_restart(char *cmd);
99924 */
99925
99926 extern void migrate_to_reboot_cpu(void);
99927-extern void machine_restart(char *cmd);
99928-extern void machine_halt(void);
99929-extern void machine_power_off(void);
99930+extern void machine_restart(char *cmd) __noreturn;
99931+extern void machine_halt(void) __noreturn;
99932+extern void machine_power_off(void) __noreturn;
99933
99934 extern void machine_shutdown(void);
99935 struct pt_regs;
99936@@ -60,9 +60,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
99937 */
99938
99939 extern void kernel_restart_prepare(char *cmd);
99940-extern void kernel_restart(char *cmd);
99941-extern void kernel_halt(void);
99942-extern void kernel_power_off(void);
99943+extern void kernel_restart(char *cmd) __noreturn;
99944+extern void kernel_halt(void) __noreturn;
99945+extern void kernel_power_off(void) __noreturn;
99946
99947 extern int C_A_D; /* for sysctl */
99948 void ctrl_alt_del(void);
99949@@ -77,7 +77,7 @@ extern void orderly_reboot(void);
99950 * Emergency restart, callable from an interrupt handler.
99951 */
99952
99953-extern void emergency_restart(void);
99954+extern void emergency_restart(void) __noreturn;
99955 #include <asm/emergency-restart.h>
99956
99957 #endif /* _LINUX_REBOOT_H */
99958diff --git a/include/linux/regset.h b/include/linux/regset.h
99959index 8e0c9fe..ac4d221 100644
99960--- a/include/linux/regset.h
99961+++ b/include/linux/regset.h
99962@@ -161,7 +161,8 @@ struct user_regset {
99963 unsigned int align;
99964 unsigned int bias;
99965 unsigned int core_note_type;
99966-};
99967+} __do_const;
99968+typedef struct user_regset __no_const user_regset_no_const;
99969
99970 /**
99971 * struct user_regset_view - available regsets
99972diff --git a/include/linux/relay.h b/include/linux/relay.h
99973index d7c8359..818daf5 100644
99974--- a/include/linux/relay.h
99975+++ b/include/linux/relay.h
99976@@ -157,7 +157,7 @@ struct rchan_callbacks
99977 * The callback should return 0 if successful, negative if not.
99978 */
99979 int (*remove_buf_file)(struct dentry *dentry);
99980-};
99981+} __no_const;
99982
99983 /*
99984 * CONFIG_RELAY kernel API, kernel/relay.c
99985diff --git a/include/linux/rio.h b/include/linux/rio.h
99986index 6bda06f..bf39a9b 100644
99987--- a/include/linux/rio.h
99988+++ b/include/linux/rio.h
99989@@ -358,7 +358,7 @@ struct rio_ops {
99990 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
99991 u64 rstart, u32 size, u32 flags);
99992 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
99993-};
99994+} __no_const;
99995
99996 #define RIO_RESOURCE_MEM 0x00000100
99997 #define RIO_RESOURCE_DOORBELL 0x00000200
99998diff --git a/include/linux/rmap.h b/include/linux/rmap.h
99999index c89c53a..aa0a65a 100644
100000--- a/include/linux/rmap.h
100001+++ b/include/linux/rmap.h
100002@@ -146,8 +146,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
100003 void anon_vma_init(void); /* create anon_vma_cachep */
100004 int anon_vma_prepare(struct vm_area_struct *);
100005 void unlink_anon_vmas(struct vm_area_struct *);
100006-int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
100007-int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
100008+int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
100009+int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
100010
100011 static inline void anon_vma_merge(struct vm_area_struct *vma,
100012 struct vm_area_struct *next)
100013diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
100014index ed8f9e70..2e627f2 100644
100015--- a/include/linux/scatterlist.h
100016+++ b/include/linux/scatterlist.h
100017@@ -1,6 +1,7 @@
100018 #ifndef _LINUX_SCATTERLIST_H
100019 #define _LINUX_SCATTERLIST_H
100020
100021+#include <linux/sched.h>
100022 #include <linux/string.h>
100023 #include <linux/bug.h>
100024 #include <linux/mm.h>
100025@@ -111,10 +112,17 @@ static inline struct page *sg_page(struct scatterlist *sg)
100026 static inline void sg_set_buf(struct scatterlist *sg, const void *buf,
100027 unsigned int buflen)
100028 {
100029+ const void *realbuf = buf;
100030+
100031+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
100032+ if (object_starts_on_stack(buf))
100033+ realbuf = buf - current->stack + current->lowmem_stack;
100034+#endif
100035+
100036 #ifdef CONFIG_DEBUG_SG
100037- BUG_ON(!virt_addr_valid(buf));
100038+ BUG_ON(!virt_addr_valid(realbuf));
100039 #endif
100040- sg_set_page(sg, virt_to_page(buf), buflen, offset_in_page(buf));
100041+ sg_set_page(sg, virt_to_page(realbuf), buflen, offset_in_page(realbuf));
100042 }
100043
100044 /*
100045diff --git a/include/linux/sched.h b/include/linux/sched.h
100046index 26a2e61..36bbf4b 100644
100047--- a/include/linux/sched.h
100048+++ b/include/linux/sched.h
100049@@ -132,6 +132,7 @@ struct fs_struct;
100050 struct perf_event_context;
100051 struct blk_plug;
100052 struct filename;
100053+struct linux_binprm;
100054
100055 #define VMACACHE_BITS 2
100056 #define VMACACHE_SIZE (1U << VMACACHE_BITS)
100057@@ -413,7 +414,7 @@ extern char __sched_text_start[], __sched_text_end[];
100058 extern int in_sched_functions(unsigned long addr);
100059
100060 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
100061-extern signed long schedule_timeout(signed long timeout);
100062+extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
100063 extern signed long schedule_timeout_interruptible(signed long timeout);
100064 extern signed long schedule_timeout_killable(signed long timeout);
100065 extern signed long schedule_timeout_uninterruptible(signed long timeout);
100066@@ -431,6 +432,19 @@ struct nsproxy;
100067 struct user_namespace;
100068
100069 #ifdef CONFIG_MMU
100070+
100071+#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
100072+extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
100073+#else
100074+static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
100075+{
100076+ return 0;
100077+}
100078+#endif
100079+
100080+extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
100081+extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
100082+
100083 extern void arch_pick_mmap_layout(struct mm_struct *mm);
100084 extern unsigned long
100085 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
100086@@ -729,6 +743,17 @@ struct signal_struct {
100087 #ifdef CONFIG_TASKSTATS
100088 struct taskstats *stats;
100089 #endif
100090+
100091+#ifdef CONFIG_GRKERNSEC
100092+ u32 curr_ip;
100093+ u32 saved_ip;
100094+ u32 gr_saddr;
100095+ u32 gr_daddr;
100096+ u16 gr_sport;
100097+ u16 gr_dport;
100098+ u8 used_accept:1;
100099+#endif
100100+
100101 #ifdef CONFIG_AUDIT
100102 unsigned audit_tty;
100103 unsigned audit_tty_log_passwd;
100104@@ -755,7 +780,7 @@ struct signal_struct {
100105 struct mutex cred_guard_mutex; /* guard against foreign influences on
100106 * credential calculations
100107 * (notably. ptrace) */
100108-};
100109+} __randomize_layout;
100110
100111 /*
100112 * Bits in flags field of signal_struct.
100113@@ -808,6 +833,14 @@ struct user_struct {
100114 struct key *session_keyring; /* UID's default session keyring */
100115 #endif
100116
100117+#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
100118+ unsigned char kernel_banned;
100119+#endif
100120+#ifdef CONFIG_GRKERNSEC_BRUTE
100121+ unsigned char suid_banned;
100122+ unsigned long suid_ban_expires;
100123+#endif
100124+
100125 /* Hash table maintenance information */
100126 struct hlist_node uidhash_node;
100127 kuid_t uid;
100128@@ -815,7 +848,7 @@ struct user_struct {
100129 #ifdef CONFIG_PERF_EVENTS
100130 atomic_long_t locked_vm;
100131 #endif
100132-};
100133+} __randomize_layout;
100134
100135 extern int uids_sysfs_init(void);
100136
100137@@ -1292,6 +1325,9 @@ enum perf_event_task_context {
100138 struct task_struct {
100139 volatile long state; /* -1 unrunnable, 0 runnable, >0 stopped */
100140 void *stack;
100141+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
100142+ void *lowmem_stack;
100143+#endif
100144 atomic_t usage;
100145 unsigned int flags; /* per process flags, defined below */
100146 unsigned int ptrace;
100147@@ -1425,8 +1461,8 @@ struct task_struct {
100148 struct list_head thread_node;
100149
100150 struct completion *vfork_done; /* for vfork() */
100151- int __user *set_child_tid; /* CLONE_CHILD_SETTID */
100152- int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
100153+ pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
100154+ pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
100155
100156 cputime_t utime, stime, utimescaled, stimescaled;
100157 cputime_t gtime;
100158@@ -1451,11 +1487,6 @@ struct task_struct {
100159 struct task_cputime cputime_expires;
100160 struct list_head cpu_timers[3];
100161
100162-/* process credentials */
100163- const struct cred __rcu *real_cred; /* objective and real subjective task
100164- * credentials (COW) */
100165- const struct cred __rcu *cred; /* effective (overridable) subjective task
100166- * credentials (COW) */
100167 char comm[TASK_COMM_LEN]; /* executable name excluding path
100168 - access with [gs]et_task_comm (which lock
100169 it with task_lock())
100170@@ -1473,6 +1504,10 @@ struct task_struct {
100171 #endif
100172 /* CPU-specific state of this task */
100173 struct thread_struct thread;
100174+/* thread_info moved to task_struct */
100175+#ifdef CONFIG_X86
100176+ struct thread_info tinfo;
100177+#endif
100178 /* filesystem information */
100179 struct fs_struct *fs;
100180 /* open file information */
100181@@ -1547,6 +1582,10 @@ struct task_struct {
100182 gfp_t lockdep_reclaim_gfp;
100183 #endif
100184
100185+/* process credentials */
100186+ const struct cred __rcu *real_cred; /* objective and real subjective task
100187+ * credentials (COW) */
100188+
100189 /* journalling filesystem info */
100190 void *journal_info;
100191
100192@@ -1585,6 +1624,10 @@ struct task_struct {
100193 /* cg_list protected by css_set_lock and tsk->alloc_lock */
100194 struct list_head cg_list;
100195 #endif
100196+
100197+ const struct cred __rcu *cred; /* effective (overridable) subjective task
100198+ * credentials (COW) */
100199+
100200 #ifdef CONFIG_FUTEX
100201 struct robust_list_head __user *robust_list;
100202 #ifdef CONFIG_COMPAT
100203@@ -1696,7 +1739,7 @@ struct task_struct {
100204 * Number of functions that haven't been traced
100205 * because of depth overrun.
100206 */
100207- atomic_t trace_overrun;
100208+ atomic_unchecked_t trace_overrun;
100209 /* Pause for the tracing */
100210 atomic_t tracing_graph_pause;
100211 #endif
100212@@ -1724,7 +1767,78 @@ struct task_struct {
100213 #ifdef CONFIG_DEBUG_ATOMIC_SLEEP
100214 unsigned long task_state_change;
100215 #endif
100216-};
100217+
100218+#ifdef CONFIG_GRKERNSEC
100219+ /* grsecurity */
100220+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
100221+ u64 exec_id;
100222+#endif
100223+#ifdef CONFIG_GRKERNSEC_SETXID
100224+ const struct cred *delayed_cred;
100225+#endif
100226+ struct dentry *gr_chroot_dentry;
100227+ struct acl_subject_label *acl;
100228+ struct acl_subject_label *tmpacl;
100229+ struct acl_role_label *role;
100230+ struct file *exec_file;
100231+ unsigned long brute_expires;
100232+ u16 acl_role_id;
100233+ u8 inherited;
100234+ /* is this the task that authenticated to the special role */
100235+ u8 acl_sp_role;
100236+ u8 is_writable;
100237+ u8 brute;
100238+ u8 gr_is_chrooted;
100239+#endif
100240+
100241+} __randomize_layout;
100242+
100243+#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
100244+#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
100245+#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
100246+#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
100247+/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
100248+#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
100249+
100250+#ifdef CONFIG_PAX_SOFTMODE
100251+extern int pax_softmode;
100252+#endif
100253+
100254+extern int pax_check_flags(unsigned long *);
100255+#define PAX_PARSE_FLAGS_FALLBACK (~0UL)
100256+
100257+/* if tsk != current then task_lock must be held on it */
100258+#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
100259+static inline unsigned long pax_get_flags(struct task_struct *tsk)
100260+{
100261+ if (likely(tsk->mm))
100262+ return tsk->mm->pax_flags;
100263+ else
100264+ return 0UL;
100265+}
100266+
100267+/* if tsk != current then task_lock must be held on it */
100268+static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
100269+{
100270+ if (likely(tsk->mm)) {
100271+ tsk->mm->pax_flags = flags;
100272+ return 0;
100273+ }
100274+ return -EINVAL;
100275+}
100276+#endif
100277+
100278+#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
100279+extern void pax_set_initial_flags(struct linux_binprm *bprm);
100280+#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
100281+extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
100282+#endif
100283+
100284+struct path;
100285+extern char *pax_get_path(const struct path *path, char *buf, int buflen);
100286+extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
100287+extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
100288+extern void pax_report_refcount_overflow(struct pt_regs *regs);
100289
100290 /* Future-safe accessor for struct task_struct's cpus_allowed. */
100291 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
100292@@ -1807,7 +1921,7 @@ struct pid_namespace;
100293 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
100294 struct pid_namespace *ns);
100295
100296-static inline pid_t task_pid_nr(struct task_struct *tsk)
100297+static inline pid_t task_pid_nr(const struct task_struct *tsk)
100298 {
100299 return tsk->pid;
100300 }
100301@@ -2175,6 +2289,25 @@ extern u64 sched_clock_cpu(int cpu);
100302
100303 extern void sched_clock_init(void);
100304
100305+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
100306+static inline void populate_stack(void)
100307+{
100308+ struct task_struct *curtask = current;
100309+ int c;
100310+ int *ptr = curtask->stack;
100311+ int *end = curtask->stack + THREAD_SIZE;
100312+
100313+ while (ptr < end) {
100314+ c = *(volatile int *)ptr;
100315+ ptr += PAGE_SIZE/sizeof(int);
100316+ }
100317+}
100318+#else
100319+static inline void populate_stack(void)
100320+{
100321+}
100322+#endif
100323+
100324 #ifndef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK
100325 static inline void sched_clock_tick(void)
100326 {
100327@@ -2303,7 +2436,9 @@ extern void set_curr_task(int cpu, struct task_struct *p);
100328 void yield(void);
100329
100330 union thread_union {
100331+#ifndef CONFIG_X86
100332 struct thread_info thread_info;
100333+#endif
100334 unsigned long stack[THREAD_SIZE/sizeof(long)];
100335 };
100336
100337@@ -2336,6 +2471,7 @@ extern struct pid_namespace init_pid_ns;
100338 */
100339
100340 extern struct task_struct *find_task_by_vpid(pid_t nr);
100341+extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
100342 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
100343 struct pid_namespace *ns);
100344
100345@@ -2500,7 +2636,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
100346 extern void exit_itimers(struct signal_struct *);
100347 extern void flush_itimer_signals(void);
100348
100349-extern void do_group_exit(int);
100350+extern __noreturn void do_group_exit(int);
100351
100352 extern int do_execve(struct filename *,
100353 const char __user * const __user *,
100354@@ -2721,9 +2857,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
100355 #define task_stack_end_corrupted(task) \
100356 (*(end_of_stack(task)) != STACK_END_MAGIC)
100357
100358-static inline int object_is_on_stack(void *obj)
100359+static inline int object_starts_on_stack(const void *obj)
100360 {
100361- void *stack = task_stack_page(current);
100362+ const void *stack = task_stack_page(current);
100363
100364 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
100365 }
100366diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
100367index 596a0e0..bea77ec 100644
100368--- a/include/linux/sched/sysctl.h
100369+++ b/include/linux/sched/sysctl.h
100370@@ -34,6 +34,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
100371 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
100372
100373 extern int sysctl_max_map_count;
100374+extern unsigned long sysctl_heap_stack_gap;
100375
100376 extern unsigned int sysctl_sched_latency;
100377 extern unsigned int sysctl_sched_min_granularity;
100378diff --git a/include/linux/security.h b/include/linux/security.h
100379index 18264ea..e0238e4 100644
100380--- a/include/linux/security.h
100381+++ b/include/linux/security.h
100382@@ -27,6 +27,7 @@
100383 #include <linux/slab.h>
100384 #include <linux/err.h>
100385 #include <linux/string.h>
100386+#include <linux/grsecurity.h>
100387
100388 struct linux_binprm;
100389 struct cred;
100390@@ -116,8 +117,6 @@ struct seq_file;
100391
100392 extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
100393
100394-void reset_security_ops(void);
100395-
100396 #ifdef CONFIG_MMU
100397 extern unsigned long mmap_min_addr;
100398 extern unsigned long dac_mmap_min_addr;
100399@@ -1755,7 +1754,7 @@ struct security_operations {
100400 struct audit_context *actx);
100401 void (*audit_rule_free) (void *lsmrule);
100402 #endif /* CONFIG_AUDIT */
100403-};
100404+} __randomize_layout;
100405
100406 /* prototypes */
100407 extern int security_init(void);
100408diff --git a/include/linux/semaphore.h b/include/linux/semaphore.h
100409index dc368b8..e895209 100644
100410--- a/include/linux/semaphore.h
100411+++ b/include/linux/semaphore.h
100412@@ -37,7 +37,7 @@ static inline void sema_init(struct semaphore *sem, int val)
100413 }
100414
100415 extern void down(struct semaphore *sem);
100416-extern int __must_check down_interruptible(struct semaphore *sem);
100417+extern int __must_check down_interruptible(struct semaphore *sem) __intentional_overflow(-1);
100418 extern int __must_check down_killable(struct semaphore *sem);
100419 extern int __must_check down_trylock(struct semaphore *sem);
100420 extern int __must_check down_timeout(struct semaphore *sem, long jiffies);
100421diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
100422index afbb1fd..e1d205d 100644
100423--- a/include/linux/seq_file.h
100424+++ b/include/linux/seq_file.h
100425@@ -27,6 +27,9 @@ struct seq_file {
100426 struct mutex lock;
100427 const struct seq_operations *op;
100428 int poll_event;
100429+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
100430+ u64 exec_id;
100431+#endif
100432 #ifdef CONFIG_USER_NS
100433 struct user_namespace *user_ns;
100434 #endif
100435@@ -39,6 +42,7 @@ struct seq_operations {
100436 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
100437 int (*show) (struct seq_file *m, void *v);
100438 };
100439+typedef struct seq_operations __no_const seq_operations_no_const;
100440
100441 #define SEQ_SKIP 1
100442
100443@@ -111,6 +115,7 @@ void seq_pad(struct seq_file *m, char c);
100444
100445 char *mangle_path(char *s, const char *p, const char *esc);
100446 int seq_open(struct file *, const struct seq_operations *);
100447+int seq_open_restrict(struct file *, const struct seq_operations *);
100448 ssize_t seq_read(struct file *, char __user *, size_t, loff_t *);
100449 loff_t seq_lseek(struct file *, loff_t, int);
100450 int seq_release(struct inode *, struct file *);
100451@@ -128,6 +133,7 @@ int seq_path_root(struct seq_file *m, const struct path *path,
100452 const struct path *root, const char *esc);
100453
100454 int single_open(struct file *, int (*)(struct seq_file *, void *), void *);
100455+int single_open_restrict(struct file *, int (*)(struct seq_file *, void *), void *);
100456 int single_open_size(struct file *, int (*)(struct seq_file *, void *), void *, size_t);
100457 int single_release(struct inode *, struct file *);
100458 void *__seq_open_private(struct file *, const struct seq_operations *, int);
100459diff --git a/include/linux/shm.h b/include/linux/shm.h
100460index 6fb8016..ab4465e 100644
100461--- a/include/linux/shm.h
100462+++ b/include/linux/shm.h
100463@@ -22,6 +22,10 @@ struct shmid_kernel /* private to the kernel */
100464 /* The task created the shm object. NULL if the task is dead. */
100465 struct task_struct *shm_creator;
100466 struct list_head shm_clist; /* list by creator */
100467+#ifdef CONFIG_GRKERNSEC
100468+ u64 shm_createtime;
100469+ pid_t shm_lapid;
100470+#endif
100471 };
100472
100473 /* shm_mode upper byte flags */
100474diff --git a/include/linux/signal.h b/include/linux/signal.h
100475index ab1e039..ad4229e 100644
100476--- a/include/linux/signal.h
100477+++ b/include/linux/signal.h
100478@@ -289,7 +289,7 @@ static inline void allow_signal(int sig)
100479 * know it'll be handled, so that they don't get converted to
100480 * SIGKILL or just silently dropped.
100481 */
100482- kernel_sigaction(sig, (__force __sighandler_t)2);
100483+ kernel_sigaction(sig, (__force_user __sighandler_t)2);
100484 }
100485
100486 static inline void disallow_signal(int sig)
100487diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
100488index f15154a..72cf02c 100644
100489--- a/include/linux/skbuff.h
100490+++ b/include/linux/skbuff.h
100491@@ -776,7 +776,7 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t priority, int flags,
100492 int node);
100493 struct sk_buff *__build_skb(void *data, unsigned int frag_size);
100494 struct sk_buff *build_skb(void *data, unsigned int frag_size);
100495-static inline struct sk_buff *alloc_skb(unsigned int size,
100496+static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
100497 gfp_t priority)
100498 {
100499 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
100500@@ -1971,7 +1971,7 @@ static inline u32 skb_inner_network_header_len(const struct sk_buff *skb)
100501 return skb->inner_transport_header - skb->inner_network_header;
100502 }
100503
100504-static inline int skb_network_offset(const struct sk_buff *skb)
100505+static inline int __intentional_overflow(0) skb_network_offset(const struct sk_buff *skb)
100506 {
100507 return skb_network_header(skb) - skb->data;
100508 }
100509@@ -2031,7 +2031,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
100510 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
100511 */
100512 #ifndef NET_SKB_PAD
100513-#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
100514+#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
100515 #endif
100516
100517 int ___pskb_trim(struct sk_buff *skb, unsigned int len);
100518@@ -2673,9 +2673,9 @@ struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags, int noblock,
100519 int *err);
100520 unsigned int datagram_poll(struct file *file, struct socket *sock,
100521 struct poll_table_struct *wait);
100522-int skb_copy_datagram_iter(const struct sk_buff *from, int offset,
100523+int __intentional_overflow(0) skb_copy_datagram_iter(const struct sk_buff *from, int offset,
100524 struct iov_iter *to, int size);
100525-static inline int skb_copy_datagram_msg(const struct sk_buff *from, int offset,
100526+static inline int __intentional_overflow(2,4) skb_copy_datagram_msg(const struct sk_buff *from, int offset,
100527 struct msghdr *msg, int size)
100528 {
100529 return skb_copy_datagram_iter(from, offset, &msg->msg_iter, size);
100530@@ -3197,6 +3197,9 @@ static inline void nf_reset(struct sk_buff *skb)
100531 nf_bridge_put(skb->nf_bridge);
100532 skb->nf_bridge = NULL;
100533 #endif
100534+#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
100535+ skb->nf_trace = 0;
100536+#endif
100537 }
100538
100539 static inline void nf_reset_trace(struct sk_buff *skb)
100540diff --git a/include/linux/slab.h b/include/linux/slab.h
100541index ffd24c8..cbbe7de 100644
100542--- a/include/linux/slab.h
100543+++ b/include/linux/slab.h
100544@@ -15,14 +15,29 @@
100545 #include <linux/types.h>
100546 #include <linux/workqueue.h>
100547
100548+#include <linux/err.h>
100549
100550 /*
100551 * Flags to pass to kmem_cache_create().
100552 * The ones marked DEBUG are only valid if CONFIG_DEBUG_SLAB is set.
100553 */
100554 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
100555+
100556+#ifdef CONFIG_PAX_USERCOPY_SLABS
100557+#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
100558+#else
100559+#define SLAB_USERCOPY 0x00000000UL
100560+#endif
100561+
100562 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
100563 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
100564+
100565+#ifdef CONFIG_PAX_MEMORY_SANITIZE
100566+#define SLAB_NO_SANITIZE 0x00001000UL /* PaX: Do not sanitize objs on free */
100567+#else
100568+#define SLAB_NO_SANITIZE 0x00000000UL
100569+#endif
100570+
100571 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
100572 #define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */
100573 #define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */
100574@@ -98,10 +113,13 @@
100575 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
100576 * Both make kfree a no-op.
100577 */
100578-#define ZERO_SIZE_PTR ((void *)16)
100579+#define ZERO_SIZE_PTR \
100580+({ \
100581+ BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
100582+ (void *)(-MAX_ERRNO-1L); \
100583+})
100584
100585-#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
100586- (unsigned long)ZERO_SIZE_PTR)
100587+#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
100588
100589 #include <linux/kmemleak.h>
100590 #include <linux/kasan.h>
100591@@ -143,6 +161,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
100592 void kfree(const void *);
100593 void kzfree(const void *);
100594 size_t ksize(const void *);
100595+const char *check_heap_object(const void *ptr, unsigned long n);
100596+bool is_usercopy_object(const void *ptr);
100597
100598 /*
100599 * Some archs want to perform DMA into kmalloc caches and need a guaranteed
100600@@ -235,6 +255,10 @@ extern struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];
100601 extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
100602 #endif
100603
100604+#ifdef CONFIG_PAX_USERCOPY_SLABS
100605+extern struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
100606+#endif
100607+
100608 /*
100609 * Figure out which kmalloc slab an allocation of a certain size
100610 * belongs to.
100611@@ -243,7 +267,7 @@ extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
100612 * 2 = 120 .. 192 bytes
100613 * n = 2^(n-1) .. 2^n -1
100614 */
100615-static __always_inline int kmalloc_index(size_t size)
100616+static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
100617 {
100618 if (!size)
100619 return 0;
100620@@ -286,15 +310,15 @@ static __always_inline int kmalloc_index(size_t size)
100621 }
100622 #endif /* !CONFIG_SLOB */
100623
100624-void *__kmalloc(size_t size, gfp_t flags);
100625+void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
100626 void *kmem_cache_alloc(struct kmem_cache *, gfp_t flags);
100627 void kmem_cache_free(struct kmem_cache *, void *);
100628
100629 #ifdef CONFIG_NUMA
100630-void *__kmalloc_node(size_t size, gfp_t flags, int node);
100631+void *__kmalloc_node(size_t size, gfp_t flags, int node) __alloc_size(1) __size_overflow(1);
100632 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
100633 #else
100634-static __always_inline void *__kmalloc_node(size_t size, gfp_t flags, int node)
100635+static __always_inline void * __size_overflow(1) __kmalloc_node(size_t size, gfp_t flags, int node)
100636 {
100637 return __kmalloc(size, flags);
100638 }
100639diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
100640index 33d0490..70a6313 100644
100641--- a/include/linux/slab_def.h
100642+++ b/include/linux/slab_def.h
100643@@ -40,7 +40,7 @@ struct kmem_cache {
100644 /* 4) cache creation/removal */
100645 const char *name;
100646 struct list_head list;
100647- int refcount;
100648+ atomic_t refcount;
100649 int object_size;
100650 int align;
100651
100652@@ -56,10 +56,14 @@ struct kmem_cache {
100653 unsigned long node_allocs;
100654 unsigned long node_frees;
100655 unsigned long node_overflow;
100656- atomic_t allochit;
100657- atomic_t allocmiss;
100658- atomic_t freehit;
100659- atomic_t freemiss;
100660+ atomic_unchecked_t allochit;
100661+ atomic_unchecked_t allocmiss;
100662+ atomic_unchecked_t freehit;
100663+ atomic_unchecked_t freemiss;
100664+#ifdef CONFIG_PAX_MEMORY_SANITIZE
100665+ atomic_unchecked_t sanitized;
100666+ atomic_unchecked_t not_sanitized;
100667+#endif
100668
100669 /*
100670 * If debugging is enabled, then the allocator can add additional
100671diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
100672index 3388511..6252f90 100644
100673--- a/include/linux/slub_def.h
100674+++ b/include/linux/slub_def.h
100675@@ -74,7 +74,7 @@ struct kmem_cache {
100676 struct kmem_cache_order_objects max;
100677 struct kmem_cache_order_objects min;
100678 gfp_t allocflags; /* gfp flags to use on each alloc */
100679- int refcount; /* Refcount for slab cache destroy */
100680+ atomic_t refcount; /* Refcount for slab cache destroy */
100681 void (*ctor)(void *);
100682 int inuse; /* Offset to metadata */
100683 int align; /* Alignment */
100684diff --git a/include/linux/smp.h b/include/linux/smp.h
100685index c441407..f487b83 100644
100686--- a/include/linux/smp.h
100687+++ b/include/linux/smp.h
100688@@ -183,7 +183,9 @@ static inline void smp_init(void) { }
100689 #endif
100690
100691 #define get_cpu() ({ preempt_disable(); smp_processor_id(); })
100692+#define raw_get_cpu() ({ raw_preempt_disable(); raw_smp_processor_id(); })
100693 #define put_cpu() preempt_enable()
100694+#define raw_put_cpu_no_resched() raw_preempt_enable_no_resched()
100695
100696 /*
100697 * Callback to arch code if there's nosmp or maxcpus=0 on the
100698diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
100699index 083ac38..b23e3e8 100644
100700--- a/include/linux/sock_diag.h
100701+++ b/include/linux/sock_diag.h
100702@@ -11,7 +11,7 @@ struct sock;
100703 struct sock_diag_handler {
100704 __u8 family;
100705 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
100706-};
100707+} __do_const;
100708
100709 int sock_diag_register(const struct sock_diag_handler *h);
100710 void sock_diag_unregister(const struct sock_diag_handler *h);
100711diff --git a/include/linux/sonet.h b/include/linux/sonet.h
100712index 680f9a3..f13aeb0 100644
100713--- a/include/linux/sonet.h
100714+++ b/include/linux/sonet.h
100715@@ -7,7 +7,7 @@
100716 #include <uapi/linux/sonet.h>
100717
100718 struct k_sonet_stats {
100719-#define __HANDLE_ITEM(i) atomic_t i
100720+#define __HANDLE_ITEM(i) atomic_unchecked_t i
100721 __SONET_ITEMS
100722 #undef __HANDLE_ITEM
100723 };
100724diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
100725index 07d8e53..dc934c9 100644
100726--- a/include/linux/sunrpc/addr.h
100727+++ b/include/linux/sunrpc/addr.h
100728@@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
100729 {
100730 switch (sap->sa_family) {
100731 case AF_INET:
100732- return ntohs(((struct sockaddr_in *)sap)->sin_port);
100733+ return ntohs(((const struct sockaddr_in *)sap)->sin_port);
100734 case AF_INET6:
100735- return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
100736+ return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
100737 }
100738 return 0;
100739 }
100740@@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
100741 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
100742 const struct sockaddr *src)
100743 {
100744- const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
100745+ const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
100746 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
100747
100748 dsin->sin_family = ssin->sin_family;
100749@@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
100750 if (sa->sa_family != AF_INET6)
100751 return 0;
100752
100753- return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
100754+ return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
100755 }
100756
100757 #endif /* _LINUX_SUNRPC_ADDR_H */
100758diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
100759index 598ba80..d90cba6 100644
100760--- a/include/linux/sunrpc/clnt.h
100761+++ b/include/linux/sunrpc/clnt.h
100762@@ -100,7 +100,7 @@ struct rpc_procinfo {
100763 unsigned int p_timer; /* Which RTT timer to use */
100764 u32 p_statidx; /* Which procedure to account */
100765 const char * p_name; /* name of procedure */
100766-};
100767+} __do_const;
100768
100769 #ifdef __KERNEL__
100770
100771diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
100772index fae6fb9..023fbcd 100644
100773--- a/include/linux/sunrpc/svc.h
100774+++ b/include/linux/sunrpc/svc.h
100775@@ -420,7 +420,7 @@ struct svc_procedure {
100776 unsigned int pc_count; /* call count */
100777 unsigned int pc_cachetype; /* cache info (NFS) */
100778 unsigned int pc_xdrressize; /* maximum size of XDR reply */
100779-};
100780+} __do_const;
100781
100782 /*
100783 * Function prototypes.
100784diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
100785index df8edf8..d140fec 100644
100786--- a/include/linux/sunrpc/svc_rdma.h
100787+++ b/include/linux/sunrpc/svc_rdma.h
100788@@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
100789 extern unsigned int svcrdma_max_requests;
100790 extern unsigned int svcrdma_max_req_size;
100791
100792-extern atomic_t rdma_stat_recv;
100793-extern atomic_t rdma_stat_read;
100794-extern atomic_t rdma_stat_write;
100795-extern atomic_t rdma_stat_sq_starve;
100796-extern atomic_t rdma_stat_rq_starve;
100797-extern atomic_t rdma_stat_rq_poll;
100798-extern atomic_t rdma_stat_rq_prod;
100799-extern atomic_t rdma_stat_sq_poll;
100800-extern atomic_t rdma_stat_sq_prod;
100801+extern atomic_unchecked_t rdma_stat_recv;
100802+extern atomic_unchecked_t rdma_stat_read;
100803+extern atomic_unchecked_t rdma_stat_write;
100804+extern atomic_unchecked_t rdma_stat_sq_starve;
100805+extern atomic_unchecked_t rdma_stat_rq_starve;
100806+extern atomic_unchecked_t rdma_stat_rq_poll;
100807+extern atomic_unchecked_t rdma_stat_rq_prod;
100808+extern atomic_unchecked_t rdma_stat_sq_poll;
100809+extern atomic_unchecked_t rdma_stat_sq_prod;
100810
100811 /*
100812 * Contexts are built when an RDMA request is created and are a
100813diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
100814index 8d71d65..f79586e 100644
100815--- a/include/linux/sunrpc/svcauth.h
100816+++ b/include/linux/sunrpc/svcauth.h
100817@@ -120,7 +120,7 @@ struct auth_ops {
100818 int (*release)(struct svc_rqst *rq);
100819 void (*domain_release)(struct auth_domain *);
100820 int (*set_client)(struct svc_rqst *rq);
100821-};
100822+} __do_const;
100823
100824 #define SVC_GARBAGE 1
100825 #define SVC_SYSERR 2
100826diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
100827index e7a018e..49f8b17 100644
100828--- a/include/linux/swiotlb.h
100829+++ b/include/linux/swiotlb.h
100830@@ -60,7 +60,8 @@ extern void
100831
100832 extern void
100833 swiotlb_free_coherent(struct device *hwdev, size_t size,
100834- void *vaddr, dma_addr_t dma_handle);
100835+ void *vaddr, dma_addr_t dma_handle,
100836+ struct dma_attrs *attrs);
100837
100838 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
100839 unsigned long offset, size_t size,
100840diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
100841index 76d1e38..200776e 100644
100842--- a/include/linux/syscalls.h
100843+++ b/include/linux/syscalls.h
100844@@ -102,7 +102,12 @@ union bpf_attr;
100845 #define __TYPE_IS_L(t) (__same_type((t)0, 0L))
100846 #define __TYPE_IS_UL(t) (__same_type((t)0, 0UL))
100847 #define __TYPE_IS_LL(t) (__same_type((t)0, 0LL) || __same_type((t)0, 0ULL))
100848-#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), 0LL, 0L)) a
100849+#define __SC_LONG(t, a) __typeof__( \
100850+ __builtin_choose_expr( \
100851+ sizeof(t) > sizeof(int), \
100852+ (t) 0, \
100853+ __builtin_choose_expr(__type_is_unsigned(t), 0UL, 0L) \
100854+ )) a
100855 #define __SC_CAST(t, a) (t) a
100856 #define __SC_ARGS(t, a) a
100857 #define __SC_TEST(t, a) (void)BUILD_BUG_ON_ZERO(!__TYPE_IS_LL(t) && sizeof(t) > sizeof(long))
100858@@ -384,11 +389,11 @@ asmlinkage long sys_sync(void);
100859 asmlinkage long sys_fsync(unsigned int fd);
100860 asmlinkage long sys_fdatasync(unsigned int fd);
100861 asmlinkage long sys_bdflush(int func, long data);
100862-asmlinkage long sys_mount(char __user *dev_name, char __user *dir_name,
100863- char __user *type, unsigned long flags,
100864+asmlinkage long sys_mount(const char __user *dev_name, const char __user *dir_name,
100865+ const char __user *type, unsigned long flags,
100866 void __user *data);
100867-asmlinkage long sys_umount(char __user *name, int flags);
100868-asmlinkage long sys_oldumount(char __user *name);
100869+asmlinkage long sys_umount(const char __user *name, int flags);
100870+asmlinkage long sys_oldumount(const char __user *name);
100871 asmlinkage long sys_truncate(const char __user *path, long length);
100872 asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
100873 asmlinkage long sys_stat(const char __user *filename,
100874@@ -604,7 +609,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
100875 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
100876 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
100877 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
100878- struct sockaddr __user *, int);
100879+ struct sockaddr __user *, int) __intentional_overflow(0);
100880 asmlinkage long sys_sendmsg(int fd, struct user_msghdr __user *msg, unsigned flags);
100881 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
100882 unsigned int vlen, unsigned flags);
100883@@ -663,10 +668,10 @@ asmlinkage long sys_msgctl(int msqid, int cmd, struct msqid_ds __user *buf);
100884
100885 asmlinkage long sys_semget(key_t key, int nsems, int semflg);
100886 asmlinkage long sys_semop(int semid, struct sembuf __user *sops,
100887- unsigned nsops);
100888+ long nsops);
100889 asmlinkage long sys_semctl(int semid, int semnum, int cmd, unsigned long arg);
100890 asmlinkage long sys_semtimedop(int semid, struct sembuf __user *sops,
100891- unsigned nsops,
100892+ long nsops,
100893 const struct timespec __user *timeout);
100894 asmlinkage long sys_shmat(int shmid, char __user *shmaddr, int shmflg);
100895 asmlinkage long sys_shmget(key_t key, size_t size, int flag);
100896diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
100897index 27b3b0b..e093dd9 100644
100898--- a/include/linux/syscore_ops.h
100899+++ b/include/linux/syscore_ops.h
100900@@ -16,7 +16,7 @@ struct syscore_ops {
100901 int (*suspend)(void);
100902 void (*resume)(void);
100903 void (*shutdown)(void);
100904-};
100905+} __do_const;
100906
100907 extern void register_syscore_ops(struct syscore_ops *ops);
100908 extern void unregister_syscore_ops(struct syscore_ops *ops);
100909diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
100910index fa7bc29..0d96561 100644
100911--- a/include/linux/sysctl.h
100912+++ b/include/linux/sysctl.h
100913@@ -39,10 +39,16 @@ typedef int proc_handler (struct ctl_table *ctl, int write,
100914
100915 extern int proc_dostring(struct ctl_table *, int,
100916 void __user *, size_t *, loff_t *);
100917+extern int proc_dostring_modpriv(struct ctl_table *, int,
100918+ void __user *, size_t *, loff_t *);
100919 extern int proc_dointvec(struct ctl_table *, int,
100920 void __user *, size_t *, loff_t *);
100921+extern int proc_dointvec_secure(struct ctl_table *, int,
100922+ void __user *, size_t *, loff_t *);
100923 extern int proc_dointvec_minmax(struct ctl_table *, int,
100924 void __user *, size_t *, loff_t *);
100925+extern int proc_dointvec_minmax_secure(struct ctl_table *, int,
100926+ void __user *, size_t *, loff_t *);
100927 extern int proc_dointvec_jiffies(struct ctl_table *, int,
100928 void __user *, size_t *, loff_t *);
100929 extern int proc_dointvec_userhz_jiffies(struct ctl_table *, int,
100930@@ -113,7 +119,8 @@ struct ctl_table
100931 struct ctl_table_poll *poll;
100932 void *extra1;
100933 void *extra2;
100934-};
100935+} __do_const __randomize_layout;
100936+typedef struct ctl_table __no_const ctl_table_no_const;
100937
100938 struct ctl_node {
100939 struct rb_node node;
100940diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
100941index 9f65758..487a6f1 100644
100942--- a/include/linux/sysfs.h
100943+++ b/include/linux/sysfs.h
100944@@ -34,7 +34,8 @@ struct attribute {
100945 struct lock_class_key *key;
100946 struct lock_class_key skey;
100947 #endif
100948-};
100949+} __do_const;
100950+typedef struct attribute __no_const attribute_no_const;
100951
100952 /**
100953 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
100954@@ -78,7 +79,8 @@ struct attribute_group {
100955 struct attribute *, int);
100956 struct attribute **attrs;
100957 struct bin_attribute **bin_attrs;
100958-};
100959+} __do_const;
100960+typedef struct attribute_group __no_const attribute_group_no_const;
100961
100962 /**
100963 * Use these macros to make defining attributes easier. See include/linux/device.h
100964@@ -152,7 +154,8 @@ struct bin_attribute {
100965 char *, loff_t, size_t);
100966 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
100967 struct vm_area_struct *vma);
100968-};
100969+} __do_const;
100970+typedef struct bin_attribute __no_const bin_attribute_no_const;
100971
100972 /**
100973 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
100974diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
100975index 387fa7d..3fcde6b 100644
100976--- a/include/linux/sysrq.h
100977+++ b/include/linux/sysrq.h
100978@@ -16,6 +16,7 @@
100979
100980 #include <linux/errno.h>
100981 #include <linux/types.h>
100982+#include <linux/compiler.h>
100983
100984 /* Possible values of bitmask for enabling sysrq functions */
100985 /* 0x0001 is reserved for enable everything */
100986@@ -33,7 +34,7 @@ struct sysrq_key_op {
100987 char *help_msg;
100988 char *action_msg;
100989 int enable_mask;
100990-};
100991+} __do_const;
100992
100993 #ifdef CONFIG_MAGIC_SYSRQ
100994
100995diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
100996index ff307b5..f1a4468 100644
100997--- a/include/linux/thread_info.h
100998+++ b/include/linux/thread_info.h
100999@@ -145,6 +145,13 @@ static inline bool test_and_clear_restore_sigmask(void)
101000 #error "no set_restore_sigmask() provided and default one won't work"
101001 #endif
101002
101003+extern void __check_object_size(const void *ptr, unsigned long n, bool to_user, bool const_size);
101004+
101005+static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
101006+{
101007+ __check_object_size(ptr, n, to_user, __builtin_constant_p(n));
101008+}
101009+
101010 #endif /* __KERNEL__ */
101011
101012 #endif /* _LINUX_THREAD_INFO_H */
101013diff --git a/include/linux/tty.h b/include/linux/tty.h
101014index d76631f..de91e82 100644
101015--- a/include/linux/tty.h
101016+++ b/include/linux/tty.h
101017@@ -225,7 +225,7 @@ struct tty_port {
101018 const struct tty_port_operations *ops; /* Port operations */
101019 spinlock_t lock; /* Lock protecting tty field */
101020 int blocked_open; /* Waiting to open */
101021- int count; /* Usage count */
101022+ atomic_t count; /* Usage count */
101023 wait_queue_head_t open_wait; /* Open waiters */
101024 wait_queue_head_t close_wait; /* Close waiters */
101025 wait_queue_head_t delta_msr_wait; /* Modem status change */
101026@@ -313,7 +313,7 @@ struct tty_struct {
101027 /* If the tty has a pending do_SAK, queue it here - akpm */
101028 struct work_struct SAK_work;
101029 struct tty_port *port;
101030-};
101031+} __randomize_layout;
101032
101033 /* Each of a tty's open files has private_data pointing to tty_file_private */
101034 struct tty_file_private {
101035@@ -573,7 +573,7 @@ extern int tty_port_open(struct tty_port *port,
101036 struct tty_struct *tty, struct file *filp);
101037 static inline int tty_port_users(struct tty_port *port)
101038 {
101039- return port->count + port->blocked_open;
101040+ return atomic_read(&port->count) + port->blocked_open;
101041 }
101042
101043 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
101044diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
101045index 92e337c..f46757b 100644
101046--- a/include/linux/tty_driver.h
101047+++ b/include/linux/tty_driver.h
101048@@ -291,7 +291,7 @@ struct tty_operations {
101049 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
101050 #endif
101051 const struct file_operations *proc_fops;
101052-};
101053+} __do_const __randomize_layout;
101054
101055 struct tty_driver {
101056 int magic; /* magic number for this structure */
101057@@ -325,7 +325,7 @@ struct tty_driver {
101058
101059 const struct tty_operations *ops;
101060 struct list_head tty_drivers;
101061-};
101062+} __randomize_layout;
101063
101064 extern struct list_head tty_drivers;
101065
101066diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
101067index 00c9d68..bc0188b 100644
101068--- a/include/linux/tty_ldisc.h
101069+++ b/include/linux/tty_ldisc.h
101070@@ -215,7 +215,7 @@ struct tty_ldisc_ops {
101071
101072 struct module *owner;
101073
101074- int refcount;
101075+ atomic_t refcount;
101076 };
101077
101078 struct tty_ldisc {
101079diff --git a/include/linux/types.h b/include/linux/types.h
101080index 8715287..1be77ee 100644
101081--- a/include/linux/types.h
101082+++ b/include/linux/types.h
101083@@ -176,10 +176,26 @@ typedef struct {
101084 int counter;
101085 } atomic_t;
101086
101087+#ifdef CONFIG_PAX_REFCOUNT
101088+typedef struct {
101089+ int counter;
101090+} atomic_unchecked_t;
101091+#else
101092+typedef atomic_t atomic_unchecked_t;
101093+#endif
101094+
101095 #ifdef CONFIG_64BIT
101096 typedef struct {
101097 long counter;
101098 } atomic64_t;
101099+
101100+#ifdef CONFIG_PAX_REFCOUNT
101101+typedef struct {
101102+ long counter;
101103+} atomic64_unchecked_t;
101104+#else
101105+typedef atomic64_t atomic64_unchecked_t;
101106+#endif
101107 #endif
101108
101109 struct list_head {
101110diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
101111index ecd3319..8a36ded 100644
101112--- a/include/linux/uaccess.h
101113+++ b/include/linux/uaccess.h
101114@@ -75,11 +75,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
101115 long ret; \
101116 mm_segment_t old_fs = get_fs(); \
101117 \
101118- set_fs(KERNEL_DS); \
101119 pagefault_disable(); \
101120- ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
101121- pagefault_enable(); \
101122+ set_fs(KERNEL_DS); \
101123+ ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
101124 set_fs(old_fs); \
101125+ pagefault_enable(); \
101126 ret; \
101127 })
101128
101129diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
101130index 0383552..a0125dd 100644
101131--- a/include/linux/uidgid.h
101132+++ b/include/linux/uidgid.h
101133@@ -187,4 +187,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
101134
101135 #endif /* CONFIG_USER_NS */
101136
101137+#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
101138+#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
101139+#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
101140+#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
101141+
101142 #endif /* _LINUX_UIDGID_H */
101143diff --git a/include/linux/uio_driver.h b/include/linux/uio_driver.h
101144index 32c0e83..671eb35 100644
101145--- a/include/linux/uio_driver.h
101146+++ b/include/linux/uio_driver.h
101147@@ -67,7 +67,7 @@ struct uio_device {
101148 struct module *owner;
101149 struct device *dev;
101150 int minor;
101151- atomic_t event;
101152+ atomic_unchecked_t event;
101153 struct fasync_struct *async_queue;
101154 wait_queue_head_t wait;
101155 struct uio_info *info;
101156diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
101157index 99c1b4d..562e6f3 100644
101158--- a/include/linux/unaligned/access_ok.h
101159+++ b/include/linux/unaligned/access_ok.h
101160@@ -4,34 +4,34 @@
101161 #include <linux/kernel.h>
101162 #include <asm/byteorder.h>
101163
101164-static inline u16 get_unaligned_le16(const void *p)
101165+static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
101166 {
101167- return le16_to_cpup((__le16 *)p);
101168+ return le16_to_cpup((const __le16 *)p);
101169 }
101170
101171-static inline u32 get_unaligned_le32(const void *p)
101172+static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
101173 {
101174- return le32_to_cpup((__le32 *)p);
101175+ return le32_to_cpup((const __le32 *)p);
101176 }
101177
101178-static inline u64 get_unaligned_le64(const void *p)
101179+static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
101180 {
101181- return le64_to_cpup((__le64 *)p);
101182+ return le64_to_cpup((const __le64 *)p);
101183 }
101184
101185-static inline u16 get_unaligned_be16(const void *p)
101186+static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
101187 {
101188- return be16_to_cpup((__be16 *)p);
101189+ return be16_to_cpup((const __be16 *)p);
101190 }
101191
101192-static inline u32 get_unaligned_be32(const void *p)
101193+static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
101194 {
101195- return be32_to_cpup((__be32 *)p);
101196+ return be32_to_cpup((const __be32 *)p);
101197 }
101198
101199-static inline u64 get_unaligned_be64(const void *p)
101200+static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
101201 {
101202- return be64_to_cpup((__be64 *)p);
101203+ return be64_to_cpup((const __be64 *)p);
101204 }
101205
101206 static inline void put_unaligned_le16(u16 val, void *p)
101207diff --git a/include/linux/usb.h b/include/linux/usb.h
101208index 447fe29..9fc875f 100644
101209--- a/include/linux/usb.h
101210+++ b/include/linux/usb.h
101211@@ -592,7 +592,7 @@ struct usb_device {
101212 int maxchild;
101213
101214 u32 quirks;
101215- atomic_t urbnum;
101216+ atomic_unchecked_t urbnum;
101217
101218 unsigned long active_duration;
101219
101220@@ -1676,7 +1676,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
101221
101222 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
101223 __u8 request, __u8 requesttype, __u16 value, __u16 index,
101224- void *data, __u16 size, int timeout);
101225+ void *data, __u16 size, int timeout) __intentional_overflow(-1);
101226 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
101227 void *data, int len, int *actual_length, int timeout);
101228 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
101229diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
101230index f06529c..dfeabd8 100644
101231--- a/include/linux/usb/renesas_usbhs.h
101232+++ b/include/linux/usb/renesas_usbhs.h
101233@@ -39,7 +39,7 @@ enum {
101234 */
101235 struct renesas_usbhs_driver_callback {
101236 int (*notify_hotplug)(struct platform_device *pdev);
101237-};
101238+} __no_const;
101239
101240 /*
101241 * callback functions for platform
101242diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h
101243index 8297e5b..0dfae27 100644
101244--- a/include/linux/user_namespace.h
101245+++ b/include/linux/user_namespace.h
101246@@ -39,7 +39,7 @@ struct user_namespace {
101247 struct key *persistent_keyring_register;
101248 struct rw_semaphore persistent_keyring_register_sem;
101249 #endif
101250-};
101251+} __randomize_layout;
101252
101253 extern struct user_namespace init_user_ns;
101254
101255diff --git a/include/linux/utsname.h b/include/linux/utsname.h
101256index 5093f58..c103e58 100644
101257--- a/include/linux/utsname.h
101258+++ b/include/linux/utsname.h
101259@@ -25,7 +25,7 @@ struct uts_namespace {
101260 struct new_utsname name;
101261 struct user_namespace *user_ns;
101262 struct ns_common ns;
101263-};
101264+} __randomize_layout;
101265 extern struct uts_namespace init_uts_ns;
101266
101267 #ifdef CONFIG_UTS_NS
101268diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
101269index 6f8fbcf..4efc177 100644
101270--- a/include/linux/vermagic.h
101271+++ b/include/linux/vermagic.h
101272@@ -25,9 +25,42 @@
101273 #define MODULE_ARCH_VERMAGIC ""
101274 #endif
101275
101276+#ifdef CONFIG_PAX_REFCOUNT
101277+#define MODULE_PAX_REFCOUNT "REFCOUNT "
101278+#else
101279+#define MODULE_PAX_REFCOUNT ""
101280+#endif
101281+
101282+#ifdef CONSTIFY_PLUGIN
101283+#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
101284+#else
101285+#define MODULE_CONSTIFY_PLUGIN ""
101286+#endif
101287+
101288+#ifdef STACKLEAK_PLUGIN
101289+#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
101290+#else
101291+#define MODULE_STACKLEAK_PLUGIN ""
101292+#endif
101293+
101294+#ifdef RANDSTRUCT_PLUGIN
101295+#include <generated/randomize_layout_hash.h>
101296+#define MODULE_RANDSTRUCT_PLUGIN "RANDSTRUCT_PLUGIN_" RANDSTRUCT_HASHED_SEED
101297+#else
101298+#define MODULE_RANDSTRUCT_PLUGIN
101299+#endif
101300+
101301+#ifdef CONFIG_GRKERNSEC
101302+#define MODULE_GRSEC "GRSEC "
101303+#else
101304+#define MODULE_GRSEC ""
101305+#endif
101306+
101307 #define VERMAGIC_STRING \
101308 UTS_RELEASE " " \
101309 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
101310 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
101311- MODULE_ARCH_VERMAGIC
101312+ MODULE_ARCH_VERMAGIC \
101313+ MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
101314+ MODULE_GRSEC MODULE_RANDSTRUCT_PLUGIN
101315
101316diff --git a/include/linux/vga_switcheroo.h b/include/linux/vga_switcheroo.h
101317index b483abd..af305ad 100644
101318--- a/include/linux/vga_switcheroo.h
101319+++ b/include/linux/vga_switcheroo.h
101320@@ -63,9 +63,9 @@ int vga_switcheroo_get_client_state(struct pci_dev *dev);
101321
101322 void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic);
101323
101324-int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain);
101325+int vga_switcheroo_init_domain_pm_ops(struct device *dev, dev_pm_domain_no_const *domain);
101326 void vga_switcheroo_fini_domain_pm_ops(struct device *dev);
101327-int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain);
101328+int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, dev_pm_domain_no_const *domain);
101329 #else
101330
101331 static inline void vga_switcheroo_unregister_client(struct pci_dev *dev) {}
101332@@ -82,9 +82,9 @@ static inline int vga_switcheroo_get_client_state(struct pci_dev *dev) { return
101333
101334 static inline void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic) {}
101335
101336-static inline int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain) { return -EINVAL; }
101337+static inline int vga_switcheroo_init_domain_pm_ops(struct device *dev, dev_pm_domain_no_const *domain) { return -EINVAL; }
101338 static inline void vga_switcheroo_fini_domain_pm_ops(struct device *dev) {}
101339-static inline int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain) { return -EINVAL; }
101340+static inline int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, dev_pm_domain_no_const *domain) { return -EINVAL; }
101341
101342 #endif
101343 #endif /* _LINUX_VGA_SWITCHEROO_H_ */
101344diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
101345index 0ec5983..cc61051 100644
101346--- a/include/linux/vmalloc.h
101347+++ b/include/linux/vmalloc.h
101348@@ -18,6 +18,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
101349 #define VM_UNINITIALIZED 0x00000020 /* vm_struct is not fully initialized */
101350 #define VM_NO_GUARD 0x00000040 /* don't add guard page */
101351 #define VM_KASAN 0x00000080 /* has allocated kasan shadow memory */
101352+
101353+#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
101354+#define VM_KERNEXEC 0x00000100 /* allocate from executable kernel memory range */
101355+#endif
101356+
101357 /* bits [20..32] reserved for arch specific ioremap internals */
101358
101359 /*
101360@@ -86,6 +91,10 @@ extern void *vmap(struct page **pages, unsigned int count,
101361 unsigned long flags, pgprot_t prot);
101362 extern void vunmap(const void *addr);
101363
101364+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
101365+extern void unmap_process_stacks(struct task_struct *task);
101366+#endif
101367+
101368 extern int remap_vmalloc_range_partial(struct vm_area_struct *vma,
101369 unsigned long uaddr, void *kaddr,
101370 unsigned long size);
101371@@ -150,7 +159,7 @@ extern void free_vm_area(struct vm_struct *area);
101372
101373 /* for /dev/kmem */
101374 extern long vread(char *buf, char *addr, unsigned long count);
101375-extern long vwrite(char *buf, char *addr, unsigned long count);
101376+extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
101377
101378 /*
101379 * Internals. Dont't use..
101380diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
101381index 82e7db7..f8ce3d0 100644
101382--- a/include/linux/vmstat.h
101383+++ b/include/linux/vmstat.h
101384@@ -108,18 +108,18 @@ static inline void vm_events_fold_cpu(int cpu)
101385 /*
101386 * Zone based page accounting with per cpu differentials.
101387 */
101388-extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
101389+extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
101390
101391 static inline void zone_page_state_add(long x, struct zone *zone,
101392 enum zone_stat_item item)
101393 {
101394- atomic_long_add(x, &zone->vm_stat[item]);
101395- atomic_long_add(x, &vm_stat[item]);
101396+ atomic_long_add_unchecked(x, &zone->vm_stat[item]);
101397+ atomic_long_add_unchecked(x, &vm_stat[item]);
101398 }
101399
101400-static inline unsigned long global_page_state(enum zone_stat_item item)
101401+static inline unsigned long __intentional_overflow(-1) global_page_state(enum zone_stat_item item)
101402 {
101403- long x = atomic_long_read(&vm_stat[item]);
101404+ long x = atomic_long_read_unchecked(&vm_stat[item]);
101405 #ifdef CONFIG_SMP
101406 if (x < 0)
101407 x = 0;
101408@@ -127,10 +127,10 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
101409 return x;
101410 }
101411
101412-static inline unsigned long zone_page_state(struct zone *zone,
101413+static inline unsigned long __intentional_overflow(-1) zone_page_state(struct zone *zone,
101414 enum zone_stat_item item)
101415 {
101416- long x = atomic_long_read(&zone->vm_stat[item]);
101417+ long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
101418 #ifdef CONFIG_SMP
101419 if (x < 0)
101420 x = 0;
101421@@ -147,7 +147,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
101422 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
101423 enum zone_stat_item item)
101424 {
101425- long x = atomic_long_read(&zone->vm_stat[item]);
101426+ long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
101427
101428 #ifdef CONFIG_SMP
101429 int cpu;
101430@@ -234,14 +234,14 @@ static inline void __mod_zone_page_state(struct zone *zone,
101431
101432 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
101433 {
101434- atomic_long_inc(&zone->vm_stat[item]);
101435- atomic_long_inc(&vm_stat[item]);
101436+ atomic_long_inc_unchecked(&zone->vm_stat[item]);
101437+ atomic_long_inc_unchecked(&vm_stat[item]);
101438 }
101439
101440 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
101441 {
101442- atomic_long_dec(&zone->vm_stat[item]);
101443- atomic_long_dec(&vm_stat[item]);
101444+ atomic_long_dec_unchecked(&zone->vm_stat[item]);
101445+ atomic_long_dec_unchecked(&vm_stat[item]);
101446 }
101447
101448 static inline void __inc_zone_page_state(struct page *page,
101449diff --git a/include/linux/xattr.h b/include/linux/xattr.h
101450index 91b0a68..0e9adf6 100644
101451--- a/include/linux/xattr.h
101452+++ b/include/linux/xattr.h
101453@@ -28,7 +28,7 @@ struct xattr_handler {
101454 size_t size, int handler_flags);
101455 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
101456 size_t size, int flags, int handler_flags);
101457-};
101458+} __do_const;
101459
101460 struct xattr {
101461 const char *name;
101462@@ -37,6 +37,9 @@ struct xattr {
101463 };
101464
101465 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
101466+#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
101467+ssize_t pax_getxattr(struct dentry *, void *, size_t);
101468+#endif
101469 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
101470 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
101471 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
101472diff --git a/include/linux/zlib.h b/include/linux/zlib.h
101473index 92dbbd3..13ab0b3 100644
101474--- a/include/linux/zlib.h
101475+++ b/include/linux/zlib.h
101476@@ -31,6 +31,7 @@
101477 #define _ZLIB_H
101478
101479 #include <linux/zconf.h>
101480+#include <linux/compiler.h>
101481
101482 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
101483 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
101484@@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
101485
101486 /* basic functions */
101487
101488-extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
101489+extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
101490 /*
101491 Returns the number of bytes that needs to be allocated for a per-
101492 stream workspace with the specified parameters. A pointer to this
101493diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
101494index acbcd2f..c3abe84 100644
101495--- a/include/media/v4l2-dev.h
101496+++ b/include/media/v4l2-dev.h
101497@@ -74,7 +74,7 @@ struct v4l2_file_operations {
101498 int (*mmap) (struct file *, struct vm_area_struct *);
101499 int (*open) (struct file *);
101500 int (*release) (struct file *);
101501-};
101502+} __do_const;
101503
101504 /*
101505 * Newer version of video_device, handled by videodev2.c
101506diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
101507index 9c58157..d86ebf5 100644
101508--- a/include/media/v4l2-device.h
101509+++ b/include/media/v4l2-device.h
101510@@ -93,7 +93,7 @@ int __must_check v4l2_device_register(struct device *dev, struct v4l2_device *v4
101511 this function returns 0. If the name ends with a digit (e.g. cx18),
101512 then the name will be set to cx18-0 since cx180 looks really odd. */
101513 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
101514- atomic_t *instance);
101515+ atomic_unchecked_t *instance);
101516
101517 /* Set v4l2_dev->dev to NULL. Call when the USB parent disconnects.
101518 Since the parent disappears this ensures that v4l2_dev doesn't have an
101519diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
101520index 5122b5e..598b440 100644
101521--- a/include/net/9p/transport.h
101522+++ b/include/net/9p/transport.h
101523@@ -62,7 +62,7 @@ struct p9_trans_module {
101524 int (*cancelled)(struct p9_client *, struct p9_req_t *req);
101525 int (*zc_request)(struct p9_client *, struct p9_req_t *,
101526 struct iov_iter *, struct iov_iter *, int , int, int);
101527-};
101528+} __do_const;
101529
101530 void v9fs_register_trans(struct p9_trans_module *m);
101531 void v9fs_unregister_trans(struct p9_trans_module *m);
101532diff --git a/include/net/af_unix.h b/include/net/af_unix.h
101533index a175ba4..196eb8242 100644
101534--- a/include/net/af_unix.h
101535+++ b/include/net/af_unix.h
101536@@ -36,7 +36,7 @@ struct unix_skb_parms {
101537 u32 secid; /* Security ID */
101538 #endif
101539 u32 consumed;
101540-};
101541+} __randomize_layout;
101542
101543 #define UNIXCB(skb) (*(struct unix_skb_parms *)&((skb)->cb))
101544 #define UNIXSID(skb) (&UNIXCB((skb)).secid)
101545diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
101546index 2239a37..a83461f 100644
101547--- a/include/net/bluetooth/l2cap.h
101548+++ b/include/net/bluetooth/l2cap.h
101549@@ -609,7 +609,7 @@ struct l2cap_ops {
101550 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
101551 unsigned long hdr_len,
101552 unsigned long len, int nb);
101553-};
101554+} __do_const;
101555
101556 struct l2cap_conn {
101557 struct hci_conn *hcon;
101558diff --git a/include/net/bonding.h b/include/net/bonding.h
101559index 78ed135..2f53667 100644
101560--- a/include/net/bonding.h
101561+++ b/include/net/bonding.h
101562@@ -658,7 +658,7 @@ extern struct rtnl_link_ops bond_link_ops;
101563
101564 static inline void bond_tx_drop(struct net_device *dev, struct sk_buff *skb)
101565 {
101566- atomic_long_inc(&dev->tx_dropped);
101567+ atomic_long_inc_unchecked(&dev->tx_dropped);
101568 dev_kfree_skb_any(skb);
101569 }
101570
101571diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
101572index f2ae33d..c457cf0 100644
101573--- a/include/net/caif/cfctrl.h
101574+++ b/include/net/caif/cfctrl.h
101575@@ -52,7 +52,7 @@ struct cfctrl_rsp {
101576 void (*radioset_rsp)(void);
101577 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
101578 struct cflayer *client_layer);
101579-};
101580+} __no_const;
101581
101582 /* Link Setup Parameters for CAIF-Links. */
101583 struct cfctrl_link_param {
101584@@ -101,8 +101,8 @@ struct cfctrl_request_info {
101585 struct cfctrl {
101586 struct cfsrvl serv;
101587 struct cfctrl_rsp res;
101588- atomic_t req_seq_no;
101589- atomic_t rsp_seq_no;
101590+ atomic_unchecked_t req_seq_no;
101591+ atomic_unchecked_t rsp_seq_no;
101592 struct list_head list;
101593 /* Protects from simultaneous access to first_req list */
101594 spinlock_t info_list_lock;
101595diff --git a/include/net/flow.h b/include/net/flow.h
101596index 8109a15..504466d 100644
101597--- a/include/net/flow.h
101598+++ b/include/net/flow.h
101599@@ -231,6 +231,6 @@ void flow_cache_fini(struct net *net);
101600
101601 void flow_cache_flush(struct net *net);
101602 void flow_cache_flush_deferred(struct net *net);
101603-extern atomic_t flow_cache_genid;
101604+extern atomic_unchecked_t flow_cache_genid;
101605
101606 #endif
101607diff --git a/include/net/genetlink.h b/include/net/genetlink.h
101608index a9af1cc..1f3fa7b 100644
101609--- a/include/net/genetlink.h
101610+++ b/include/net/genetlink.h
101611@@ -128,7 +128,7 @@ struct genl_ops {
101612 u8 cmd;
101613 u8 internal_flags;
101614 u8 flags;
101615-};
101616+} __do_const;
101617
101618 int __genl_register_family(struct genl_family *family);
101619
101620diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
101621index 0f712c0..cd762c4 100644
101622--- a/include/net/gro_cells.h
101623+++ b/include/net/gro_cells.h
101624@@ -27,7 +27,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
101625 cell = this_cpu_ptr(gcells->cells);
101626
101627 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
101628- atomic_long_inc(&dev->rx_dropped);
101629+ atomic_long_inc_unchecked(&dev->rx_dropped);
101630 kfree_skb(skb);
101631 return;
101632 }
101633diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
101634index 0320bbb..938789c 100644
101635--- a/include/net/inet_connection_sock.h
101636+++ b/include/net/inet_connection_sock.h
101637@@ -63,7 +63,7 @@ struct inet_connection_sock_af_ops {
101638 int (*bind_conflict)(const struct sock *sk,
101639 const struct inet_bind_bucket *tb, bool relax);
101640 void (*mtu_reduced)(struct sock *sk);
101641-};
101642+} __do_const;
101643
101644 /** inet_connection_sock - INET connection oriented sock
101645 *
101646diff --git a/include/net/inet_frag.h b/include/net/inet_frag.h
101647index 8d17655..2f3246d 100644
101648--- a/include/net/inet_frag.h
101649+++ b/include/net/inet_frag.h
101650@@ -21,13 +21,11 @@ struct netns_frags {
101651 * @INET_FRAG_FIRST_IN: first fragment has arrived
101652 * @INET_FRAG_LAST_IN: final fragment has arrived
101653 * @INET_FRAG_COMPLETE: frag queue has been processed and is due for destruction
101654- * @INET_FRAG_EVICTED: frag queue is being evicted
101655 */
101656 enum {
101657 INET_FRAG_FIRST_IN = BIT(0),
101658 INET_FRAG_LAST_IN = BIT(1),
101659 INET_FRAG_COMPLETE = BIT(2),
101660- INET_FRAG_EVICTED = BIT(3)
101661 };
101662
101663 /**
101664@@ -45,6 +43,7 @@ enum {
101665 * @flags: fragment queue flags
101666 * @max_size: (ipv4 only) maximum received fragment size with IP_DF set
101667 * @net: namespace that this frag belongs to
101668+ * @list_evictor: list of queues to forcefully evict (e.g. due to low memory)
101669 */
101670 struct inet_frag_queue {
101671 spinlock_t lock;
101672@@ -59,6 +58,7 @@ struct inet_frag_queue {
101673 __u8 flags;
101674 u16 max_size;
101675 struct netns_frags *net;
101676+ struct hlist_node list_evictor;
101677 };
101678
101679 #define INETFRAGS_HASHSZ 1024
101680@@ -125,6 +125,11 @@ static inline void inet_frag_put(struct inet_frag_queue *q, struct inet_frags *f
101681 inet_frag_destroy(q, f);
101682 }
101683
101684+static inline bool inet_frag_evicting(struct inet_frag_queue *q)
101685+{
101686+ return !hlist_unhashed(&q->list_evictor);
101687+}
101688+
101689 /* Memory Tracking Functions. */
101690
101691 /* The default percpu_counter batch size is not big enough to scale to
101692@@ -139,14 +144,14 @@ static inline int frag_mem_limit(struct netns_frags *nf)
101693 return percpu_counter_read(&nf->mem);
101694 }
101695
101696-static inline void sub_frag_mem_limit(struct inet_frag_queue *q, int i)
101697+static inline void sub_frag_mem_limit(struct netns_frags *nf, int i)
101698 {
101699- __percpu_counter_add(&q->net->mem, -i, frag_percpu_counter_batch);
101700+ __percpu_counter_add(&nf->mem, -i, frag_percpu_counter_batch);
101701 }
101702
101703-static inline void add_frag_mem_limit(struct inet_frag_queue *q, int i)
101704+static inline void add_frag_mem_limit(struct netns_frags *nf, int i)
101705 {
101706- __percpu_counter_add(&q->net->mem, i, frag_percpu_counter_batch);
101707+ __percpu_counter_add(&nf->mem, i, frag_percpu_counter_batch);
101708 }
101709
101710 static inline void init_frag_mem_limit(struct netns_frags *nf)
101711diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
101712index d5332dd..10a5c3c 100644
101713--- a/include/net/inetpeer.h
101714+++ b/include/net/inetpeer.h
101715@@ -48,7 +48,7 @@ struct inet_peer {
101716 */
101717 union {
101718 struct {
101719- atomic_t rid; /* Frag reception counter */
101720+ atomic_unchecked_t rid; /* Frag reception counter */
101721 };
101722 struct rcu_head rcu;
101723 struct inet_peer *gc_next;
101724diff --git a/include/net/ip.h b/include/net/ip.h
101725index d14af7e..52816c2 100644
101726--- a/include/net/ip.h
101727+++ b/include/net/ip.h
101728@@ -318,7 +318,7 @@ static inline unsigned int ip_skb_dst_mtu(const struct sk_buff *skb)
101729 }
101730 }
101731
101732-u32 ip_idents_reserve(u32 hash, int segs);
101733+u32 ip_idents_reserve(u32 hash, int segs) __intentional_overflow(-1);
101734 void __ip_select_ident(struct net *net, struct iphdr *iph, int segs);
101735
101736 static inline void ip_select_ident_segs(struct net *net, struct sk_buff *skb,
101737diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
101738index 54271ed..eb7e0e6 100644
101739--- a/include/net/ip_fib.h
101740+++ b/include/net/ip_fib.h
101741@@ -170,7 +170,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
101742
101743 #define FIB_RES_SADDR(net, res) \
101744 ((FIB_RES_NH(res).nh_saddr_genid == \
101745- atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
101746+ atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
101747 FIB_RES_NH(res).nh_saddr : \
101748 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
101749 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
101750diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
101751index 4e3731e..a242e28 100644
101752--- a/include/net/ip_vs.h
101753+++ b/include/net/ip_vs.h
101754@@ -551,7 +551,7 @@ struct ip_vs_conn {
101755 struct ip_vs_conn *control; /* Master control connection */
101756 atomic_t n_control; /* Number of controlled ones */
101757 struct ip_vs_dest *dest; /* real server */
101758- atomic_t in_pkts; /* incoming packet counter */
101759+ atomic_unchecked_t in_pkts; /* incoming packet counter */
101760
101761 /* Packet transmitter for different forwarding methods. If it
101762 * mangles the packet, it must return NF_DROP or better NF_STOLEN,
101763@@ -699,7 +699,7 @@ struct ip_vs_dest {
101764 __be16 port; /* port number of the server */
101765 union nf_inet_addr addr; /* IP address of the server */
101766 volatile unsigned int flags; /* dest status flags */
101767- atomic_t conn_flags; /* flags to copy to conn */
101768+ atomic_unchecked_t conn_flags; /* flags to copy to conn */
101769 atomic_t weight; /* server weight */
101770
101771 atomic_t refcnt; /* reference counter */
101772@@ -946,11 +946,11 @@ struct netns_ipvs {
101773 /* ip_vs_lblc */
101774 int sysctl_lblc_expiration;
101775 struct ctl_table_header *lblc_ctl_header;
101776- struct ctl_table *lblc_ctl_table;
101777+ ctl_table_no_const *lblc_ctl_table;
101778 /* ip_vs_lblcr */
101779 int sysctl_lblcr_expiration;
101780 struct ctl_table_header *lblcr_ctl_header;
101781- struct ctl_table *lblcr_ctl_table;
101782+ ctl_table_no_const *lblcr_ctl_table;
101783 /* ip_vs_est */
101784 struct list_head est_list; /* estimator list */
101785 spinlock_t est_lock;
101786diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
101787index 8d4f588..2e37ad2 100644
101788--- a/include/net/irda/ircomm_tty.h
101789+++ b/include/net/irda/ircomm_tty.h
101790@@ -33,6 +33,7 @@
101791 #include <linux/termios.h>
101792 #include <linux/timer.h>
101793 #include <linux/tty.h> /* struct tty_struct */
101794+#include <asm/local.h>
101795
101796 #include <net/irda/irias_object.h>
101797 #include <net/irda/ircomm_core.h>
101798diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
101799index 714cc9a..ea05f3e 100644
101800--- a/include/net/iucv/af_iucv.h
101801+++ b/include/net/iucv/af_iucv.h
101802@@ -149,7 +149,7 @@ struct iucv_skb_cb {
101803 struct iucv_sock_list {
101804 struct hlist_head head;
101805 rwlock_t lock;
101806- atomic_t autobind_name;
101807+ atomic_unchecked_t autobind_name;
101808 };
101809
101810 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
101811diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
101812index f3be818..bf46196 100644
101813--- a/include/net/llc_c_ac.h
101814+++ b/include/net/llc_c_ac.h
101815@@ -87,7 +87,7 @@
101816 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
101817 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
101818
101819-typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
101820+typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
101821
101822 int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
101823 int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
101824diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
101825index 3948cf1..83b28c4 100644
101826--- a/include/net/llc_c_ev.h
101827+++ b/include/net/llc_c_ev.h
101828@@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
101829 return (struct llc_conn_state_ev *)skb->cb;
101830 }
101831
101832-typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
101833-typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
101834+typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
101835+typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
101836
101837 int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
101838 int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
101839diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
101840index 48f3f89..0e92c50 100644
101841--- a/include/net/llc_c_st.h
101842+++ b/include/net/llc_c_st.h
101843@@ -37,7 +37,7 @@ struct llc_conn_state_trans {
101844 u8 next_state;
101845 const llc_conn_ev_qfyr_t *ev_qualifiers;
101846 const llc_conn_action_t *ev_actions;
101847-};
101848+} __do_const;
101849
101850 struct llc_conn_state {
101851 u8 current_state;
101852diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
101853index a61b98c..aade1eb 100644
101854--- a/include/net/llc_s_ac.h
101855+++ b/include/net/llc_s_ac.h
101856@@ -23,7 +23,7 @@
101857 #define SAP_ACT_TEST_IND 9
101858
101859 /* All action functions must look like this */
101860-typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
101861+typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
101862
101863 int llc_sap_action_unitdata_ind(struct llc_sap *sap, struct sk_buff *skb);
101864 int llc_sap_action_send_ui(struct llc_sap *sap, struct sk_buff *skb);
101865diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
101866index c4359e2..76dbc4a 100644
101867--- a/include/net/llc_s_st.h
101868+++ b/include/net/llc_s_st.h
101869@@ -20,7 +20,7 @@ struct llc_sap_state_trans {
101870 llc_sap_ev_t ev;
101871 u8 next_state;
101872 const llc_sap_action_t *ev_actions;
101873-};
101874+} __do_const;
101875
101876 struct llc_sap_state {
101877 u8 curr_state;
101878diff --git a/include/net/mac80211.h b/include/net/mac80211.h
101879index fc57f6b..9c1fdb2 100644
101880--- a/include/net/mac80211.h
101881+++ b/include/net/mac80211.h
101882@@ -5104,7 +5104,7 @@ struct rate_control_ops {
101883 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
101884
101885 u32 (*get_expected_throughput)(void *priv_sta);
101886-};
101887+} __do_const;
101888
101889 static inline int rate_supported(struct ieee80211_sta *sta,
101890 enum ieee80211_band band,
101891diff --git a/include/net/neighbour.h b/include/net/neighbour.h
101892index bd33e66..6508d00 100644
101893--- a/include/net/neighbour.h
101894+++ b/include/net/neighbour.h
101895@@ -162,7 +162,7 @@ struct neigh_ops {
101896 void (*error_report)(struct neighbour *, struct sk_buff *);
101897 int (*output)(struct neighbour *, struct sk_buff *);
101898 int (*connected_output)(struct neighbour *, struct sk_buff *);
101899-};
101900+} __do_const;
101901
101902 struct pneigh_entry {
101903 struct pneigh_entry *next;
101904@@ -216,7 +216,7 @@ struct neigh_table {
101905 struct neigh_statistics __percpu *stats;
101906 struct neigh_hash_table __rcu *nht;
101907 struct pneigh_entry **phash_buckets;
101908-};
101909+} __randomize_layout;
101910
101911 enum {
101912 NEIGH_ARP_TABLE = 0,
101913diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
101914index f733656..54053db 100644
101915--- a/include/net/net_namespace.h
101916+++ b/include/net/net_namespace.h
101917@@ -132,8 +132,8 @@ struct net {
101918 struct netns_mpls mpls;
101919 #endif
101920 struct sock *diag_nlsk;
101921- atomic_t fnhe_genid;
101922-};
101923+ atomic_unchecked_t fnhe_genid;
101924+} __randomize_layout;
101925
101926 #include <linux/seq_file_net.h>
101927
101928@@ -268,7 +268,11 @@ static inline struct net *read_pnet(const possible_net_t *pnet)
101929 #define __net_init __init
101930 #define __net_exit __exit_refok
101931 #define __net_initdata __initdata
101932+#ifdef CONSTIFY_PLUGIN
101933 #define __net_initconst __initconst
101934+#else
101935+#define __net_initconst __initdata
101936+#endif
101937 #endif
101938
101939 int peernet2id(struct net *net, struct net *peer);
101940@@ -281,7 +285,7 @@ struct pernet_operations {
101941 void (*exit_batch)(struct list_head *net_exit_list);
101942 int *id;
101943 size_t size;
101944-};
101945+} __do_const;
101946
101947 /*
101948 * Use these carefully. If you implement a network device and it
101949@@ -329,12 +333,12 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
101950
101951 static inline int rt_genid_ipv4(struct net *net)
101952 {
101953- return atomic_read(&net->ipv4.rt_genid);
101954+ return atomic_read_unchecked(&net->ipv4.rt_genid);
101955 }
101956
101957 static inline void rt_genid_bump_ipv4(struct net *net)
101958 {
101959- atomic_inc(&net->ipv4.rt_genid);
101960+ atomic_inc_unchecked(&net->ipv4.rt_genid);
101961 }
101962
101963 extern void (*__fib6_flush_trees)(struct net *net);
101964@@ -361,12 +365,12 @@ static inline void rt_genid_bump_all(struct net *net)
101965
101966 static inline int fnhe_genid(struct net *net)
101967 {
101968- return atomic_read(&net->fnhe_genid);
101969+ return atomic_read_unchecked(&net->fnhe_genid);
101970 }
101971
101972 static inline void fnhe_genid_bump(struct net *net)
101973 {
101974- atomic_inc(&net->fnhe_genid);
101975+ atomic_inc_unchecked(&net->fnhe_genid);
101976 }
101977
101978 #endif /* __NET_NET_NAMESPACE_H */
101979diff --git a/include/net/netlink.h b/include/net/netlink.h
101980index 2a5dbcc..8243656 100644
101981--- a/include/net/netlink.h
101982+++ b/include/net/netlink.h
101983@@ -521,7 +521,7 @@ static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
101984 {
101985 if (mark) {
101986 WARN_ON((unsigned char *) mark < skb->data);
101987- skb_trim(skb, (unsigned char *) mark - skb->data);
101988+ skb_trim(skb, (const unsigned char *) mark - skb->data);
101989 }
101990 }
101991
101992diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
101993index 29d6a94..235d3d84 100644
101994--- a/include/net/netns/conntrack.h
101995+++ b/include/net/netns/conntrack.h
101996@@ -14,10 +14,10 @@ struct nf_conntrack_ecache;
101997 struct nf_proto_net {
101998 #ifdef CONFIG_SYSCTL
101999 struct ctl_table_header *ctl_table_header;
102000- struct ctl_table *ctl_table;
102001+ ctl_table_no_const *ctl_table;
102002 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
102003 struct ctl_table_header *ctl_compat_header;
102004- struct ctl_table *ctl_compat_table;
102005+ ctl_table_no_const *ctl_compat_table;
102006 #endif
102007 #endif
102008 unsigned int users;
102009@@ -60,7 +60,7 @@ struct nf_ip_net {
102010 struct nf_icmp_net icmpv6;
102011 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
102012 struct ctl_table_header *ctl_table_header;
102013- struct ctl_table *ctl_table;
102014+ ctl_table_no_const *ctl_table;
102015 #endif
102016 };
102017
102018diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
102019index 614a49b..0b94386 100644
102020--- a/include/net/netns/ipv4.h
102021+++ b/include/net/netns/ipv4.h
102022@@ -90,7 +90,7 @@ struct netns_ipv4 {
102023
102024 struct ping_group_range ping_group_range;
102025
102026- atomic_t dev_addr_genid;
102027+ atomic_unchecked_t dev_addr_genid;
102028
102029 #ifdef CONFIG_SYSCTL
102030 unsigned long *sysctl_local_reserved_ports;
102031@@ -104,6 +104,6 @@ struct netns_ipv4 {
102032 struct fib_rules_ops *mr_rules_ops;
102033 #endif
102034 #endif
102035- atomic_t rt_genid;
102036+ atomic_unchecked_t rt_genid;
102037 };
102038 #endif
102039diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
102040index d2527bf..2c802d5 100644
102041--- a/include/net/netns/ipv6.h
102042+++ b/include/net/netns/ipv6.h
102043@@ -78,8 +78,8 @@ struct netns_ipv6 {
102044 struct fib_rules_ops *mr6_rules_ops;
102045 #endif
102046 #endif
102047- atomic_t dev_addr_genid;
102048- atomic_t fib6_sernum;
102049+ atomic_unchecked_t dev_addr_genid;
102050+ atomic_unchecked_t fib6_sernum;
102051 };
102052
102053 #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
102054diff --git a/include/net/netns/xfrm.h b/include/net/netns/xfrm.h
102055index 730d82a..045f2c4 100644
102056--- a/include/net/netns/xfrm.h
102057+++ b/include/net/netns/xfrm.h
102058@@ -78,7 +78,7 @@ struct netns_xfrm {
102059
102060 /* flow cache part */
102061 struct flow_cache flow_cache_global;
102062- atomic_t flow_cache_genid;
102063+ atomic_unchecked_t flow_cache_genid;
102064 struct list_head flow_cache_gc_list;
102065 spinlock_t flow_cache_gc_lock;
102066 struct work_struct flow_cache_gc_work;
102067diff --git a/include/net/ping.h b/include/net/ping.h
102068index ac80cb4..ec1ed09 100644
102069--- a/include/net/ping.h
102070+++ b/include/net/ping.h
102071@@ -54,7 +54,7 @@ struct ping_iter_state {
102072
102073 extern struct proto ping_prot;
102074 #if IS_ENABLED(CONFIG_IPV6)
102075-extern struct pingv6_ops pingv6_ops;
102076+extern struct pingv6_ops *pingv6_ops;
102077 #endif
102078
102079 struct pingfakehdr {
102080diff --git a/include/net/protocol.h b/include/net/protocol.h
102081index d6fcc1f..ca277058 100644
102082--- a/include/net/protocol.h
102083+++ b/include/net/protocol.h
102084@@ -49,7 +49,7 @@ struct net_protocol {
102085 * socket lookup?
102086 */
102087 icmp_strict_tag_validation:1;
102088-};
102089+} __do_const;
102090
102091 #if IS_ENABLED(CONFIG_IPV6)
102092 struct inet6_protocol {
102093@@ -62,7 +62,7 @@ struct inet6_protocol {
102094 u8 type, u8 code, int offset,
102095 __be32 info);
102096 unsigned int flags; /* INET6_PROTO_xxx */
102097-};
102098+} __do_const;
102099
102100 #define INET6_PROTO_NOPOLICY 0x1
102101 #define INET6_PROTO_FINAL 0x2
102102diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
102103index 343d922..7959cde 100644
102104--- a/include/net/rtnetlink.h
102105+++ b/include/net/rtnetlink.h
102106@@ -95,7 +95,7 @@ struct rtnl_link_ops {
102107 const struct net_device *dev,
102108 const struct net_device *slave_dev);
102109 struct net *(*get_link_net)(const struct net_device *dev);
102110-};
102111+} __do_const;
102112
102113 int __rtnl_link_register(struct rtnl_link_ops *ops);
102114 void __rtnl_link_unregister(struct rtnl_link_ops *ops);
102115diff --git a/include/net/sctp/checksum.h b/include/net/sctp/checksum.h
102116index 4a5b9a3..ca27d73 100644
102117--- a/include/net/sctp/checksum.h
102118+++ b/include/net/sctp/checksum.h
102119@@ -61,8 +61,8 @@ static inline __le32 sctp_compute_cksum(const struct sk_buff *skb,
102120 unsigned int offset)
102121 {
102122 struct sctphdr *sh = sctp_hdr(skb);
102123- __le32 ret, old = sh->checksum;
102124- const struct skb_checksum_ops ops = {
102125+ __le32 ret, old = sh->checksum;
102126+ static const struct skb_checksum_ops ops = {
102127 .update = sctp_csum_update,
102128 .combine = sctp_csum_combine,
102129 };
102130diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
102131index 487ef34..d457f98 100644
102132--- a/include/net/sctp/sm.h
102133+++ b/include/net/sctp/sm.h
102134@@ -80,7 +80,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
102135 typedef struct {
102136 sctp_state_fn_t *fn;
102137 const char *name;
102138-} sctp_sm_table_entry_t;
102139+} __do_const sctp_sm_table_entry_t;
102140
102141 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
102142 * currently in use.
102143@@ -292,7 +292,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
102144 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
102145
102146 /* Extern declarations for major data structures. */
102147-extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
102148+extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
102149
102150
102151 /* Get the size of a DATA chunk payload. */
102152diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
102153index 495c87e..5b327ff 100644
102154--- a/include/net/sctp/structs.h
102155+++ b/include/net/sctp/structs.h
102156@@ -513,7 +513,7 @@ struct sctp_pf {
102157 void (*to_sk_saddr)(union sctp_addr *, struct sock *sk);
102158 void (*to_sk_daddr)(union sctp_addr *, struct sock *sk);
102159 struct sctp_af *af;
102160-};
102161+} __do_const;
102162
102163
102164 /* Structure to track chunk fragments that have been acked, but peer
102165diff --git a/include/net/sock.h b/include/net/sock.h
102166index 3a4898e..67456ac 100644
102167--- a/include/net/sock.h
102168+++ b/include/net/sock.h
102169@@ -363,7 +363,7 @@ struct sock {
102170 unsigned int sk_napi_id;
102171 unsigned int sk_ll_usec;
102172 #endif
102173- atomic_t sk_drops;
102174+ atomic_unchecked_t sk_drops;
102175 int sk_rcvbuf;
102176
102177 struct sk_filter __rcu *sk_filter;
102178@@ -1039,7 +1039,7 @@ struct proto {
102179 void (*destroy_cgroup)(struct mem_cgroup *memcg);
102180 struct cg_proto *(*proto_cgroup)(struct mem_cgroup *memcg);
102181 #endif
102182-};
102183+} __randomize_layout;
102184
102185 /*
102186 * Bits in struct cg_proto.flags
102187@@ -1212,7 +1212,7 @@ static inline void memcg_memory_allocated_sub(struct cg_proto *prot,
102188 page_counter_uncharge(&prot->memory_allocated, amt);
102189 }
102190
102191-static inline long
102192+static inline long __intentional_overflow(-1)
102193 sk_memory_allocated(const struct sock *sk)
102194 {
102195 struct proto *prot = sk->sk_prot;
102196@@ -1777,7 +1777,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
102197 }
102198
102199 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
102200- struct iov_iter *from, char *to,
102201+ struct iov_iter *from, unsigned char *to,
102202 int copy, int offset)
102203 {
102204 if (skb->ip_summed == CHECKSUM_NONE) {
102205@@ -2024,7 +2024,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
102206 }
102207 }
102208
102209-struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
102210+struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
102211
102212 /**
102213 * sk_page_frag - return an appropriate page_frag
102214@@ -2099,7 +2099,7 @@ struct sock_skb_cb {
102215 static inline void
102216 sock_skb_set_dropcount(const struct sock *sk, struct sk_buff *skb)
102217 {
102218- SOCK_SKB_CB(skb)->dropcount = atomic_read(&sk->sk_drops);
102219+ SOCK_SKB_CB(skb)->dropcount = atomic_read_unchecked(&sk->sk_drops);
102220 }
102221
102222 void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk,
102223diff --git a/include/net/tcp.h b/include/net/tcp.h
102224index 6d204f3..d5a8ff0 100644
102225--- a/include/net/tcp.h
102226+++ b/include/net/tcp.h
102227@@ -523,7 +523,7 @@ void tcp_retransmit_timer(struct sock *sk);
102228 void tcp_xmit_retransmit_queue(struct sock *);
102229 void tcp_simple_retransmit(struct sock *);
102230 int tcp_trim_head(struct sock *, struct sk_buff *, u32);
102231-int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int, gfp_t);
102232+int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int, gfp_t);
102233
102234 void tcp_send_probe0(struct sock *);
102235 void tcp_send_partial(struct sock *);
102236@@ -699,8 +699,8 @@ static inline u32 tcp_skb_timestamp(const struct sk_buff *skb)
102237 * If this grows please adjust skbuff.h:skbuff->cb[xxx] size appropriately.
102238 */
102239 struct tcp_skb_cb {
102240- __u32 seq; /* Starting sequence number */
102241- __u32 end_seq; /* SEQ + FIN + SYN + datalen */
102242+ __u32 seq __intentional_overflow(0); /* Starting sequence number */
102243+ __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
102244 union {
102245 /* Note : tcp_tw_isn is used in input path only
102246 * (isn chosen by tcp_timewait_state_process())
102247@@ -725,7 +725,7 @@ struct tcp_skb_cb {
102248
102249 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
102250 /* 1 byte hole */
102251- __u32 ack_seq; /* Sequence number ACK'd */
102252+ __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
102253 union {
102254 struct inet_skb_parm h4;
102255 #if IS_ENABLED(CONFIG_IPV6)
102256diff --git a/include/net/xfrm.h b/include/net/xfrm.h
102257index 36ac102..6e8b34b 100644
102258--- a/include/net/xfrm.h
102259+++ b/include/net/xfrm.h
102260@@ -283,7 +283,6 @@ struct xfrm_dst;
102261 struct xfrm_policy_afinfo {
102262 unsigned short family;
102263 struct dst_ops *dst_ops;
102264- void (*garbage_collect)(struct net *net);
102265 struct dst_entry *(*dst_lookup)(struct net *net, int tos,
102266 const xfrm_address_t *saddr,
102267 const xfrm_address_t *daddr);
102268@@ -301,7 +300,7 @@ struct xfrm_policy_afinfo {
102269 struct net_device *dev,
102270 const struct flowi *fl);
102271 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
102272-};
102273+} __do_const;
102274
102275 int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
102276 int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
102277@@ -340,7 +339,7 @@ struct xfrm_state_afinfo {
102278 int (*transport_finish)(struct sk_buff *skb,
102279 int async);
102280 void (*local_error)(struct sk_buff *skb, u32 mtu);
102281-};
102282+} __do_const;
102283
102284 int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
102285 int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
102286@@ -435,7 +434,7 @@ struct xfrm_mode {
102287 struct module *owner;
102288 unsigned int encap;
102289 int flags;
102290-};
102291+} __do_const;
102292
102293 /* Flags for xfrm_mode. */
102294 enum {
102295@@ -530,7 +529,7 @@ struct xfrm_policy {
102296 struct timer_list timer;
102297
102298 struct flow_cache_object flo;
102299- atomic_t genid;
102300+ atomic_unchecked_t genid;
102301 u32 priority;
102302 u32 index;
102303 struct xfrm_mark mark;
102304@@ -1163,6 +1162,7 @@ static inline void xfrm_sk_free_policy(struct sock *sk)
102305 }
102306
102307 void xfrm_garbage_collect(struct net *net);
102308+void xfrm_garbage_collect_deferred(struct net *net);
102309
102310 #else
102311
102312@@ -1201,6 +1201,9 @@ static inline int xfrm6_policy_check_reverse(struct sock *sk, int dir,
102313 static inline void xfrm_garbage_collect(struct net *net)
102314 {
102315 }
102316+static inline void xfrm_garbage_collect_deferred(struct net *net)
102317+{
102318+}
102319 #endif
102320
102321 static __inline__
102322diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
102323index 1017e0b..227aa4d 100644
102324--- a/include/rdma/iw_cm.h
102325+++ b/include/rdma/iw_cm.h
102326@@ -122,7 +122,7 @@ struct iw_cm_verbs {
102327 int backlog);
102328
102329 int (*destroy_listen)(struct iw_cm_id *cm_id);
102330-};
102331+} __no_const;
102332
102333 /**
102334 * iw_create_cm_id - Create an IW CM identifier.
102335diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
102336index 93d14da..734b3d8 100644
102337--- a/include/scsi/libfc.h
102338+++ b/include/scsi/libfc.h
102339@@ -771,6 +771,7 @@ struct libfc_function_template {
102340 */
102341 void (*disc_stop_final) (struct fc_lport *);
102342 };
102343+typedef struct libfc_function_template __no_const libfc_function_template_no_const;
102344
102345 /**
102346 * struct fc_disc - Discovery context
102347@@ -875,7 +876,7 @@ struct fc_lport {
102348 struct fc_vport *vport;
102349
102350 /* Operational Information */
102351- struct libfc_function_template tt;
102352+ libfc_function_template_no_const tt;
102353 u8 link_up;
102354 u8 qfull;
102355 enum fc_lport_state state;
102356diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
102357index a4c9336..d6f8f34 100644
102358--- a/include/scsi/scsi_device.h
102359+++ b/include/scsi/scsi_device.h
102360@@ -185,9 +185,9 @@ struct scsi_device {
102361 unsigned int max_device_blocked; /* what device_blocked counts down from */
102362 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
102363
102364- atomic_t iorequest_cnt;
102365- atomic_t iodone_cnt;
102366- atomic_t ioerr_cnt;
102367+ atomic_unchecked_t iorequest_cnt;
102368+ atomic_unchecked_t iodone_cnt;
102369+ atomic_unchecked_t ioerr_cnt;
102370
102371 struct device sdev_gendev,
102372 sdev_dev;
102373diff --git a/include/scsi/scsi_driver.h b/include/scsi/scsi_driver.h
102374index 891a658..fcd68df 100644
102375--- a/include/scsi/scsi_driver.h
102376+++ b/include/scsi/scsi_driver.h
102377@@ -14,7 +14,7 @@ struct scsi_driver {
102378 void (*rescan)(struct device *);
102379 int (*init_command)(struct scsi_cmnd *);
102380 void (*uninit_command)(struct scsi_cmnd *);
102381- int (*done)(struct scsi_cmnd *);
102382+ unsigned int (*done)(struct scsi_cmnd *);
102383 int (*eh_action)(struct scsi_cmnd *, int);
102384 };
102385 #define to_scsi_driver(drv) \
102386diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
102387index 784bc2c..855a04c 100644
102388--- a/include/scsi/scsi_transport_fc.h
102389+++ b/include/scsi/scsi_transport_fc.h
102390@@ -757,7 +757,8 @@ struct fc_function_template {
102391 unsigned long show_host_system_hostname:1;
102392
102393 unsigned long disable_target_scan:1;
102394-};
102395+} __do_const;
102396+typedef struct fc_function_template __no_const fc_function_template_no_const;
102397
102398
102399 /**
102400diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
102401index fa1d055..3647940 100644
102402--- a/include/sound/compress_driver.h
102403+++ b/include/sound/compress_driver.h
102404@@ -130,7 +130,7 @@ struct snd_compr_ops {
102405 struct snd_compr_caps *caps);
102406 int (*get_codec_caps) (struct snd_compr_stream *stream,
102407 struct snd_compr_codec_caps *codec);
102408-};
102409+} __no_const;
102410
102411 /**
102412 * struct snd_compr: Compressed device
102413diff --git a/include/sound/soc.h b/include/sound/soc.h
102414index f6226914..e919a2e 100644
102415--- a/include/sound/soc.h
102416+++ b/include/sound/soc.h
102417@@ -870,7 +870,7 @@ struct snd_soc_codec_driver {
102418 enum snd_soc_dapm_type, int);
102419
102420 bool ignore_pmdown_time; /* Doesn't benefit from pmdown delay */
102421-};
102422+} __do_const;
102423
102424 /* SoC platform interface */
102425 struct snd_soc_platform_driver {
102426@@ -897,7 +897,7 @@ struct snd_soc_platform_driver {
102427 const struct snd_compr_ops *compr_ops;
102428
102429 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
102430-};
102431+} __do_const;
102432
102433 struct snd_soc_dai_link_component {
102434 const char *name;
102435diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
102436index 480e9f8..2d59c93 100644
102437--- a/include/target/target_core_base.h
102438+++ b/include/target/target_core_base.h
102439@@ -767,7 +767,7 @@ struct se_device {
102440 atomic_long_t write_bytes;
102441 /* Active commands on this virtual SE device */
102442 atomic_t simple_cmds;
102443- atomic_t dev_ordered_id;
102444+ atomic_unchecked_t dev_ordered_id;
102445 atomic_t dev_ordered_sync;
102446 atomic_t dev_qf_count;
102447 int export_count;
102448diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
102449new file mode 100644
102450index 0000000..fb634b7
102451--- /dev/null
102452+++ b/include/trace/events/fs.h
102453@@ -0,0 +1,53 @@
102454+#undef TRACE_SYSTEM
102455+#define TRACE_SYSTEM fs
102456+
102457+#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
102458+#define _TRACE_FS_H
102459+
102460+#include <linux/fs.h>
102461+#include <linux/tracepoint.h>
102462+
102463+TRACE_EVENT(do_sys_open,
102464+
102465+ TP_PROTO(const char *filename, int flags, int mode),
102466+
102467+ TP_ARGS(filename, flags, mode),
102468+
102469+ TP_STRUCT__entry(
102470+ __string( filename, filename )
102471+ __field( int, flags )
102472+ __field( int, mode )
102473+ ),
102474+
102475+ TP_fast_assign(
102476+ __assign_str(filename, filename);
102477+ __entry->flags = flags;
102478+ __entry->mode = mode;
102479+ ),
102480+
102481+ TP_printk("\"%s\" %x %o",
102482+ __get_str(filename), __entry->flags, __entry->mode)
102483+);
102484+
102485+TRACE_EVENT(open_exec,
102486+
102487+ TP_PROTO(const char *filename),
102488+
102489+ TP_ARGS(filename),
102490+
102491+ TP_STRUCT__entry(
102492+ __string( filename, filename )
102493+ ),
102494+
102495+ TP_fast_assign(
102496+ __assign_str(filename, filename);
102497+ ),
102498+
102499+ TP_printk("\"%s\"",
102500+ __get_str(filename))
102501+);
102502+
102503+#endif /* _TRACE_FS_H */
102504+
102505+/* This part must be outside protection */
102506+#include <trace/define_trace.h>
102507diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
102508index ff8f6c0..6b6bae3 100644
102509--- a/include/trace/events/irq.h
102510+++ b/include/trace/events/irq.h
102511@@ -51,7 +51,7 @@ SOFTIRQ_NAME_LIST
102512 */
102513 TRACE_EVENT(irq_handler_entry,
102514
102515- TP_PROTO(int irq, struct irqaction *action),
102516+ TP_PROTO(int irq, const struct irqaction *action),
102517
102518 TP_ARGS(irq, action),
102519
102520@@ -81,7 +81,7 @@ TRACE_EVENT(irq_handler_entry,
102521 */
102522 TRACE_EVENT(irq_handler_exit,
102523
102524- TP_PROTO(int irq, struct irqaction *action, int ret),
102525+ TP_PROTO(int irq, const struct irqaction *action, int ret),
102526
102527 TP_ARGS(irq, action, ret),
102528
102529diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h
102530index 551b673..9c680df 100644
102531--- a/include/uapi/drm/i915_drm.h
102532+++ b/include/uapi/drm/i915_drm.h
102533@@ -350,6 +350,7 @@ typedef struct drm_i915_irq_wait {
102534 #define I915_PARAM_REVISION 32
102535 #define I915_PARAM_SUBSLICE_TOTAL 33
102536 #define I915_PARAM_EU_TOTAL 34
102537+#define I915_PARAM_HAS_LEGACY_CONTEXT 35
102538
102539 typedef struct drm_i915_getparam {
102540 int param;
102541diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
102542index 7caf44c..23c6f27 100644
102543--- a/include/uapi/linux/a.out.h
102544+++ b/include/uapi/linux/a.out.h
102545@@ -39,6 +39,14 @@ enum machine_type {
102546 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
102547 };
102548
102549+/* Constants for the N_FLAGS field */
102550+#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
102551+#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
102552+#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
102553+#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
102554+/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
102555+#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
102556+
102557 #if !defined (N_MAGIC)
102558 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
102559 #endif
102560diff --git a/include/uapi/linux/bcache.h b/include/uapi/linux/bcache.h
102561index 22b6ad3..aeba37e 100644
102562--- a/include/uapi/linux/bcache.h
102563+++ b/include/uapi/linux/bcache.h
102564@@ -5,6 +5,7 @@
102565 * Bcache on disk data structures
102566 */
102567
102568+#include <linux/compiler.h>
102569 #include <asm/types.h>
102570
102571 #define BITMASK(name, type, field, offset, size) \
102572@@ -20,8 +21,8 @@ static inline void SET_##name(type *k, __u64 v) \
102573 /* Btree keys - all units are in sectors */
102574
102575 struct bkey {
102576- __u64 high;
102577- __u64 low;
102578+ __u64 high __intentional_overflow(-1);
102579+ __u64 low __intentional_overflow(-1);
102580 __u64 ptr[];
102581 };
102582
102583diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
102584index d876736..ccce5c0 100644
102585--- a/include/uapi/linux/byteorder/little_endian.h
102586+++ b/include/uapi/linux/byteorder/little_endian.h
102587@@ -42,51 +42,51 @@
102588
102589 static inline __le64 __cpu_to_le64p(const __u64 *p)
102590 {
102591- return (__force __le64)*p;
102592+ return (__force const __le64)*p;
102593 }
102594-static inline __u64 __le64_to_cpup(const __le64 *p)
102595+static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
102596 {
102597- return (__force __u64)*p;
102598+ return (__force const __u64)*p;
102599 }
102600 static inline __le32 __cpu_to_le32p(const __u32 *p)
102601 {
102602- return (__force __le32)*p;
102603+ return (__force const __le32)*p;
102604 }
102605 static inline __u32 __le32_to_cpup(const __le32 *p)
102606 {
102607- return (__force __u32)*p;
102608+ return (__force const __u32)*p;
102609 }
102610 static inline __le16 __cpu_to_le16p(const __u16 *p)
102611 {
102612- return (__force __le16)*p;
102613+ return (__force const __le16)*p;
102614 }
102615 static inline __u16 __le16_to_cpup(const __le16 *p)
102616 {
102617- return (__force __u16)*p;
102618+ return (__force const __u16)*p;
102619 }
102620 static inline __be64 __cpu_to_be64p(const __u64 *p)
102621 {
102622- return (__force __be64)__swab64p(p);
102623+ return (__force const __be64)__swab64p(p);
102624 }
102625 static inline __u64 __be64_to_cpup(const __be64 *p)
102626 {
102627- return __swab64p((__u64 *)p);
102628+ return __swab64p((const __u64 *)p);
102629 }
102630 static inline __be32 __cpu_to_be32p(const __u32 *p)
102631 {
102632- return (__force __be32)__swab32p(p);
102633+ return (__force const __be32)__swab32p(p);
102634 }
102635-static inline __u32 __be32_to_cpup(const __be32 *p)
102636+static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
102637 {
102638- return __swab32p((__u32 *)p);
102639+ return __swab32p((const __u32 *)p);
102640 }
102641 static inline __be16 __cpu_to_be16p(const __u16 *p)
102642 {
102643- return (__force __be16)__swab16p(p);
102644+ return (__force const __be16)__swab16p(p);
102645 }
102646 static inline __u16 __be16_to_cpup(const __be16 *p)
102647 {
102648- return __swab16p((__u16 *)p);
102649+ return __swab16p((const __u16 *)p);
102650 }
102651 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
102652 #define __le64_to_cpus(x) do { (void)(x); } while (0)
102653diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
102654index 71e1d0e..6cc9caf 100644
102655--- a/include/uapi/linux/elf.h
102656+++ b/include/uapi/linux/elf.h
102657@@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
102658 #define PT_GNU_EH_FRAME 0x6474e550
102659
102660 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
102661+#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
102662+
102663+#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
102664+
102665+/* Constants for the e_flags field */
102666+#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
102667+#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
102668+#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
102669+#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
102670+/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
102671+#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
102672
102673 /*
102674 * Extended Numbering
102675@@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
102676 #define DT_DEBUG 21
102677 #define DT_TEXTREL 22
102678 #define DT_JMPREL 23
102679+#define DT_FLAGS 30
102680+ #define DF_TEXTREL 0x00000004
102681 #define DT_ENCODING 32
102682 #define OLD_DT_LOOS 0x60000000
102683 #define DT_LOOS 0x6000000d
102684@@ -240,6 +253,19 @@ typedef struct elf64_hdr {
102685 #define PF_W 0x2
102686 #define PF_X 0x1
102687
102688+#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
102689+#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
102690+#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
102691+#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
102692+#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
102693+#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
102694+/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
102695+/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
102696+#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
102697+#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
102698+#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
102699+#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
102700+
102701 typedef struct elf32_phdr{
102702 Elf32_Word p_type;
102703 Elf32_Off p_offset;
102704@@ -332,6 +358,8 @@ typedef struct elf64_shdr {
102705 #define EI_OSABI 7
102706 #define EI_PAD 8
102707
102708+#define EI_PAX 14
102709+
102710 #define ELFMAG0 0x7f /* EI_MAG */
102711 #define ELFMAG1 'E'
102712 #define ELFMAG2 'L'
102713diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
102714index aa169c4..6a2771d 100644
102715--- a/include/uapi/linux/personality.h
102716+++ b/include/uapi/linux/personality.h
102717@@ -30,6 +30,7 @@ enum {
102718 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
102719 ADDR_NO_RANDOMIZE | \
102720 ADDR_COMPAT_LAYOUT | \
102721+ ADDR_LIMIT_3GB | \
102722 MMAP_PAGE_ZERO)
102723
102724 /*
102725diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
102726index 7530e74..e714828 100644
102727--- a/include/uapi/linux/screen_info.h
102728+++ b/include/uapi/linux/screen_info.h
102729@@ -43,7 +43,8 @@ struct screen_info {
102730 __u16 pages; /* 0x32 */
102731 __u16 vesa_attributes; /* 0x34 */
102732 __u32 capabilities; /* 0x36 */
102733- __u8 _reserved[6]; /* 0x3a */
102734+ __u16 vesapm_size; /* 0x3a */
102735+ __u8 _reserved[4]; /* 0x3c */
102736 } __attribute__((packed));
102737
102738 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
102739diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
102740index 0e011eb..82681b1 100644
102741--- a/include/uapi/linux/swab.h
102742+++ b/include/uapi/linux/swab.h
102743@@ -43,7 +43,7 @@
102744 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
102745 */
102746
102747-static inline __attribute_const__ __u16 __fswab16(__u16 val)
102748+static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
102749 {
102750 #ifdef __HAVE_BUILTIN_BSWAP16__
102751 return __builtin_bswap16(val);
102752@@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
102753 #endif
102754 }
102755
102756-static inline __attribute_const__ __u32 __fswab32(__u32 val)
102757+static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
102758 {
102759 #ifdef __HAVE_BUILTIN_BSWAP32__
102760 return __builtin_bswap32(val);
102761@@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
102762 #endif
102763 }
102764
102765-static inline __attribute_const__ __u64 __fswab64(__u64 val)
102766+static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
102767 {
102768 #ifdef __HAVE_BUILTIN_BSWAP64__
102769 return __builtin_bswap64(val);
102770diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
102771index 1590c49..5eab462 100644
102772--- a/include/uapi/linux/xattr.h
102773+++ b/include/uapi/linux/xattr.h
102774@@ -73,5 +73,9 @@
102775 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
102776 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
102777
102778+/* User namespace */
102779+#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
102780+#define XATTR_PAX_FLAGS_SUFFIX "flags"
102781+#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
102782
102783 #endif /* _UAPI_LINUX_XATTR_H */
102784diff --git a/include/video/udlfb.h b/include/video/udlfb.h
102785index f9466fa..f4e2b81 100644
102786--- a/include/video/udlfb.h
102787+++ b/include/video/udlfb.h
102788@@ -53,10 +53,10 @@ struct dlfb_data {
102789 u32 pseudo_palette[256];
102790 int blank_mode; /*one of FB_BLANK_ */
102791 /* blit-only rendering path metrics, exposed through sysfs */
102792- atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
102793- atomic_t bytes_identical; /* saved effort with backbuffer comparison */
102794- atomic_t bytes_sent; /* to usb, after compression including overhead */
102795- atomic_t cpu_kcycles_used; /* transpired during pixel processing */
102796+ atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
102797+ atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
102798+ atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
102799+ atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
102800 };
102801
102802 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
102803diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
102804index 30f5362..8ed8ac9 100644
102805--- a/include/video/uvesafb.h
102806+++ b/include/video/uvesafb.h
102807@@ -122,6 +122,7 @@ struct uvesafb_par {
102808 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
102809 u8 pmi_setpal; /* PMI for palette changes */
102810 u16 *pmi_base; /* protected mode interface location */
102811+ u8 *pmi_code; /* protected mode code location */
102812 void *pmi_start;
102813 void *pmi_pal;
102814 u8 *vbe_state_orig; /*
102815diff --git a/init/Kconfig b/init/Kconfig
102816index dc24dec..b77638f 100644
102817--- a/init/Kconfig
102818+++ b/init/Kconfig
102819@@ -1145,6 +1145,7 @@ endif # CGROUPS
102820
102821 config CHECKPOINT_RESTORE
102822 bool "Checkpoint/restore support" if EXPERT
102823+ depends on !GRKERNSEC
102824 default n
102825 help
102826 Enables additional kernel features in a sake of checkpoint/restore.
102827@@ -1670,7 +1671,7 @@ config SLUB_DEBUG
102828
102829 config COMPAT_BRK
102830 bool "Disable heap randomization"
102831- default y
102832+ default n
102833 help
102834 Randomizing heap placement makes heap exploits harder, but it
102835 also breaks ancient binaries (including anything libc5 based).
102836@@ -2001,7 +2002,7 @@ config INIT_ALL_POSSIBLE
102837 config STOP_MACHINE
102838 bool
102839 default y
102840- depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
102841+ depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
102842 help
102843 Need stop_machine() primitive.
102844
102845diff --git a/init/Makefile b/init/Makefile
102846index 7bc47ee..6da2dc7 100644
102847--- a/init/Makefile
102848+++ b/init/Makefile
102849@@ -2,6 +2,9 @@
102850 # Makefile for the linux kernel.
102851 #
102852
102853+ccflags-y := $(GCC_PLUGINS_CFLAGS)
102854+asflags-y := $(GCC_PLUGINS_AFLAGS)
102855+
102856 obj-y := main.o version.o mounts.o
102857 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
102858 obj-y += noinitramfs.o
102859diff --git a/init/do_mounts.c b/init/do_mounts.c
102860index a95bbdb..82c48fd 100644
102861--- a/init/do_mounts.c
102862+++ b/init/do_mounts.c
102863@@ -363,11 +363,11 @@ static void __init get_fs_names(char *page)
102864 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
102865 {
102866 struct super_block *s;
102867- int err = sys_mount(name, "/root", fs, flags, data);
102868+ int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
102869 if (err)
102870 return err;
102871
102872- sys_chdir("/root");
102873+ sys_chdir((const char __force_user *)"/root");
102874 s = current->fs->pwd.dentry->d_sb;
102875 ROOT_DEV = s->s_dev;
102876 printk(KERN_INFO
102877@@ -490,18 +490,18 @@ void __init change_floppy(char *fmt, ...)
102878 va_start(args, fmt);
102879 vsprintf(buf, fmt, args);
102880 va_end(args);
102881- fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
102882+ fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
102883 if (fd >= 0) {
102884 sys_ioctl(fd, FDEJECT, 0);
102885 sys_close(fd);
102886 }
102887 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
102888- fd = sys_open("/dev/console", O_RDWR, 0);
102889+ fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
102890 if (fd >= 0) {
102891 sys_ioctl(fd, TCGETS, (long)&termios);
102892 termios.c_lflag &= ~ICANON;
102893 sys_ioctl(fd, TCSETSF, (long)&termios);
102894- sys_read(fd, &c, 1);
102895+ sys_read(fd, (char __user *)&c, 1);
102896 termios.c_lflag |= ICANON;
102897 sys_ioctl(fd, TCSETSF, (long)&termios);
102898 sys_close(fd);
102899@@ -595,8 +595,8 @@ void __init prepare_namespace(void)
102900 mount_root();
102901 out:
102902 devtmpfs_mount("dev");
102903- sys_mount(".", "/", NULL, MS_MOVE, NULL);
102904- sys_chroot(".");
102905+ sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
102906+ sys_chroot((const char __force_user *)".");
102907 }
102908
102909 static bool is_tmpfs;
102910diff --git a/init/do_mounts.h b/init/do_mounts.h
102911index f5b978a..69dbfe8 100644
102912--- a/init/do_mounts.h
102913+++ b/init/do_mounts.h
102914@@ -15,15 +15,15 @@ extern int root_mountflags;
102915
102916 static inline int create_dev(char *name, dev_t dev)
102917 {
102918- sys_unlink(name);
102919- return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
102920+ sys_unlink((char __force_user *)name);
102921+ return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
102922 }
102923
102924 #if BITS_PER_LONG == 32
102925 static inline u32 bstat(char *name)
102926 {
102927 struct stat64 stat;
102928- if (sys_stat64(name, &stat) != 0)
102929+ if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
102930 return 0;
102931 if (!S_ISBLK(stat.st_mode))
102932 return 0;
102933@@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
102934 static inline u32 bstat(char *name)
102935 {
102936 struct stat stat;
102937- if (sys_newstat(name, &stat) != 0)
102938+ if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
102939 return 0;
102940 if (!S_ISBLK(stat.st_mode))
102941 return 0;
102942diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
102943index 3e0878e..8a9d7a0 100644
102944--- a/init/do_mounts_initrd.c
102945+++ b/init/do_mounts_initrd.c
102946@@ -37,13 +37,13 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
102947 {
102948 sys_unshare(CLONE_FS | CLONE_FILES);
102949 /* stdin/stdout/stderr for /linuxrc */
102950- sys_open("/dev/console", O_RDWR, 0);
102951+ sys_open((const char __force_user *)"/dev/console", O_RDWR, 0);
102952 sys_dup(0);
102953 sys_dup(0);
102954 /* move initrd over / and chdir/chroot in initrd root */
102955- sys_chdir("/root");
102956- sys_mount(".", "/", NULL, MS_MOVE, NULL);
102957- sys_chroot(".");
102958+ sys_chdir((const char __force_user *)"/root");
102959+ sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
102960+ sys_chroot((const char __force_user *)".");
102961 sys_setsid();
102962 return 0;
102963 }
102964@@ -59,8 +59,8 @@ static void __init handle_initrd(void)
102965 create_dev("/dev/root.old", Root_RAM0);
102966 /* mount initrd on rootfs' /root */
102967 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
102968- sys_mkdir("/old", 0700);
102969- sys_chdir("/old");
102970+ sys_mkdir((const char __force_user *)"/old", 0700);
102971+ sys_chdir((const char __force_user *)"/old");
102972
102973 /* try loading default modules from initrd */
102974 load_default_modules();
102975@@ -80,31 +80,31 @@ static void __init handle_initrd(void)
102976 current->flags &= ~PF_FREEZER_SKIP;
102977
102978 /* move initrd to rootfs' /old */
102979- sys_mount("..", ".", NULL, MS_MOVE, NULL);
102980+ sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
102981 /* switch root and cwd back to / of rootfs */
102982- sys_chroot("..");
102983+ sys_chroot((const char __force_user *)"..");
102984
102985 if (new_decode_dev(real_root_dev) == Root_RAM0) {
102986- sys_chdir("/old");
102987+ sys_chdir((const char __force_user *)"/old");
102988 return;
102989 }
102990
102991- sys_chdir("/");
102992+ sys_chdir((const char __force_user *)"/");
102993 ROOT_DEV = new_decode_dev(real_root_dev);
102994 mount_root();
102995
102996 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
102997- error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
102998+ error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
102999 if (!error)
103000 printk("okay\n");
103001 else {
103002- int fd = sys_open("/dev/root.old", O_RDWR, 0);
103003+ int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
103004 if (error == -ENOENT)
103005 printk("/initrd does not exist. Ignored.\n");
103006 else
103007 printk("failed\n");
103008 printk(KERN_NOTICE "Unmounting old root\n");
103009- sys_umount("/old", MNT_DETACH);
103010+ sys_umount((char __force_user *)"/old", MNT_DETACH);
103011 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
103012 if (fd < 0) {
103013 error = fd;
103014@@ -127,11 +127,11 @@ int __init initrd_load(void)
103015 * mounted in the normal path.
103016 */
103017 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
103018- sys_unlink("/initrd.image");
103019+ sys_unlink((const char __force_user *)"/initrd.image");
103020 handle_initrd();
103021 return 1;
103022 }
103023 }
103024- sys_unlink("/initrd.image");
103025+ sys_unlink((const char __force_user *)"/initrd.image");
103026 return 0;
103027 }
103028diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
103029index 8cb6db5..d729f50 100644
103030--- a/init/do_mounts_md.c
103031+++ b/init/do_mounts_md.c
103032@@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
103033 partitioned ? "_d" : "", minor,
103034 md_setup_args[ent].device_names);
103035
103036- fd = sys_open(name, 0, 0);
103037+ fd = sys_open((char __force_user *)name, 0, 0);
103038 if (fd < 0) {
103039 printk(KERN_ERR "md: open failed - cannot start "
103040 "array %s\n", name);
103041@@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
103042 * array without it
103043 */
103044 sys_close(fd);
103045- fd = sys_open(name, 0, 0);
103046+ fd = sys_open((char __force_user *)name, 0, 0);
103047 sys_ioctl(fd, BLKRRPART, 0);
103048 }
103049 sys_close(fd);
103050@@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
103051
103052 wait_for_device_probe();
103053
103054- fd = sys_open("/dev/md0", 0, 0);
103055+ fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
103056 if (fd >= 0) {
103057 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
103058 sys_close(fd);
103059diff --git a/init/init_task.c b/init/init_task.c
103060index ba0a7f36..2bcf1d5 100644
103061--- a/init/init_task.c
103062+++ b/init/init_task.c
103063@@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
103064 * Initial thread structure. Alignment of this is handled by a special
103065 * linker map entry.
103066 */
103067+#ifdef CONFIG_X86
103068+union thread_union init_thread_union __init_task_data;
103069+#else
103070 union thread_union init_thread_union __init_task_data =
103071 { INIT_THREAD_INFO(init_task) };
103072+#endif
103073diff --git a/init/initramfs.c b/init/initramfs.c
103074index ad1bd77..dca2c1b 100644
103075--- a/init/initramfs.c
103076+++ b/init/initramfs.c
103077@@ -25,7 +25,7 @@ static ssize_t __init xwrite(int fd, const char *p, size_t count)
103078
103079 /* sys_write only can write MAX_RW_COUNT aka 2G-4K bytes at most */
103080 while (count) {
103081- ssize_t rv = sys_write(fd, p, count);
103082+ ssize_t rv = sys_write(fd, (char __force_user *)p, count);
103083
103084 if (rv < 0) {
103085 if (rv == -EINTR || rv == -EAGAIN)
103086@@ -107,7 +107,7 @@ static void __init free_hash(void)
103087 }
103088 }
103089
103090-static long __init do_utime(char *filename, time_t mtime)
103091+static long __init do_utime(char __force_user *filename, time_t mtime)
103092 {
103093 struct timespec t[2];
103094
103095@@ -142,7 +142,7 @@ static void __init dir_utime(void)
103096 struct dir_entry *de, *tmp;
103097 list_for_each_entry_safe(de, tmp, &dir_list, list) {
103098 list_del(&de->list);
103099- do_utime(de->name, de->mtime);
103100+ do_utime((char __force_user *)de->name, de->mtime);
103101 kfree(de->name);
103102 kfree(de);
103103 }
103104@@ -304,7 +304,7 @@ static int __init maybe_link(void)
103105 if (nlink >= 2) {
103106 char *old = find_link(major, minor, ino, mode, collected);
103107 if (old)
103108- return (sys_link(old, collected) < 0) ? -1 : 1;
103109+ return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
103110 }
103111 return 0;
103112 }
103113@@ -313,11 +313,11 @@ static void __init clean_path(char *path, umode_t fmode)
103114 {
103115 struct stat st;
103116
103117- if (!sys_newlstat(path, &st) && (st.st_mode ^ fmode) & S_IFMT) {
103118+ if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode ^ fmode) & S_IFMT) {
103119 if (S_ISDIR(st.st_mode))
103120- sys_rmdir(path);
103121+ sys_rmdir((char __force_user *)path);
103122 else
103123- sys_unlink(path);
103124+ sys_unlink((char __force_user *)path);
103125 }
103126 }
103127
103128@@ -338,7 +338,7 @@ static int __init do_name(void)
103129 int openflags = O_WRONLY|O_CREAT;
103130 if (ml != 1)
103131 openflags |= O_TRUNC;
103132- wfd = sys_open(collected, openflags, mode);
103133+ wfd = sys_open((char __force_user *)collected, openflags, mode);
103134
103135 if (wfd >= 0) {
103136 sys_fchown(wfd, uid, gid);
103137@@ -350,17 +350,17 @@ static int __init do_name(void)
103138 }
103139 }
103140 } else if (S_ISDIR(mode)) {
103141- sys_mkdir(collected, mode);
103142- sys_chown(collected, uid, gid);
103143- sys_chmod(collected, mode);
103144+ sys_mkdir((char __force_user *)collected, mode);
103145+ sys_chown((char __force_user *)collected, uid, gid);
103146+ sys_chmod((char __force_user *)collected, mode);
103147 dir_add(collected, mtime);
103148 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
103149 S_ISFIFO(mode) || S_ISSOCK(mode)) {
103150 if (maybe_link() == 0) {
103151- sys_mknod(collected, mode, rdev);
103152- sys_chown(collected, uid, gid);
103153- sys_chmod(collected, mode);
103154- do_utime(collected, mtime);
103155+ sys_mknod((char __force_user *)collected, mode, rdev);
103156+ sys_chown((char __force_user *)collected, uid, gid);
103157+ sys_chmod((char __force_user *)collected, mode);
103158+ do_utime((char __force_user *)collected, mtime);
103159 }
103160 }
103161 return 0;
103162@@ -372,7 +372,7 @@ static int __init do_copy(void)
103163 if (xwrite(wfd, victim, body_len) != body_len)
103164 error("write error");
103165 sys_close(wfd);
103166- do_utime(vcollected, mtime);
103167+ do_utime((char __force_user *)vcollected, mtime);
103168 kfree(vcollected);
103169 eat(body_len);
103170 state = SkipIt;
103171@@ -390,9 +390,9 @@ static int __init do_symlink(void)
103172 {
103173 collected[N_ALIGN(name_len) + body_len] = '\0';
103174 clean_path(collected, 0);
103175- sys_symlink(collected + N_ALIGN(name_len), collected);
103176- sys_lchown(collected, uid, gid);
103177- do_utime(collected, mtime);
103178+ sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
103179+ sys_lchown((char __force_user *)collected, uid, gid);
103180+ do_utime((char __force_user *)collected, mtime);
103181 state = SkipIt;
103182 next_state = Reset;
103183 return 0;
103184diff --git a/init/main.c b/init/main.c
103185index 2a89545..449eca2 100644
103186--- a/init/main.c
103187+++ b/init/main.c
103188@@ -97,6 +97,8 @@ extern void radix_tree_init(void);
103189 static inline void mark_rodata_ro(void) { }
103190 #endif
103191
103192+extern void grsecurity_init(void);
103193+
103194 /*
103195 * Debug helper: via this flag we know that we are in 'early bootup code'
103196 * where only the boot processor is running with IRQ disabled. This means
103197@@ -158,6 +160,85 @@ static int __init set_reset_devices(char *str)
103198
103199 __setup("reset_devices", set_reset_devices);
103200
103201+#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
103202+kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
103203+static int __init setup_grsec_proc_gid(char *str)
103204+{
103205+ grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
103206+ return 1;
103207+}
103208+__setup("grsec_proc_gid=", setup_grsec_proc_gid);
103209+#endif
103210+#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
103211+int grsec_enable_sysfs_restrict = 1;
103212+static int __init setup_grsec_sysfs_restrict(char *str)
103213+{
103214+ if (!simple_strtol(str, NULL, 0))
103215+ grsec_enable_sysfs_restrict = 0;
103216+ return 1;
103217+}
103218+__setup("grsec_sysfs_restrict", setup_grsec_sysfs_restrict);
103219+#endif
103220+
103221+#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
103222+unsigned long pax_user_shadow_base __read_only;
103223+EXPORT_SYMBOL(pax_user_shadow_base);
103224+extern char pax_enter_kernel_user[];
103225+extern char pax_exit_kernel_user[];
103226+#endif
103227+
103228+#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
103229+static int __init setup_pax_nouderef(char *str)
103230+{
103231+#ifdef CONFIG_X86_32
103232+ unsigned int cpu;
103233+ struct desc_struct *gdt;
103234+
103235+ for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
103236+ gdt = get_cpu_gdt_table(cpu);
103237+ gdt[GDT_ENTRY_KERNEL_DS].type = 3;
103238+ gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
103239+ gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
103240+ gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
103241+ }
103242+ loadsegment(ds, __KERNEL_DS);
103243+ loadsegment(es, __KERNEL_DS);
103244+ loadsegment(ss, __KERNEL_DS);
103245+#else
103246+ memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
103247+ memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
103248+ clone_pgd_mask = ~(pgdval_t)0UL;
103249+ pax_user_shadow_base = 0UL;
103250+ setup_clear_cpu_cap(X86_FEATURE_PCID);
103251+ setup_clear_cpu_cap(X86_FEATURE_INVPCID);
103252+#endif
103253+
103254+ return 0;
103255+}
103256+early_param("pax_nouderef", setup_pax_nouderef);
103257+
103258+#ifdef CONFIG_X86_64
103259+static int __init setup_pax_weakuderef(char *str)
103260+{
103261+ if (clone_pgd_mask != ~(pgdval_t)0UL)
103262+ pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
103263+ return 1;
103264+}
103265+__setup("pax_weakuderef", setup_pax_weakuderef);
103266+#endif
103267+#endif
103268+
103269+#ifdef CONFIG_PAX_SOFTMODE
103270+int pax_softmode;
103271+
103272+static int __init setup_pax_softmode(char *str)
103273+{
103274+ get_option(&str, &pax_softmode);
103275+ return 1;
103276+}
103277+__setup("pax_softmode=", setup_pax_softmode);
103278+#endif
103279+
103280 static const char *argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
103281 const char *envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
103282 static const char *panic_later, *panic_param;
103283@@ -726,7 +807,7 @@ static bool __init_or_module initcall_blacklisted(initcall_t fn)
103284 struct blacklist_entry *entry;
103285 char *fn_name;
103286
103287- fn_name = kasprintf(GFP_KERNEL, "%pf", fn);
103288+ fn_name = kasprintf(GFP_KERNEL, "%pX", fn);
103289 if (!fn_name)
103290 return false;
103291
103292@@ -778,7 +859,7 @@ int __init_or_module do_one_initcall(initcall_t fn)
103293 {
103294 int count = preempt_count();
103295 int ret;
103296- char msgbuf[64];
103297+ const char *msg1 = "", *msg2 = "";
103298
103299 if (initcall_blacklisted(fn))
103300 return -EPERM;
103301@@ -788,18 +869,17 @@ int __init_or_module do_one_initcall(initcall_t fn)
103302 else
103303 ret = fn();
103304
103305- msgbuf[0] = 0;
103306-
103307 if (preempt_count() != count) {
103308- sprintf(msgbuf, "preemption imbalance ");
103309+ msg1 = " preemption imbalance";
103310 preempt_count_set(count);
103311 }
103312 if (irqs_disabled()) {
103313- strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
103314+ msg2 = " disabled interrupts";
103315 local_irq_enable();
103316 }
103317- WARN(msgbuf[0], "initcall %pF returned with %s\n", fn, msgbuf);
103318+ WARN(*msg1 || *msg2, "initcall %pF returned with%s%s\n", fn, msg1, msg2);
103319
103320+ add_latent_entropy();
103321 return ret;
103322 }
103323
103324@@ -905,8 +985,8 @@ static int run_init_process(const char *init_filename)
103325 {
103326 argv_init[0] = init_filename;
103327 return do_execve(getname_kernel(init_filename),
103328- (const char __user *const __user *)argv_init,
103329- (const char __user *const __user *)envp_init);
103330+ (const char __user *const __force_user *)argv_init,
103331+ (const char __user *const __force_user *)envp_init);
103332 }
103333
103334 static int try_to_run_init_process(const char *init_filename)
103335@@ -923,6 +1003,10 @@ static int try_to_run_init_process(const char *init_filename)
103336 return ret;
103337 }
103338
103339+#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
103340+extern int gr_init_ran;
103341+#endif
103342+
103343 static noinline void __init kernel_init_freeable(void);
103344
103345 static int __ref kernel_init(void *unused)
103346@@ -947,6 +1031,11 @@ static int __ref kernel_init(void *unused)
103347 ramdisk_execute_command, ret);
103348 }
103349
103350+#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
103351+ /* if no initrd was used, be extra sure we enforce chroot restrictions */
103352+ gr_init_ran = 1;
103353+#endif
103354+
103355 /*
103356 * We try each of these until one succeeds.
103357 *
103358@@ -1002,7 +1091,7 @@ static noinline void __init kernel_init_freeable(void)
103359 do_basic_setup();
103360
103361 /* Open the /dev/console on the rootfs, this should never fail */
103362- if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
103363+ if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
103364 pr_err("Warning: unable to open an initial console.\n");
103365
103366 (void) sys_dup(0);
103367@@ -1015,11 +1104,13 @@ static noinline void __init kernel_init_freeable(void)
103368 if (!ramdisk_execute_command)
103369 ramdisk_execute_command = "/init";
103370
103371- if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
103372+ if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
103373 ramdisk_execute_command = NULL;
103374 prepare_namespace();
103375 }
103376
103377+ grsecurity_init();
103378+
103379 /*
103380 * Ok, we have completed the initial bootup, and
103381 * we're essentially up and running. Get rid of the
103382diff --git a/ipc/compat.c b/ipc/compat.c
103383index 9b3c85f..5266b0f 100644
103384--- a/ipc/compat.c
103385+++ b/ipc/compat.c
103386@@ -396,7 +396,7 @@ COMPAT_SYSCALL_DEFINE6(ipc, u32, call, int, first, int, second,
103387 COMPAT_SHMLBA);
103388 if (err < 0)
103389 return err;
103390- return put_user(raddr, (compat_ulong_t *)compat_ptr(third));
103391+ return put_user(raddr, (compat_ulong_t __user *)compat_ptr(third));
103392 }
103393 case SHMDT:
103394 return sys_shmdt(compat_ptr(ptr));
103395@@ -747,7 +747,7 @@ COMPAT_SYSCALL_DEFINE3(shmctl, int, first, int, second, void __user *, uptr)
103396 }
103397
103398 COMPAT_SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsems,
103399- unsigned, nsops,
103400+ compat_long_t, nsops,
103401 const struct compat_timespec __user *, timeout)
103402 {
103403 struct timespec __user *ts64;
103404diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
103405index 8ad93c2..efd80f8 100644
103406--- a/ipc/ipc_sysctl.c
103407+++ b/ipc/ipc_sysctl.c
103408@@ -30,7 +30,7 @@ static void *get_ipc(struct ctl_table *table)
103409 static int proc_ipc_dointvec(struct ctl_table *table, int write,
103410 void __user *buffer, size_t *lenp, loff_t *ppos)
103411 {
103412- struct ctl_table ipc_table;
103413+ ctl_table_no_const ipc_table;
103414
103415 memcpy(&ipc_table, table, sizeof(ipc_table));
103416 ipc_table.data = get_ipc(table);
103417@@ -41,7 +41,7 @@ static int proc_ipc_dointvec(struct ctl_table *table, int write,
103418 static int proc_ipc_dointvec_minmax(struct ctl_table *table, int write,
103419 void __user *buffer, size_t *lenp, loff_t *ppos)
103420 {
103421- struct ctl_table ipc_table;
103422+ ctl_table_no_const ipc_table;
103423
103424 memcpy(&ipc_table, table, sizeof(ipc_table));
103425 ipc_table.data = get_ipc(table);
103426@@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(struct ctl_table *table, int write,
103427 static int proc_ipc_doulongvec_minmax(struct ctl_table *table, int write,
103428 void __user *buffer, size_t *lenp, loff_t *ppos)
103429 {
103430- struct ctl_table ipc_table;
103431+ ctl_table_no_const ipc_table;
103432 memcpy(&ipc_table, table, sizeof(ipc_table));
103433 ipc_table.data = get_ipc(table);
103434
103435@@ -76,7 +76,7 @@ static int proc_ipc_doulongvec_minmax(struct ctl_table *table, int write,
103436 static int proc_ipc_auto_msgmni(struct ctl_table *table, int write,
103437 void __user *buffer, size_t *lenp, loff_t *ppos)
103438 {
103439- struct ctl_table ipc_table;
103440+ ctl_table_no_const ipc_table;
103441 int dummy = 0;
103442
103443 memcpy(&ipc_table, table, sizeof(ipc_table));
103444diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
103445index 68d4e95..1477ded 100644
103446--- a/ipc/mq_sysctl.c
103447+++ b/ipc/mq_sysctl.c
103448@@ -25,7 +25,7 @@ static void *get_mq(struct ctl_table *table)
103449 static int proc_mq_dointvec(struct ctl_table *table, int write,
103450 void __user *buffer, size_t *lenp, loff_t *ppos)
103451 {
103452- struct ctl_table mq_table;
103453+ ctl_table_no_const mq_table;
103454 memcpy(&mq_table, table, sizeof(mq_table));
103455 mq_table.data = get_mq(table);
103456
103457@@ -35,7 +35,7 @@ static int proc_mq_dointvec(struct ctl_table *table, int write,
103458 static int proc_mq_dointvec_minmax(struct ctl_table *table, int write,
103459 void __user *buffer, size_t *lenp, loff_t *ppos)
103460 {
103461- struct ctl_table mq_table;
103462+ ctl_table_no_const mq_table;
103463 memcpy(&mq_table, table, sizeof(mq_table));
103464 mq_table.data = get_mq(table);
103465
103466diff --git a/ipc/mqueue.c b/ipc/mqueue.c
103467index 3aaea7f..e8a13d6 100644
103468--- a/ipc/mqueue.c
103469+++ b/ipc/mqueue.c
103470@@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
103471 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
103472 info->attr.mq_msgsize);
103473
103474+ gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
103475 spin_lock(&mq_lock);
103476 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
103477 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
103478diff --git a/ipc/sem.c b/ipc/sem.c
103479index d1a6edd..ef08b40 100644
103480--- a/ipc/sem.c
103481+++ b/ipc/sem.c
103482@@ -1780,7 +1780,7 @@ static int get_queue_result(struct sem_queue *q)
103483 }
103484
103485 SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops,
103486- unsigned, nsops, const struct timespec __user *, timeout)
103487+ long, nsops, const struct timespec __user *, timeout)
103488 {
103489 int error = -EINVAL;
103490 struct sem_array *sma;
103491@@ -2015,7 +2015,7 @@ out_free:
103492 }
103493
103494 SYSCALL_DEFINE3(semop, int, semid, struct sembuf __user *, tsops,
103495- unsigned, nsops)
103496+ long, nsops)
103497 {
103498 return sys_semtimedop(semid, tsops, nsops, NULL);
103499 }
103500diff --git a/ipc/shm.c b/ipc/shm.c
103501index 6d76707..b646bbe 100644
103502--- a/ipc/shm.c
103503+++ b/ipc/shm.c
103504@@ -72,6 +72,14 @@ static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp);
103505 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
103506 #endif
103507
103508+#ifdef CONFIG_GRKERNSEC
103509+extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
103510+ const u64 shm_createtime, const kuid_t cuid,
103511+ const int shmid);
103512+extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
103513+ const u64 shm_createtime);
103514+#endif
103515+
103516 void shm_init_ns(struct ipc_namespace *ns)
103517 {
103518 ns->shm_ctlmax = SHMMAX;
103519@@ -560,6 +568,9 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
103520 shp->shm_lprid = 0;
103521 shp->shm_atim = shp->shm_dtim = 0;
103522 shp->shm_ctim = get_seconds();
103523+#ifdef CONFIG_GRKERNSEC
103524+ shp->shm_createtime = ktime_get_ns();
103525+#endif
103526 shp->shm_segsz = size;
103527 shp->shm_nattch = 0;
103528 shp->shm_file = file;
103529@@ -1096,6 +1107,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
103530 f_mode = FMODE_READ | FMODE_WRITE;
103531 }
103532 if (shmflg & SHM_EXEC) {
103533+
103534+#ifdef CONFIG_PAX_MPROTECT
103535+ if (current->mm->pax_flags & MF_PAX_MPROTECT)
103536+ goto out;
103537+#endif
103538+
103539 prot |= PROT_EXEC;
103540 acc_mode |= S_IXUGO;
103541 }
103542@@ -1120,6 +1137,15 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
103543 if (err)
103544 goto out_unlock;
103545
103546+#ifdef CONFIG_GRKERNSEC
103547+ if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
103548+ shp->shm_perm.cuid, shmid) ||
103549+ !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
103550+ err = -EACCES;
103551+ goto out_unlock;
103552+ }
103553+#endif
103554+
103555 ipc_lock_object(&shp->shm_perm);
103556
103557 /* check if shm_destroy() is tearing down shp */
103558@@ -1132,6 +1158,9 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
103559 path = shp->shm_file->f_path;
103560 path_get(&path);
103561 shp->shm_nattch++;
103562+#ifdef CONFIG_GRKERNSEC
103563+ shp->shm_lapid = current->pid;
103564+#endif
103565 size = i_size_read(d_inode(path.dentry));
103566 ipc_unlock_object(&shp->shm_perm);
103567 rcu_read_unlock();
103568diff --git a/ipc/util.c b/ipc/util.c
103569index ff3323e..d6d63d1 100644
103570--- a/ipc/util.c
103571+++ b/ipc/util.c
103572@@ -71,6 +71,8 @@ struct ipc_proc_iface {
103573 int (*show)(struct seq_file *, void *);
103574 };
103575
103576+extern int gr_ipc_permitted(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, int requested_mode, int granted_mode);
103577+
103578 /**
103579 * ipc_init - initialise ipc subsystem
103580 *
103581@@ -497,6 +499,10 @@ int ipcperms(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, short flag)
103582 granted_mode >>= 6;
103583 else if (in_group_p(ipcp->cgid) || in_group_p(ipcp->gid))
103584 granted_mode >>= 3;
103585+
103586+ if (!gr_ipc_permitted(ns, ipcp, requested_mode, granted_mode))
103587+ return -1;
103588+
103589 /* is there some bit set in requested_mode but not in granted_mode? */
103590 if ((requested_mode & ~granted_mode & 0007) &&
103591 !ns_capable(ns->user_ns, CAP_IPC_OWNER))
103592diff --git a/kernel/audit.c b/kernel/audit.c
103593index 1c13e42..6c171ab 100644
103594--- a/kernel/audit.c
103595+++ b/kernel/audit.c
103596@@ -124,7 +124,7 @@ u32 audit_sig_sid = 0;
103597 3) suppressed due to audit_rate_limit
103598 4) suppressed due to audit_backlog_limit
103599 */
103600-static atomic_t audit_lost = ATOMIC_INIT(0);
103601+static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
103602
103603 /* The netlink socket. */
103604 static struct sock *audit_sock;
103605@@ -258,7 +258,7 @@ void audit_log_lost(const char *message)
103606 unsigned long now;
103607 int print;
103608
103609- atomic_inc(&audit_lost);
103610+ atomic_inc_unchecked(&audit_lost);
103611
103612 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
103613
103614@@ -275,7 +275,7 @@ void audit_log_lost(const char *message)
103615 if (print) {
103616 if (printk_ratelimit())
103617 pr_warn("audit_lost=%u audit_rate_limit=%u audit_backlog_limit=%u\n",
103618- atomic_read(&audit_lost),
103619+ atomic_read_unchecked(&audit_lost),
103620 audit_rate_limit,
103621 audit_backlog_limit);
103622 audit_panic(message);
103623@@ -833,7 +833,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
103624 s.pid = audit_pid;
103625 s.rate_limit = audit_rate_limit;
103626 s.backlog_limit = audit_backlog_limit;
103627- s.lost = atomic_read(&audit_lost);
103628+ s.lost = atomic_read_unchecked(&audit_lost);
103629 s.backlog = skb_queue_len(&audit_skb_queue);
103630 s.feature_bitmap = AUDIT_FEATURE_BITMAP_ALL;
103631 s.backlog_wait_time = audit_backlog_wait_time_master;
103632diff --git a/kernel/auditsc.c b/kernel/auditsc.c
103633index 9fb9d1c..afb1610 100644
103634--- a/kernel/auditsc.c
103635+++ b/kernel/auditsc.c
103636@@ -1023,7 +1023,7 @@ static int audit_log_single_execve_arg(struct audit_context *context,
103637 * for strings that are too long, we should not have created
103638 * any.
103639 */
103640- if (unlikely((len == -1) || len > MAX_ARG_STRLEN - 1)) {
103641+ if (unlikely(len > MAX_ARG_STRLEN - 1)) {
103642 WARN_ON(1);
103643 send_sig(SIGKILL, current, 0);
103644 return -1;
103645@@ -1955,7 +1955,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
103646 }
103647
103648 /* global counter which is incremented every time something logs in */
103649-static atomic_t session_id = ATOMIC_INIT(0);
103650+static atomic_unchecked_t session_id = ATOMIC_INIT(0);
103651
103652 static int audit_set_loginuid_perm(kuid_t loginuid)
103653 {
103654@@ -2022,7 +2022,7 @@ int audit_set_loginuid(kuid_t loginuid)
103655
103656 /* are we setting or clearing? */
103657 if (uid_valid(loginuid))
103658- sessionid = (unsigned int)atomic_inc_return(&session_id);
103659+ sessionid = (unsigned int)atomic_inc_return_unchecked(&session_id);
103660
103661 task->sessionid = sessionid;
103662 task->loginuid = loginuid;
103663diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
103664index 54f0e7f..fed997b 100644
103665--- a/kernel/bpf/core.c
103666+++ b/kernel/bpf/core.c
103667@@ -143,14 +143,17 @@ bpf_jit_binary_alloc(unsigned int proglen, u8 **image_ptr,
103668 * random section of illegal instructions.
103669 */
103670 size = round_up(proglen + sizeof(*hdr) + 128, PAGE_SIZE);
103671- hdr = module_alloc(size);
103672+ hdr = module_alloc_exec(size);
103673 if (hdr == NULL)
103674 return NULL;
103675
103676 /* Fill space with illegal/arch-dep instructions. */
103677 bpf_fill_ill_insns(hdr, size);
103678
103679+ pax_open_kernel();
103680 hdr->pages = size / PAGE_SIZE;
103681+ pax_close_kernel();
103682+
103683 hole = min_t(unsigned int, size - (proglen + sizeof(*hdr)),
103684 PAGE_SIZE - sizeof(*hdr));
103685 start = (prandom_u32() % hole) & ~(alignment - 1);
103686@@ -163,7 +166,7 @@ bpf_jit_binary_alloc(unsigned int proglen, u8 **image_ptr,
103687
103688 void bpf_jit_binary_free(struct bpf_binary_header *hdr)
103689 {
103690- module_memfree(hdr);
103691+ module_memfree_exec(hdr);
103692 }
103693 #endif /* CONFIG_BPF_JIT */
103694
103695diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
103696index 3bae6c5..59ea175 100644
103697--- a/kernel/bpf/syscall.c
103698+++ b/kernel/bpf/syscall.c
103699@@ -554,11 +554,15 @@ SYSCALL_DEFINE3(bpf, int, cmd, union bpf_attr __user *, uattr, unsigned int, siz
103700 int err;
103701
103702 /* the syscall is limited to root temporarily. This restriction will be
103703- * lifted when security audit is clean. Note that eBPF+tracing must have
103704- * this restriction, since it may pass kernel data to user space
103705+ * lifted by upstream when a half-assed security audit is clean. Note
103706+ * that eBPF+tracing must have this restriction, since it may pass
103707+ * kernel data to user space
103708 */
103709 if (!capable(CAP_SYS_ADMIN))
103710 return -EPERM;
103711+#ifdef CONFIG_GRKERNSEC
103712+ return -EPERM;
103713+#endif
103714
103715 if (!access_ok(VERIFY_READ, uattr, 1))
103716 return -EFAULT;
103717diff --git a/kernel/capability.c b/kernel/capability.c
103718index 45432b5..988f1e4 100644
103719--- a/kernel/capability.c
103720+++ b/kernel/capability.c
103721@@ -193,6 +193,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
103722 * before modification is attempted and the application
103723 * fails.
103724 */
103725+ if (tocopy > ARRAY_SIZE(kdata))
103726+ return -EFAULT;
103727+
103728 if (copy_to_user(dataptr, kdata, tocopy
103729 * sizeof(struct __user_cap_data_struct))) {
103730 return -EFAULT;
103731@@ -298,10 +301,11 @@ bool has_ns_capability(struct task_struct *t,
103732 int ret;
103733
103734 rcu_read_lock();
103735- ret = security_capable(__task_cred(t), ns, cap);
103736+ ret = security_capable(__task_cred(t), ns, cap) == 0 &&
103737+ gr_task_is_capable(t, __task_cred(t), cap);
103738 rcu_read_unlock();
103739
103740- return (ret == 0);
103741+ return ret;
103742 }
103743
103744 /**
103745@@ -338,10 +342,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
103746 int ret;
103747
103748 rcu_read_lock();
103749- ret = security_capable_noaudit(__task_cred(t), ns, cap);
103750+ ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
103751 rcu_read_unlock();
103752
103753- return (ret == 0);
103754+ return ret;
103755 }
103756
103757 /**
103758@@ -379,7 +383,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
103759 BUG();
103760 }
103761
103762- if (security_capable(current_cred(), ns, cap) == 0) {
103763+ if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
103764 current->flags |= PF_SUPERPRIV;
103765 return true;
103766 }
103767@@ -387,6 +391,20 @@ bool ns_capable(struct user_namespace *ns, int cap)
103768 }
103769 EXPORT_SYMBOL(ns_capable);
103770
103771+bool ns_capable_nolog(struct user_namespace *ns, int cap)
103772+{
103773+ if (unlikely(!cap_valid(cap))) {
103774+ pr_crit("capable_nolog() called with invalid cap=%u\n", cap);
103775+ BUG();
103776+ }
103777+
103778+ if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
103779+ current->flags |= PF_SUPERPRIV;
103780+ return true;
103781+ }
103782+ return false;
103783+}
103784+EXPORT_SYMBOL(ns_capable_nolog);
103785
103786 /**
103787 * capable - Determine if the current task has a superior capability in effect
103788@@ -403,6 +421,13 @@ bool capable(int cap)
103789 return ns_capable(&init_user_ns, cap);
103790 }
103791 EXPORT_SYMBOL(capable);
103792+
103793+bool capable_nolog(int cap)
103794+{
103795+ return ns_capable_nolog(&init_user_ns, cap);
103796+}
103797+EXPORT_SYMBOL(capable_nolog);
103798+
103799 #endif /* CONFIG_MULTIUSER */
103800
103801 /**
103802@@ -447,3 +472,12 @@ bool capable_wrt_inode_uidgid(const struct inode *inode, int cap)
103803 kgid_has_mapping(ns, inode->i_gid);
103804 }
103805 EXPORT_SYMBOL(capable_wrt_inode_uidgid);
103806+
103807+bool capable_wrt_inode_uidgid_nolog(const struct inode *inode, int cap)
103808+{
103809+ struct user_namespace *ns = current_user_ns();
103810+
103811+ return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid) &&
103812+ kgid_has_mapping(ns, inode->i_gid);
103813+}
103814+EXPORT_SYMBOL(capable_wrt_inode_uidgid_nolog);
103815diff --git a/kernel/cgroup.c b/kernel/cgroup.c
103816index e8a5491..ab4bfa3 100644
103817--- a/kernel/cgroup.c
103818+++ b/kernel/cgroup.c
103819@@ -5347,6 +5347,9 @@ static void cgroup_release_agent(struct work_struct *work)
103820 if (!pathbuf || !agentbuf)
103821 goto out;
103822
103823+ if (agentbuf[0] == '\0')
103824+ goto out;
103825+
103826 path = cgroup_path(cgrp, pathbuf, PATH_MAX);
103827 if (!path)
103828 goto out;
103829@@ -5532,7 +5535,7 @@ static int cgroup_css_links_read(struct seq_file *seq, void *v)
103830 struct task_struct *task;
103831 int count = 0;
103832
103833- seq_printf(seq, "css_set %p\n", cset);
103834+ seq_printf(seq, "css_set %pK\n", cset);
103835
103836 list_for_each_entry(task, &cset->tasks, cg_list) {
103837 if (count++ > MAX_TASKS_SHOWN_PER_CSS)
103838diff --git a/kernel/compat.c b/kernel/compat.c
103839index 333d364..762ec00 100644
103840--- a/kernel/compat.c
103841+++ b/kernel/compat.c
103842@@ -13,6 +13,7 @@
103843
103844 #include <linux/linkage.h>
103845 #include <linux/compat.h>
103846+#include <linux/module.h>
103847 #include <linux/errno.h>
103848 #include <linux/time.h>
103849 #include <linux/signal.h>
103850@@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
103851 mm_segment_t oldfs;
103852 long ret;
103853
103854- restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
103855+ restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
103856 oldfs = get_fs();
103857 set_fs(KERNEL_DS);
103858 ret = hrtimer_nanosleep_restart(restart);
103859@@ -252,7 +253,7 @@ COMPAT_SYSCALL_DEFINE2(nanosleep, struct compat_timespec __user *, rqtp,
103860 oldfs = get_fs();
103861 set_fs(KERNEL_DS);
103862 ret = hrtimer_nanosleep(&tu,
103863- rmtp ? (struct timespec __user *)&rmt : NULL,
103864+ rmtp ? (struct timespec __force_user *)&rmt : NULL,
103865 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
103866 set_fs(oldfs);
103867
103868@@ -378,7 +379,7 @@ COMPAT_SYSCALL_DEFINE1(sigpending, compat_old_sigset_t __user *, set)
103869 mm_segment_t old_fs = get_fs();
103870
103871 set_fs(KERNEL_DS);
103872- ret = sys_sigpending((old_sigset_t __user *) &s);
103873+ ret = sys_sigpending((old_sigset_t __force_user *) &s);
103874 set_fs(old_fs);
103875 if (ret == 0)
103876 ret = put_user(s, set);
103877@@ -468,7 +469,7 @@ COMPAT_SYSCALL_DEFINE2(old_getrlimit, unsigned int, resource,
103878 mm_segment_t old_fs = get_fs();
103879
103880 set_fs(KERNEL_DS);
103881- ret = sys_old_getrlimit(resource, (struct rlimit __user *)&r);
103882+ ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
103883 set_fs(old_fs);
103884
103885 if (!ret) {
103886@@ -550,8 +551,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
103887 set_fs (KERNEL_DS);
103888 ret = sys_wait4(pid,
103889 (stat_addr ?
103890- (unsigned int __user *) &status : NULL),
103891- options, (struct rusage __user *) &r);
103892+ (unsigned int __force_user *) &status : NULL),
103893+ options, (struct rusage __force_user *) &r);
103894 set_fs (old_fs);
103895
103896 if (ret > 0) {
103897@@ -577,8 +578,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
103898 memset(&info, 0, sizeof(info));
103899
103900 set_fs(KERNEL_DS);
103901- ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
103902- uru ? (struct rusage __user *)&ru : NULL);
103903+ ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
103904+ uru ? (struct rusage __force_user *)&ru : NULL);
103905 set_fs(old_fs);
103906
103907 if ((ret < 0) || (info.si_signo == 0))
103908@@ -712,8 +713,8 @@ COMPAT_SYSCALL_DEFINE4(timer_settime, timer_t, timer_id, int, flags,
103909 oldfs = get_fs();
103910 set_fs(KERNEL_DS);
103911 err = sys_timer_settime(timer_id, flags,
103912- (struct itimerspec __user *) &newts,
103913- (struct itimerspec __user *) &oldts);
103914+ (struct itimerspec __force_user *) &newts,
103915+ (struct itimerspec __force_user *) &oldts);
103916 set_fs(oldfs);
103917 if (!err && old && put_compat_itimerspec(old, &oldts))
103918 return -EFAULT;
103919@@ -730,7 +731,7 @@ COMPAT_SYSCALL_DEFINE2(timer_gettime, timer_t, timer_id,
103920 oldfs = get_fs();
103921 set_fs(KERNEL_DS);
103922 err = sys_timer_gettime(timer_id,
103923- (struct itimerspec __user *) &ts);
103924+ (struct itimerspec __force_user *) &ts);
103925 set_fs(oldfs);
103926 if (!err && put_compat_itimerspec(setting, &ts))
103927 return -EFAULT;
103928@@ -749,7 +750,7 @@ COMPAT_SYSCALL_DEFINE2(clock_settime, clockid_t, which_clock,
103929 oldfs = get_fs();
103930 set_fs(KERNEL_DS);
103931 err = sys_clock_settime(which_clock,
103932- (struct timespec __user *) &ts);
103933+ (struct timespec __force_user *) &ts);
103934 set_fs(oldfs);
103935 return err;
103936 }
103937@@ -764,7 +765,7 @@ COMPAT_SYSCALL_DEFINE2(clock_gettime, clockid_t, which_clock,
103938 oldfs = get_fs();
103939 set_fs(KERNEL_DS);
103940 err = sys_clock_gettime(which_clock,
103941- (struct timespec __user *) &ts);
103942+ (struct timespec __force_user *) &ts);
103943 set_fs(oldfs);
103944 if (!err && compat_put_timespec(&ts, tp))
103945 return -EFAULT;
103946@@ -784,7 +785,7 @@ COMPAT_SYSCALL_DEFINE2(clock_adjtime, clockid_t, which_clock,
103947
103948 oldfs = get_fs();
103949 set_fs(KERNEL_DS);
103950- ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
103951+ ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
103952 set_fs(oldfs);
103953
103954 err = compat_put_timex(utp, &txc);
103955@@ -804,7 +805,7 @@ COMPAT_SYSCALL_DEFINE2(clock_getres, clockid_t, which_clock,
103956 oldfs = get_fs();
103957 set_fs(KERNEL_DS);
103958 err = sys_clock_getres(which_clock,
103959- (struct timespec __user *) &ts);
103960+ (struct timespec __force_user *) &ts);
103961 set_fs(oldfs);
103962 if (!err && tp && compat_put_timespec(&ts, tp))
103963 return -EFAULT;
103964@@ -818,7 +819,7 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
103965 struct timespec tu;
103966 struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
103967
103968- restart->nanosleep.rmtp = (struct timespec __user *) &tu;
103969+ restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
103970 oldfs = get_fs();
103971 set_fs(KERNEL_DS);
103972 err = clock_nanosleep_restart(restart);
103973@@ -850,8 +851,8 @@ COMPAT_SYSCALL_DEFINE4(clock_nanosleep, clockid_t, which_clock, int, flags,
103974 oldfs = get_fs();
103975 set_fs(KERNEL_DS);
103976 err = sys_clock_nanosleep(which_clock, flags,
103977- (struct timespec __user *) &in,
103978- (struct timespec __user *) &out);
103979+ (struct timespec __force_user *) &in,
103980+ (struct timespec __force_user *) &out);
103981 set_fs(oldfs);
103982
103983 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
103984@@ -1147,7 +1148,7 @@ COMPAT_SYSCALL_DEFINE2(sched_rr_get_interval,
103985 mm_segment_t old_fs = get_fs();
103986
103987 set_fs(KERNEL_DS);
103988- ret = sys_sched_rr_get_interval(pid, (struct timespec __user *)&t);
103989+ ret = sys_sched_rr_get_interval(pid, (struct timespec __force_user *)&t);
103990 set_fs(old_fs);
103991 if (compat_put_timespec(&t, interval))
103992 return -EFAULT;
103993diff --git a/kernel/configs.c b/kernel/configs.c
103994index c18b1f1..b9a0132 100644
103995--- a/kernel/configs.c
103996+++ b/kernel/configs.c
103997@@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
103998 struct proc_dir_entry *entry;
103999
104000 /* create the current config file */
104001+#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
104002+#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
104003+ entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
104004+ &ikconfig_file_ops);
104005+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
104006+ entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
104007+ &ikconfig_file_ops);
104008+#endif
104009+#else
104010 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
104011 &ikconfig_file_ops);
104012+#endif
104013+
104014 if (!entry)
104015 return -ENOMEM;
104016
104017diff --git a/kernel/cred.c b/kernel/cred.c
104018index ec1c076..7da8a0e 100644
104019--- a/kernel/cred.c
104020+++ b/kernel/cred.c
104021@@ -167,6 +167,15 @@ void exit_creds(struct task_struct *tsk)
104022 validate_creds(cred);
104023 alter_cred_subscribers(cred, -1);
104024 put_cred(cred);
104025+
104026+#ifdef CONFIG_GRKERNSEC_SETXID
104027+ cred = (struct cred *) tsk->delayed_cred;
104028+ if (cred != NULL) {
104029+ tsk->delayed_cred = NULL;
104030+ validate_creds(cred);
104031+ put_cred(cred);
104032+ }
104033+#endif
104034 }
104035
104036 /**
104037@@ -414,7 +423,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
104038 * Always returns 0 thus allowing this function to be tail-called at the end
104039 * of, say, sys_setgid().
104040 */
104041-int commit_creds(struct cred *new)
104042+static int __commit_creds(struct cred *new)
104043 {
104044 struct task_struct *task = current;
104045 const struct cred *old = task->real_cred;
104046@@ -433,6 +442,8 @@ int commit_creds(struct cred *new)
104047
104048 get_cred(new); /* we will require a ref for the subj creds too */
104049
104050+ gr_set_role_label(task, new->uid, new->gid);
104051+
104052 /* dumpability changes */
104053 if (!uid_eq(old->euid, new->euid) ||
104054 !gid_eq(old->egid, new->egid) ||
104055@@ -482,6 +493,105 @@ int commit_creds(struct cred *new)
104056 put_cred(old);
104057 return 0;
104058 }
104059+#ifdef CONFIG_GRKERNSEC_SETXID
104060+extern int set_user(struct cred *new);
104061+
104062+void gr_delayed_cred_worker(void)
104063+{
104064+ const struct cred *new = current->delayed_cred;
104065+ struct cred *ncred;
104066+
104067+ current->delayed_cred = NULL;
104068+
104069+ if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
104070+ // from doing get_cred on it when queueing this
104071+ put_cred(new);
104072+ return;
104073+ } else if (new == NULL)
104074+ return;
104075+
104076+ ncred = prepare_creds();
104077+ if (!ncred)
104078+ goto die;
104079+ // uids
104080+ ncred->uid = new->uid;
104081+ ncred->euid = new->euid;
104082+ ncred->suid = new->suid;
104083+ ncred->fsuid = new->fsuid;
104084+ // gids
104085+ ncred->gid = new->gid;
104086+ ncred->egid = new->egid;
104087+ ncred->sgid = new->sgid;
104088+ ncred->fsgid = new->fsgid;
104089+ // groups
104090+ set_groups(ncred, new->group_info);
104091+ // caps
104092+ ncred->securebits = new->securebits;
104093+ ncred->cap_inheritable = new->cap_inheritable;
104094+ ncred->cap_permitted = new->cap_permitted;
104095+ ncred->cap_effective = new->cap_effective;
104096+ ncred->cap_bset = new->cap_bset;
104097+
104098+ if (set_user(ncred)) {
104099+ abort_creds(ncred);
104100+ goto die;
104101+ }
104102+
104103+ // from doing get_cred on it when queueing this
104104+ put_cred(new);
104105+
104106+ __commit_creds(ncred);
104107+ return;
104108+die:
104109+ // from doing get_cred on it when queueing this
104110+ put_cred(new);
104111+ do_group_exit(SIGKILL);
104112+}
104113+#endif
104114+
104115+int commit_creds(struct cred *new)
104116+{
104117+#ifdef CONFIG_GRKERNSEC_SETXID
104118+ int ret;
104119+ int schedule_it = 0;
104120+ struct task_struct *t;
104121+ unsigned oldsecurebits = current_cred()->securebits;
104122+
104123+ /* we won't get called with tasklist_lock held for writing
104124+ and interrupts disabled as the cred struct in that case is
104125+ init_cred
104126+ */
104127+ if (grsec_enable_setxid && !current_is_single_threaded() &&
104128+ uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
104129+ !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
104130+ schedule_it = 1;
104131+ }
104132+ ret = __commit_creds(new);
104133+ if (schedule_it) {
104134+ rcu_read_lock();
104135+ read_lock(&tasklist_lock);
104136+ for (t = next_thread(current); t != current;
104137+ t = next_thread(t)) {
104138+ /* we'll check if the thread has uid 0 in
104139+ * the delayed worker routine
104140+ */
104141+ if (task_securebits(t) == oldsecurebits &&
104142+ t->delayed_cred == NULL) {
104143+ t->delayed_cred = get_cred(new);
104144+ set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
104145+ set_tsk_need_resched(t);
104146+ }
104147+ }
104148+ read_unlock(&tasklist_lock);
104149+ rcu_read_unlock();
104150+ }
104151+
104152+ return ret;
104153+#else
104154+ return __commit_creds(new);
104155+#endif
104156+}
104157+
104158 EXPORT_SYMBOL(commit_creds);
104159
104160 /**
104161diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
104162index 0874e2e..5b32cc9 100644
104163--- a/kernel/debug/debug_core.c
104164+++ b/kernel/debug/debug_core.c
104165@@ -127,7 +127,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
104166 */
104167 static atomic_t masters_in_kgdb;
104168 static atomic_t slaves_in_kgdb;
104169-static atomic_t kgdb_break_tasklet_var;
104170+static atomic_unchecked_t kgdb_break_tasklet_var;
104171 atomic_t kgdb_setting_breakpoint;
104172
104173 struct task_struct *kgdb_usethread;
104174@@ -137,7 +137,7 @@ int kgdb_single_step;
104175 static pid_t kgdb_sstep_pid;
104176
104177 /* to keep track of the CPU which is doing the single stepping*/
104178-atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
104179+atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
104180
104181 /*
104182 * If you are debugging a problem where roundup (the collection of
104183@@ -552,7 +552,7 @@ return_normal:
104184 * kernel will only try for the value of sstep_tries before
104185 * giving up and continuing on.
104186 */
104187- if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
104188+ if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
104189 (kgdb_info[cpu].task &&
104190 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
104191 atomic_set(&kgdb_active, -1);
104192@@ -654,8 +654,8 @@ cpu_master_loop:
104193 }
104194
104195 kgdb_restore:
104196- if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
104197- int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
104198+ if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
104199+ int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
104200 if (kgdb_info[sstep_cpu].task)
104201 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
104202 else
104203@@ -949,18 +949,18 @@ static void kgdb_unregister_callbacks(void)
104204 static void kgdb_tasklet_bpt(unsigned long ing)
104205 {
104206 kgdb_breakpoint();
104207- atomic_set(&kgdb_break_tasklet_var, 0);
104208+ atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
104209 }
104210
104211 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
104212
104213 void kgdb_schedule_breakpoint(void)
104214 {
104215- if (atomic_read(&kgdb_break_tasklet_var) ||
104216+ if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
104217 atomic_read(&kgdb_active) != -1 ||
104218 atomic_read(&kgdb_setting_breakpoint))
104219 return;
104220- atomic_inc(&kgdb_break_tasklet_var);
104221+ atomic_inc_unchecked(&kgdb_break_tasklet_var);
104222 tasklet_schedule(&kgdb_tasklet_breakpoint);
104223 }
104224 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
104225diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
104226index 41213454..861e178 100644
104227--- a/kernel/debug/kdb/kdb_main.c
104228+++ b/kernel/debug/kdb/kdb_main.c
104229@@ -2021,7 +2021,7 @@ static int kdb_lsmod(int argc, const char **argv)
104230 continue;
104231
104232 kdb_printf("%-20s%8u 0x%p ", mod->name,
104233- mod->core_size, (void *)mod);
104234+ mod->core_size_rx + mod->core_size_rw, (void *)mod);
104235 #ifdef CONFIG_MODULE_UNLOAD
104236 kdb_printf("%4d ", module_refcount(mod));
104237 #endif
104238@@ -2031,7 +2031,7 @@ static int kdb_lsmod(int argc, const char **argv)
104239 kdb_printf(" (Loading)");
104240 else
104241 kdb_printf(" (Live)");
104242- kdb_printf(" 0x%p", mod->module_core);
104243+ kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
104244
104245 #ifdef CONFIG_MODULE_UNLOAD
104246 {
104247diff --git a/kernel/events/core.c b/kernel/events/core.c
104248index 0ceb386..ddaf008 100644
104249--- a/kernel/events/core.c
104250+++ b/kernel/events/core.c
104251@@ -172,8 +172,15 @@ static struct srcu_struct pmus_srcu;
104252 * 0 - disallow raw tracepoint access for unpriv
104253 * 1 - disallow cpu events for unpriv
104254 * 2 - disallow kernel profiling for unpriv
104255+ * 3 - disallow all unpriv perf event use
104256 */
104257-int sysctl_perf_event_paranoid __read_mostly = 1;
104258+#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
104259+int sysctl_perf_event_legitimately_concerned __read_only = 3;
104260+#elif defined(CONFIG_GRKERNSEC_HIDESYM)
104261+int sysctl_perf_event_legitimately_concerned __read_only = 2;
104262+#else
104263+int sysctl_perf_event_legitimately_concerned __read_only = 1;
104264+#endif
104265
104266 /* Minimum for 512 kiB + 1 user control page */
104267 int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
104268@@ -199,7 +206,7 @@ void update_perf_cpu_limits(void)
104269
104270 tmp *= sysctl_perf_cpu_time_max_percent;
104271 do_div(tmp, 100);
104272- ACCESS_ONCE(perf_sample_allowed_ns) = tmp;
104273+ ACCESS_ONCE_RW(perf_sample_allowed_ns) = tmp;
104274 }
104275
104276 static int perf_rotate_context(struct perf_cpu_context *cpuctx);
104277@@ -305,7 +312,7 @@ void perf_sample_event_took(u64 sample_len_ns)
104278 }
104279 }
104280
104281-static atomic64_t perf_event_id;
104282+static atomic64_unchecked_t perf_event_id;
104283
104284 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
104285 enum event_type_t event_type);
104286@@ -3771,9 +3778,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
104287 mutex_lock(&event->child_mutex);
104288 total += perf_event_read(event);
104289 *enabled += event->total_time_enabled +
104290- atomic64_read(&event->child_total_time_enabled);
104291+ atomic64_read_unchecked(&event->child_total_time_enabled);
104292 *running += event->total_time_running +
104293- atomic64_read(&event->child_total_time_running);
104294+ atomic64_read_unchecked(&event->child_total_time_running);
104295
104296 list_for_each_entry(child, &event->child_list, child_list) {
104297 total += perf_event_read(child);
104298@@ -4268,10 +4275,10 @@ void perf_event_update_userpage(struct perf_event *event)
104299 userpg->offset -= local64_read(&event->hw.prev_count);
104300
104301 userpg->time_enabled = enabled +
104302- atomic64_read(&event->child_total_time_enabled);
104303+ atomic64_read_unchecked(&event->child_total_time_enabled);
104304
104305 userpg->time_running = running +
104306- atomic64_read(&event->child_total_time_running);
104307+ atomic64_read_unchecked(&event->child_total_time_running);
104308
104309 arch_perf_update_userpage(event, userpg, now);
104310
104311@@ -4946,7 +4953,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
104312
104313 /* Data. */
104314 sp = perf_user_stack_pointer(regs);
104315- rem = __output_copy_user(handle, (void *) sp, dump_size);
104316+ rem = __output_copy_user(handle, (void __user *) sp, dump_size);
104317 dyn_size = dump_size - rem;
104318
104319 perf_output_skip(handle, rem);
104320@@ -5037,11 +5044,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
104321 values[n++] = perf_event_count(event);
104322 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
104323 values[n++] = enabled +
104324- atomic64_read(&event->child_total_time_enabled);
104325+ atomic64_read_unchecked(&event->child_total_time_enabled);
104326 }
104327 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
104328 values[n++] = running +
104329- atomic64_read(&event->child_total_time_running);
104330+ atomic64_read_unchecked(&event->child_total_time_running);
104331 }
104332 if (read_format & PERF_FORMAT_ID)
104333 values[n++] = primary_event_id(event);
104334@@ -7533,7 +7540,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
104335 event->parent = parent_event;
104336
104337 event->ns = get_pid_ns(task_active_pid_ns(current));
104338- event->id = atomic64_inc_return(&perf_event_id);
104339+ event->id = atomic64_inc_return_unchecked(&perf_event_id);
104340
104341 event->state = PERF_EVENT_STATE_INACTIVE;
104342
104343@@ -7892,6 +7899,11 @@ SYSCALL_DEFINE5(perf_event_open,
104344 if (flags & ~PERF_FLAG_ALL)
104345 return -EINVAL;
104346
104347+#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
104348+ if (perf_paranoid_any() && !capable(CAP_SYS_ADMIN))
104349+ return -EACCES;
104350+#endif
104351+
104352 err = perf_copy_attr(attr_uptr, &attr);
104353 if (err)
104354 return err;
104355@@ -8340,10 +8352,10 @@ static void sync_child_event(struct perf_event *child_event,
104356 /*
104357 * Add back the child's count to the parent's count:
104358 */
104359- atomic64_add(child_val, &parent_event->child_count);
104360- atomic64_add(child_event->total_time_enabled,
104361+ atomic64_add_unchecked(child_val, &parent_event->child_count);
104362+ atomic64_add_unchecked(child_event->total_time_enabled,
104363 &parent_event->child_total_time_enabled);
104364- atomic64_add(child_event->total_time_running,
104365+ atomic64_add_unchecked(child_event->total_time_running,
104366 &parent_event->child_total_time_running);
104367
104368 /*
104369diff --git a/kernel/events/internal.h b/kernel/events/internal.h
104370index 9f6ce9b..e4f2cbb 100644
104371--- a/kernel/events/internal.h
104372+++ b/kernel/events/internal.h
104373@@ -114,10 +114,10 @@ static inline unsigned long perf_aux_size(struct ring_buffer *rb)
104374 return rb->aux_nr_pages << PAGE_SHIFT;
104375 }
104376
104377-#define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \
104378+#define DEFINE_OUTPUT_COPY(func_name, memcpy_func, user) \
104379 static inline unsigned long \
104380 func_name(struct perf_output_handle *handle, \
104381- const void *buf, unsigned long len) \
104382+ const void user *buf, unsigned long len) \
104383 { \
104384 unsigned long size, written; \
104385 \
104386@@ -150,7 +150,7 @@ memcpy_common(void *dst, const void *src, unsigned long n)
104387 return 0;
104388 }
104389
104390-DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
104391+DEFINE_OUTPUT_COPY(__output_copy, memcpy_common, )
104392
104393 static inline unsigned long
104394 memcpy_skip(void *dst, const void *src, unsigned long n)
104395@@ -158,7 +158,7 @@ memcpy_skip(void *dst, const void *src, unsigned long n)
104396 return 0;
104397 }
104398
104399-DEFINE_OUTPUT_COPY(__output_skip, memcpy_skip)
104400+DEFINE_OUTPUT_COPY(__output_skip, memcpy_skip, )
104401
104402 #ifndef arch_perf_out_copy_user
104403 #define arch_perf_out_copy_user arch_perf_out_copy_user
104404@@ -176,7 +176,7 @@ arch_perf_out_copy_user(void *dst, const void *src, unsigned long n)
104405 }
104406 #endif
104407
104408-DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
104409+DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user, __user)
104410
104411 /* Callchain handling */
104412 extern struct perf_callchain_entry *
104413diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
104414index cb346f2..e4dc317 100644
104415--- a/kernel/events/uprobes.c
104416+++ b/kernel/events/uprobes.c
104417@@ -1670,7 +1670,7 @@ static int is_trap_at_addr(struct mm_struct *mm, unsigned long vaddr)
104418 {
104419 struct page *page;
104420 uprobe_opcode_t opcode;
104421- int result;
104422+ long result;
104423
104424 pagefault_disable();
104425 result = __copy_from_user_inatomic(&opcode, (void __user*)vaddr,
104426diff --git a/kernel/exit.c b/kernel/exit.c
104427index 22fcc05..5f07dbc 100644
104428--- a/kernel/exit.c
104429+++ b/kernel/exit.c
104430@@ -171,6 +171,10 @@ void release_task(struct task_struct *p)
104431 struct task_struct *leader;
104432 int zap_leader;
104433 repeat:
104434+#ifdef CONFIG_NET
104435+ gr_del_task_from_ip_table(p);
104436+#endif
104437+
104438 /* don't need to get the RCU readlock here - the process is dead and
104439 * can't be modifying its own credentials. But shut RCU-lockdep up */
104440 rcu_read_lock();
104441@@ -656,6 +660,8 @@ void do_exit(long code)
104442 int group_dead;
104443 TASKS_RCU(int tasks_rcu_i);
104444
104445+ set_fs(USER_DS);
104446+
104447 profile_task_exit(tsk);
104448
104449 WARN_ON(blk_needs_flush_plug(tsk));
104450@@ -672,7 +678,6 @@ void do_exit(long code)
104451 * mm_release()->clear_child_tid() from writing to a user-controlled
104452 * kernel address.
104453 */
104454- set_fs(USER_DS);
104455
104456 ptrace_event(PTRACE_EVENT_EXIT, code);
104457
104458@@ -730,6 +735,9 @@ void do_exit(long code)
104459 tsk->exit_code = code;
104460 taskstats_exit(tsk, group_dead);
104461
104462+ gr_acl_handle_psacct(tsk, code);
104463+ gr_acl_handle_exit();
104464+
104465 exit_mm(tsk);
104466
104467 if (group_dead)
104468@@ -847,7 +855,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
104469 * Take down every thread in the group. This is called by fatal signals
104470 * as well as by sys_exit_group (below).
104471 */
104472-void
104473+__noreturn void
104474 do_group_exit(int exit_code)
104475 {
104476 struct signal_struct *sig = current->signal;
104477diff --git a/kernel/fork.c b/kernel/fork.c
104478index 03c1eaa..461be4c 100644
104479--- a/kernel/fork.c
104480+++ b/kernel/fork.c
104481@@ -188,12 +188,54 @@ static void free_thread_info(struct thread_info *ti)
104482 void thread_info_cache_init(void)
104483 {
104484 thread_info_cache = kmem_cache_create("thread_info", THREAD_SIZE,
104485- THREAD_SIZE, 0, NULL);
104486+ THREAD_SIZE, SLAB_USERCOPY, NULL);
104487 BUG_ON(thread_info_cache == NULL);
104488 }
104489 # endif
104490 #endif
104491
104492+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
104493+static inline struct thread_info *gr_alloc_thread_info_node(struct task_struct *tsk,
104494+ int node, void **lowmem_stack)
104495+{
104496+ struct page *pages[THREAD_SIZE / PAGE_SIZE];
104497+ void *ret = NULL;
104498+ unsigned int i;
104499+
104500+ *lowmem_stack = alloc_thread_info_node(tsk, node);
104501+ if (*lowmem_stack == NULL)
104502+ goto out;
104503+
104504+ for (i = 0; i < THREAD_SIZE / PAGE_SIZE; i++)
104505+ pages[i] = virt_to_page(*lowmem_stack + (i * PAGE_SIZE));
104506+
104507+ /* use VM_IOREMAP to gain THREAD_SIZE alignment */
104508+ ret = vmap(pages, THREAD_SIZE / PAGE_SIZE, VM_IOREMAP, PAGE_KERNEL);
104509+ if (ret == NULL) {
104510+ free_thread_info(*lowmem_stack);
104511+ *lowmem_stack = NULL;
104512+ }
104513+
104514+out:
104515+ return ret;
104516+}
104517+
104518+static inline void gr_free_thread_info(struct task_struct *tsk, struct thread_info *ti)
104519+{
104520+ unmap_process_stacks(tsk);
104521+}
104522+#else
104523+static inline struct thread_info *gr_alloc_thread_info_node(struct task_struct *tsk,
104524+ int node, void **lowmem_stack)
104525+{
104526+ return alloc_thread_info_node(tsk, node);
104527+}
104528+static inline void gr_free_thread_info(struct task_struct *tsk, struct thread_info *ti)
104529+{
104530+ free_thread_info(ti);
104531+}
104532+#endif
104533+
104534 /* SLAB cache for signal_struct structures (tsk->signal) */
104535 static struct kmem_cache *signal_cachep;
104536
104537@@ -212,18 +254,22 @@ struct kmem_cache *vm_area_cachep;
104538 /* SLAB cache for mm_struct structures (tsk->mm) */
104539 static struct kmem_cache *mm_cachep;
104540
104541-static void account_kernel_stack(struct thread_info *ti, int account)
104542+static void account_kernel_stack(struct task_struct *tsk, struct thread_info *ti, int account)
104543 {
104544+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
104545+ struct zone *zone = page_zone(virt_to_page(tsk->lowmem_stack));
104546+#else
104547 struct zone *zone = page_zone(virt_to_page(ti));
104548+#endif
104549
104550 mod_zone_page_state(zone, NR_KERNEL_STACK, account);
104551 }
104552
104553 void free_task(struct task_struct *tsk)
104554 {
104555- account_kernel_stack(tsk->stack, -1);
104556+ account_kernel_stack(tsk, tsk->stack, -1);
104557 arch_release_thread_info(tsk->stack);
104558- free_thread_info(tsk->stack);
104559+ gr_free_thread_info(tsk, tsk->stack);
104560 rt_mutex_debug_task_free(tsk);
104561 ftrace_graph_exit_task(tsk);
104562 put_seccomp_filter(tsk);
104563@@ -329,6 +375,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
104564 {
104565 struct task_struct *tsk;
104566 struct thread_info *ti;
104567+ void *lowmem_stack;
104568 int node = tsk_fork_get_node(orig);
104569 int err;
104570
104571@@ -336,7 +383,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
104572 if (!tsk)
104573 return NULL;
104574
104575- ti = alloc_thread_info_node(tsk, node);
104576+ ti = gr_alloc_thread_info_node(tsk, node, &lowmem_stack);
104577 if (!ti)
104578 goto free_tsk;
104579
104580@@ -345,6 +392,9 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
104581 goto free_ti;
104582
104583 tsk->stack = ti;
104584+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
104585+ tsk->lowmem_stack = lowmem_stack;
104586+#endif
104587 #ifdef CONFIG_SECCOMP
104588 /*
104589 * We must handle setting up seccomp filters once we're under
104590@@ -361,7 +411,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
104591 set_task_stack_end_magic(tsk);
104592
104593 #ifdef CONFIG_CC_STACKPROTECTOR
104594- tsk->stack_canary = get_random_int();
104595+ tsk->stack_canary = pax_get_random_long();
104596 #endif
104597
104598 /*
104599@@ -375,24 +425,89 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
104600 tsk->splice_pipe = NULL;
104601 tsk->task_frag.page = NULL;
104602
104603- account_kernel_stack(ti, 1);
104604+ account_kernel_stack(tsk, ti, 1);
104605
104606 return tsk;
104607
104608 free_ti:
104609- free_thread_info(ti);
104610+ gr_free_thread_info(tsk, ti);
104611 free_tsk:
104612 free_task_struct(tsk);
104613 return NULL;
104614 }
104615
104616 #ifdef CONFIG_MMU
104617-static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
104618+static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
104619+{
104620+ struct vm_area_struct *tmp;
104621+ unsigned long charge;
104622+ struct file *file;
104623+ int retval;
104624+
104625+ charge = 0;
104626+ if (mpnt->vm_flags & VM_ACCOUNT) {
104627+ unsigned long len = vma_pages(mpnt);
104628+
104629+ if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
104630+ goto fail_nomem;
104631+ charge = len;
104632+ }
104633+ tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
104634+ if (!tmp)
104635+ goto fail_nomem;
104636+ *tmp = *mpnt;
104637+ tmp->vm_mm = mm;
104638+ INIT_LIST_HEAD(&tmp->anon_vma_chain);
104639+ retval = vma_dup_policy(mpnt, tmp);
104640+ if (retval)
104641+ goto fail_nomem_policy;
104642+ if (anon_vma_fork(tmp, mpnt))
104643+ goto fail_nomem_anon_vma_fork;
104644+ tmp->vm_flags &= ~VM_LOCKED;
104645+ tmp->vm_next = tmp->vm_prev = NULL;
104646+ tmp->vm_mirror = NULL;
104647+ file = tmp->vm_file;
104648+ if (file) {
104649+ struct inode *inode = file_inode(file);
104650+ struct address_space *mapping = file->f_mapping;
104651+
104652+ get_file(file);
104653+ if (tmp->vm_flags & VM_DENYWRITE)
104654+ atomic_dec(&inode->i_writecount);
104655+ i_mmap_lock_write(mapping);
104656+ if (tmp->vm_flags & VM_SHARED)
104657+ atomic_inc(&mapping->i_mmap_writable);
104658+ flush_dcache_mmap_lock(mapping);
104659+ /* insert tmp into the share list, just after mpnt */
104660+ vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
104661+ flush_dcache_mmap_unlock(mapping);
104662+ i_mmap_unlock_write(mapping);
104663+ }
104664+
104665+ /*
104666+ * Clear hugetlb-related page reserves for children. This only
104667+ * affects MAP_PRIVATE mappings. Faults generated by the child
104668+ * are not guaranteed to succeed, even if read-only
104669+ */
104670+ if (is_vm_hugetlb_page(tmp))
104671+ reset_vma_resv_huge_pages(tmp);
104672+
104673+ return tmp;
104674+
104675+fail_nomem_anon_vma_fork:
104676+ mpol_put(vma_policy(tmp));
104677+fail_nomem_policy:
104678+ kmem_cache_free(vm_area_cachep, tmp);
104679+fail_nomem:
104680+ vm_unacct_memory(charge);
104681+ return NULL;
104682+}
104683+
104684+static __latent_entropy int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
104685 {
104686 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
104687 struct rb_node **rb_link, *rb_parent;
104688 int retval;
104689- unsigned long charge;
104690
104691 uprobe_start_dup_mmap();
104692 down_write(&oldmm->mmap_sem);
104693@@ -423,51 +538,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
104694
104695 prev = NULL;
104696 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
104697- struct file *file;
104698-
104699 if (mpnt->vm_flags & VM_DONTCOPY) {
104700 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
104701 -vma_pages(mpnt));
104702 continue;
104703 }
104704- charge = 0;
104705- if (mpnt->vm_flags & VM_ACCOUNT) {
104706- unsigned long len = vma_pages(mpnt);
104707-
104708- if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
104709- goto fail_nomem;
104710- charge = len;
104711- }
104712- tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
104713- if (!tmp)
104714- goto fail_nomem;
104715- *tmp = *mpnt;
104716- INIT_LIST_HEAD(&tmp->anon_vma_chain);
104717- retval = vma_dup_policy(mpnt, tmp);
104718- if (retval)
104719- goto fail_nomem_policy;
104720- tmp->vm_mm = mm;
104721- if (anon_vma_fork(tmp, mpnt))
104722- goto fail_nomem_anon_vma_fork;
104723- tmp->vm_flags &= ~VM_LOCKED;
104724- tmp->vm_next = tmp->vm_prev = NULL;
104725- file = tmp->vm_file;
104726- if (file) {
104727- struct inode *inode = file_inode(file);
104728- struct address_space *mapping = file->f_mapping;
104729-
104730- get_file(file);
104731- if (tmp->vm_flags & VM_DENYWRITE)
104732- atomic_dec(&inode->i_writecount);
104733- i_mmap_lock_write(mapping);
104734- if (tmp->vm_flags & VM_SHARED)
104735- atomic_inc(&mapping->i_mmap_writable);
104736- flush_dcache_mmap_lock(mapping);
104737- /* insert tmp into the share list, just after mpnt */
104738- vma_interval_tree_insert_after(tmp, mpnt,
104739- &mapping->i_mmap);
104740- flush_dcache_mmap_unlock(mapping);
104741- i_mmap_unlock_write(mapping);
104742+ tmp = dup_vma(mm, oldmm, mpnt);
104743+ if (!tmp) {
104744+ retval = -ENOMEM;
104745+ goto out;
104746 }
104747
104748 /*
104749@@ -499,6 +578,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
104750 if (retval)
104751 goto out;
104752 }
104753+
104754+#ifdef CONFIG_PAX_SEGMEXEC
104755+ if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
104756+ struct vm_area_struct *mpnt_m;
104757+
104758+ for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
104759+ BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
104760+
104761+ if (!mpnt->vm_mirror)
104762+ continue;
104763+
104764+ if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
104765+ BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
104766+ mpnt->vm_mirror = mpnt_m;
104767+ } else {
104768+ BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
104769+ mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
104770+ mpnt_m->vm_mirror->vm_mirror = mpnt_m;
104771+ mpnt->vm_mirror->vm_mirror = mpnt;
104772+ }
104773+ }
104774+ BUG_ON(mpnt_m);
104775+ }
104776+#endif
104777+
104778 /* a new mm has just been created */
104779 arch_dup_mmap(oldmm, mm);
104780 retval = 0;
104781@@ -508,14 +612,6 @@ out:
104782 up_write(&oldmm->mmap_sem);
104783 uprobe_end_dup_mmap();
104784 return retval;
104785-fail_nomem_anon_vma_fork:
104786- mpol_put(vma_policy(tmp));
104787-fail_nomem_policy:
104788- kmem_cache_free(vm_area_cachep, tmp);
104789-fail_nomem:
104790- retval = -ENOMEM;
104791- vm_unacct_memory(charge);
104792- goto out;
104793 }
104794
104795 static inline int mm_alloc_pgd(struct mm_struct *mm)
104796@@ -790,8 +886,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
104797 return ERR_PTR(err);
104798
104799 mm = get_task_mm(task);
104800- if (mm && mm != current->mm &&
104801- !ptrace_may_access(task, mode)) {
104802+ if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
104803+ (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
104804 mmput(mm);
104805 mm = ERR_PTR(-EACCES);
104806 }
104807@@ -992,13 +1088,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
104808 spin_unlock(&fs->lock);
104809 return -EAGAIN;
104810 }
104811- fs->users++;
104812+ atomic_inc(&fs->users);
104813 spin_unlock(&fs->lock);
104814 return 0;
104815 }
104816 tsk->fs = copy_fs_struct(fs);
104817 if (!tsk->fs)
104818 return -ENOMEM;
104819+ /* Carry through gr_chroot_dentry and is_chrooted instead
104820+ of recomputing it here. Already copied when the task struct
104821+ is duplicated. This allows pivot_root to not be treated as
104822+ a chroot
104823+ */
104824+ //gr_set_chroot_entries(tsk, &tsk->fs->root);
104825+
104826 return 0;
104827 }
104828
104829@@ -1236,7 +1339,7 @@ init_task_pid(struct task_struct *task, enum pid_type type, struct pid *pid)
104830 * parts of the process environment (as per the clone
104831 * flags). The actual kick-off is left to the caller.
104832 */
104833-static struct task_struct *copy_process(unsigned long clone_flags,
104834+static __latent_entropy struct task_struct *copy_process(unsigned long clone_flags,
104835 unsigned long stack_start,
104836 unsigned long stack_size,
104837 int __user *child_tidptr,
104838@@ -1307,6 +1410,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
104839 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
104840 #endif
104841 retval = -EAGAIN;
104842+
104843+ gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
104844+
104845 if (atomic_read(&p->real_cred->user->processes) >=
104846 task_rlimit(p, RLIMIT_NPROC)) {
104847 if (p->real_cred->user != INIT_USER &&
104848@@ -1554,6 +1660,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
104849 goto bad_fork_free_pid;
104850 }
104851
104852+ /* synchronizes with gr_set_acls()
104853+ we need to call this past the point of no return for fork()
104854+ */
104855+ gr_copy_label(p);
104856+
104857 if (likely(p->pid)) {
104858 ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace);
104859
104860@@ -1643,6 +1754,8 @@ bad_fork_cleanup_count:
104861 bad_fork_free:
104862 free_task(p);
104863 fork_out:
104864+ gr_log_forkfail(retval);
104865+
104866 return ERR_PTR(retval);
104867 }
104868
104869@@ -1704,6 +1817,7 @@ long do_fork(unsigned long clone_flags,
104870
104871 p = copy_process(clone_flags, stack_start, stack_size,
104872 child_tidptr, NULL, trace);
104873+ add_latent_entropy();
104874 /*
104875 * Do this prior waking up the new thread - the thread pointer
104876 * might get invalid after that point, if the thread exits quickly.
104877@@ -1720,6 +1834,8 @@ long do_fork(unsigned long clone_flags,
104878 if (clone_flags & CLONE_PARENT_SETTID)
104879 put_user(nr, parent_tidptr);
104880
104881+ gr_handle_brute_check();
104882+
104883 if (clone_flags & CLONE_VFORK) {
104884 p->vfork_done = &vfork;
104885 init_completion(&vfork);
104886@@ -1838,7 +1954,7 @@ void __init proc_caches_init(void)
104887 mm_cachep = kmem_cache_create("mm_struct",
104888 sizeof(struct mm_struct), ARCH_MIN_MMSTRUCT_ALIGN,
104889 SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_NOTRACK, NULL);
104890- vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC);
104891+ vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC | SLAB_NO_SANITIZE);
104892 mmap_init();
104893 nsproxy_cache_init();
104894 }
104895@@ -1878,7 +1994,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
104896 return 0;
104897
104898 /* don't need lock here; in the worst case we'll do useless copy */
104899- if (fs->users == 1)
104900+ if (atomic_read(&fs->users) == 1)
104901 return 0;
104902
104903 *new_fsp = copy_fs_struct(fs);
104904@@ -1990,7 +2106,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
104905 fs = current->fs;
104906 spin_lock(&fs->lock);
104907 current->fs = new_fs;
104908- if (--fs->users)
104909+ gr_set_chroot_entries(current, &current->fs->root);
104910+ if (atomic_dec_return(&fs->users))
104911 new_fs = NULL;
104912 else
104913 new_fs = fs;
104914@@ -2054,7 +2171,7 @@ int unshare_files(struct files_struct **displaced)
104915 int sysctl_max_threads(struct ctl_table *table, int write,
104916 void __user *buffer, size_t *lenp, loff_t *ppos)
104917 {
104918- struct ctl_table t;
104919+ ctl_table_no_const t;
104920 int ret;
104921 int threads = max_threads;
104922 int min = MIN_THREADS;
104923diff --git a/kernel/futex.c b/kernel/futex.c
104924index 2579e40..c33f33e 100644
104925--- a/kernel/futex.c
104926+++ b/kernel/futex.c
104927@@ -201,7 +201,7 @@ struct futex_pi_state {
104928 atomic_t refcount;
104929
104930 union futex_key key;
104931-};
104932+} __randomize_layout;
104933
104934 /**
104935 * struct futex_q - The hashed futex queue entry, one per waiting task
104936@@ -235,7 +235,7 @@ struct futex_q {
104937 struct rt_mutex_waiter *rt_waiter;
104938 union futex_key *requeue_pi_key;
104939 u32 bitset;
104940-};
104941+} __randomize_layout;
104942
104943 static const struct futex_q futex_q_init = {
104944 /* list gets initialized in queue_me()*/
104945@@ -402,6 +402,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
104946 struct page *page, *page_head;
104947 int err, ro = 0;
104948
104949+#ifdef CONFIG_PAX_SEGMEXEC
104950+ if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
104951+ return -EFAULT;
104952+#endif
104953+
104954 /*
104955 * The futex address must be "naturally" aligned.
104956 */
104957@@ -601,7 +606,7 @@ static int cmpxchg_futex_value_locked(u32 *curval, u32 __user *uaddr,
104958
104959 static int get_futex_value_locked(u32 *dest, u32 __user *from)
104960 {
104961- int ret;
104962+ unsigned long ret;
104963
104964 pagefault_disable();
104965 ret = __copy_from_user_inatomic(dest, from, sizeof(u32));
104966@@ -3006,6 +3011,7 @@ static void __init futex_detect_cmpxchg(void)
104967 {
104968 #ifndef CONFIG_HAVE_FUTEX_CMPXCHG
104969 u32 curval;
104970+ mm_segment_t oldfs;
104971
104972 /*
104973 * This will fail and we want it. Some arch implementations do
104974@@ -3017,8 +3023,11 @@ static void __init futex_detect_cmpxchg(void)
104975 * implementation, the non-functional ones will return
104976 * -ENOSYS.
104977 */
104978+ oldfs = get_fs();
104979+ set_fs(USER_DS);
104980 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
104981 futex_cmpxchg_enabled = 1;
104982+ set_fs(oldfs);
104983 #endif
104984 }
104985
104986diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
104987index 55c8c93..9ba7ad6 100644
104988--- a/kernel/futex_compat.c
104989+++ b/kernel/futex_compat.c
104990@@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
104991 return 0;
104992 }
104993
104994-static void __user *futex_uaddr(struct robust_list __user *entry,
104995+static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
104996 compat_long_t futex_offset)
104997 {
104998 compat_uptr_t base = ptr_to_compat(entry);
104999diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
105000index a744098..539f7b6 100644
105001--- a/kernel/gcov/base.c
105002+++ b/kernel/gcov/base.c
105003@@ -117,11 +117,6 @@ void gcov_enable_events(void)
105004 }
105005
105006 #ifdef CONFIG_MODULES
105007-static inline int within(void *addr, void *start, unsigned long size)
105008-{
105009- return ((addr >= start) && (addr < start + size));
105010-}
105011-
105012 /* Update list and generate events when modules are unloaded. */
105013 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
105014 void *data)
105015@@ -136,7 +131,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
105016
105017 /* Remove entries located in module from linked list. */
105018 while ((info = gcov_info_next(info))) {
105019- if (within(info, mod->module_core, mod->core_size)) {
105020+ if (within_module_core_rw((unsigned long)info, mod)) {
105021 gcov_info_unlink(prev, info);
105022 if (gcov_events_enabled)
105023 gcov_event(GCOV_REMOVE, info);
105024diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
105025index e68932b..2247e06 100644
105026--- a/kernel/irq/manage.c
105027+++ b/kernel/irq/manage.c
105028@@ -906,7 +906,7 @@ static int irq_thread(void *data)
105029
105030 action_ret = handler_fn(desc, action);
105031 if (action_ret == IRQ_HANDLED)
105032- atomic_inc(&desc->threads_handled);
105033+ atomic_inc_unchecked(&desc->threads_handled);
105034
105035 wake_threads_waitq(desc);
105036 }
105037diff --git a/kernel/irq/spurious.c b/kernel/irq/spurious.c
105038index e2514b0..de3dfe0 100644
105039--- a/kernel/irq/spurious.c
105040+++ b/kernel/irq/spurious.c
105041@@ -337,7 +337,7 @@ void note_interrupt(unsigned int irq, struct irq_desc *desc,
105042 * count. We just care about the count being
105043 * different than the one we saw before.
105044 */
105045- handled = atomic_read(&desc->threads_handled);
105046+ handled = atomic_read_unchecked(&desc->threads_handled);
105047 handled |= SPURIOUS_DEFERRED;
105048 if (handled != desc->threads_handled_last) {
105049 action_ret = IRQ_HANDLED;
105050diff --git a/kernel/jump_label.c b/kernel/jump_label.c
105051index 9019f15..9a3c42e 100644
105052--- a/kernel/jump_label.c
105053+++ b/kernel/jump_label.c
105054@@ -14,6 +14,7 @@
105055 #include <linux/err.h>
105056 #include <linux/static_key.h>
105057 #include <linux/jump_label_ratelimit.h>
105058+#include <linux/mm.h>
105059
105060 #ifdef HAVE_JUMP_LABEL
105061
105062@@ -51,7 +52,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
105063
105064 size = (((unsigned long)stop - (unsigned long)start)
105065 / sizeof(struct jump_entry));
105066+ pax_open_kernel();
105067 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
105068+ pax_close_kernel();
105069 }
105070
105071 static void jump_label_update(struct static_key *key, int enable);
105072@@ -363,10 +366,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
105073 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
105074 struct jump_entry *iter;
105075
105076+ pax_open_kernel();
105077 for (iter = iter_start; iter < iter_stop; iter++) {
105078 if (within_module_init(iter->code, mod))
105079 iter->code = 0;
105080 }
105081+ pax_close_kernel();
105082 }
105083
105084 static int
105085diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
105086index 5c5987f..bc502b0 100644
105087--- a/kernel/kallsyms.c
105088+++ b/kernel/kallsyms.c
105089@@ -11,6 +11,9 @@
105090 * Changed the compression method from stem compression to "table lookup"
105091 * compression (see scripts/kallsyms.c for a more complete description)
105092 */
105093+#ifdef CONFIG_GRKERNSEC_HIDESYM
105094+#define __INCLUDED_BY_HIDESYM 1
105095+#endif
105096 #include <linux/kallsyms.h>
105097 #include <linux/module.h>
105098 #include <linux/init.h>
105099@@ -54,12 +57,33 @@ extern const unsigned long kallsyms_markers[] __weak;
105100
105101 static inline int is_kernel_inittext(unsigned long addr)
105102 {
105103+ if (system_state != SYSTEM_BOOTING)
105104+ return 0;
105105+
105106 if (addr >= (unsigned long)_sinittext
105107 && addr <= (unsigned long)_einittext)
105108 return 1;
105109 return 0;
105110 }
105111
105112+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
105113+#ifdef CONFIG_MODULES
105114+static inline int is_module_text(unsigned long addr)
105115+{
105116+ if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
105117+ return 1;
105118+
105119+ addr = ktla_ktva(addr);
105120+ return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
105121+}
105122+#else
105123+static inline int is_module_text(unsigned long addr)
105124+{
105125+ return 0;
105126+}
105127+#endif
105128+#endif
105129+
105130 static inline int is_kernel_text(unsigned long addr)
105131 {
105132 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
105133@@ -70,13 +94,28 @@ static inline int is_kernel_text(unsigned long addr)
105134
105135 static inline int is_kernel(unsigned long addr)
105136 {
105137+
105138+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
105139+ if (is_kernel_text(addr) || is_kernel_inittext(addr))
105140+ return 1;
105141+
105142+ if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
105143+#else
105144 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
105145+#endif
105146+
105147 return 1;
105148 return in_gate_area_no_mm(addr);
105149 }
105150
105151 static int is_ksym_addr(unsigned long addr)
105152 {
105153+
105154+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
105155+ if (is_module_text(addr))
105156+ return 0;
105157+#endif
105158+
105159 if (all_var)
105160 return is_kernel(addr);
105161
105162@@ -481,7 +520,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
105163
105164 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
105165 {
105166- iter->name[0] = '\0';
105167 iter->nameoff = get_symbol_offset(new_pos);
105168 iter->pos = new_pos;
105169 }
105170@@ -529,6 +567,11 @@ static int s_show(struct seq_file *m, void *p)
105171 {
105172 struct kallsym_iter *iter = m->private;
105173
105174+#ifdef CONFIG_GRKERNSEC_HIDESYM
105175+ if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
105176+ return 0;
105177+#endif
105178+
105179 /* Some debugging symbols have no name. Ignore them. */
105180 if (!iter->name[0])
105181 return 0;
105182@@ -542,6 +585,7 @@ static int s_show(struct seq_file *m, void *p)
105183 */
105184 type = iter->exported ? toupper(iter->type) :
105185 tolower(iter->type);
105186+
105187 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
105188 type, iter->name, iter->module_name);
105189 } else
105190diff --git a/kernel/kcmp.c b/kernel/kcmp.c
105191index 0aa69ea..a7fcafb 100644
105192--- a/kernel/kcmp.c
105193+++ b/kernel/kcmp.c
105194@@ -100,6 +100,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
105195 struct task_struct *task1, *task2;
105196 int ret;
105197
105198+#ifdef CONFIG_GRKERNSEC
105199+ return -ENOSYS;
105200+#endif
105201+
105202 rcu_read_lock();
105203
105204 /*
105205diff --git a/kernel/kexec.c b/kernel/kexec.c
105206index 7a36fdc..de8c4ed 100644
105207--- a/kernel/kexec.c
105208+++ b/kernel/kexec.c
105209@@ -1232,7 +1232,7 @@ static int kimage_load_segment(struct kimage *image,
105210 */
105211 struct kimage *kexec_image;
105212 struct kimage *kexec_crash_image;
105213-int kexec_load_disabled;
105214+int kexec_load_disabled __read_only;
105215
105216 static DEFINE_MUTEX(kexec_mutex);
105217
105218@@ -1348,7 +1348,8 @@ COMPAT_SYSCALL_DEFINE4(kexec_load, compat_ulong_t, entry,
105219 compat_ulong_t, flags)
105220 {
105221 struct compat_kexec_segment in;
105222- struct kexec_segment out, __user *ksegments;
105223+ struct kexec_segment out;
105224+ struct kexec_segment __user *ksegments;
105225 unsigned long i, result;
105226
105227 /* Don't allow clients that don't understand the native
105228diff --git a/kernel/kmod.c b/kernel/kmod.c
105229index 2777f40..a689506 100644
105230--- a/kernel/kmod.c
105231+++ b/kernel/kmod.c
105232@@ -68,7 +68,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
105233 kfree(info->argv);
105234 }
105235
105236-static int call_modprobe(char *module_name, int wait)
105237+static int call_modprobe(char *module_name, char *module_param, int wait)
105238 {
105239 struct subprocess_info *info;
105240 static char *envp[] = {
105241@@ -78,7 +78,7 @@ static int call_modprobe(char *module_name, int wait)
105242 NULL
105243 };
105244
105245- char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
105246+ char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
105247 if (!argv)
105248 goto out;
105249
105250@@ -90,7 +90,8 @@ static int call_modprobe(char *module_name, int wait)
105251 argv[1] = "-q";
105252 argv[2] = "--";
105253 argv[3] = module_name; /* check free_modprobe_argv() */
105254- argv[4] = NULL;
105255+ argv[4] = module_param;
105256+ argv[5] = NULL;
105257
105258 info = call_usermodehelper_setup(modprobe_path, argv, envp, GFP_KERNEL,
105259 NULL, free_modprobe_argv, NULL);
105260@@ -122,9 +123,8 @@ out:
105261 * If module auto-loading support is disabled then this function
105262 * becomes a no-operation.
105263 */
105264-int __request_module(bool wait, const char *fmt, ...)
105265+static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
105266 {
105267- va_list args;
105268 char module_name[MODULE_NAME_LEN];
105269 unsigned int max_modprobes;
105270 int ret;
105271@@ -143,9 +143,7 @@ int __request_module(bool wait, const char *fmt, ...)
105272 if (!modprobe_path[0])
105273 return 0;
105274
105275- va_start(args, fmt);
105276- ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
105277- va_end(args);
105278+ ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
105279 if (ret >= MODULE_NAME_LEN)
105280 return -ENAMETOOLONG;
105281
105282@@ -153,6 +151,20 @@ int __request_module(bool wait, const char *fmt, ...)
105283 if (ret)
105284 return ret;
105285
105286+#ifdef CONFIG_GRKERNSEC_MODHARDEN
105287+ if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
105288+ /* hack to workaround consolekit/udisks stupidity */
105289+ read_lock(&tasklist_lock);
105290+ if (!strcmp(current->comm, "mount") &&
105291+ current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
105292+ read_unlock(&tasklist_lock);
105293+ printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
105294+ return -EPERM;
105295+ }
105296+ read_unlock(&tasklist_lock);
105297+ }
105298+#endif
105299+
105300 /* If modprobe needs a service that is in a module, we get a recursive
105301 * loop. Limit the number of running kmod threads to max_threads/2 or
105302 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
105303@@ -181,16 +193,61 @@ int __request_module(bool wait, const char *fmt, ...)
105304
105305 trace_module_request(module_name, wait, _RET_IP_);
105306
105307- ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
105308+ ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
105309
105310 atomic_dec(&kmod_concurrent);
105311 return ret;
105312 }
105313+
105314+int ___request_module(bool wait, char *module_param, const char *fmt, ...)
105315+{
105316+ va_list args;
105317+ int ret;
105318+
105319+ va_start(args, fmt);
105320+ ret = ____request_module(wait, module_param, fmt, args);
105321+ va_end(args);
105322+
105323+ return ret;
105324+}
105325+
105326+int __request_module(bool wait, const char *fmt, ...)
105327+{
105328+ va_list args;
105329+ int ret;
105330+
105331+#ifdef CONFIG_GRKERNSEC_MODHARDEN
105332+ if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
105333+ char module_param[MODULE_NAME_LEN];
105334+
105335+ memset(module_param, 0, sizeof(module_param));
105336+
105337+ snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
105338+
105339+ va_start(args, fmt);
105340+ ret = ____request_module(wait, module_param, fmt, args);
105341+ va_end(args);
105342+
105343+ return ret;
105344+ }
105345+#endif
105346+
105347+ va_start(args, fmt);
105348+ ret = ____request_module(wait, NULL, fmt, args);
105349+ va_end(args);
105350+
105351+ return ret;
105352+}
105353+
105354 EXPORT_SYMBOL(__request_module);
105355 #endif /* CONFIG_MODULES */
105356
105357 static void call_usermodehelper_freeinfo(struct subprocess_info *info)
105358 {
105359+#ifdef CONFIG_GRKERNSEC
105360+ kfree(info->path);
105361+ info->path = info->origpath;
105362+#endif
105363 if (info->cleanup)
105364 (*info->cleanup)(info);
105365 kfree(info);
105366@@ -232,6 +289,21 @@ static int ____call_usermodehelper(void *data)
105367 */
105368 set_user_nice(current, 0);
105369
105370+#ifdef CONFIG_GRKERNSEC
105371+ /* this is race-free as far as userland is concerned as we copied
105372+ out the path to be used prior to this point and are now operating
105373+ on that copy
105374+ */
105375+ if ((strncmp(sub_info->path, "/sbin/", 6) && strncmp(sub_info->path, "/usr/lib/", 9) &&
105376+ strncmp(sub_info->path, "/lib/", 5) && strncmp(sub_info->path, "/lib64/", 7) &&
105377+ strncmp(sub_info->path, "/usr/libexec/", 13) && strncmp(sub_info->path, "/usr/bin/", 9) &&
105378+ strcmp(sub_info->path, "/usr/share/apport/apport")) || strstr(sub_info->path, "..")) {
105379+ printk(KERN_ALERT "grsec: denied exec of usermode helper binary %.950s located outside of permitted system paths\n", sub_info->path);
105380+ retval = -EPERM;
105381+ goto out;
105382+ }
105383+#endif
105384+
105385 retval = -ENOMEM;
105386 new = prepare_kernel_cred(current);
105387 if (!new)
105388@@ -254,8 +326,8 @@ static int ____call_usermodehelper(void *data)
105389 commit_creds(new);
105390
105391 retval = do_execve(getname_kernel(sub_info->path),
105392- (const char __user *const __user *)sub_info->argv,
105393- (const char __user *const __user *)sub_info->envp);
105394+ (const char __user *const __force_user *)sub_info->argv,
105395+ (const char __user *const __force_user *)sub_info->envp);
105396 out:
105397 sub_info->retval = retval;
105398 /* wait_for_helper() will call umh_complete if UHM_WAIT_PROC. */
105399@@ -288,7 +360,7 @@ static int wait_for_helper(void *data)
105400 *
105401 * Thus the __user pointer cast is valid here.
105402 */
105403- sys_wait4(pid, (int __user *)&ret, 0, NULL);
105404+ sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
105405
105406 /*
105407 * If ret is 0, either ____call_usermodehelper failed and the
105408@@ -510,7 +582,12 @@ struct subprocess_info *call_usermodehelper_setup(char *path, char **argv,
105409 goto out;
105410
105411 INIT_WORK(&sub_info->work, __call_usermodehelper);
105412+#ifdef CONFIG_GRKERNSEC
105413+ sub_info->origpath = path;
105414+ sub_info->path = kstrdup(path, gfp_mask);
105415+#else
105416 sub_info->path = path;
105417+#endif
105418 sub_info->argv = argv;
105419 sub_info->envp = envp;
105420
105421@@ -612,7 +689,7 @@ EXPORT_SYMBOL(call_usermodehelper);
105422 static int proc_cap_handler(struct ctl_table *table, int write,
105423 void __user *buffer, size_t *lenp, loff_t *ppos)
105424 {
105425- struct ctl_table t;
105426+ ctl_table_no_const t;
105427 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
105428 kernel_cap_t new_cap;
105429 int err, i;
105430diff --git a/kernel/kprobes.c b/kernel/kprobes.c
105431index c90e417..e6c515d 100644
105432--- a/kernel/kprobes.c
105433+++ b/kernel/kprobes.c
105434@@ -31,6 +31,9 @@
105435 * <jkenisto@us.ibm.com> and Prasanna S Panchamukhi
105436 * <prasanna@in.ibm.com> added function-return probes.
105437 */
105438+#ifdef CONFIG_GRKERNSEC_HIDESYM
105439+#define __INCLUDED_BY_HIDESYM 1
105440+#endif
105441 #include <linux/kprobes.h>
105442 #include <linux/hash.h>
105443 #include <linux/init.h>
105444@@ -122,12 +125,12 @@ enum kprobe_slot_state {
105445
105446 static void *alloc_insn_page(void)
105447 {
105448- return module_alloc(PAGE_SIZE);
105449+ return module_alloc_exec(PAGE_SIZE);
105450 }
105451
105452 static void free_insn_page(void *page)
105453 {
105454- module_memfree(page);
105455+ module_memfree_exec(page);
105456 }
105457
105458 struct kprobe_insn_cache kprobe_insn_slots = {
105459@@ -2198,11 +2201,11 @@ static void report_probe(struct seq_file *pi, struct kprobe *p,
105460 kprobe_type = "k";
105461
105462 if (sym)
105463- seq_printf(pi, "%p %s %s+0x%x %s ",
105464+ seq_printf(pi, "%pK %s %s+0x%x %s ",
105465 p->addr, kprobe_type, sym, offset,
105466 (modname ? modname : " "));
105467 else
105468- seq_printf(pi, "%p %s %p ",
105469+ seq_printf(pi, "%pK %s %pK ",
105470 p->addr, kprobe_type, p->addr);
105471
105472 if (!pp)
105473diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
105474index 6683cce..daf8999 100644
105475--- a/kernel/ksysfs.c
105476+++ b/kernel/ksysfs.c
105477@@ -50,6 +50,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
105478 {
105479 if (count+1 > UEVENT_HELPER_PATH_LEN)
105480 return -ENOENT;
105481+ if (!capable(CAP_SYS_ADMIN))
105482+ return -EPERM;
105483 memcpy(uevent_helper, buf, count);
105484 uevent_helper[count] = '\0';
105485 if (count && uevent_helper[count-1] == '\n')
105486@@ -176,7 +178,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
105487 return count;
105488 }
105489
105490-static struct bin_attribute notes_attr = {
105491+static bin_attribute_no_const notes_attr __read_only = {
105492 .attr = {
105493 .name = "notes",
105494 .mode = S_IRUGO,
105495diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
105496index aaeae88..10f3663 100644
105497--- a/kernel/locking/lockdep.c
105498+++ b/kernel/locking/lockdep.c
105499@@ -613,6 +613,10 @@ static int static_obj(void *obj)
105500 end = (unsigned long) &_end,
105501 addr = (unsigned long) obj;
105502
105503+#ifdef CONFIG_PAX_KERNEXEC
105504+ start = ktla_ktva(start);
105505+#endif
105506+
105507 /*
105508 * static variable?
105509 */
105510@@ -757,6 +761,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
105511 if (!static_obj(lock->key)) {
105512 debug_locks_off();
105513 printk("INFO: trying to register non-static key.\n");
105514+ printk("lock:%pS key:%pS.\n", lock, lock->key);
105515 printk("the code is fine but needs lockdep annotation.\n");
105516 printk("turning off the locking correctness validator.\n");
105517 dump_stack();
105518@@ -3102,7 +3107,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
105519 if (!class)
105520 return 0;
105521 }
105522- atomic_inc((atomic_t *)&class->ops);
105523+ atomic_long_inc_unchecked((atomic_long_unchecked_t *)&class->ops);
105524 if (very_verbose(class)) {
105525 printk("\nacquire class [%p] %s", class->key, class->name);
105526 if (class->name_version > 1)
105527diff --git a/kernel/locking/lockdep_proc.c b/kernel/locking/lockdep_proc.c
105528index d83d798..ea3120d 100644
105529--- a/kernel/locking/lockdep_proc.c
105530+++ b/kernel/locking/lockdep_proc.c
105531@@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
105532 return 0;
105533 }
105534
105535- seq_printf(m, "%p", class->key);
105536+ seq_printf(m, "%pK", class->key);
105537 #ifdef CONFIG_DEBUG_LOCKDEP
105538 seq_printf(m, " OPS:%8ld", class->ops);
105539 #endif
105540@@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
105541
105542 list_for_each_entry(entry, &class->locks_after, entry) {
105543 if (entry->distance == 1) {
105544- seq_printf(m, " -> [%p] ", entry->class->key);
105545+ seq_printf(m, " -> [%pK] ", entry->class->key);
105546 print_name(m, entry->class);
105547 seq_puts(m, "\n");
105548 }
105549@@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
105550 if (!class->key)
105551 continue;
105552
105553- seq_printf(m, "[%p] ", class->key);
105554+ seq_printf(m, "[%pK] ", class->key);
105555 print_name(m, class);
105556 seq_puts(m, "\n");
105557 }
105558@@ -508,7 +508,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
105559 if (!i)
105560 seq_line(m, '-', 40-namelen, namelen);
105561
105562- snprintf(ip, sizeof(ip), "[<%p>]",
105563+ snprintf(ip, sizeof(ip), "[<%pK>]",
105564 (void *)class->contention_point[i]);
105565 seq_printf(m, "%40s %14lu %29s %pS\n",
105566 name, stats->contention_point[i],
105567@@ -523,7 +523,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
105568 if (!i)
105569 seq_line(m, '-', 40-namelen, namelen);
105570
105571- snprintf(ip, sizeof(ip), "[<%p>]",
105572+ snprintf(ip, sizeof(ip), "[<%pK>]",
105573 (void *)class->contending_point[i]);
105574 seq_printf(m, "%40s %14lu %29s %pS\n",
105575 name, stats->contending_point[i],
105576diff --git a/kernel/locking/mutex-debug.c b/kernel/locking/mutex-debug.c
105577index 3ef3736..9c951fa 100644
105578--- a/kernel/locking/mutex-debug.c
105579+++ b/kernel/locking/mutex-debug.c
105580@@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
105581 }
105582
105583 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
105584- struct thread_info *ti)
105585+ struct task_struct *task)
105586 {
105587 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
105588
105589 /* Mark the current thread as blocked on the lock: */
105590- ti->task->blocked_on = waiter;
105591+ task->blocked_on = waiter;
105592 }
105593
105594 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
105595- struct thread_info *ti)
105596+ struct task_struct *task)
105597 {
105598 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
105599- DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
105600- DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
105601- ti->task->blocked_on = NULL;
105602+ DEBUG_LOCKS_WARN_ON(waiter->task != task);
105603+ DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
105604+ task->blocked_on = NULL;
105605
105606 list_del_init(&waiter->list);
105607 waiter->task = NULL;
105608diff --git a/kernel/locking/mutex-debug.h b/kernel/locking/mutex-debug.h
105609index 0799fd3..d06ae3b 100644
105610--- a/kernel/locking/mutex-debug.h
105611+++ b/kernel/locking/mutex-debug.h
105612@@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
105613 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
105614 extern void debug_mutex_add_waiter(struct mutex *lock,
105615 struct mutex_waiter *waiter,
105616- struct thread_info *ti);
105617+ struct task_struct *task);
105618 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
105619- struct thread_info *ti);
105620+ struct task_struct *task);
105621 extern void debug_mutex_unlock(struct mutex *lock);
105622 extern void debug_mutex_init(struct mutex *lock, const char *name,
105623 struct lock_class_key *key);
105624diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c
105625index 4cccea6..4382db9 100644
105626--- a/kernel/locking/mutex.c
105627+++ b/kernel/locking/mutex.c
105628@@ -533,7 +533,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
105629 goto skip_wait;
105630
105631 debug_mutex_lock_common(lock, &waiter);
105632- debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
105633+ debug_mutex_add_waiter(lock, &waiter, task);
105634
105635 /* add waiting tasks to the end of the waitqueue (FIFO): */
105636 list_add_tail(&waiter.list, &lock->wait_list);
105637@@ -580,7 +580,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
105638 }
105639 __set_task_state(task, TASK_RUNNING);
105640
105641- mutex_remove_waiter(lock, &waiter, current_thread_info());
105642+ mutex_remove_waiter(lock, &waiter, task);
105643 /* set it to 0 if there are no waiters left: */
105644 if (likely(list_empty(&lock->wait_list)))
105645 atomic_set(&lock->count, 0);
105646@@ -601,7 +601,7 @@ skip_wait:
105647 return 0;
105648
105649 err:
105650- mutex_remove_waiter(lock, &waiter, task_thread_info(task));
105651+ mutex_remove_waiter(lock, &waiter, task);
105652 spin_unlock_mutex(&lock->wait_lock, flags);
105653 debug_mutex_free_waiter(&waiter);
105654 mutex_release(&lock->dep_map, 1, ip);
105655diff --git a/kernel/locking/rtmutex-tester.c b/kernel/locking/rtmutex-tester.c
105656index 1d96dd0..994ff19 100644
105657--- a/kernel/locking/rtmutex-tester.c
105658+++ b/kernel/locking/rtmutex-tester.c
105659@@ -22,7 +22,7 @@
105660 #define MAX_RT_TEST_MUTEXES 8
105661
105662 static spinlock_t rttest_lock;
105663-static atomic_t rttest_event;
105664+static atomic_unchecked_t rttest_event;
105665
105666 struct test_thread_data {
105667 int opcode;
105668@@ -63,7 +63,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
105669
105670 case RTTEST_LOCKCONT:
105671 td->mutexes[td->opdata] = 1;
105672- td->event = atomic_add_return(1, &rttest_event);
105673+ td->event = atomic_add_return_unchecked(1, &rttest_event);
105674 return 0;
105675
105676 case RTTEST_RESET:
105677@@ -76,7 +76,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
105678 return 0;
105679
105680 case RTTEST_RESETEVENT:
105681- atomic_set(&rttest_event, 0);
105682+ atomic_set_unchecked(&rttest_event, 0);
105683 return 0;
105684
105685 default:
105686@@ -93,9 +93,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
105687 return ret;
105688
105689 td->mutexes[id] = 1;
105690- td->event = atomic_add_return(1, &rttest_event);
105691+ td->event = atomic_add_return_unchecked(1, &rttest_event);
105692 rt_mutex_lock(&mutexes[id]);
105693- td->event = atomic_add_return(1, &rttest_event);
105694+ td->event = atomic_add_return_unchecked(1, &rttest_event);
105695 td->mutexes[id] = 4;
105696 return 0;
105697
105698@@ -106,9 +106,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
105699 return ret;
105700
105701 td->mutexes[id] = 1;
105702- td->event = atomic_add_return(1, &rttest_event);
105703+ td->event = atomic_add_return_unchecked(1, &rttest_event);
105704 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
105705- td->event = atomic_add_return(1, &rttest_event);
105706+ td->event = atomic_add_return_unchecked(1, &rttest_event);
105707 td->mutexes[id] = ret ? 0 : 4;
105708 return ret ? -EINTR : 0;
105709
105710@@ -117,9 +117,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
105711 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
105712 return ret;
105713
105714- td->event = atomic_add_return(1, &rttest_event);
105715+ td->event = atomic_add_return_unchecked(1, &rttest_event);
105716 rt_mutex_unlock(&mutexes[id]);
105717- td->event = atomic_add_return(1, &rttest_event);
105718+ td->event = atomic_add_return_unchecked(1, &rttest_event);
105719 td->mutexes[id] = 0;
105720 return 0;
105721
105722@@ -166,7 +166,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
105723 break;
105724
105725 td->mutexes[dat] = 2;
105726- td->event = atomic_add_return(1, &rttest_event);
105727+ td->event = atomic_add_return_unchecked(1, &rttest_event);
105728 break;
105729
105730 default:
105731@@ -186,7 +186,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
105732 return;
105733
105734 td->mutexes[dat] = 3;
105735- td->event = atomic_add_return(1, &rttest_event);
105736+ td->event = atomic_add_return_unchecked(1, &rttest_event);
105737 break;
105738
105739 case RTTEST_LOCKNOWAIT:
105740@@ -198,7 +198,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
105741 return;
105742
105743 td->mutexes[dat] = 1;
105744- td->event = atomic_add_return(1, &rttest_event);
105745+ td->event = atomic_add_return_unchecked(1, &rttest_event);
105746 return;
105747
105748 default:
105749diff --git a/kernel/module.c b/kernel/module.c
105750index cfc9e84..a058697 100644
105751--- a/kernel/module.c
105752+++ b/kernel/module.c
105753@@ -59,6 +59,7 @@
105754 #include <linux/jump_label.h>
105755 #include <linux/pfn.h>
105756 #include <linux/bsearch.h>
105757+#include <linux/grsecurity.h>
105758 #include <uapi/linux/module.h>
105759 #include "module-internal.h"
105760
105761@@ -145,7 +146,7 @@ module_param(sig_enforce, bool_enable_only, 0644);
105762 #endif /* CONFIG_MODULE_SIG */
105763
105764 /* Block module loading/unloading? */
105765-int modules_disabled = 0;
105766+int modules_disabled __read_only = 0;
105767 core_param(nomodule, modules_disabled, bint, 0);
105768
105769 /* Waiting for a module to finish initializing? */
105770@@ -155,7 +156,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
105771
105772 /* Bounds of module allocation, for speeding __module_address.
105773 * Protected by module_mutex. */
105774-static unsigned long module_addr_min = -1UL, module_addr_max = 0;
105775+static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
105776+static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
105777
105778 int register_module_notifier(struct notifier_block *nb)
105779 {
105780@@ -322,7 +324,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
105781 return true;
105782
105783 list_for_each_entry_rcu(mod, &modules, list) {
105784- struct symsearch arr[] = {
105785+ struct symsearch modarr[] = {
105786 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
105787 NOT_GPL_ONLY, false },
105788 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
105789@@ -347,7 +349,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
105790 if (mod->state == MODULE_STATE_UNFORMED)
105791 continue;
105792
105793- if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
105794+ if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
105795 return true;
105796 }
105797 return false;
105798@@ -487,7 +489,7 @@ static int percpu_modalloc(struct module *mod, struct load_info *info)
105799 if (!pcpusec->sh_size)
105800 return 0;
105801
105802- if (align > PAGE_SIZE) {
105803+ if (align-1 >= PAGE_SIZE) {
105804 pr_warn("%s: per-cpu alignment %li > %li\n",
105805 mod->name, align, PAGE_SIZE);
105806 align = PAGE_SIZE;
105807@@ -1053,7 +1055,7 @@ struct module_attribute module_uevent =
105808 static ssize_t show_coresize(struct module_attribute *mattr,
105809 struct module_kobject *mk, char *buffer)
105810 {
105811- return sprintf(buffer, "%u\n", mk->mod->core_size);
105812+ return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
105813 }
105814
105815 static struct module_attribute modinfo_coresize =
105816@@ -1062,7 +1064,7 @@ static struct module_attribute modinfo_coresize =
105817 static ssize_t show_initsize(struct module_attribute *mattr,
105818 struct module_kobject *mk, char *buffer)
105819 {
105820- return sprintf(buffer, "%u\n", mk->mod->init_size);
105821+ return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
105822 }
105823
105824 static struct module_attribute modinfo_initsize =
105825@@ -1154,12 +1156,29 @@ static int check_version(Elf_Shdr *sechdrs,
105826 goto bad_version;
105827 }
105828
105829+#ifdef CONFIG_GRKERNSEC_RANDSTRUCT
105830+ /*
105831+ * avoid potentially printing jibberish on attempted load
105832+ * of a module randomized with a different seed
105833+ */
105834+ pr_warn("no symbol version for %s\n", symname);
105835+#else
105836 pr_warn("%s: no symbol version for %s\n", mod->name, symname);
105837+#endif
105838 return 0;
105839
105840 bad_version:
105841+#ifdef CONFIG_GRKERNSEC_RANDSTRUCT
105842+ /*
105843+ * avoid potentially printing jibberish on attempted load
105844+ * of a module randomized with a different seed
105845+ */
105846+ pr_warn("attempted module disagrees about version of symbol %s\n",
105847+ symname);
105848+#else
105849 pr_warn("%s: disagrees about version of symbol %s\n",
105850 mod->name, symname);
105851+#endif
105852 return 0;
105853 }
105854
105855@@ -1281,7 +1300,7 @@ resolve_symbol_wait(struct module *mod,
105856 */
105857 #ifdef CONFIG_SYSFS
105858
105859-#ifdef CONFIG_KALLSYMS
105860+#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
105861 static inline bool sect_empty(const Elf_Shdr *sect)
105862 {
105863 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
105864@@ -1419,7 +1438,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
105865 {
105866 unsigned int notes, loaded, i;
105867 struct module_notes_attrs *notes_attrs;
105868- struct bin_attribute *nattr;
105869+ bin_attribute_no_const *nattr;
105870
105871 /* failed to create section attributes, so can't create notes */
105872 if (!mod->sect_attrs)
105873@@ -1531,7 +1550,7 @@ static void del_usage_links(struct module *mod)
105874 static int module_add_modinfo_attrs(struct module *mod)
105875 {
105876 struct module_attribute *attr;
105877- struct module_attribute *temp_attr;
105878+ module_attribute_no_const *temp_attr;
105879 int error = 0;
105880 int i;
105881
105882@@ -1741,21 +1760,21 @@ static void set_section_ro_nx(void *base,
105883
105884 static void unset_module_core_ro_nx(struct module *mod)
105885 {
105886- set_page_attributes(mod->module_core + mod->core_text_size,
105887- mod->module_core + mod->core_size,
105888+ set_page_attributes(mod->module_core_rw,
105889+ mod->module_core_rw + mod->core_size_rw,
105890 set_memory_x);
105891- set_page_attributes(mod->module_core,
105892- mod->module_core + mod->core_ro_size,
105893+ set_page_attributes(mod->module_core_rx,
105894+ mod->module_core_rx + mod->core_size_rx,
105895 set_memory_rw);
105896 }
105897
105898 static void unset_module_init_ro_nx(struct module *mod)
105899 {
105900- set_page_attributes(mod->module_init + mod->init_text_size,
105901- mod->module_init + mod->init_size,
105902+ set_page_attributes(mod->module_init_rw,
105903+ mod->module_init_rw + mod->init_size_rw,
105904 set_memory_x);
105905- set_page_attributes(mod->module_init,
105906- mod->module_init + mod->init_ro_size,
105907+ set_page_attributes(mod->module_init_rx,
105908+ mod->module_init_rx + mod->init_size_rx,
105909 set_memory_rw);
105910 }
105911
105912@@ -1768,14 +1787,14 @@ void set_all_modules_text_rw(void)
105913 list_for_each_entry_rcu(mod, &modules, list) {
105914 if (mod->state == MODULE_STATE_UNFORMED)
105915 continue;
105916- if ((mod->module_core) && (mod->core_text_size)) {
105917- set_page_attributes(mod->module_core,
105918- mod->module_core + mod->core_text_size,
105919+ if ((mod->module_core_rx) && (mod->core_size_rx)) {
105920+ set_page_attributes(mod->module_core_rx,
105921+ mod->module_core_rx + mod->core_size_rx,
105922 set_memory_rw);
105923 }
105924- if ((mod->module_init) && (mod->init_text_size)) {
105925- set_page_attributes(mod->module_init,
105926- mod->module_init + mod->init_text_size,
105927+ if ((mod->module_init_rx) && (mod->init_size_rx)) {
105928+ set_page_attributes(mod->module_init_rx,
105929+ mod->module_init_rx + mod->init_size_rx,
105930 set_memory_rw);
105931 }
105932 }
105933@@ -1791,14 +1810,14 @@ void set_all_modules_text_ro(void)
105934 list_for_each_entry_rcu(mod, &modules, list) {
105935 if (mod->state == MODULE_STATE_UNFORMED)
105936 continue;
105937- if ((mod->module_core) && (mod->core_text_size)) {
105938- set_page_attributes(mod->module_core,
105939- mod->module_core + mod->core_text_size,
105940+ if ((mod->module_core_rx) && (mod->core_size_rx)) {
105941+ set_page_attributes(mod->module_core_rx,
105942+ mod->module_core_rx + mod->core_size_rx,
105943 set_memory_ro);
105944 }
105945- if ((mod->module_init) && (mod->init_text_size)) {
105946- set_page_attributes(mod->module_init,
105947- mod->module_init + mod->init_text_size,
105948+ if ((mod->module_init_rx) && (mod->init_size_rx)) {
105949+ set_page_attributes(mod->module_init_rx,
105950+ mod->module_init_rx + mod->init_size_rx,
105951 set_memory_ro);
105952 }
105953 }
105954@@ -1807,7 +1826,15 @@ void set_all_modules_text_ro(void)
105955 #else
105956 static inline void set_section_ro_nx(void *base, unsigned long text_size, unsigned long ro_size, unsigned long total_size) { }
105957 static void unset_module_core_ro_nx(struct module *mod) { }
105958-static void unset_module_init_ro_nx(struct module *mod) { }
105959+static void unset_module_init_ro_nx(struct module *mod)
105960+{
105961+
105962+#ifdef CONFIG_PAX_KERNEXEC
105963+ set_memory_nx((unsigned long)mod->module_init_rx, PFN_UP(mod->init_size_rx));
105964+ set_memory_rw((unsigned long)mod->module_init_rx, PFN_UP(mod->init_size_rx));
105965+#endif
105966+
105967+}
105968 #endif
105969
105970 void __weak module_memfree(void *module_region)
105971@@ -1861,16 +1888,19 @@ static void free_module(struct module *mod)
105972 /* This may be NULL, but that's OK */
105973 unset_module_init_ro_nx(mod);
105974 module_arch_freeing_init(mod);
105975- module_memfree(mod->module_init);
105976+ module_memfree(mod->module_init_rw);
105977+ module_memfree_exec(mod->module_init_rx);
105978 kfree(mod->args);
105979 percpu_modfree(mod);
105980
105981 /* Free lock-classes; relies on the preceding sync_rcu(). */
105982- lockdep_free_key_range(mod->module_core, mod->core_size);
105983+ lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
105984+ lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
105985
105986 /* Finally, free the core (containing the module structure) */
105987 unset_module_core_ro_nx(mod);
105988- module_memfree(mod->module_core);
105989+ module_memfree_exec(mod->module_core_rx);
105990+ module_memfree(mod->module_core_rw);
105991
105992 #ifdef CONFIG_MPU
105993 update_protections(current->mm);
105994@@ -1939,9 +1969,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
105995 int ret = 0;
105996 const struct kernel_symbol *ksym;
105997
105998+#ifdef CONFIG_GRKERNSEC_MODHARDEN
105999+ int is_fs_load = 0;
106000+ int register_filesystem_found = 0;
106001+ char *p;
106002+
106003+ p = strstr(mod->args, "grsec_modharden_fs");
106004+ if (p) {
106005+ char *endptr = p + sizeof("grsec_modharden_fs") - 1;
106006+ /* copy \0 as well */
106007+ memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
106008+ is_fs_load = 1;
106009+ }
106010+#endif
106011+
106012 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
106013 const char *name = info->strtab + sym[i].st_name;
106014
106015+#ifdef CONFIG_GRKERNSEC_MODHARDEN
106016+ /* it's a real shame this will never get ripped and copied
106017+ upstream! ;(
106018+ */
106019+ if (is_fs_load && !strcmp(name, "register_filesystem"))
106020+ register_filesystem_found = 1;
106021+#endif
106022+
106023 switch (sym[i].st_shndx) {
106024 case SHN_COMMON:
106025 /* Ignore common symbols */
106026@@ -1966,7 +2018,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
106027 ksym = resolve_symbol_wait(mod, info, name);
106028 /* Ok if resolved. */
106029 if (ksym && !IS_ERR(ksym)) {
106030+ pax_open_kernel();
106031 sym[i].st_value = ksym->value;
106032+ pax_close_kernel();
106033 break;
106034 }
106035
106036@@ -1985,11 +2039,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
106037 secbase = (unsigned long)mod_percpu(mod);
106038 else
106039 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
106040+ pax_open_kernel();
106041 sym[i].st_value += secbase;
106042+ pax_close_kernel();
106043 break;
106044 }
106045 }
106046
106047+#ifdef CONFIG_GRKERNSEC_MODHARDEN
106048+ if (is_fs_load && !register_filesystem_found) {
106049+ printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
106050+ ret = -EPERM;
106051+ }
106052+#endif
106053+
106054 return ret;
106055 }
106056
106057@@ -2073,22 +2136,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
106058 || s->sh_entsize != ~0UL
106059 || strstarts(sname, ".init"))
106060 continue;
106061- s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
106062+ if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
106063+ s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
106064+ else
106065+ s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
106066 pr_debug("\t%s\n", sname);
106067 }
106068- switch (m) {
106069- case 0: /* executable */
106070- mod->core_size = debug_align(mod->core_size);
106071- mod->core_text_size = mod->core_size;
106072- break;
106073- case 1: /* RO: text and ro-data */
106074- mod->core_size = debug_align(mod->core_size);
106075- mod->core_ro_size = mod->core_size;
106076- break;
106077- case 3: /* whole core */
106078- mod->core_size = debug_align(mod->core_size);
106079- break;
106080- }
106081 }
106082
106083 pr_debug("Init section allocation order:\n");
106084@@ -2102,23 +2155,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
106085 || s->sh_entsize != ~0UL
106086 || !strstarts(sname, ".init"))
106087 continue;
106088- s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
106089- | INIT_OFFSET_MASK);
106090+ if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
106091+ s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
106092+ else
106093+ s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
106094+ s->sh_entsize |= INIT_OFFSET_MASK;
106095 pr_debug("\t%s\n", sname);
106096 }
106097- switch (m) {
106098- case 0: /* executable */
106099- mod->init_size = debug_align(mod->init_size);
106100- mod->init_text_size = mod->init_size;
106101- break;
106102- case 1: /* RO: text and ro-data */
106103- mod->init_size = debug_align(mod->init_size);
106104- mod->init_ro_size = mod->init_size;
106105- break;
106106- case 3: /* whole init */
106107- mod->init_size = debug_align(mod->init_size);
106108- break;
106109- }
106110 }
106111 }
106112
106113@@ -2291,7 +2334,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
106114
106115 /* Put symbol section at end of init part of module. */
106116 symsect->sh_flags |= SHF_ALLOC;
106117- symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
106118+ symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
106119 info->index.sym) | INIT_OFFSET_MASK;
106120 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
106121
106122@@ -2308,16 +2351,16 @@ static void layout_symtab(struct module *mod, struct load_info *info)
106123 }
106124
106125 /* Append room for core symbols at end of core part. */
106126- info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
106127- info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
106128- mod->core_size += strtab_size;
106129- mod->core_size = debug_align(mod->core_size);
106130+ info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
106131+ info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
106132+ mod->core_size_rx += strtab_size;
106133+ mod->core_size_rx = debug_align(mod->core_size_rx);
106134
106135 /* Put string table section at end of init part of module. */
106136 strsect->sh_flags |= SHF_ALLOC;
106137- strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
106138+ strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
106139 info->index.str) | INIT_OFFSET_MASK;
106140- mod->init_size = debug_align(mod->init_size);
106141+ mod->init_size_rx = debug_align(mod->init_size_rx);
106142 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
106143 }
106144
106145@@ -2334,12 +2377,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
106146 /* Make sure we get permanent strtab: don't use info->strtab. */
106147 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
106148
106149+ pax_open_kernel();
106150+
106151 /* Set types up while we still have access to sections. */
106152 for (i = 0; i < mod->num_symtab; i++)
106153 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
106154
106155- mod->core_symtab = dst = mod->module_core + info->symoffs;
106156- mod->core_strtab = s = mod->module_core + info->stroffs;
106157+ mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
106158+ mod->core_strtab = s = mod->module_core_rx + info->stroffs;
106159 src = mod->symtab;
106160 for (ndst = i = 0; i < mod->num_symtab; i++) {
106161 if (i == 0 ||
106162@@ -2351,6 +2396,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
106163 }
106164 }
106165 mod->core_num_syms = ndst;
106166+
106167+ pax_close_kernel();
106168 }
106169 #else
106170 static inline void layout_symtab(struct module *mod, struct load_info *info)
106171@@ -2384,17 +2431,33 @@ void * __weak module_alloc(unsigned long size)
106172 return vmalloc_exec(size);
106173 }
106174
106175-static void *module_alloc_update_bounds(unsigned long size)
106176+static void *module_alloc_update_bounds_rw(unsigned long size)
106177 {
106178 void *ret = module_alloc(size);
106179
106180 if (ret) {
106181 mutex_lock(&module_mutex);
106182 /* Update module bounds. */
106183- if ((unsigned long)ret < module_addr_min)
106184- module_addr_min = (unsigned long)ret;
106185- if ((unsigned long)ret + size > module_addr_max)
106186- module_addr_max = (unsigned long)ret + size;
106187+ if ((unsigned long)ret < module_addr_min_rw)
106188+ module_addr_min_rw = (unsigned long)ret;
106189+ if ((unsigned long)ret + size > module_addr_max_rw)
106190+ module_addr_max_rw = (unsigned long)ret + size;
106191+ mutex_unlock(&module_mutex);
106192+ }
106193+ return ret;
106194+}
106195+
106196+static void *module_alloc_update_bounds_rx(unsigned long size)
106197+{
106198+ void *ret = module_alloc_exec(size);
106199+
106200+ if (ret) {
106201+ mutex_lock(&module_mutex);
106202+ /* Update module bounds. */
106203+ if ((unsigned long)ret < module_addr_min_rx)
106204+ module_addr_min_rx = (unsigned long)ret;
106205+ if ((unsigned long)ret + size > module_addr_max_rx)
106206+ module_addr_max_rx = (unsigned long)ret + size;
106207 mutex_unlock(&module_mutex);
106208 }
106209 return ret;
106210@@ -2666,7 +2729,15 @@ static struct module *setup_load_info(struct load_info *info, int flags)
106211 mod = (void *)info->sechdrs[info->index.mod].sh_addr;
106212
106213 if (info->index.sym == 0) {
106214+#ifdef CONFIG_GRKERNSEC_RANDSTRUCT
106215+ /*
106216+ * avoid potentially printing jibberish on attempted load
106217+ * of a module randomized with a different seed
106218+ */
106219+ pr_warn("module has no symbols (stripped?)\n");
106220+#else
106221 pr_warn("%s: module has no symbols (stripped?)\n", mod->name);
106222+#endif
106223 return ERR_PTR(-ENOEXEC);
106224 }
106225
106226@@ -2682,8 +2753,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
106227 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
106228 {
106229 const char *modmagic = get_modinfo(info, "vermagic");
106230+ const char *license = get_modinfo(info, "license");
106231 int err;
106232
106233+#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
106234+ if (!license || !license_is_gpl_compatible(license))
106235+ return -ENOEXEC;
106236+#endif
106237+
106238 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
106239 modmagic = NULL;
106240
106241@@ -2708,7 +2785,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
106242 }
106243
106244 /* Set up license info based on the info section */
106245- set_license(mod, get_modinfo(info, "license"));
106246+ set_license(mod, license);
106247
106248 return 0;
106249 }
106250@@ -2805,7 +2882,7 @@ static int move_module(struct module *mod, struct load_info *info)
106251 void *ptr;
106252
106253 /* Do the allocs. */
106254- ptr = module_alloc_update_bounds(mod->core_size);
106255+ ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
106256 /*
106257 * The pointer to this block is stored in the module structure
106258 * which is inside the block. Just mark it as not being a
106259@@ -2815,11 +2892,11 @@ static int move_module(struct module *mod, struct load_info *info)
106260 if (!ptr)
106261 return -ENOMEM;
106262
106263- memset(ptr, 0, mod->core_size);
106264- mod->module_core = ptr;
106265+ memset(ptr, 0, mod->core_size_rw);
106266+ mod->module_core_rw = ptr;
106267
106268- if (mod->init_size) {
106269- ptr = module_alloc_update_bounds(mod->init_size);
106270+ if (mod->init_size_rw) {
106271+ ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
106272 /*
106273 * The pointer to this block is stored in the module structure
106274 * which is inside the block. This block doesn't need to be
106275@@ -2828,13 +2905,45 @@ static int move_module(struct module *mod, struct load_info *info)
106276 */
106277 kmemleak_ignore(ptr);
106278 if (!ptr) {
106279- module_memfree(mod->module_core);
106280+ module_memfree(mod->module_core_rw);
106281 return -ENOMEM;
106282 }
106283- memset(ptr, 0, mod->init_size);
106284- mod->module_init = ptr;
106285+ memset(ptr, 0, mod->init_size_rw);
106286+ mod->module_init_rw = ptr;
106287 } else
106288- mod->module_init = NULL;
106289+ mod->module_init_rw = NULL;
106290+
106291+ ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
106292+ kmemleak_not_leak(ptr);
106293+ if (!ptr) {
106294+ if (mod->module_init_rw)
106295+ module_memfree(mod->module_init_rw);
106296+ module_memfree(mod->module_core_rw);
106297+ return -ENOMEM;
106298+ }
106299+
106300+ pax_open_kernel();
106301+ memset(ptr, 0, mod->core_size_rx);
106302+ pax_close_kernel();
106303+ mod->module_core_rx = ptr;
106304+
106305+ if (mod->init_size_rx) {
106306+ ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
106307+ kmemleak_ignore(ptr);
106308+ if (!ptr && mod->init_size_rx) {
106309+ module_memfree_exec(mod->module_core_rx);
106310+ if (mod->module_init_rw)
106311+ module_memfree(mod->module_init_rw);
106312+ module_memfree(mod->module_core_rw);
106313+ return -ENOMEM;
106314+ }
106315+
106316+ pax_open_kernel();
106317+ memset(ptr, 0, mod->init_size_rx);
106318+ pax_close_kernel();
106319+ mod->module_init_rx = ptr;
106320+ } else
106321+ mod->module_init_rx = NULL;
106322
106323 /* Transfer each section which specifies SHF_ALLOC */
106324 pr_debug("final section addresses:\n");
106325@@ -2845,16 +2954,45 @@ static int move_module(struct module *mod, struct load_info *info)
106326 if (!(shdr->sh_flags & SHF_ALLOC))
106327 continue;
106328
106329- if (shdr->sh_entsize & INIT_OFFSET_MASK)
106330- dest = mod->module_init
106331- + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
106332- else
106333- dest = mod->module_core + shdr->sh_entsize;
106334+ if (shdr->sh_entsize & INIT_OFFSET_MASK) {
106335+ if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
106336+ dest = mod->module_init_rw
106337+ + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
106338+ else
106339+ dest = mod->module_init_rx
106340+ + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
106341+ } else {
106342+ if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
106343+ dest = mod->module_core_rw + shdr->sh_entsize;
106344+ else
106345+ dest = mod->module_core_rx + shdr->sh_entsize;
106346+ }
106347+
106348+ if (shdr->sh_type != SHT_NOBITS) {
106349+
106350+#ifdef CONFIG_PAX_KERNEXEC
106351+#ifdef CONFIG_X86_64
106352+ if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
106353+ set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
106354+#endif
106355+ if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
106356+ pax_open_kernel();
106357+ memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
106358+ pax_close_kernel();
106359+ } else
106360+#endif
106361
106362- if (shdr->sh_type != SHT_NOBITS)
106363 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
106364+ }
106365 /* Update sh_addr to point to copy in image. */
106366- shdr->sh_addr = (unsigned long)dest;
106367+
106368+#ifdef CONFIG_PAX_KERNEXEC
106369+ if (shdr->sh_flags & SHF_EXECINSTR)
106370+ shdr->sh_addr = ktva_ktla((unsigned long)dest);
106371+ else
106372+#endif
106373+
106374+ shdr->sh_addr = (unsigned long)dest;
106375 pr_debug("\t0x%lx %s\n",
106376 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
106377 }
106378@@ -2911,12 +3049,12 @@ static void flush_module_icache(const struct module *mod)
106379 * Do it before processing of module parameters, so the module
106380 * can provide parameter accessor functions of its own.
106381 */
106382- if (mod->module_init)
106383- flush_icache_range((unsigned long)mod->module_init,
106384- (unsigned long)mod->module_init
106385- + mod->init_size);
106386- flush_icache_range((unsigned long)mod->module_core,
106387- (unsigned long)mod->module_core + mod->core_size);
106388+ if (mod->module_init_rx)
106389+ flush_icache_range((unsigned long)mod->module_init_rx,
106390+ (unsigned long)mod->module_init_rx
106391+ + mod->init_size_rx);
106392+ flush_icache_range((unsigned long)mod->module_core_rx,
106393+ (unsigned long)mod->module_core_rx + mod->core_size_rx);
106394
106395 set_fs(old_fs);
106396 }
106397@@ -2974,8 +3112,10 @@ static void module_deallocate(struct module *mod, struct load_info *info)
106398 {
106399 percpu_modfree(mod);
106400 module_arch_freeing_init(mod);
106401- module_memfree(mod->module_init);
106402- module_memfree(mod->module_core);
106403+ module_memfree_exec(mod->module_init_rx);
106404+ module_memfree_exec(mod->module_core_rx);
106405+ module_memfree(mod->module_init_rw);
106406+ module_memfree(mod->module_core_rw);
106407 }
106408
106409 int __weak module_finalize(const Elf_Ehdr *hdr,
106410@@ -2988,7 +3128,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
106411 static int post_relocation(struct module *mod, const struct load_info *info)
106412 {
106413 /* Sort exception table now relocations are done. */
106414+ pax_open_kernel();
106415 sort_extable(mod->extable, mod->extable + mod->num_exentries);
106416+ pax_close_kernel();
106417
106418 /* Copy relocated percpu area over. */
106419 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
106420@@ -3036,13 +3178,15 @@ static void do_mod_ctors(struct module *mod)
106421 /* For freeing module_init on success, in case kallsyms traversing */
106422 struct mod_initfree {
106423 struct rcu_head rcu;
106424- void *module_init;
106425+ void *module_init_rw;
106426+ void *module_init_rx;
106427 };
106428
106429 static void do_free_init(struct rcu_head *head)
106430 {
106431 struct mod_initfree *m = container_of(head, struct mod_initfree, rcu);
106432- module_memfree(m->module_init);
106433+ module_memfree(m->module_init_rw);
106434+ module_memfree_exec(m->module_init_rx);
106435 kfree(m);
106436 }
106437
106438@@ -3062,7 +3206,8 @@ static noinline int do_init_module(struct module *mod)
106439 ret = -ENOMEM;
106440 goto fail;
106441 }
106442- freeinit->module_init = mod->module_init;
106443+ freeinit->module_init_rw = mod->module_init_rw;
106444+ freeinit->module_init_rx = mod->module_init_rx;
106445
106446 /*
106447 * We want to find out whether @mod uses async during init. Clear
106448@@ -3121,10 +3266,10 @@ static noinline int do_init_module(struct module *mod)
106449 #endif
106450 unset_module_init_ro_nx(mod);
106451 module_arch_freeing_init(mod);
106452- mod->module_init = NULL;
106453- mod->init_size = 0;
106454- mod->init_ro_size = 0;
106455- mod->init_text_size = 0;
106456+ mod->module_init_rw = NULL;
106457+ mod->module_init_rx = NULL;
106458+ mod->init_size_rw = 0;
106459+ mod->init_size_rx = 0;
106460 /*
106461 * We want to free module_init, but be aware that kallsyms may be
106462 * walking this with preempt disabled. In all the failure paths,
106463@@ -3212,16 +3357,16 @@ static int complete_formation(struct module *mod, struct load_info *info)
106464 module_bug_finalize(info->hdr, info->sechdrs, mod);
106465
106466 /* Set RO and NX regions for core */
106467- set_section_ro_nx(mod->module_core,
106468- mod->core_text_size,
106469- mod->core_ro_size,
106470- mod->core_size);
106471+ set_section_ro_nx(mod->module_core_rx,
106472+ mod->core_size_rx,
106473+ mod->core_size_rx,
106474+ mod->core_size_rx);
106475
106476 /* Set RO and NX regions for init */
106477- set_section_ro_nx(mod->module_init,
106478- mod->init_text_size,
106479- mod->init_ro_size,
106480- mod->init_size);
106481+ set_section_ro_nx(mod->module_init_rx,
106482+ mod->init_size_rx,
106483+ mod->init_size_rx,
106484+ mod->init_size_rx);
106485
106486 /* Mark state as coming so strong_try_module_get() ignores us,
106487 * but kallsyms etc. can see us. */
106488@@ -3305,9 +3450,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
106489 if (err)
106490 goto free_unload;
106491
106492+ /* Now copy in args */
106493+ mod->args = strndup_user(uargs, ~0UL >> 1);
106494+ if (IS_ERR(mod->args)) {
106495+ err = PTR_ERR(mod->args);
106496+ goto free_unload;
106497+ }
106498+
106499 /* Set up MODINFO_ATTR fields */
106500 setup_modinfo(mod, info);
106501
106502+#ifdef CONFIG_GRKERNSEC_MODHARDEN
106503+ {
106504+ char *p, *p2;
106505+
106506+ if (strstr(mod->args, "grsec_modharden_netdev")) {
106507+ 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);
106508+ err = -EPERM;
106509+ goto free_modinfo;
106510+ } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
106511+ p += sizeof("grsec_modharden_normal") - 1;
106512+ p2 = strstr(p, "_");
106513+ if (p2) {
106514+ *p2 = '\0';
106515+ printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
106516+ *p2 = '_';
106517+ }
106518+ err = -EPERM;
106519+ goto free_modinfo;
106520+ }
106521+ }
106522+#endif
106523+
106524 /* Fix up syms, so that st_value is a pointer to location. */
106525 err = simplify_symbols(mod, info);
106526 if (err < 0)
106527@@ -3323,13 +3497,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
106528
106529 flush_module_icache(mod);
106530
106531- /* Now copy in args */
106532- mod->args = strndup_user(uargs, ~0UL >> 1);
106533- if (IS_ERR(mod->args)) {
106534- err = PTR_ERR(mod->args);
106535- goto free_arch_cleanup;
106536- }
106537-
106538 dynamic_debug_setup(info->debug, info->num_debug);
106539
106540 /* Ftrace init must be called in the MODULE_STATE_UNFORMED state */
106541@@ -3380,11 +3547,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
106542 ddebug_cleanup:
106543 dynamic_debug_remove(info->debug);
106544 synchronize_sched();
106545- kfree(mod->args);
106546- free_arch_cleanup:
106547 module_arch_cleanup(mod);
106548 free_modinfo:
106549 free_modinfo(mod);
106550+ kfree(mod->args);
106551 free_unload:
106552 module_unload_free(mod);
106553 unlink_mod:
106554@@ -3397,7 +3563,8 @@ static int load_module(struct load_info *info, const char __user *uargs,
106555 mutex_unlock(&module_mutex);
106556 free_module:
106557 /* Free lock-classes; relies on the preceding sync_rcu() */
106558- lockdep_free_key_range(mod->module_core, mod->core_size);
106559+ lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
106560+ lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
106561
106562 module_deallocate(mod, info);
106563 free_copy:
106564@@ -3474,10 +3641,16 @@ static const char *get_ksymbol(struct module *mod,
106565 unsigned long nextval;
106566
106567 /* At worse, next value is at end of module */
106568- if (within_module_init(addr, mod))
106569- nextval = (unsigned long)mod->module_init+mod->init_text_size;
106570+ if (within_module_init_rx(addr, mod))
106571+ nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
106572+ else if (within_module_init_rw(addr, mod))
106573+ nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
106574+ else if (within_module_core_rx(addr, mod))
106575+ nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
106576+ else if (within_module_core_rw(addr, mod))
106577+ nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
106578 else
106579- nextval = (unsigned long)mod->module_core+mod->core_text_size;
106580+ return NULL;
106581
106582 /* Scan for closest preceding symbol, and next symbol. (ELF
106583 starts real symbols at 1). */
106584@@ -3725,7 +3898,7 @@ static int m_show(struct seq_file *m, void *p)
106585 return 0;
106586
106587 seq_printf(m, "%s %u",
106588- mod->name, mod->init_size + mod->core_size);
106589+ mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
106590 print_unload_info(m, mod);
106591
106592 /* Informative for users. */
106593@@ -3734,7 +3907,7 @@ static int m_show(struct seq_file *m, void *p)
106594 mod->state == MODULE_STATE_COMING ? "Loading" :
106595 "Live");
106596 /* Used by oprofile and other similar tools. */
106597- seq_printf(m, " 0x%pK", mod->module_core);
106598+ seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
106599
106600 /* Taints info */
106601 if (mod->taints)
106602@@ -3770,7 +3943,17 @@ static const struct file_operations proc_modules_operations = {
106603
106604 static int __init proc_modules_init(void)
106605 {
106606+#ifndef CONFIG_GRKERNSEC_HIDESYM
106607+#ifdef CONFIG_GRKERNSEC_PROC_USER
106608+ proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
106609+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
106610+ proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
106611+#else
106612 proc_create("modules", 0, NULL, &proc_modules_operations);
106613+#endif
106614+#else
106615+ proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
106616+#endif
106617 return 0;
106618 }
106619 module_init(proc_modules_init);
106620@@ -3831,7 +4014,8 @@ struct module *__module_address(unsigned long addr)
106621 {
106622 struct module *mod;
106623
106624- if (addr < module_addr_min || addr > module_addr_max)
106625+ if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
106626+ (addr < module_addr_min_rw || addr > module_addr_max_rw))
106627 return NULL;
106628
106629 list_for_each_entry_rcu(mod, &modules, list) {
106630@@ -3872,11 +4056,20 @@ bool is_module_text_address(unsigned long addr)
106631 */
106632 struct module *__module_text_address(unsigned long addr)
106633 {
106634- struct module *mod = __module_address(addr);
106635+ struct module *mod;
106636+
106637+#ifdef CONFIG_X86_32
106638+ addr = ktla_ktva(addr);
106639+#endif
106640+
106641+ if (addr < module_addr_min_rx || addr > module_addr_max_rx)
106642+ return NULL;
106643+
106644+ mod = __module_address(addr);
106645+
106646 if (mod) {
106647 /* Make sure it's within the text section. */
106648- if (!within(addr, mod->module_init, mod->init_text_size)
106649- && !within(addr, mod->module_core, mod->core_text_size))
106650+ if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
106651 mod = NULL;
106652 }
106653 return mod;
106654diff --git a/kernel/notifier.c b/kernel/notifier.c
106655index ae9fc7c..5085fbf 100644
106656--- a/kernel/notifier.c
106657+++ b/kernel/notifier.c
106658@@ -5,6 +5,7 @@
106659 #include <linux/rcupdate.h>
106660 #include <linux/vmalloc.h>
106661 #include <linux/reboot.h>
106662+#include <linux/mm.h>
106663
106664 /*
106665 * Notifier list for kernel code which wants to be called
106666@@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
106667 while ((*nl) != NULL) {
106668 if (n->priority > (*nl)->priority)
106669 break;
106670- nl = &((*nl)->next);
106671+ nl = (struct notifier_block **)&((*nl)->next);
106672 }
106673- n->next = *nl;
106674+ pax_open_kernel();
106675+ *(const void **)&n->next = *nl;
106676 rcu_assign_pointer(*nl, n);
106677+ pax_close_kernel();
106678 return 0;
106679 }
106680
106681@@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
106682 return 0;
106683 if (n->priority > (*nl)->priority)
106684 break;
106685- nl = &((*nl)->next);
106686+ nl = (struct notifier_block **)&((*nl)->next);
106687 }
106688- n->next = *nl;
106689+ pax_open_kernel();
106690+ *(const void **)&n->next = *nl;
106691 rcu_assign_pointer(*nl, n);
106692+ pax_close_kernel();
106693 return 0;
106694 }
106695
106696@@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
106697 {
106698 while ((*nl) != NULL) {
106699 if ((*nl) == n) {
106700+ pax_open_kernel();
106701 rcu_assign_pointer(*nl, n->next);
106702+ pax_close_kernel();
106703 return 0;
106704 }
106705- nl = &((*nl)->next);
106706+ nl = (struct notifier_block **)&((*nl)->next);
106707 }
106708 return -ENOENT;
106709 }
106710diff --git a/kernel/padata.c b/kernel/padata.c
106711index b38bea9..91acfbe 100644
106712--- a/kernel/padata.c
106713+++ b/kernel/padata.c
106714@@ -54,7 +54,7 @@ static int padata_cpu_hash(struct parallel_data *pd)
106715 * seq_nr mod. number of cpus in use.
106716 */
106717
106718- seq_nr = atomic_inc_return(&pd->seq_nr);
106719+ seq_nr = atomic_inc_return_unchecked(&pd->seq_nr);
106720 cpu_index = seq_nr % cpumask_weight(pd->cpumask.pcpu);
106721
106722 return padata_index_to_cpu(pd, cpu_index);
106723@@ -428,7 +428,7 @@ static struct parallel_data *padata_alloc_pd(struct padata_instance *pinst,
106724 padata_init_pqueues(pd);
106725 padata_init_squeues(pd);
106726 setup_timer(&pd->timer, padata_reorder_timer, (unsigned long)pd);
106727- atomic_set(&pd->seq_nr, -1);
106728+ atomic_set_unchecked(&pd->seq_nr, -1);
106729 atomic_set(&pd->reorder_objects, 0);
106730 atomic_set(&pd->refcnt, 0);
106731 pd->pinst = pinst;
106732diff --git a/kernel/panic.c b/kernel/panic.c
106733index 8136ad7..15c857b 100644
106734--- a/kernel/panic.c
106735+++ b/kernel/panic.c
106736@@ -54,7 +54,7 @@ EXPORT_SYMBOL(panic_blink);
106737 /*
106738 * Stop ourself in panic -- architecture code may override this
106739 */
106740-void __weak panic_smp_self_stop(void)
106741+void __weak __noreturn panic_smp_self_stop(void)
106742 {
106743 while (1)
106744 cpu_relax();
106745@@ -425,7 +425,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
106746 disable_trace_on_warning();
106747
106748 pr_warn("------------[ cut here ]------------\n");
106749- pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pS()\n",
106750+ pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pA()\n",
106751 raw_smp_processor_id(), current->pid, file, line, caller);
106752
106753 if (args)
106754@@ -490,7 +490,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
106755 */
106756 __visible void __stack_chk_fail(void)
106757 {
106758- panic("stack-protector: Kernel stack is corrupted in: %p\n",
106759+ dump_stack();
106760+ panic("stack-protector: Kernel stack is corrupted in: %pA\n",
106761 __builtin_return_address(0));
106762 }
106763 EXPORT_SYMBOL(__stack_chk_fail);
106764diff --git a/kernel/pid.c b/kernel/pid.c
106765index 4fd07d5..02bce4f 100644
106766--- a/kernel/pid.c
106767+++ b/kernel/pid.c
106768@@ -33,6 +33,7 @@
106769 #include <linux/rculist.h>
106770 #include <linux/bootmem.h>
106771 #include <linux/hash.h>
106772+#include <linux/security.h>
106773 #include <linux/pid_namespace.h>
106774 #include <linux/init_task.h>
106775 #include <linux/syscalls.h>
106776@@ -47,7 +48,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
106777
106778 int pid_max = PID_MAX_DEFAULT;
106779
106780-#define RESERVED_PIDS 300
106781+#define RESERVED_PIDS 500
106782
106783 int pid_max_min = RESERVED_PIDS + 1;
106784 int pid_max_max = PID_MAX_LIMIT;
106785@@ -451,10 +452,18 @@ EXPORT_SYMBOL(pid_task);
106786 */
106787 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
106788 {
106789+ struct task_struct *task;
106790+
106791 rcu_lockdep_assert(rcu_read_lock_held(),
106792 "find_task_by_pid_ns() needs rcu_read_lock()"
106793 " protection");
106794- return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
106795+
106796+ task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
106797+
106798+ if (gr_pid_is_chrooted(task))
106799+ return NULL;
106800+
106801+ return task;
106802 }
106803
106804 struct task_struct *find_task_by_vpid(pid_t vnr)
106805@@ -462,6 +471,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
106806 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
106807 }
106808
106809+struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
106810+{
106811+ rcu_lockdep_assert(rcu_read_lock_held(),
106812+ "find_task_by_pid_ns() needs rcu_read_lock()"
106813+ " protection");
106814+ return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
106815+}
106816+
106817 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
106818 {
106819 struct pid *pid;
106820diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
106821index a65ba13..f600dbb 100644
106822--- a/kernel/pid_namespace.c
106823+++ b/kernel/pid_namespace.c
106824@@ -274,7 +274,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
106825 void __user *buffer, size_t *lenp, loff_t *ppos)
106826 {
106827 struct pid_namespace *pid_ns = task_active_pid_ns(current);
106828- struct ctl_table tmp = *table;
106829+ ctl_table_no_const tmp = *table;
106830
106831 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
106832 return -EPERM;
106833diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig
106834index 7e01f78..f5da19d 100644
106835--- a/kernel/power/Kconfig
106836+++ b/kernel/power/Kconfig
106837@@ -24,6 +24,8 @@ config HIBERNATE_CALLBACKS
106838 config HIBERNATION
106839 bool "Hibernation (aka 'suspend to disk')"
106840 depends on SWAP && ARCH_HIBERNATION_POSSIBLE
106841+ depends on !GRKERNSEC_KMEM
106842+ depends on !PAX_MEMORY_SANITIZE
106843 select HIBERNATE_CALLBACKS
106844 select LZO_COMPRESS
106845 select LZO_DECOMPRESS
106846diff --git a/kernel/power/process.c b/kernel/power/process.c
106847index 564f786..361a18e 100644
106848--- a/kernel/power/process.c
106849+++ b/kernel/power/process.c
106850@@ -35,6 +35,7 @@ static int try_to_freeze_tasks(bool user_only)
106851 unsigned int elapsed_msecs;
106852 bool wakeup = false;
106853 int sleep_usecs = USEC_PER_MSEC;
106854+ bool timedout = false;
106855
106856 do_gettimeofday(&start);
106857
106858@@ -45,13 +46,20 @@ static int try_to_freeze_tasks(bool user_only)
106859
106860 while (true) {
106861 todo = 0;
106862+ if (time_after(jiffies, end_time))
106863+ timedout = true;
106864 read_lock(&tasklist_lock);
106865 for_each_process_thread(g, p) {
106866 if (p == current || !freeze_task(p))
106867 continue;
106868
106869- if (!freezer_should_skip(p))
106870+ if (!freezer_should_skip(p)) {
106871 todo++;
106872+ if (timedout) {
106873+ printk(KERN_ERR "Task refusing to freeze:\n");
106874+ sched_show_task(p);
106875+ }
106876+ }
106877 }
106878 read_unlock(&tasklist_lock);
106879
106880@@ -60,7 +68,7 @@ static int try_to_freeze_tasks(bool user_only)
106881 todo += wq_busy;
106882 }
106883
106884- if (!todo || time_after(jiffies, end_time))
106885+ if (!todo || timedout)
106886 break;
106887
106888 if (pm_wakeup_pending()) {
106889diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
106890index c099b08..54bcfe8 100644
106891--- a/kernel/printk/printk.c
106892+++ b/kernel/printk/printk.c
106893@@ -463,7 +463,7 @@ static int log_store(int facility, int level,
106894 return msg->text_len;
106895 }
106896
106897-int dmesg_restrict = IS_ENABLED(CONFIG_SECURITY_DMESG_RESTRICT);
106898+int dmesg_restrict __read_only = IS_ENABLED(CONFIG_SECURITY_DMESG_RESTRICT);
106899
106900 static int syslog_action_restricted(int type)
106901 {
106902@@ -486,6 +486,11 @@ int check_syslog_permissions(int type, bool from_file)
106903 if (from_file && type != SYSLOG_ACTION_OPEN)
106904 return 0;
106905
106906+#ifdef CONFIG_GRKERNSEC_DMESG
106907+ if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
106908+ return -EPERM;
106909+#endif
106910+
106911 if (syslog_action_restricted(type)) {
106912 if (capable(CAP_SYSLOG))
106913 return 0;
106914diff --git a/kernel/profile.c b/kernel/profile.c
106915index a7bcd28..5b368fa 100644
106916--- a/kernel/profile.c
106917+++ b/kernel/profile.c
106918@@ -37,7 +37,7 @@ struct profile_hit {
106919 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
106920 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
106921
106922-static atomic_t *prof_buffer;
106923+static atomic_unchecked_t *prof_buffer;
106924 static unsigned long prof_len, prof_shift;
106925
106926 int prof_on __read_mostly;
106927@@ -256,7 +256,7 @@ static void profile_flip_buffers(void)
106928 hits[i].pc = 0;
106929 continue;
106930 }
106931- atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
106932+ atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
106933 hits[i].hits = hits[i].pc = 0;
106934 }
106935 }
106936@@ -317,9 +317,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
106937 * Add the current hit(s) and flush the write-queue out
106938 * to the global buffer:
106939 */
106940- atomic_add(nr_hits, &prof_buffer[pc]);
106941+ atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
106942 for (i = 0; i < NR_PROFILE_HIT; ++i) {
106943- atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
106944+ atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
106945 hits[i].pc = hits[i].hits = 0;
106946 }
106947 out:
106948@@ -394,7 +394,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
106949 {
106950 unsigned long pc;
106951 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
106952- atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
106953+ atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
106954 }
106955 #endif /* !CONFIG_SMP */
106956
106957@@ -489,7 +489,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
106958 return -EFAULT;
106959 buf++; p++; count--; read++;
106960 }
106961- pnt = (char *)prof_buffer + p - sizeof(atomic_t);
106962+ pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
106963 if (copy_to_user(buf, (void *)pnt, count))
106964 return -EFAULT;
106965 read += count;
106966@@ -520,7 +520,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
106967 }
106968 #endif
106969 profile_discard_flip_buffers();
106970- memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
106971+ memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
106972 return count;
106973 }
106974
106975diff --git a/kernel/ptrace.c b/kernel/ptrace.c
106976index c8e0e05..2be5614 100644
106977--- a/kernel/ptrace.c
106978+++ b/kernel/ptrace.c
106979@@ -321,7 +321,7 @@ static int ptrace_attach(struct task_struct *task, long request,
106980 if (seize)
106981 flags |= PT_SEIZED;
106982 rcu_read_lock();
106983- if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
106984+ if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
106985 flags |= PT_PTRACE_CAP;
106986 rcu_read_unlock();
106987 task->ptrace = flags;
106988@@ -514,7 +514,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
106989 break;
106990 return -EIO;
106991 }
106992- if (copy_to_user(dst, buf, retval))
106993+ if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
106994 return -EFAULT;
106995 copied += retval;
106996 src += retval;
106997@@ -802,7 +802,7 @@ int ptrace_request(struct task_struct *child, long request,
106998 bool seized = child->ptrace & PT_SEIZED;
106999 int ret = -EIO;
107000 siginfo_t siginfo, *si;
107001- void __user *datavp = (void __user *) data;
107002+ void __user *datavp = (__force void __user *) data;
107003 unsigned long __user *datalp = datavp;
107004 unsigned long flags;
107005
107006@@ -1048,14 +1048,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
107007 goto out;
107008 }
107009
107010+ if (gr_handle_ptrace(child, request)) {
107011+ ret = -EPERM;
107012+ goto out_put_task_struct;
107013+ }
107014+
107015 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
107016 ret = ptrace_attach(child, request, addr, data);
107017 /*
107018 * Some architectures need to do book-keeping after
107019 * a ptrace attach.
107020 */
107021- if (!ret)
107022+ if (!ret) {
107023 arch_ptrace_attach(child);
107024+ gr_audit_ptrace(child);
107025+ }
107026 goto out_put_task_struct;
107027 }
107028
107029@@ -1083,7 +1090,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
107030 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
107031 if (copied != sizeof(tmp))
107032 return -EIO;
107033- return put_user(tmp, (unsigned long __user *)data);
107034+ return put_user(tmp, (__force unsigned long __user *)data);
107035 }
107036
107037 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
107038@@ -1176,7 +1183,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
107039 }
107040
107041 COMPAT_SYSCALL_DEFINE4(ptrace, compat_long_t, request, compat_long_t, pid,
107042- compat_long_t, addr, compat_long_t, data)
107043+ compat_ulong_t, addr, compat_ulong_t, data)
107044 {
107045 struct task_struct *child;
107046 long ret;
107047@@ -1192,14 +1199,21 @@ COMPAT_SYSCALL_DEFINE4(ptrace, compat_long_t, request, compat_long_t, pid,
107048 goto out;
107049 }
107050
107051+ if (gr_handle_ptrace(child, request)) {
107052+ ret = -EPERM;
107053+ goto out_put_task_struct;
107054+ }
107055+
107056 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
107057 ret = ptrace_attach(child, request, addr, data);
107058 /*
107059 * Some architectures need to do book-keeping after
107060 * a ptrace attach.
107061 */
107062- if (!ret)
107063+ if (!ret) {
107064 arch_ptrace_attach(child);
107065+ gr_audit_ptrace(child);
107066+ }
107067 goto out_put_task_struct;
107068 }
107069
107070diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
107071index 8dbe276..8e87dbd 100644
107072--- a/kernel/rcu/rcutorture.c
107073+++ b/kernel/rcu/rcutorture.c
107074@@ -134,12 +134,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1],
107075 rcu_torture_count) = { 0 };
107076 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1],
107077 rcu_torture_batch) = { 0 };
107078-static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
107079-static atomic_t n_rcu_torture_alloc;
107080-static atomic_t n_rcu_torture_alloc_fail;
107081-static atomic_t n_rcu_torture_free;
107082-static atomic_t n_rcu_torture_mberror;
107083-static atomic_t n_rcu_torture_error;
107084+static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
107085+static atomic_unchecked_t n_rcu_torture_alloc;
107086+static atomic_unchecked_t n_rcu_torture_alloc_fail;
107087+static atomic_unchecked_t n_rcu_torture_free;
107088+static atomic_unchecked_t n_rcu_torture_mberror;
107089+static atomic_unchecked_t n_rcu_torture_error;
107090 static long n_rcu_torture_barrier_error;
107091 static long n_rcu_torture_boost_ktrerror;
107092 static long n_rcu_torture_boost_rterror;
107093@@ -148,7 +148,7 @@ static long n_rcu_torture_boosts;
107094 static long n_rcu_torture_timers;
107095 static long n_barrier_attempts;
107096 static long n_barrier_successes;
107097-static atomic_long_t n_cbfloods;
107098+static atomic_long_unchecked_t n_cbfloods;
107099 static struct list_head rcu_torture_removed;
107100
107101 static int rcu_torture_writer_state;
107102@@ -211,11 +211,11 @@ rcu_torture_alloc(void)
107103
107104 spin_lock_bh(&rcu_torture_lock);
107105 if (list_empty(&rcu_torture_freelist)) {
107106- atomic_inc(&n_rcu_torture_alloc_fail);
107107+ atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
107108 spin_unlock_bh(&rcu_torture_lock);
107109 return NULL;
107110 }
107111- atomic_inc(&n_rcu_torture_alloc);
107112+ atomic_inc_unchecked(&n_rcu_torture_alloc);
107113 p = rcu_torture_freelist.next;
107114 list_del_init(p);
107115 spin_unlock_bh(&rcu_torture_lock);
107116@@ -228,7 +228,7 @@ rcu_torture_alloc(void)
107117 static void
107118 rcu_torture_free(struct rcu_torture *p)
107119 {
107120- atomic_inc(&n_rcu_torture_free);
107121+ atomic_inc_unchecked(&n_rcu_torture_free);
107122 spin_lock_bh(&rcu_torture_lock);
107123 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
107124 spin_unlock_bh(&rcu_torture_lock);
107125@@ -308,7 +308,7 @@ rcu_torture_pipe_update_one(struct rcu_torture *rp)
107126 i = rp->rtort_pipe_count;
107127 if (i > RCU_TORTURE_PIPE_LEN)
107128 i = RCU_TORTURE_PIPE_LEN;
107129- atomic_inc(&rcu_torture_wcount[i]);
107130+ atomic_inc_unchecked(&rcu_torture_wcount[i]);
107131 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
107132 rp->rtort_mbtest = 0;
107133 return true;
107134@@ -796,7 +796,7 @@ rcu_torture_cbflood(void *arg)
107135 VERBOSE_TOROUT_STRING("rcu_torture_cbflood task started");
107136 do {
107137 schedule_timeout_interruptible(cbflood_inter_holdoff);
107138- atomic_long_inc(&n_cbfloods);
107139+ atomic_long_inc_unchecked(&n_cbfloods);
107140 WARN_ON(signal_pending(current));
107141 for (i = 0; i < cbflood_n_burst; i++) {
107142 for (j = 0; j < cbflood_n_per_burst; j++) {
107143@@ -923,7 +923,7 @@ rcu_torture_writer(void *arg)
107144 i = old_rp->rtort_pipe_count;
107145 if (i > RCU_TORTURE_PIPE_LEN)
107146 i = RCU_TORTURE_PIPE_LEN;
107147- atomic_inc(&rcu_torture_wcount[i]);
107148+ atomic_inc_unchecked(&rcu_torture_wcount[i]);
107149 old_rp->rtort_pipe_count++;
107150 switch (synctype[torture_random(&rand) % nsynctypes]) {
107151 case RTWS_DEF_FREE:
107152@@ -1061,7 +1061,7 @@ static void rcu_torture_timer(unsigned long unused)
107153 return;
107154 }
107155 if (p->rtort_mbtest == 0)
107156- atomic_inc(&n_rcu_torture_mberror);
107157+ atomic_inc_unchecked(&n_rcu_torture_mberror);
107158 spin_lock(&rand_lock);
107159 cur_ops->read_delay(&rand);
107160 n_rcu_torture_timers++;
107161@@ -1136,7 +1136,7 @@ rcu_torture_reader(void *arg)
107162 continue;
107163 }
107164 if (p->rtort_mbtest == 0)
107165- atomic_inc(&n_rcu_torture_mberror);
107166+ atomic_inc_unchecked(&n_rcu_torture_mberror);
107167 cur_ops->read_delay(&rand);
107168 preempt_disable();
107169 pipe_count = p->rtort_pipe_count;
107170@@ -1205,11 +1205,11 @@ rcu_torture_stats_print(void)
107171 rcu_torture_current,
107172 rcu_torture_current_version,
107173 list_empty(&rcu_torture_freelist),
107174- atomic_read(&n_rcu_torture_alloc),
107175- atomic_read(&n_rcu_torture_alloc_fail),
107176- atomic_read(&n_rcu_torture_free));
107177+ atomic_read_unchecked(&n_rcu_torture_alloc),
107178+ atomic_read_unchecked(&n_rcu_torture_alloc_fail),
107179+ atomic_read_unchecked(&n_rcu_torture_free));
107180 pr_cont("rtmbe: %d rtbke: %ld rtbre: %ld ",
107181- atomic_read(&n_rcu_torture_mberror),
107182+ atomic_read_unchecked(&n_rcu_torture_mberror),
107183 n_rcu_torture_boost_ktrerror,
107184 n_rcu_torture_boost_rterror);
107185 pr_cont("rtbf: %ld rtb: %ld nt: %ld ",
107186@@ -1221,17 +1221,17 @@ rcu_torture_stats_print(void)
107187 n_barrier_successes,
107188 n_barrier_attempts,
107189 n_rcu_torture_barrier_error);
107190- pr_cont("cbflood: %ld\n", atomic_long_read(&n_cbfloods));
107191+ pr_cont("cbflood: %ld\n", atomic_long_read_unchecked(&n_cbfloods));
107192
107193 pr_alert("%s%s ", torture_type, TORTURE_FLAG);
107194- if (atomic_read(&n_rcu_torture_mberror) != 0 ||
107195+ if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
107196 n_rcu_torture_barrier_error != 0 ||
107197 n_rcu_torture_boost_ktrerror != 0 ||
107198 n_rcu_torture_boost_rterror != 0 ||
107199 n_rcu_torture_boost_failure != 0 ||
107200 i > 1) {
107201 pr_cont("%s", "!!! ");
107202- atomic_inc(&n_rcu_torture_error);
107203+ atomic_inc_unchecked(&n_rcu_torture_error);
107204 WARN_ON_ONCE(1);
107205 }
107206 pr_cont("Reader Pipe: ");
107207@@ -1248,7 +1248,7 @@ rcu_torture_stats_print(void)
107208 pr_alert("%s%s ", torture_type, TORTURE_FLAG);
107209 pr_cont("Free-Block Circulation: ");
107210 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
107211- pr_cont(" %d", atomic_read(&rcu_torture_wcount[i]));
107212+ pr_cont(" %d", atomic_read_unchecked(&rcu_torture_wcount[i]));
107213 }
107214 pr_cont("\n");
107215
107216@@ -1595,7 +1595,7 @@ rcu_torture_cleanup(void)
107217
107218 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
107219
107220- if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
107221+ if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
107222 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
107223 else if (torture_onoff_failures())
107224 rcu_torture_print_module_parms(cur_ops,
107225@@ -1720,18 +1720,18 @@ rcu_torture_init(void)
107226
107227 rcu_torture_current = NULL;
107228 rcu_torture_current_version = 0;
107229- atomic_set(&n_rcu_torture_alloc, 0);
107230- atomic_set(&n_rcu_torture_alloc_fail, 0);
107231- atomic_set(&n_rcu_torture_free, 0);
107232- atomic_set(&n_rcu_torture_mberror, 0);
107233- atomic_set(&n_rcu_torture_error, 0);
107234+ atomic_set_unchecked(&n_rcu_torture_alloc, 0);
107235+ atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
107236+ atomic_set_unchecked(&n_rcu_torture_free, 0);
107237+ atomic_set_unchecked(&n_rcu_torture_mberror, 0);
107238+ atomic_set_unchecked(&n_rcu_torture_error, 0);
107239 n_rcu_torture_barrier_error = 0;
107240 n_rcu_torture_boost_ktrerror = 0;
107241 n_rcu_torture_boost_rterror = 0;
107242 n_rcu_torture_boost_failure = 0;
107243 n_rcu_torture_boosts = 0;
107244 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
107245- atomic_set(&rcu_torture_wcount[i], 0);
107246+ atomic_set_unchecked(&rcu_torture_wcount[i], 0);
107247 for_each_possible_cpu(cpu) {
107248 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
107249 per_cpu(rcu_torture_count, cpu)[i] = 0;
107250diff --git a/kernel/rcu/tiny.c b/kernel/rcu/tiny.c
107251index ec30868..89752ff 100644
107252--- a/kernel/rcu/tiny.c
107253+++ b/kernel/rcu/tiny.c
107254@@ -42,7 +42,7 @@
107255 /* Forward declarations for tiny_plugin.h. */
107256 struct rcu_ctrlblk;
107257 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
107258-static void rcu_process_callbacks(struct softirq_action *unused);
107259+static void rcu_process_callbacks(void);
107260 static void __call_rcu(struct rcu_head *head,
107261 void (*func)(struct rcu_head *rcu),
107262 struct rcu_ctrlblk *rcp);
107263@@ -203,7 +203,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
107264 false));
107265 }
107266
107267-static void rcu_process_callbacks(struct softirq_action *unused)
107268+static __latent_entropy void rcu_process_callbacks(void)
107269 {
107270 __rcu_process_callbacks(&rcu_sched_ctrlblk);
107271 __rcu_process_callbacks(&rcu_bh_ctrlblk);
107272diff --git a/kernel/rcu/tiny_plugin.h b/kernel/rcu/tiny_plugin.h
107273index f94e209..d2985bd 100644
107274--- a/kernel/rcu/tiny_plugin.h
107275+++ b/kernel/rcu/tiny_plugin.h
107276@@ -150,10 +150,10 @@ static void check_cpu_stall(struct rcu_ctrlblk *rcp)
107277 rcp->name, rcp->ticks_this_gp, DYNTICK_TASK_EXIT_IDLE,
107278 jiffies - rcp->gp_start, rcp->qlen);
107279 dump_stack();
107280- ACCESS_ONCE(rcp->jiffies_stall) = jiffies +
107281+ ACCESS_ONCE_RW(rcp->jiffies_stall) = jiffies +
107282 3 * rcu_jiffies_till_stall_check() + 3;
107283 } else if (ULONG_CMP_GE(j, js)) {
107284- ACCESS_ONCE(rcp->jiffies_stall) = jiffies + rcu_jiffies_till_stall_check();
107285+ ACCESS_ONCE_RW(rcp->jiffies_stall) = jiffies + rcu_jiffies_till_stall_check();
107286 }
107287 }
107288
107289@@ -161,7 +161,7 @@ static void reset_cpu_stall_ticks(struct rcu_ctrlblk *rcp)
107290 {
107291 rcp->ticks_this_gp = 0;
107292 rcp->gp_start = jiffies;
107293- ACCESS_ONCE(rcp->jiffies_stall) = jiffies + rcu_jiffies_till_stall_check();
107294+ ACCESS_ONCE_RW(rcp->jiffies_stall) = jiffies + rcu_jiffies_till_stall_check();
107295 }
107296
107297 static void check_cpu_stalls(void)
107298diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
107299index 8cf7304..953f8ad 100644
107300--- a/kernel/rcu/tree.c
107301+++ b/kernel/rcu/tree.c
107302@@ -290,7 +290,7 @@ static void rcu_momentary_dyntick_idle(void)
107303 */
107304 rdtp = this_cpu_ptr(&rcu_dynticks);
107305 smp_mb__before_atomic(); /* Earlier stuff before QS. */
107306- atomic_add(2, &rdtp->dynticks); /* QS. */
107307+ atomic_add_unchecked(2, &rdtp->dynticks); /* QS. */
107308 smp_mb__after_atomic(); /* Later stuff after QS. */
107309 break;
107310 }
107311@@ -602,9 +602,9 @@ static void rcu_eqs_enter_common(long long oldval, bool user)
107312 rcu_prepare_for_idle();
107313 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
107314 smp_mb__before_atomic(); /* See above. */
107315- atomic_inc(&rdtp->dynticks);
107316+ atomic_inc_unchecked(&rdtp->dynticks);
107317 smp_mb__after_atomic(); /* Force ordering with next sojourn. */
107318- WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
107319+ WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
107320 rcu_dynticks_task_enter();
107321
107322 /*
107323@@ -725,10 +725,10 @@ static void rcu_eqs_exit_common(long long oldval, int user)
107324
107325 rcu_dynticks_task_exit();
107326 smp_mb__before_atomic(); /* Force ordering w/previous sojourn. */
107327- atomic_inc(&rdtp->dynticks);
107328+ atomic_inc_unchecked(&rdtp->dynticks);
107329 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
107330 smp_mb__after_atomic(); /* See above. */
107331- WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
107332+ WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
107333 rcu_cleanup_after_idle();
107334 trace_rcu_dyntick(TPS("End"), oldval, rdtp->dynticks_nesting);
107335 if (!user && !is_idle_task(current)) {
107336@@ -862,12 +862,12 @@ void rcu_nmi_enter(void)
107337 * to be in the outermost NMI handler that interrupted an RCU-idle
107338 * period (observation due to Andy Lutomirski).
107339 */
107340- if (!(atomic_read(&rdtp->dynticks) & 0x1)) {
107341+ if (!(atomic_read_unchecked(&rdtp->dynticks) & 0x1)) {
107342 smp_mb__before_atomic(); /* Force delay from prior write. */
107343- atomic_inc(&rdtp->dynticks);
107344+ atomic_inc_unchecked(&rdtp->dynticks);
107345 /* atomic_inc() before later RCU read-side crit sects */
107346 smp_mb__after_atomic(); /* See above. */
107347- WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
107348+ WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
107349 incby = 1;
107350 }
107351 rdtp->dynticks_nmi_nesting += incby;
107352@@ -892,7 +892,7 @@ void rcu_nmi_exit(void)
107353 * to us!)
107354 */
107355 WARN_ON_ONCE(rdtp->dynticks_nmi_nesting <= 0);
107356- WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
107357+ WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
107358
107359 /*
107360 * If the nesting level is not 1, the CPU wasn't RCU-idle, so
107361@@ -907,9 +907,9 @@ void rcu_nmi_exit(void)
107362 rdtp->dynticks_nmi_nesting = 0;
107363 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
107364 smp_mb__before_atomic(); /* See above. */
107365- atomic_inc(&rdtp->dynticks);
107366+ atomic_inc_unchecked(&rdtp->dynticks);
107367 smp_mb__after_atomic(); /* Force delay to next write. */
107368- WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
107369+ WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
107370 }
107371
107372 /**
107373@@ -922,7 +922,7 @@ void rcu_nmi_exit(void)
107374 */
107375 bool notrace __rcu_is_watching(void)
107376 {
107377- return atomic_read(this_cpu_ptr(&rcu_dynticks.dynticks)) & 0x1;
107378+ return atomic_read_unchecked(this_cpu_ptr(&rcu_dynticks.dynticks)) & 0x1;
107379 }
107380
107381 /**
107382@@ -1005,7 +1005,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
107383 static int dyntick_save_progress_counter(struct rcu_data *rdp,
107384 bool *isidle, unsigned long *maxj)
107385 {
107386- rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
107387+ rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
107388 rcu_sysidle_check_cpu(rdp, isidle, maxj);
107389 if ((rdp->dynticks_snap & 0x1) == 0) {
107390 trace_rcu_fqs(rdp->rsp->name, rdp->gpnum, rdp->cpu, TPS("dti"));
107391@@ -1013,7 +1013,7 @@ static int dyntick_save_progress_counter(struct rcu_data *rdp,
107392 } else {
107393 if (ULONG_CMP_LT(ACCESS_ONCE(rdp->gpnum) + ULONG_MAX / 4,
107394 rdp->mynode->gpnum))
107395- ACCESS_ONCE(rdp->gpwrap) = true;
107396+ ACCESS_ONCE_RW(rdp->gpwrap) = true;
107397 return 0;
107398 }
107399 }
107400@@ -1031,7 +1031,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp,
107401 int *rcrmp;
107402 unsigned int snap;
107403
107404- curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
107405+ curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
107406 snap = (unsigned int)rdp->dynticks_snap;
107407
107408 /*
107409@@ -1094,10 +1094,10 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp,
107410 rdp->rsp->gp_start + jiffies_till_sched_qs) ||
107411 ULONG_CMP_GE(jiffies, rdp->rsp->jiffies_resched)) {
107412 if (!(ACCESS_ONCE(*rcrmp) & rdp->rsp->flavor_mask)) {
107413- ACCESS_ONCE(rdp->cond_resched_completed) =
107414+ ACCESS_ONCE_RW(rdp->cond_resched_completed) =
107415 ACCESS_ONCE(rdp->mynode->completed);
107416 smp_mb(); /* ->cond_resched_completed before *rcrmp. */
107417- ACCESS_ONCE(*rcrmp) =
107418+ ACCESS_ONCE_RW(*rcrmp) =
107419 ACCESS_ONCE(*rcrmp) + rdp->rsp->flavor_mask;
107420 resched_cpu(rdp->cpu); /* Force CPU into scheduler. */
107421 rdp->rsp->jiffies_resched += 5; /* Enable beating. */
107422@@ -1119,7 +1119,7 @@ static void record_gp_stall_check_time(struct rcu_state *rsp)
107423 rsp->gp_start = j;
107424 smp_wmb(); /* Record start time before stall time. */
107425 j1 = rcu_jiffies_till_stall_check();
107426- ACCESS_ONCE(rsp->jiffies_stall) = j + j1;
107427+ ACCESS_ONCE_RW(rsp->jiffies_stall) = j + j1;
107428 rsp->jiffies_resched = j + j1 / 2;
107429 rsp->n_force_qs_gpstart = ACCESS_ONCE(rsp->n_force_qs);
107430 }
107431@@ -1178,7 +1178,7 @@ static void print_other_cpu_stall(struct rcu_state *rsp, unsigned long gpnum)
107432 raw_spin_unlock_irqrestore(&rnp->lock, flags);
107433 return;
107434 }
107435- ACCESS_ONCE(rsp->jiffies_stall) = jiffies + 3 * rcu_jiffies_till_stall_check() + 3;
107436+ ACCESS_ONCE_RW(rsp->jiffies_stall) = jiffies + 3 * rcu_jiffies_till_stall_check() + 3;
107437 raw_spin_unlock_irqrestore(&rnp->lock, flags);
107438
107439 /*
107440@@ -1263,7 +1263,7 @@ static void print_cpu_stall(struct rcu_state *rsp)
107441
107442 raw_spin_lock_irqsave(&rnp->lock, flags);
107443 if (ULONG_CMP_GE(jiffies, ACCESS_ONCE(rsp->jiffies_stall)))
107444- ACCESS_ONCE(rsp->jiffies_stall) = jiffies +
107445+ ACCESS_ONCE_RW(rsp->jiffies_stall) = jiffies +
107446 3 * rcu_jiffies_till_stall_check() + 3;
107447 raw_spin_unlock_irqrestore(&rnp->lock, flags);
107448
107449@@ -1347,7 +1347,7 @@ void rcu_cpu_stall_reset(void)
107450 struct rcu_state *rsp;
107451
107452 for_each_rcu_flavor(rsp)
107453- ACCESS_ONCE(rsp->jiffies_stall) = jiffies + ULONG_MAX / 2;
107454+ ACCESS_ONCE_RW(rsp->jiffies_stall) = jiffies + ULONG_MAX / 2;
107455 }
107456
107457 /*
107458@@ -1704,7 +1704,7 @@ static bool __note_gp_changes(struct rcu_state *rsp, struct rcu_node *rnp,
107459 rdp->rcu_qs_ctr_snap = __this_cpu_read(rcu_qs_ctr);
107460 rdp->qs_pending = !!(rnp->qsmask & rdp->grpmask);
107461 zero_cpu_stall_ticks(rdp);
107462- ACCESS_ONCE(rdp->gpwrap) = false;
107463+ ACCESS_ONCE_RW(rdp->gpwrap) = false;
107464 }
107465 return ret;
107466 }
107467@@ -1740,7 +1740,7 @@ static int rcu_gp_init(struct rcu_state *rsp)
107468 struct rcu_data *rdp;
107469 struct rcu_node *rnp = rcu_get_root(rsp);
107470
107471- ACCESS_ONCE(rsp->gp_activity) = jiffies;
107472+ ACCESS_ONCE_RW(rsp->gp_activity) = jiffies;
107473 raw_spin_lock_irq(&rnp->lock);
107474 smp_mb__after_unlock_lock();
107475 if (!ACCESS_ONCE(rsp->gp_flags)) {
107476@@ -1748,7 +1748,7 @@ static int rcu_gp_init(struct rcu_state *rsp)
107477 raw_spin_unlock_irq(&rnp->lock);
107478 return 0;
107479 }
107480- ACCESS_ONCE(rsp->gp_flags) = 0; /* Clear all flags: New grace period. */
107481+ ACCESS_ONCE_RW(rsp->gp_flags) = 0; /* Clear all flags: New grace period. */
107482
107483 if (WARN_ON_ONCE(rcu_gp_in_progress(rsp))) {
107484 /*
107485@@ -1834,9 +1834,9 @@ static int rcu_gp_init(struct rcu_state *rsp)
107486 rdp = this_cpu_ptr(rsp->rda);
107487 rcu_preempt_check_blocked_tasks(rnp);
107488 rnp->qsmask = rnp->qsmaskinit;
107489- ACCESS_ONCE(rnp->gpnum) = rsp->gpnum;
107490+ ACCESS_ONCE_RW(rnp->gpnum) = rsp->gpnum;
107491 if (WARN_ON_ONCE(rnp->completed != rsp->completed))
107492- ACCESS_ONCE(rnp->completed) = rsp->completed;
107493+ ACCESS_ONCE_RW(rnp->completed) = rsp->completed;
107494 if (rnp == rdp->mynode)
107495 (void)__note_gp_changes(rsp, rnp, rdp);
107496 rcu_preempt_boost_start_gp(rnp);
107497@@ -1845,7 +1845,7 @@ static int rcu_gp_init(struct rcu_state *rsp)
107498 rnp->grphi, rnp->qsmask);
107499 raw_spin_unlock_irq(&rnp->lock);
107500 cond_resched_rcu_qs();
107501- ACCESS_ONCE(rsp->gp_activity) = jiffies;
107502+ ACCESS_ONCE_RW(rsp->gp_activity) = jiffies;
107503 if (gp_init_delay > 0 &&
107504 !(rsp->gpnum % (rcu_num_nodes * PER_RCU_NODE_PERIOD)))
107505 schedule_timeout_uninterruptible(gp_init_delay);
107506@@ -1864,7 +1864,7 @@ static int rcu_gp_fqs(struct rcu_state *rsp, int fqs_state_in)
107507 unsigned long maxj;
107508 struct rcu_node *rnp = rcu_get_root(rsp);
107509
107510- ACCESS_ONCE(rsp->gp_activity) = jiffies;
107511+ ACCESS_ONCE_RW(rsp->gp_activity) = jiffies;
107512 rsp->n_force_qs++;
107513 if (fqs_state == RCU_SAVE_DYNTICK) {
107514 /* Collect dyntick-idle snapshots. */
107515@@ -1885,7 +1885,7 @@ static int rcu_gp_fqs(struct rcu_state *rsp, int fqs_state_in)
107516 if (ACCESS_ONCE(rsp->gp_flags) & RCU_GP_FLAG_FQS) {
107517 raw_spin_lock_irq(&rnp->lock);
107518 smp_mb__after_unlock_lock();
107519- ACCESS_ONCE(rsp->gp_flags) =
107520+ ACCESS_ONCE_RW(rsp->gp_flags) =
107521 ACCESS_ONCE(rsp->gp_flags) & ~RCU_GP_FLAG_FQS;
107522 raw_spin_unlock_irq(&rnp->lock);
107523 }
107524@@ -1903,7 +1903,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
107525 struct rcu_data *rdp;
107526 struct rcu_node *rnp = rcu_get_root(rsp);
107527
107528- ACCESS_ONCE(rsp->gp_activity) = jiffies;
107529+ ACCESS_ONCE_RW(rsp->gp_activity) = jiffies;
107530 raw_spin_lock_irq(&rnp->lock);
107531 smp_mb__after_unlock_lock();
107532 gp_duration = jiffies - rsp->gp_start;
107533@@ -1934,7 +1934,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
107534 smp_mb__after_unlock_lock();
107535 WARN_ON_ONCE(rcu_preempt_blocked_readers_cgp(rnp));
107536 WARN_ON_ONCE(rnp->qsmask);
107537- ACCESS_ONCE(rnp->completed) = rsp->gpnum;
107538+ ACCESS_ONCE_RW(rnp->completed) = rsp->gpnum;
107539 rdp = this_cpu_ptr(rsp->rda);
107540 if (rnp == rdp->mynode)
107541 needgp = __note_gp_changes(rsp, rnp, rdp) || needgp;
107542@@ -1942,7 +1942,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
107543 nocb += rcu_future_gp_cleanup(rsp, rnp);
107544 raw_spin_unlock_irq(&rnp->lock);
107545 cond_resched_rcu_qs();
107546- ACCESS_ONCE(rsp->gp_activity) = jiffies;
107547+ ACCESS_ONCE_RW(rsp->gp_activity) = jiffies;
107548 }
107549 rnp = rcu_get_root(rsp);
107550 raw_spin_lock_irq(&rnp->lock);
107551@@ -1950,14 +1950,14 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
107552 rcu_nocb_gp_set(rnp, nocb);
107553
107554 /* Declare grace period done. */
107555- ACCESS_ONCE(rsp->completed) = rsp->gpnum;
107556+ ACCESS_ONCE_RW(rsp->completed) = rsp->gpnum;
107557 trace_rcu_grace_period(rsp->name, rsp->completed, TPS("end"));
107558 rsp->fqs_state = RCU_GP_IDLE;
107559 rdp = this_cpu_ptr(rsp->rda);
107560 /* Advance CBs to reduce false positives below. */
107561 needgp = rcu_advance_cbs(rsp, rnp, rdp) || needgp;
107562 if (needgp || cpu_needs_another_gp(rsp, rdp)) {
107563- ACCESS_ONCE(rsp->gp_flags) = RCU_GP_FLAG_INIT;
107564+ ACCESS_ONCE_RW(rsp->gp_flags) = RCU_GP_FLAG_INIT;
107565 trace_rcu_grace_period(rsp->name,
107566 ACCESS_ONCE(rsp->gpnum),
107567 TPS("newreq"));
107568@@ -1993,7 +1993,7 @@ static int __noreturn rcu_gp_kthread(void *arg)
107569 if (rcu_gp_init(rsp))
107570 break;
107571 cond_resched_rcu_qs();
107572- ACCESS_ONCE(rsp->gp_activity) = jiffies;
107573+ ACCESS_ONCE_RW(rsp->gp_activity) = jiffies;
107574 WARN_ON(signal_pending(current));
107575 trace_rcu_grace_period(rsp->name,
107576 ACCESS_ONCE(rsp->gpnum),
107577@@ -2037,11 +2037,11 @@ static int __noreturn rcu_gp_kthread(void *arg)
107578 ACCESS_ONCE(rsp->gpnum),
107579 TPS("fqsend"));
107580 cond_resched_rcu_qs();
107581- ACCESS_ONCE(rsp->gp_activity) = jiffies;
107582+ ACCESS_ONCE_RW(rsp->gp_activity) = jiffies;
107583 } else {
107584 /* Deal with stray signal. */
107585 cond_resched_rcu_qs();
107586- ACCESS_ONCE(rsp->gp_activity) = jiffies;
107587+ ACCESS_ONCE_RW(rsp->gp_activity) = jiffies;
107588 WARN_ON(signal_pending(current));
107589 trace_rcu_grace_period(rsp->name,
107590 ACCESS_ONCE(rsp->gpnum),
107591@@ -2086,7 +2086,7 @@ rcu_start_gp_advanced(struct rcu_state *rsp, struct rcu_node *rnp,
107592 */
107593 return false;
107594 }
107595- ACCESS_ONCE(rsp->gp_flags) = RCU_GP_FLAG_INIT;
107596+ ACCESS_ONCE_RW(rsp->gp_flags) = RCU_GP_FLAG_INIT;
107597 trace_rcu_grace_period(rsp->name, ACCESS_ONCE(rsp->gpnum),
107598 TPS("newreq"));
107599
107600@@ -2359,7 +2359,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
107601 rsp->qlen += rdp->qlen;
107602 rdp->n_cbs_orphaned += rdp->qlen;
107603 rdp->qlen_lazy = 0;
107604- ACCESS_ONCE(rdp->qlen) = 0;
107605+ ACCESS_ONCE_RW(rdp->qlen) = 0;
107606 }
107607
107608 /*
107609@@ -2636,7 +2636,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
107610 }
107611 smp_mb(); /* List handling before counting for rcu_barrier(). */
107612 rdp->qlen_lazy -= count_lazy;
107613- ACCESS_ONCE(rdp->qlen) = rdp->qlen - count;
107614+ ACCESS_ONCE_RW(rdp->qlen) = rdp->qlen - count;
107615 rdp->n_cbs_invoked += count;
107616
107617 /* Reinstate batch limit if we have worked down the excess. */
107618@@ -2814,7 +2814,7 @@ static void force_quiescent_state(struct rcu_state *rsp)
107619 raw_spin_unlock_irqrestore(&rnp_old->lock, flags);
107620 return; /* Someone beat us to it. */
107621 }
107622- ACCESS_ONCE(rsp->gp_flags) =
107623+ ACCESS_ONCE_RW(rsp->gp_flags) =
107624 ACCESS_ONCE(rsp->gp_flags) | RCU_GP_FLAG_FQS;
107625 raw_spin_unlock_irqrestore(&rnp_old->lock, flags);
107626 rcu_gp_kthread_wake(rsp);
107627@@ -2860,7 +2860,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
107628 /*
107629 * Do RCU core processing for the current CPU.
107630 */
107631-static void rcu_process_callbacks(struct softirq_action *unused)
107632+static void rcu_process_callbacks(void)
107633 {
107634 struct rcu_state *rsp;
107635
107636@@ -2972,7 +2972,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
107637 WARN_ON_ONCE((unsigned long)head & 0x1); /* Misaligned rcu_head! */
107638 if (debug_rcu_head_queue(head)) {
107639 /* Probable double call_rcu(), so leak the callback. */
107640- ACCESS_ONCE(head->func) = rcu_leak_callback;
107641+ ACCESS_ONCE_RW(head->func) = rcu_leak_callback;
107642 WARN_ONCE(1, "__call_rcu(): Leaked duplicate callback\n");
107643 return;
107644 }
107645@@ -3011,7 +3011,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
107646 if (!likely(rdp->nxtlist))
107647 init_default_callback_list(rdp);
107648 }
107649- ACCESS_ONCE(rdp->qlen) = rdp->qlen + 1;
107650+ ACCESS_ONCE_RW(rdp->qlen) = rdp->qlen + 1;
107651 if (lazy)
107652 rdp->qlen_lazy++;
107653 else
107654@@ -3284,11 +3284,11 @@ void synchronize_sched_expedited(void)
107655 * counter wrap on a 32-bit system. Quite a few more CPUs would of
107656 * course be required on a 64-bit system.
107657 */
107658- if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
107659+ if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
107660 (ulong)atomic_long_read(&rsp->expedited_done) +
107661 ULONG_MAX / 8)) {
107662 synchronize_sched();
107663- atomic_long_inc(&rsp->expedited_wrap);
107664+ atomic_long_inc_unchecked(&rsp->expedited_wrap);
107665 return;
107666 }
107667
107668@@ -3296,12 +3296,12 @@ void synchronize_sched_expedited(void)
107669 * Take a ticket. Note that atomic_inc_return() implies a
107670 * full memory barrier.
107671 */
107672- snap = atomic_long_inc_return(&rsp->expedited_start);
107673+ snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
107674 firstsnap = snap;
107675 if (!try_get_online_cpus()) {
107676 /* CPU hotplug operation in flight, fall back to normal GP. */
107677 wait_rcu_gp(call_rcu_sched);
107678- atomic_long_inc(&rsp->expedited_normal);
107679+ atomic_long_inc_unchecked(&rsp->expedited_normal);
107680 return;
107681 }
107682 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
107683@@ -3314,7 +3314,7 @@ void synchronize_sched_expedited(void)
107684 for_each_cpu(cpu, cm) {
107685 struct rcu_dynticks *rdtp = &per_cpu(rcu_dynticks, cpu);
107686
107687- if (!(atomic_add_return(0, &rdtp->dynticks) & 0x1))
107688+ if (!(atomic_add_return_unchecked(0, &rdtp->dynticks) & 0x1))
107689 cpumask_clear_cpu(cpu, cm);
107690 }
107691 if (cpumask_weight(cm) == 0)
107692@@ -3329,14 +3329,14 @@ void synchronize_sched_expedited(void)
107693 synchronize_sched_expedited_cpu_stop,
107694 NULL) == -EAGAIN) {
107695 put_online_cpus();
107696- atomic_long_inc(&rsp->expedited_tryfail);
107697+ atomic_long_inc_unchecked(&rsp->expedited_tryfail);
107698
107699 /* Check to see if someone else did our work for us. */
107700 s = atomic_long_read(&rsp->expedited_done);
107701 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
107702 /* ensure test happens before caller kfree */
107703 smp_mb__before_atomic(); /* ^^^ */
107704- atomic_long_inc(&rsp->expedited_workdone1);
107705+ atomic_long_inc_unchecked(&rsp->expedited_workdone1);
107706 free_cpumask_var(cm);
107707 return;
107708 }
107709@@ -3346,7 +3346,7 @@ void synchronize_sched_expedited(void)
107710 udelay(trycount * num_online_cpus());
107711 } else {
107712 wait_rcu_gp(call_rcu_sched);
107713- atomic_long_inc(&rsp->expedited_normal);
107714+ atomic_long_inc_unchecked(&rsp->expedited_normal);
107715 free_cpumask_var(cm);
107716 return;
107717 }
107718@@ -3356,7 +3356,7 @@ void synchronize_sched_expedited(void)
107719 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
107720 /* ensure test happens before caller kfree */
107721 smp_mb__before_atomic(); /* ^^^ */
107722- atomic_long_inc(&rsp->expedited_workdone2);
107723+ atomic_long_inc_unchecked(&rsp->expedited_workdone2);
107724 free_cpumask_var(cm);
107725 return;
107726 }
107727@@ -3371,14 +3371,14 @@ void synchronize_sched_expedited(void)
107728 if (!try_get_online_cpus()) {
107729 /* CPU hotplug operation in flight, use normal GP. */
107730 wait_rcu_gp(call_rcu_sched);
107731- atomic_long_inc(&rsp->expedited_normal);
107732+ atomic_long_inc_unchecked(&rsp->expedited_normal);
107733 free_cpumask_var(cm);
107734 return;
107735 }
107736- snap = atomic_long_read(&rsp->expedited_start);
107737+ snap = atomic_long_read_unchecked(&rsp->expedited_start);
107738 smp_mb(); /* ensure read is before try_stop_cpus(). */
107739 }
107740- atomic_long_inc(&rsp->expedited_stoppedcpus);
107741+ atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
107742
107743 all_cpus_idle:
107744 free_cpumask_var(cm);
107745@@ -3390,16 +3390,16 @@ all_cpus_idle:
107746 * than we did already did their update.
107747 */
107748 do {
107749- atomic_long_inc(&rsp->expedited_done_tries);
107750+ atomic_long_inc_unchecked(&rsp->expedited_done_tries);
107751 s = atomic_long_read(&rsp->expedited_done);
107752 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
107753 /* ensure test happens before caller kfree */
107754 smp_mb__before_atomic(); /* ^^^ */
107755- atomic_long_inc(&rsp->expedited_done_lost);
107756+ atomic_long_inc_unchecked(&rsp->expedited_done_lost);
107757 break;
107758 }
107759 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
107760- atomic_long_inc(&rsp->expedited_done_exit);
107761+ atomic_long_inc_unchecked(&rsp->expedited_done_exit);
107762
107763 put_online_cpus();
107764 }
107765@@ -3609,7 +3609,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
107766 * ACCESS_ONCE() to prevent the compiler from speculating
107767 * the increment to precede the early-exit check.
107768 */
107769- ACCESS_ONCE(rsp->n_barrier_done) = rsp->n_barrier_done + 1;
107770+ ACCESS_ONCE_RW(rsp->n_barrier_done) = rsp->n_barrier_done + 1;
107771 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
107772 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
107773 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
107774@@ -3665,7 +3665,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
107775
107776 /* Increment ->n_barrier_done to prevent duplicate work. */
107777 smp_mb(); /* Keep increment after above mechanism. */
107778- ACCESS_ONCE(rsp->n_barrier_done) = rsp->n_barrier_done + 1;
107779+ ACCESS_ONCE_RW(rsp->n_barrier_done) = rsp->n_barrier_done + 1;
107780 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
107781 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
107782 smp_mb(); /* Keep increment before caller's subsequent code. */
107783@@ -3732,7 +3732,7 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
107784 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
107785 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
107786 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
107787- WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
107788+ WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
107789 rdp->cpu = cpu;
107790 rdp->rsp = rsp;
107791 rcu_boot_init_nocb_percpu_data(rdp);
107792@@ -3763,8 +3763,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp)
107793 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
107794 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
107795 rcu_sysidle_init_percpu_data(rdp->dynticks);
107796- atomic_set(&rdp->dynticks->dynticks,
107797- (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
107798+ atomic_set_unchecked(&rdp->dynticks->dynticks,
107799+ (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
107800 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
107801
107802 /*
107803diff --git a/kernel/rcu/tree.h b/kernel/rcu/tree.h
107804index a69d3da..51993c4 100644
107805--- a/kernel/rcu/tree.h
107806+++ b/kernel/rcu/tree.h
107807@@ -86,11 +86,11 @@ struct rcu_dynticks {
107808 long long dynticks_nesting; /* Track irq/process nesting level. */
107809 /* Process level is worth LLONG_MAX/2. */
107810 int dynticks_nmi_nesting; /* Track NMI nesting level. */
107811- atomic_t dynticks; /* Even value for idle, else odd. */
107812+ atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
107813 #ifdef CONFIG_NO_HZ_FULL_SYSIDLE
107814 long long dynticks_idle_nesting;
107815 /* irq/process nesting level from idle. */
107816- atomic_t dynticks_idle; /* Even value for idle, else odd. */
107817+ atomic_unchecked_t dynticks_idle;/* Even value for idle, else odd. */
107818 /* "Idle" excludes userspace execution. */
107819 unsigned long dynticks_idle_jiffies;
107820 /* End of last non-NMI non-idle period. */
107821@@ -463,17 +463,17 @@ struct rcu_state {
107822 /* _rcu_barrier(). */
107823 /* End of fields guarded by barrier_mutex. */
107824
107825- atomic_long_t expedited_start; /* Starting ticket. */
107826- atomic_long_t expedited_done; /* Done ticket. */
107827- atomic_long_t expedited_wrap; /* # near-wrap incidents. */
107828- atomic_long_t expedited_tryfail; /* # acquisition failures. */
107829- atomic_long_t expedited_workdone1; /* # done by others #1. */
107830- atomic_long_t expedited_workdone2; /* # done by others #2. */
107831- atomic_long_t expedited_normal; /* # fallbacks to normal. */
107832- atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
107833- atomic_long_t expedited_done_tries; /* # tries to update _done. */
107834- atomic_long_t expedited_done_lost; /* # times beaten to _done. */
107835- atomic_long_t expedited_done_exit; /* # times exited _done loop. */
107836+ atomic_long_unchecked_t expedited_start; /* Starting ticket. */
107837+ atomic_long_t expedited_done; /* Done ticket. */
107838+ atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
107839+ atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
107840+ atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
107841+ atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
107842+ atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
107843+ atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
107844+ atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
107845+ atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
107846+ atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
107847
107848 unsigned long jiffies_force_qs; /* Time at which to invoke */
107849 /* force_quiescent_state(). */
107850diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
107851index 8c0ec0f..99d52c5 100644
107852--- a/kernel/rcu/tree_plugin.h
107853+++ b/kernel/rcu/tree_plugin.h
107854@@ -570,7 +570,7 @@ static int rcu_preempted_readers_exp(struct rcu_node *rnp)
107855 static int sync_rcu_preempt_exp_done(struct rcu_node *rnp)
107856 {
107857 return !rcu_preempted_readers_exp(rnp) &&
107858- ACCESS_ONCE(rnp->expmask) == 0;
107859+ ACCESS_ONCE_RW(rnp->expmask) == 0;
107860 }
107861
107862 /*
107863@@ -780,7 +780,7 @@ void synchronize_rcu_expedited(void)
107864
107865 /* Clean up and exit. */
107866 smp_mb(); /* ensure expedited GP seen before counter increment. */
107867- ACCESS_ONCE(sync_rcu_preempt_exp_count) =
107868+ ACCESS_ONCE_RW(sync_rcu_preempt_exp_count) =
107869 sync_rcu_preempt_exp_count + 1;
107870 unlock_mb_ret:
107871 mutex_unlock(&sync_rcu_preempt_exp_mutex);
107872@@ -1286,7 +1286,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
107873 free_cpumask_var(cm);
107874 }
107875
107876-static struct smp_hotplug_thread rcu_cpu_thread_spec = {
107877+static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
107878 .store = &rcu_cpu_kthread_task,
107879 .thread_should_run = rcu_cpu_kthread_should_run,
107880 .thread_fn = rcu_cpu_kthread,
107881@@ -1757,7 +1757,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
107882 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
107883 pr_err("\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u fqs=%ld %s\n",
107884 cpu, ticks_value, ticks_title,
107885- atomic_read(&rdtp->dynticks) & 0xfff,
107886+ atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
107887 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
107888 rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu),
107889 ACCESS_ONCE(rsp->n_force_qs) - rsp->n_force_qs_gpstart,
107890@@ -1902,7 +1902,7 @@ static void wake_nocb_leader(struct rcu_data *rdp, bool force)
107891 return;
107892 if (ACCESS_ONCE(rdp_leader->nocb_leader_sleep) || force) {
107893 /* Prior smp_mb__after_atomic() orders against prior enqueue. */
107894- ACCESS_ONCE(rdp_leader->nocb_leader_sleep) = false;
107895+ ACCESS_ONCE_RW(rdp_leader->nocb_leader_sleep) = false;
107896 wake_up(&rdp_leader->nocb_wq);
107897 }
107898 }
107899@@ -1975,7 +1975,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
107900 atomic_long_add(rhcount, &rdp->nocb_q_count);
107901 /* rcu_barrier() relies on ->nocb_q_count add before xchg. */
107902 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
107903- ACCESS_ONCE(*old_rhpp) = rhp;
107904+ ACCESS_ONCE_RW(*old_rhpp) = rhp;
107905 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
107906 smp_mb__after_atomic(); /* Store *old_rhpp before _wake test. */
107907
107908@@ -2164,7 +2164,7 @@ wait_again:
107909 continue; /* No CBs here, try next follower. */
107910
107911 /* Move callbacks to wait-for-GP list, which is empty. */
107912- ACCESS_ONCE(rdp->nocb_head) = NULL;
107913+ ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
107914 rdp->nocb_gp_tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
107915 gotcbs = true;
107916 }
107917@@ -2285,7 +2285,7 @@ static int rcu_nocb_kthread(void *arg)
107918 list = ACCESS_ONCE(rdp->nocb_follower_head);
107919 BUG_ON(!list);
107920 trace_rcu_nocb_wake(rdp->rsp->name, rdp->cpu, "WokeNonEmpty");
107921- ACCESS_ONCE(rdp->nocb_follower_head) = NULL;
107922+ ACCESS_ONCE_RW(rdp->nocb_follower_head) = NULL;
107923 tail = xchg(&rdp->nocb_follower_tail, &rdp->nocb_follower_head);
107924
107925 /* Each pass through the following loop invokes a callback. */
107926@@ -2335,7 +2335,7 @@ static void do_nocb_deferred_wakeup(struct rcu_data *rdp)
107927 if (!rcu_nocb_need_deferred_wakeup(rdp))
107928 return;
107929 ndw = ACCESS_ONCE(rdp->nocb_defer_wakeup);
107930- ACCESS_ONCE(rdp->nocb_defer_wakeup) = RCU_NOGP_WAKE_NOT;
107931+ ACCESS_ONCE_RW(rdp->nocb_defer_wakeup) = RCU_NOGP_WAKE_NOT;
107932 wake_nocb_leader(rdp, ndw == RCU_NOGP_WAKE_FORCE);
107933 trace_rcu_nocb_wake(rdp->rsp->name, rdp->cpu, TPS("DeferredWake"));
107934 }
107935@@ -2448,7 +2448,7 @@ static void rcu_spawn_one_nocb_kthread(struct rcu_state *rsp, int cpu)
107936 t = kthread_run(rcu_nocb_kthread, rdp_spawn,
107937 "rcuo%c/%d", rsp->abbr, cpu);
107938 BUG_ON(IS_ERR(t));
107939- ACCESS_ONCE(rdp_spawn->nocb_kthread) = t;
107940+ ACCESS_ONCE_RW(rdp_spawn->nocb_kthread) = t;
107941 }
107942
107943 /*
107944@@ -2663,11 +2663,11 @@ static void rcu_sysidle_enter(int irq)
107945
107946 /* Record start of fully idle period. */
107947 j = jiffies;
107948- ACCESS_ONCE(rdtp->dynticks_idle_jiffies) = j;
107949+ ACCESS_ONCE_RW(rdtp->dynticks_idle_jiffies) = j;
107950 smp_mb__before_atomic();
107951- atomic_inc(&rdtp->dynticks_idle);
107952+ atomic_inc_unchecked(&rdtp->dynticks_idle);
107953 smp_mb__after_atomic();
107954- WARN_ON_ONCE(atomic_read(&rdtp->dynticks_idle) & 0x1);
107955+ WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks_idle) & 0x1);
107956 }
107957
107958 /*
107959@@ -2738,9 +2738,9 @@ static void rcu_sysidle_exit(int irq)
107960
107961 /* Record end of idle period. */
107962 smp_mb__before_atomic();
107963- atomic_inc(&rdtp->dynticks_idle);
107964+ atomic_inc_unchecked(&rdtp->dynticks_idle);
107965 smp_mb__after_atomic();
107966- WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks_idle) & 0x1));
107967+ WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks_idle) & 0x1));
107968
107969 /*
107970 * If we are the timekeeping CPU, we are permitted to be non-idle
107971@@ -2786,7 +2786,7 @@ static void rcu_sysidle_check_cpu(struct rcu_data *rdp, bool *isidle,
107972 WARN_ON_ONCE(smp_processor_id() != tick_do_timer_cpu);
107973
107974 /* Pick up current idle and NMI-nesting counter and check. */
107975- cur = atomic_read(&rdtp->dynticks_idle);
107976+ cur = atomic_read_unchecked(&rdtp->dynticks_idle);
107977 if (cur & 0x1) {
107978 *isidle = false; /* We are not idle! */
107979 return;
107980@@ -2835,7 +2835,7 @@ static void rcu_sysidle(unsigned long j)
107981 case RCU_SYSIDLE_NOT:
107982
107983 /* First time all are idle, so note a short idle period. */
107984- ACCESS_ONCE(full_sysidle_state) = RCU_SYSIDLE_SHORT;
107985+ ACCESS_ONCE_RW(full_sysidle_state) = RCU_SYSIDLE_SHORT;
107986 break;
107987
107988 case RCU_SYSIDLE_SHORT:
107989@@ -2873,7 +2873,7 @@ static void rcu_sysidle_cancel(void)
107990 {
107991 smp_mb();
107992 if (full_sysidle_state > RCU_SYSIDLE_SHORT)
107993- ACCESS_ONCE(full_sysidle_state) = RCU_SYSIDLE_NOT;
107994+ ACCESS_ONCE_RW(full_sysidle_state) = RCU_SYSIDLE_NOT;
107995 }
107996
107997 /*
107998@@ -2925,7 +2925,7 @@ static void rcu_sysidle_cb(struct rcu_head *rhp)
107999 smp_mb(); /* grace period precedes setting inuse. */
108000
108001 rshp = container_of(rhp, struct rcu_sysidle_head, rh);
108002- ACCESS_ONCE(rshp->inuse) = 0;
108003+ ACCESS_ONCE_RW(rshp->inuse) = 0;
108004 }
108005
108006 /*
108007@@ -3077,7 +3077,7 @@ static void rcu_bind_gp_kthread(void)
108008 static void rcu_dynticks_task_enter(void)
108009 {
108010 #if defined(CONFIG_TASKS_RCU) && defined(CONFIG_NO_HZ_FULL)
108011- ACCESS_ONCE(current->rcu_tasks_idle_cpu) = smp_processor_id();
108012+ ACCESS_ONCE_RW(current->rcu_tasks_idle_cpu) = smp_processor_id();
108013 #endif /* #if defined(CONFIG_TASKS_RCU) && defined(CONFIG_NO_HZ_FULL) */
108014 }
108015
108016@@ -3085,6 +3085,6 @@ static void rcu_dynticks_task_enter(void)
108017 static void rcu_dynticks_task_exit(void)
108018 {
108019 #if defined(CONFIG_TASKS_RCU) && defined(CONFIG_NO_HZ_FULL)
108020- ACCESS_ONCE(current->rcu_tasks_idle_cpu) = -1;
108021+ ACCESS_ONCE_RW(current->rcu_tasks_idle_cpu) = -1;
108022 #endif /* #if defined(CONFIG_TASKS_RCU) && defined(CONFIG_NO_HZ_FULL) */
108023 }
108024diff --git a/kernel/rcu/tree_trace.c b/kernel/rcu/tree_trace.c
108025index f92361e..0052f88 100644
108026--- a/kernel/rcu/tree_trace.c
108027+++ b/kernel/rcu/tree_trace.c
108028@@ -125,7 +125,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
108029 rdp->rcu_qs_ctr_snap == per_cpu(rcu_qs_ctr, rdp->cpu),
108030 rdp->qs_pending);
108031 seq_printf(m, " dt=%d/%llx/%d df=%lu",
108032- atomic_read(&rdp->dynticks->dynticks),
108033+ atomic_read_unchecked(&rdp->dynticks->dynticks),
108034 rdp->dynticks->dynticks_nesting,
108035 rdp->dynticks->dynticks_nmi_nesting,
108036 rdp->dynticks_fqs);
108037@@ -186,17 +186,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
108038 struct rcu_state *rsp = (struct rcu_state *)m->private;
108039
108040 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",
108041- atomic_long_read(&rsp->expedited_start),
108042+ atomic_long_read_unchecked(&rsp->expedited_start),
108043 atomic_long_read(&rsp->expedited_done),
108044- atomic_long_read(&rsp->expedited_wrap),
108045- atomic_long_read(&rsp->expedited_tryfail),
108046- atomic_long_read(&rsp->expedited_workdone1),
108047- atomic_long_read(&rsp->expedited_workdone2),
108048- atomic_long_read(&rsp->expedited_normal),
108049- atomic_long_read(&rsp->expedited_stoppedcpus),
108050- atomic_long_read(&rsp->expedited_done_tries),
108051- atomic_long_read(&rsp->expedited_done_lost),
108052- atomic_long_read(&rsp->expedited_done_exit));
108053+ atomic_long_read_unchecked(&rsp->expedited_wrap),
108054+ atomic_long_read_unchecked(&rsp->expedited_tryfail),
108055+ atomic_long_read_unchecked(&rsp->expedited_workdone1),
108056+ atomic_long_read_unchecked(&rsp->expedited_workdone2),
108057+ atomic_long_read_unchecked(&rsp->expedited_normal),
108058+ atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
108059+ atomic_long_read_unchecked(&rsp->expedited_done_tries),
108060+ atomic_long_read_unchecked(&rsp->expedited_done_lost),
108061+ atomic_long_read_unchecked(&rsp->expedited_done_exit));
108062 return 0;
108063 }
108064
108065diff --git a/kernel/rcu/update.c b/kernel/rcu/update.c
108066index 1f13335..77ebb7f 100644
108067--- a/kernel/rcu/update.c
108068+++ b/kernel/rcu/update.c
108069@@ -396,10 +396,10 @@ int rcu_jiffies_till_stall_check(void)
108070 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
108071 */
108072 if (till_stall_check < 3) {
108073- ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
108074+ ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
108075 till_stall_check = 3;
108076 } else if (till_stall_check > 300) {
108077- ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
108078+ ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
108079 till_stall_check = 300;
108080 }
108081 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
108082@@ -555,7 +555,7 @@ static void check_holdout_task(struct task_struct *t,
108083 !ACCESS_ONCE(t->on_rq) ||
108084 (IS_ENABLED(CONFIG_NO_HZ_FULL) &&
108085 !is_idle_task(t) && t->rcu_tasks_idle_cpu >= 0)) {
108086- ACCESS_ONCE(t->rcu_tasks_holdout) = false;
108087+ ACCESS_ONCE_RW(t->rcu_tasks_holdout) = false;
108088 list_del_init(&t->rcu_tasks_holdout_list);
108089 put_task_struct(t);
108090 return;
108091@@ -643,7 +643,7 @@ static int __noreturn rcu_tasks_kthread(void *arg)
108092 !is_idle_task(t)) {
108093 get_task_struct(t);
108094 t->rcu_tasks_nvcsw = ACCESS_ONCE(t->nvcsw);
108095- ACCESS_ONCE(t->rcu_tasks_holdout) = true;
108096+ ACCESS_ONCE_RW(t->rcu_tasks_holdout) = true;
108097 list_add(&t->rcu_tasks_holdout_list,
108098 &rcu_tasks_holdouts);
108099 }
108100@@ -740,7 +740,7 @@ static void rcu_spawn_tasks_kthread(void)
108101 t = kthread_run(rcu_tasks_kthread, NULL, "rcu_tasks_kthread");
108102 BUG_ON(IS_ERR(t));
108103 smp_mb(); /* Ensure others see full kthread. */
108104- ACCESS_ONCE(rcu_tasks_kthread_ptr) = t;
108105+ ACCESS_ONCE_RW(rcu_tasks_kthread_ptr) = t;
108106 mutex_unlock(&rcu_tasks_kthread_mutex);
108107 }
108108
108109diff --git a/kernel/resource.c b/kernel/resource.c
108110index 90552aa..ad13346 100644
108111--- a/kernel/resource.c
108112+++ b/kernel/resource.c
108113@@ -162,8 +162,18 @@ static const struct file_operations proc_iomem_operations = {
108114
108115 static int __init ioresources_init(void)
108116 {
108117+#ifdef CONFIG_GRKERNSEC_PROC_ADD
108118+#ifdef CONFIG_GRKERNSEC_PROC_USER
108119+ proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
108120+ proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
108121+#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
108122+ proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
108123+ proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
108124+#endif
108125+#else
108126 proc_create("ioports", 0, NULL, &proc_ioports_operations);
108127 proc_create("iomem", 0, NULL, &proc_iomem_operations);
108128+#endif
108129 return 0;
108130 }
108131 __initcall(ioresources_init);
108132@@ -504,13 +514,13 @@ int region_is_ram(resource_size_t start, unsigned long size)
108133 {
108134 struct resource *p;
108135 resource_size_t end = start + size - 1;
108136- int flags = IORESOURCE_MEM | IORESOURCE_BUSY;
108137+ unsigned long flags = IORESOURCE_MEM | IORESOURCE_BUSY;
108138 const char *name = "System RAM";
108139 int ret = -1;
108140
108141 read_lock(&resource_lock);
108142 for (p = iomem_resource.child; p ; p = p->sibling) {
108143- if (end < p->start)
108144+ if (p->end < start)
108145 continue;
108146
108147 if (p->start <= start && end <= p->end) {
108148@@ -521,7 +531,7 @@ int region_is_ram(resource_size_t start, unsigned long size)
108149 ret = 1;
108150 break;
108151 }
108152- if (p->end < start)
108153+ if (end < p->start)
108154 break; /* not found */
108155 }
108156 read_unlock(&resource_lock);
108157diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
108158index eae160d..c9aa22e 100644
108159--- a/kernel/sched/auto_group.c
108160+++ b/kernel/sched/auto_group.c
108161@@ -11,7 +11,7 @@
108162
108163 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
108164 static struct autogroup autogroup_default;
108165-static atomic_t autogroup_seq_nr;
108166+static atomic_unchecked_t autogroup_seq_nr;
108167
108168 void __init autogroup_init(struct task_struct *init_task)
108169 {
108170@@ -79,7 +79,7 @@ static inline struct autogroup *autogroup_create(void)
108171
108172 kref_init(&ag->kref);
108173 init_rwsem(&ag->lock);
108174- ag->id = atomic_inc_return(&autogroup_seq_nr);
108175+ ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
108176 ag->tg = tg;
108177 #ifdef CONFIG_RT_GROUP_SCHED
108178 /*
108179diff --git a/kernel/sched/completion.c b/kernel/sched/completion.c
108180index 8d0f35d..c16360d 100644
108181--- a/kernel/sched/completion.c
108182+++ b/kernel/sched/completion.c
108183@@ -205,7 +205,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
108184 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
108185 * or number of jiffies left till timeout) if completed.
108186 */
108187-long __sched
108188+long __sched __intentional_overflow(-1)
108189 wait_for_completion_interruptible_timeout(struct completion *x,
108190 unsigned long timeout)
108191 {
108192@@ -222,7 +222,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
108193 *
108194 * Return: -ERESTARTSYS if interrupted, 0 if completed.
108195 */
108196-int __sched wait_for_completion_killable(struct completion *x)
108197+int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
108198 {
108199 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
108200 if (t == -ERESTARTSYS)
108201@@ -243,7 +243,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
108202 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
108203 * or number of jiffies left till timeout) if completed.
108204 */
108205-long __sched
108206+long __sched __intentional_overflow(-1)
108207 wait_for_completion_killable_timeout(struct completion *x,
108208 unsigned long timeout)
108209 {
108210diff --git a/kernel/sched/core.c b/kernel/sched/core.c
108211index 1236732..df281d6 100644
108212--- a/kernel/sched/core.c
108213+++ b/kernel/sched/core.c
108214@@ -1867,7 +1867,7 @@ void set_numabalancing_state(bool enabled)
108215 int sysctl_numa_balancing(struct ctl_table *table, int write,
108216 void __user *buffer, size_t *lenp, loff_t *ppos)
108217 {
108218- struct ctl_table t;
108219+ ctl_table_no_const t;
108220 int err;
108221 int state = numabalancing_enabled;
108222
108223@@ -2317,8 +2317,10 @@ context_switch(struct rq *rq, struct task_struct *prev,
108224 next->active_mm = oldmm;
108225 atomic_inc(&oldmm->mm_count);
108226 enter_lazy_tlb(oldmm, next);
108227- } else
108228+ } else {
108229 switch_mm(oldmm, mm, next);
108230+ populate_stack();
108231+ }
108232
108233 if (!prev->mm) {
108234 prev->active_mm = NULL;
108235@@ -3129,6 +3131,8 @@ int can_nice(const struct task_struct *p, const int nice)
108236 /* convert nice value [19,-20] to rlimit style value [1,40] */
108237 int nice_rlim = nice_to_rlimit(nice);
108238
108239+ gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
108240+
108241 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
108242 capable(CAP_SYS_NICE));
108243 }
108244@@ -3155,7 +3159,8 @@ SYSCALL_DEFINE1(nice, int, increment)
108245 nice = task_nice(current) + increment;
108246
108247 nice = clamp_val(nice, MIN_NICE, MAX_NICE);
108248- if (increment < 0 && !can_nice(current, nice))
108249+ if (increment < 0 && (!can_nice(current, nice) ||
108250+ gr_handle_chroot_nice()))
108251 return -EPERM;
108252
108253 retval = security_task_setnice(current, nice);
108254@@ -3467,6 +3472,7 @@ recheck:
108255 if (policy != p->policy && !rlim_rtprio)
108256 return -EPERM;
108257
108258+ gr_learn_resource(p, RLIMIT_RTPRIO, attr->sched_priority, 1);
108259 /* can't increase priority */
108260 if (attr->sched_priority > p->rt_priority &&
108261 attr->sched_priority > rlim_rtprio)
108262@@ -4950,6 +4956,7 @@ void idle_task_exit(void)
108263
108264 if (mm != &init_mm) {
108265 switch_mm(mm, &init_mm, current);
108266+ populate_stack();
108267 finish_arch_post_lock_switch();
108268 }
108269 mmdrop(mm);
108270@@ -5045,7 +5052,7 @@ static void migrate_tasks(unsigned int dead_cpu)
108271
108272 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
108273
108274-static struct ctl_table sd_ctl_dir[] = {
108275+static ctl_table_no_const sd_ctl_dir[] __read_only = {
108276 {
108277 .procname = "sched_domain",
108278 .mode = 0555,
108279@@ -5062,17 +5069,17 @@ static struct ctl_table sd_ctl_root[] = {
108280 {}
108281 };
108282
108283-static struct ctl_table *sd_alloc_ctl_entry(int n)
108284+static ctl_table_no_const *sd_alloc_ctl_entry(int n)
108285 {
108286- struct ctl_table *entry =
108287+ ctl_table_no_const *entry =
108288 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
108289
108290 return entry;
108291 }
108292
108293-static void sd_free_ctl_entry(struct ctl_table **tablep)
108294+static void sd_free_ctl_entry(ctl_table_no_const *tablep)
108295 {
108296- struct ctl_table *entry;
108297+ ctl_table_no_const *entry;
108298
108299 /*
108300 * In the intermediate directories, both the child directory and
108301@@ -5080,22 +5087,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
108302 * will always be set. In the lowest directory the names are
108303 * static strings and all have proc handlers.
108304 */
108305- for (entry = *tablep; entry->mode; entry++) {
108306- if (entry->child)
108307- sd_free_ctl_entry(&entry->child);
108308+ for (entry = tablep; entry->mode; entry++) {
108309+ if (entry->child) {
108310+ sd_free_ctl_entry(entry->child);
108311+ pax_open_kernel();
108312+ entry->child = NULL;
108313+ pax_close_kernel();
108314+ }
108315 if (entry->proc_handler == NULL)
108316 kfree(entry->procname);
108317 }
108318
108319- kfree(*tablep);
108320- *tablep = NULL;
108321+ kfree(tablep);
108322 }
108323
108324 static int min_load_idx = 0;
108325 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
108326
108327 static void
108328-set_table_entry(struct ctl_table *entry,
108329+set_table_entry(ctl_table_no_const *entry,
108330 const char *procname, void *data, int maxlen,
108331 umode_t mode, proc_handler *proc_handler,
108332 bool load_idx)
108333@@ -5115,7 +5125,7 @@ set_table_entry(struct ctl_table *entry,
108334 static struct ctl_table *
108335 sd_alloc_ctl_domain_table(struct sched_domain *sd)
108336 {
108337- struct ctl_table *table = sd_alloc_ctl_entry(14);
108338+ ctl_table_no_const *table = sd_alloc_ctl_entry(14);
108339
108340 if (table == NULL)
108341 return NULL;
108342@@ -5153,9 +5163,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
108343 return table;
108344 }
108345
108346-static struct ctl_table *sd_alloc_ctl_cpu_table(int cpu)
108347+static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
108348 {
108349- struct ctl_table *entry, *table;
108350+ ctl_table_no_const *entry, *table;
108351 struct sched_domain *sd;
108352 int domain_num = 0, i;
108353 char buf[32];
108354@@ -5182,11 +5192,13 @@ static struct ctl_table_header *sd_sysctl_header;
108355 static void register_sched_domain_sysctl(void)
108356 {
108357 int i, cpu_num = num_possible_cpus();
108358- struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
108359+ ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
108360 char buf[32];
108361
108362 WARN_ON(sd_ctl_dir[0].child);
108363+ pax_open_kernel();
108364 sd_ctl_dir[0].child = entry;
108365+ pax_close_kernel();
108366
108367 if (entry == NULL)
108368 return;
108369@@ -5209,8 +5221,12 @@ static void unregister_sched_domain_sysctl(void)
108370 if (sd_sysctl_header)
108371 unregister_sysctl_table(sd_sysctl_header);
108372 sd_sysctl_header = NULL;
108373- if (sd_ctl_dir[0].child)
108374- sd_free_ctl_entry(&sd_ctl_dir[0].child);
108375+ if (sd_ctl_dir[0].child) {
108376+ sd_free_ctl_entry(sd_ctl_dir[0].child);
108377+ pax_open_kernel();
108378+ sd_ctl_dir[0].child = NULL;
108379+ pax_close_kernel();
108380+ }
108381 }
108382 #else
108383 static void register_sched_domain_sysctl(void)
108384diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
108385index c2980e8..4737a6d 100644
108386--- a/kernel/sched/fair.c
108387+++ b/kernel/sched/fair.c
108388@@ -2107,7 +2107,7 @@ void task_numa_fault(int last_cpupid, int mem_node, int pages, int flags)
108389
108390 static void reset_ptenuma_scan(struct task_struct *p)
108391 {
108392- ACCESS_ONCE(p->mm->numa_scan_seq)++;
108393+ ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
108394 p->mm->numa_scan_offset = 0;
108395 }
108396
108397@@ -7753,7 +7753,7 @@ static void nohz_idle_balance(struct rq *this_rq, enum cpu_idle_type idle) { }
108398 * run_rebalance_domains is triggered when needed from the scheduler tick.
108399 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
108400 */
108401-static void run_rebalance_domains(struct softirq_action *h)
108402+static __latent_entropy void run_rebalance_domains(void)
108403 {
108404 struct rq *this_rq = this_rq();
108405 enum cpu_idle_type idle = this_rq->idle_balance ?
108406diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
108407index e0e1299..e1e896b 100644
108408--- a/kernel/sched/sched.h
108409+++ b/kernel/sched/sched.h
108410@@ -1219,7 +1219,7 @@ struct sched_class {
108411 #ifdef CONFIG_FAIR_GROUP_SCHED
108412 void (*task_move_group) (struct task_struct *p, int on_rq);
108413 #endif
108414-};
108415+} __do_const;
108416
108417 static inline void put_prev_task(struct rq *rq, struct task_struct *prev)
108418 {
108419diff --git a/kernel/signal.c b/kernel/signal.c
108420index d51c5dd..065c4c8 100644
108421--- a/kernel/signal.c
108422+++ b/kernel/signal.c
108423@@ -53,12 +53,12 @@ static struct kmem_cache *sigqueue_cachep;
108424
108425 int print_fatal_signals __read_mostly;
108426
108427-static void __user *sig_handler(struct task_struct *t, int sig)
108428+static __sighandler_t sig_handler(struct task_struct *t, int sig)
108429 {
108430 return t->sighand->action[sig - 1].sa.sa_handler;
108431 }
108432
108433-static int sig_handler_ignored(void __user *handler, int sig)
108434+static int sig_handler_ignored(__sighandler_t handler, int sig)
108435 {
108436 /* Is it explicitly or implicitly ignored? */
108437 return handler == SIG_IGN ||
108438@@ -67,7 +67,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
108439
108440 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
108441 {
108442- void __user *handler;
108443+ __sighandler_t handler;
108444
108445 handler = sig_handler(t, sig);
108446
108447@@ -372,6 +372,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
108448 atomic_inc(&user->sigpending);
108449 rcu_read_unlock();
108450
108451+ if (!override_rlimit)
108452+ gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
108453+
108454 if (override_rlimit ||
108455 atomic_read(&user->sigpending) <=
108456 task_rlimit(t, RLIMIT_SIGPENDING)) {
108457@@ -499,7 +502,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
108458
108459 int unhandled_signal(struct task_struct *tsk, int sig)
108460 {
108461- void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
108462+ __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
108463 if (is_global_init(tsk))
108464 return 1;
108465 if (handler != SIG_IGN && handler != SIG_DFL)
108466@@ -793,6 +796,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
108467 }
108468 }
108469
108470+ /* allow glibc communication via tgkill to other threads in our
108471+ thread group */
108472+ if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
108473+ sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
108474+ && gr_handle_signal(t, sig))
108475+ return -EPERM;
108476+
108477 return security_task_kill(t, info, sig, 0);
108478 }
108479
108480@@ -1176,7 +1186,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
108481 return send_signal(sig, info, p, 1);
108482 }
108483
108484-static int
108485+int
108486 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
108487 {
108488 return send_signal(sig, info, t, 0);
108489@@ -1213,6 +1223,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
108490 unsigned long int flags;
108491 int ret, blocked, ignored;
108492 struct k_sigaction *action;
108493+ int is_unhandled = 0;
108494
108495 spin_lock_irqsave(&t->sighand->siglock, flags);
108496 action = &t->sighand->action[sig-1];
108497@@ -1227,9 +1238,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
108498 }
108499 if (action->sa.sa_handler == SIG_DFL)
108500 t->signal->flags &= ~SIGNAL_UNKILLABLE;
108501+ if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
108502+ is_unhandled = 1;
108503 ret = specific_send_sig_info(sig, info, t);
108504 spin_unlock_irqrestore(&t->sighand->siglock, flags);
108505
108506+ /* only deal with unhandled signals, java etc trigger SIGSEGV during
108507+ normal operation */
108508+ if (is_unhandled) {
108509+ gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
108510+ gr_handle_crash(t, sig);
108511+ }
108512+
108513 return ret;
108514 }
108515
108516@@ -1310,8 +1330,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
108517 ret = check_kill_permission(sig, info, p);
108518 rcu_read_unlock();
108519
108520- if (!ret && sig)
108521+ if (!ret && sig) {
108522 ret = do_send_sig_info(sig, info, p, true);
108523+ if (!ret)
108524+ gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
108525+ }
108526
108527 return ret;
108528 }
108529@@ -2915,7 +2938,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
108530 int error = -ESRCH;
108531
108532 rcu_read_lock();
108533- p = find_task_by_vpid(pid);
108534+#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
108535+ /* allow glibc communication via tgkill to other threads in our
108536+ thread group */
108537+ if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
108538+ sig == (SIGRTMIN+1) && tgid == info->si_pid)
108539+ p = find_task_by_vpid_unrestricted(pid);
108540+ else
108541+#endif
108542+ p = find_task_by_vpid(pid);
108543 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
108544 error = check_kill_permission(sig, info, p);
108545 /*
108546@@ -3244,8 +3275,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
108547 }
108548 seg = get_fs();
108549 set_fs(KERNEL_DS);
108550- ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
108551- (stack_t __force __user *) &uoss,
108552+ ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
108553+ (stack_t __force_user *) &uoss,
108554 compat_user_stack_pointer());
108555 set_fs(seg);
108556 if (ret >= 0 && uoss_ptr) {
108557diff --git a/kernel/smpboot.c b/kernel/smpboot.c
108558index c697f73..4ef1c25 100644
108559--- a/kernel/smpboot.c
108560+++ b/kernel/smpboot.c
108561@@ -291,7 +291,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
108562 }
108563 smpboot_unpark_thread(plug_thread, cpu);
108564 }
108565- list_add(&plug_thread->list, &hotplug_threads);
108566+ pax_list_add(&plug_thread->list, &hotplug_threads);
108567 out:
108568 mutex_unlock(&smpboot_threads_lock);
108569 put_online_cpus();
108570@@ -309,7 +309,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
108571 {
108572 get_online_cpus();
108573 mutex_lock(&smpboot_threads_lock);
108574- list_del(&plug_thread->list);
108575+ pax_list_del(&plug_thread->list);
108576 smpboot_destroy_threads(plug_thread);
108577 mutex_unlock(&smpboot_threads_lock);
108578 put_online_cpus();
108579diff --git a/kernel/softirq.c b/kernel/softirq.c
108580index 479e443..66d845e1 100644
108581--- a/kernel/softirq.c
108582+++ b/kernel/softirq.c
108583@@ -53,7 +53,7 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
108584 EXPORT_SYMBOL(irq_stat);
108585 #endif
108586
108587-static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
108588+static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
108589
108590 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
108591
108592@@ -270,7 +270,7 @@ restart:
108593 kstat_incr_softirqs_this_cpu(vec_nr);
108594
108595 trace_softirq_entry(vec_nr);
108596- h->action(h);
108597+ h->action();
108598 trace_softirq_exit(vec_nr);
108599 if (unlikely(prev_count != preempt_count())) {
108600 pr_err("huh, entered softirq %u %s %p with preempt_count %08x, exited with %08x?\n",
108601@@ -430,7 +430,7 @@ void __raise_softirq_irqoff(unsigned int nr)
108602 or_softirq_pending(1UL << nr);
108603 }
108604
108605-void open_softirq(int nr, void (*action)(struct softirq_action *))
108606+void __init open_softirq(int nr, void (*action)(void))
108607 {
108608 softirq_vec[nr].action = action;
108609 }
108610@@ -482,7 +482,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
108611 }
108612 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
108613
108614-static void tasklet_action(struct softirq_action *a)
108615+static void tasklet_action(void)
108616 {
108617 struct tasklet_struct *list;
108618
108619@@ -518,7 +518,7 @@ static void tasklet_action(struct softirq_action *a)
108620 }
108621 }
108622
108623-static void tasklet_hi_action(struct softirq_action *a)
108624+static __latent_entropy void tasklet_hi_action(void)
108625 {
108626 struct tasklet_struct *list;
108627
108628@@ -744,7 +744,7 @@ static struct notifier_block cpu_nfb = {
108629 .notifier_call = cpu_callback
108630 };
108631
108632-static struct smp_hotplug_thread softirq_threads = {
108633+static struct smp_hotplug_thread softirq_threads __read_only = {
108634 .store = &ksoftirqd,
108635 .thread_should_run = ksoftirqd_should_run,
108636 .thread_fn = run_ksoftirqd,
108637diff --git a/kernel/sys.c b/kernel/sys.c
108638index a4e372b..766810e 100644
108639--- a/kernel/sys.c
108640+++ b/kernel/sys.c
108641@@ -160,6 +160,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
108642 error = -EACCES;
108643 goto out;
108644 }
108645+
108646+ if (gr_handle_chroot_setpriority(p, niceval)) {
108647+ error = -EACCES;
108648+ goto out;
108649+ }
108650+
108651 no_nice = security_task_setnice(p, niceval);
108652 if (no_nice) {
108653 error = no_nice;
108654@@ -366,6 +372,20 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
108655 goto error;
108656 }
108657
108658+ if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
108659+ goto error;
108660+
108661+ if (!gid_eq(new->gid, old->gid)) {
108662+ /* make sure we generate a learn log for what will
108663+ end up being a role transition after a full-learning
108664+ policy is generated
108665+ CAP_SETGID is required to perform a transition
108666+ we may not log a CAP_SETGID check above, e.g.
108667+ in the case where new rgid = old egid
108668+ */
108669+ gr_learn_cap(current, new, CAP_SETGID);
108670+ }
108671+
108672 if (rgid != (gid_t) -1 ||
108673 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
108674 new->sgid = new->egid;
108675@@ -401,6 +421,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
108676 old = current_cred();
108677
108678 retval = -EPERM;
108679+
108680+ if (gr_check_group_change(kgid, kgid, kgid))
108681+ goto error;
108682+
108683 if (ns_capable(old->user_ns, CAP_SETGID))
108684 new->gid = new->egid = new->sgid = new->fsgid = kgid;
108685 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
108686@@ -418,7 +442,7 @@ error:
108687 /*
108688 * change the user struct in a credentials set to match the new UID
108689 */
108690-static int set_user(struct cred *new)
108691+int set_user(struct cred *new)
108692 {
108693 struct user_struct *new_user;
108694
108695@@ -498,7 +522,18 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
108696 goto error;
108697 }
108698
108699+ if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
108700+ goto error;
108701+
108702 if (!uid_eq(new->uid, old->uid)) {
108703+ /* make sure we generate a learn log for what will
108704+ end up being a role transition after a full-learning
108705+ policy is generated
108706+ CAP_SETUID is required to perform a transition
108707+ we may not log a CAP_SETUID check above, e.g.
108708+ in the case where new ruid = old euid
108709+ */
108710+ gr_learn_cap(current, new, CAP_SETUID);
108711 retval = set_user(new);
108712 if (retval < 0)
108713 goto error;
108714@@ -548,6 +583,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
108715 old = current_cred();
108716
108717 retval = -EPERM;
108718+
108719+ if (gr_check_crash_uid(kuid))
108720+ goto error;
108721+ if (gr_check_user_change(kuid, kuid, kuid))
108722+ goto error;
108723+
108724 if (ns_capable(old->user_ns, CAP_SETUID)) {
108725 new->suid = new->uid = kuid;
108726 if (!uid_eq(kuid, old->uid)) {
108727@@ -617,6 +658,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
108728 goto error;
108729 }
108730
108731+ if (gr_check_user_change(kruid, keuid, INVALID_UID))
108732+ goto error;
108733+
108734 if (ruid != (uid_t) -1) {
108735 new->uid = kruid;
108736 if (!uid_eq(kruid, old->uid)) {
108737@@ -701,6 +745,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
108738 goto error;
108739 }
108740
108741+ if (gr_check_group_change(krgid, kegid, INVALID_GID))
108742+ goto error;
108743+
108744 if (rgid != (gid_t) -1)
108745 new->gid = krgid;
108746 if (egid != (gid_t) -1)
108747@@ -765,12 +812,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
108748 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
108749 ns_capable(old->user_ns, CAP_SETUID)) {
108750 if (!uid_eq(kuid, old->fsuid)) {
108751+ if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
108752+ goto error;
108753+
108754 new->fsuid = kuid;
108755 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
108756 goto change_okay;
108757 }
108758 }
108759
108760+error:
108761 abort_creds(new);
108762 return old_fsuid;
108763
108764@@ -803,12 +854,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
108765 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
108766 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
108767 ns_capable(old->user_ns, CAP_SETGID)) {
108768+ if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
108769+ goto error;
108770+
108771 if (!gid_eq(kgid, old->fsgid)) {
108772 new->fsgid = kgid;
108773 goto change_okay;
108774 }
108775 }
108776
108777+error:
108778 abort_creds(new);
108779 return old_fsgid;
108780
108781@@ -1187,19 +1242,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
108782 return -EFAULT;
108783
108784 down_read(&uts_sem);
108785- error = __copy_to_user(&name->sysname, &utsname()->sysname,
108786+ error = __copy_to_user(name->sysname, &utsname()->sysname,
108787 __OLD_UTS_LEN);
108788 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
108789- error |= __copy_to_user(&name->nodename, &utsname()->nodename,
108790+ error |= __copy_to_user(name->nodename, &utsname()->nodename,
108791 __OLD_UTS_LEN);
108792 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
108793- error |= __copy_to_user(&name->release, &utsname()->release,
108794+ error |= __copy_to_user(name->release, &utsname()->release,
108795 __OLD_UTS_LEN);
108796 error |= __put_user(0, name->release + __OLD_UTS_LEN);
108797- error |= __copy_to_user(&name->version, &utsname()->version,
108798+ error |= __copy_to_user(name->version, &utsname()->version,
108799 __OLD_UTS_LEN);
108800 error |= __put_user(0, name->version + __OLD_UTS_LEN);
108801- error |= __copy_to_user(&name->machine, &utsname()->machine,
108802+ error |= __copy_to_user(name->machine, &utsname()->machine,
108803 __OLD_UTS_LEN);
108804 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
108805 up_read(&uts_sem);
108806@@ -1400,6 +1455,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
108807 */
108808 new_rlim->rlim_cur = 1;
108809 }
108810+ /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
108811+ is changed to a lower value. Since tasks can be created by the same
108812+ user in between this limit change and an execve by this task, force
108813+ a recheck only for this task by setting PF_NPROC_EXCEEDED
108814+ */
108815+ if (resource == RLIMIT_NPROC && tsk->real_cred->user != INIT_USER)
108816+ tsk->flags |= PF_NPROC_EXCEEDED;
108817 }
108818 if (!retval) {
108819 if (old_rlim)
108820diff --git a/kernel/sysctl.c b/kernel/sysctl.c
108821index c3eee4c..586e4a0 100644
108822--- a/kernel/sysctl.c
108823+++ b/kernel/sysctl.c
108824@@ -94,7 +94,6 @@
108825 #endif
108826
108827 #if defined(CONFIG_SYSCTL)
108828-
108829 /* External variables not in a header file. */
108830 extern int suid_dumpable;
108831 #ifdef CONFIG_COREDUMP
108832@@ -111,22 +110,24 @@ extern int sysctl_nr_open_min, sysctl_nr_open_max;
108833 #ifndef CONFIG_MMU
108834 extern int sysctl_nr_trim_pages;
108835 #endif
108836+extern int sysctl_modify_ldt;
108837
108838 /* Constants used for minimum and maximum */
108839 #ifdef CONFIG_LOCKUP_DETECTOR
108840-static int sixty = 60;
108841+static int sixty __read_only = 60;
108842 #endif
108843
108844-static int __maybe_unused neg_one = -1;
108845+static int __maybe_unused neg_one __read_only = -1;
108846
108847-static int zero;
108848-static int __maybe_unused one = 1;
108849-static int __maybe_unused two = 2;
108850-static int __maybe_unused four = 4;
108851-static unsigned long one_ul = 1;
108852-static int one_hundred = 100;
108853+static int zero __read_only = 0;
108854+static int __maybe_unused one __read_only = 1;
108855+static int __maybe_unused two __read_only = 2;
108856+static int __maybe_unused three __read_only = 3;
108857+static int __maybe_unused four __read_only = 4;
108858+static unsigned long one_ul __read_only = 1;
108859+static int one_hundred __read_only = 100;
108860 #ifdef CONFIG_PRINTK
108861-static int ten_thousand = 10000;
108862+static int ten_thousand __read_only = 10000;
108863 #endif
108864
108865 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
108866@@ -180,10 +181,8 @@ static int proc_taint(struct ctl_table *table, int write,
108867 void __user *buffer, size_t *lenp, loff_t *ppos);
108868 #endif
108869
108870-#ifdef CONFIG_PRINTK
108871-static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
108872+static int proc_dointvec_minmax_secure_sysadmin(struct ctl_table *table, int write,
108873 void __user *buffer, size_t *lenp, loff_t *ppos);
108874-#endif
108875
108876 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
108877 void __user *buffer, size_t *lenp, loff_t *ppos);
108878@@ -214,6 +213,8 @@ static int sysrq_sysctl_handler(struct ctl_table *table, int write,
108879
108880 #endif
108881
108882+extern struct ctl_table grsecurity_table[];
108883+
108884 static struct ctl_table kern_table[];
108885 static struct ctl_table vm_table[];
108886 static struct ctl_table fs_table[];
108887@@ -228,6 +229,20 @@ extern struct ctl_table epoll_table[];
108888 int sysctl_legacy_va_layout;
108889 #endif
108890
108891+#ifdef CONFIG_PAX_SOFTMODE
108892+static struct ctl_table pax_table[] = {
108893+ {
108894+ .procname = "softmode",
108895+ .data = &pax_softmode,
108896+ .maxlen = sizeof(unsigned int),
108897+ .mode = 0600,
108898+ .proc_handler = &proc_dointvec,
108899+ },
108900+
108901+ { }
108902+};
108903+#endif
108904+
108905 /* The default sysctl tables: */
108906
108907 static struct ctl_table sysctl_base_table[] = {
108908@@ -276,6 +291,22 @@ static int max_extfrag_threshold = 1000;
108909 #endif
108910
108911 static struct ctl_table kern_table[] = {
108912+#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
108913+ {
108914+ .procname = "grsecurity",
108915+ .mode = 0500,
108916+ .child = grsecurity_table,
108917+ },
108918+#endif
108919+
108920+#ifdef CONFIG_PAX_SOFTMODE
108921+ {
108922+ .procname = "pax",
108923+ .mode = 0500,
108924+ .child = pax_table,
108925+ },
108926+#endif
108927+
108928 {
108929 .procname = "sched_child_runs_first",
108930 .data = &sysctl_sched_child_runs_first,
108931@@ -637,7 +668,7 @@ static struct ctl_table kern_table[] = {
108932 .maxlen = sizeof(int),
108933 .mode = 0644,
108934 /* only handle a transition from default "0" to "1" */
108935- .proc_handler = proc_dointvec_minmax,
108936+ .proc_handler = proc_dointvec_minmax_secure,
108937 .extra1 = &one,
108938 .extra2 = &one,
108939 },
108940@@ -648,7 +679,7 @@ static struct ctl_table kern_table[] = {
108941 .data = &modprobe_path,
108942 .maxlen = KMOD_PATH_LEN,
108943 .mode = 0644,
108944- .proc_handler = proc_dostring,
108945+ .proc_handler = proc_dostring_modpriv,
108946 },
108947 {
108948 .procname = "modules_disabled",
108949@@ -656,7 +687,7 @@ static struct ctl_table kern_table[] = {
108950 .maxlen = sizeof(int),
108951 .mode = 0644,
108952 /* only handle a transition from default "0" to "1" */
108953- .proc_handler = proc_dointvec_minmax,
108954+ .proc_handler = proc_dointvec_minmax_secure,
108955 .extra1 = &one,
108956 .extra2 = &one,
108957 },
108958@@ -811,20 +842,24 @@ static struct ctl_table kern_table[] = {
108959 .data = &dmesg_restrict,
108960 .maxlen = sizeof(int),
108961 .mode = 0644,
108962- .proc_handler = proc_dointvec_minmax_sysadmin,
108963+ .proc_handler = proc_dointvec_minmax_secure_sysadmin,
108964 .extra1 = &zero,
108965 .extra2 = &one,
108966 },
108967+#endif
108968 {
108969 .procname = "kptr_restrict",
108970 .data = &kptr_restrict,
108971 .maxlen = sizeof(int),
108972 .mode = 0644,
108973- .proc_handler = proc_dointvec_minmax_sysadmin,
108974+ .proc_handler = proc_dointvec_minmax_secure_sysadmin,
108975+#ifdef CONFIG_GRKERNSEC_HIDESYM
108976+ .extra1 = &two,
108977+#else
108978 .extra1 = &zero,
108979+#endif
108980 .extra2 = &two,
108981 },
108982-#endif
108983 {
108984 .procname = "ngroups_max",
108985 .data = &ngroups_max,
108986@@ -962,6 +997,15 @@ static struct ctl_table kern_table[] = {
108987 .mode = 0644,
108988 .proc_handler = proc_dointvec,
108989 },
108990+ {
108991+ .procname = "modify_ldt",
108992+ .data = &sysctl_modify_ldt,
108993+ .maxlen = sizeof(int),
108994+ .mode = 0644,
108995+ .proc_handler = proc_dointvec_minmax_secure_sysadmin,
108996+ .extra1 = &zero,
108997+ .extra2 = &one,
108998+ },
108999 #endif
109000 #if defined(CONFIG_MMU)
109001 {
109002@@ -1084,10 +1128,17 @@ static struct ctl_table kern_table[] = {
109003 */
109004 {
109005 .procname = "perf_event_paranoid",
109006- .data = &sysctl_perf_event_paranoid,
109007- .maxlen = sizeof(sysctl_perf_event_paranoid),
109008+ .data = &sysctl_perf_event_legitimately_concerned,
109009+ .maxlen = sizeof(sysctl_perf_event_legitimately_concerned),
109010 .mode = 0644,
109011- .proc_handler = proc_dointvec,
109012+ /* go ahead, be a hero */
109013+ .proc_handler = proc_dointvec_minmax_secure_sysadmin,
109014+ .extra1 = &neg_one,
109015+#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
109016+ .extra2 = &three,
109017+#else
109018+ .extra2 = &two,
109019+#endif
109020 },
109021 {
109022 .procname = "perf_event_mlock_kb",
109023@@ -1369,6 +1420,13 @@ static struct ctl_table vm_table[] = {
109024 .proc_handler = proc_dointvec_minmax,
109025 .extra1 = &zero,
109026 },
109027+ {
109028+ .procname = "heap_stack_gap",
109029+ .data = &sysctl_heap_stack_gap,
109030+ .maxlen = sizeof(sysctl_heap_stack_gap),
109031+ .mode = 0644,
109032+ .proc_handler = proc_doulongvec_minmax,
109033+ },
109034 #else
109035 {
109036 .procname = "nr_trim_pages",
109037@@ -1845,6 +1903,16 @@ int proc_dostring(struct ctl_table *table, int write,
109038 (char __user *)buffer, lenp, ppos);
109039 }
109040
109041+int proc_dostring_modpriv(struct ctl_table *table, int write,
109042+ void __user *buffer, size_t *lenp, loff_t *ppos)
109043+{
109044+ if (write && !capable(CAP_SYS_MODULE))
109045+ return -EPERM;
109046+
109047+ return _proc_do_string(table->data, table->maxlen, write,
109048+ buffer, lenp, ppos);
109049+}
109050+
109051 static size_t proc_skip_spaces(char **buf)
109052 {
109053 size_t ret;
109054@@ -1950,6 +2018,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
109055 len = strlen(tmp);
109056 if (len > *size)
109057 len = *size;
109058+ if (len > sizeof(tmp))
109059+ len = sizeof(tmp);
109060 if (copy_to_user(*buf, tmp, len))
109061 return -EFAULT;
109062 *size -= len;
109063@@ -2128,6 +2198,44 @@ int proc_dointvec(struct ctl_table *table, int write,
109064 NULL,NULL);
109065 }
109066
109067+static int do_proc_dointvec_conv_secure(bool *negp, unsigned long *lvalp,
109068+ int *valp,
109069+ int write, void *data)
109070+{
109071+ if (write) {
109072+ if (*negp) {
109073+ if (*lvalp > (unsigned long) INT_MAX + 1)
109074+ return -EINVAL;
109075+ pax_open_kernel();
109076+ *valp = -*lvalp;
109077+ pax_close_kernel();
109078+ } else {
109079+ if (*lvalp > (unsigned long) INT_MAX)
109080+ return -EINVAL;
109081+ pax_open_kernel();
109082+ *valp = *lvalp;
109083+ pax_close_kernel();
109084+ }
109085+ } else {
109086+ int val = *valp;
109087+ if (val < 0) {
109088+ *negp = true;
109089+ *lvalp = (unsigned long)-val;
109090+ } else {
109091+ *negp = false;
109092+ *lvalp = (unsigned long)val;
109093+ }
109094+ }
109095+ return 0;
109096+}
109097+
109098+int proc_dointvec_secure(struct ctl_table *table, int write,
109099+ void __user *buffer, size_t *lenp, loff_t *ppos)
109100+{
109101+ return do_proc_dointvec(table,write,buffer,lenp,ppos,
109102+ do_proc_dointvec_conv_secure,NULL);
109103+}
109104+
109105 /*
109106 * Taint values can only be increased
109107 * This means we can safely use a temporary.
109108@@ -2135,7 +2243,7 @@ int proc_dointvec(struct ctl_table *table, int write,
109109 static int proc_taint(struct ctl_table *table, int write,
109110 void __user *buffer, size_t *lenp, loff_t *ppos)
109111 {
109112- struct ctl_table t;
109113+ ctl_table_no_const t;
109114 unsigned long tmptaint = get_taint();
109115 int err;
109116
109117@@ -2163,16 +2271,14 @@ static int proc_taint(struct ctl_table *table, int write,
109118 return err;
109119 }
109120
109121-#ifdef CONFIG_PRINTK
109122-static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
109123+static int proc_dointvec_minmax_secure_sysadmin(struct ctl_table *table, int write,
109124 void __user *buffer, size_t *lenp, loff_t *ppos)
109125 {
109126 if (write && !capable(CAP_SYS_ADMIN))
109127 return -EPERM;
109128
109129- return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
109130+ return proc_dointvec_minmax_secure(table, write, buffer, lenp, ppos);
109131 }
109132-#endif
109133
109134 struct do_proc_dointvec_minmax_conv_param {
109135 int *min;
109136@@ -2203,6 +2309,32 @@ static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
109137 return 0;
109138 }
109139
109140+static int do_proc_dointvec_minmax_conv_secure(bool *negp, unsigned long *lvalp,
109141+ int *valp,
109142+ int write, void *data)
109143+{
109144+ struct do_proc_dointvec_minmax_conv_param *param = data;
109145+ if (write) {
109146+ int val = *negp ? -*lvalp : *lvalp;
109147+ if ((param->min && *param->min > val) ||
109148+ (param->max && *param->max < val))
109149+ return -EINVAL;
109150+ pax_open_kernel();
109151+ *valp = val;
109152+ pax_close_kernel();
109153+ } else {
109154+ int val = *valp;
109155+ if (val < 0) {
109156+ *negp = true;
109157+ *lvalp = (unsigned long)-val;
109158+ } else {
109159+ *negp = false;
109160+ *lvalp = (unsigned long)val;
109161+ }
109162+ }
109163+ return 0;
109164+}
109165+
109166 /**
109167 * proc_dointvec_minmax - read a vector of integers with min/max values
109168 * @table: the sysctl table
109169@@ -2230,6 +2362,17 @@ int proc_dointvec_minmax(struct ctl_table *table, int write,
109170 do_proc_dointvec_minmax_conv, &param);
109171 }
109172
109173+int proc_dointvec_minmax_secure(struct ctl_table *table, int write,
109174+ void __user *buffer, size_t *lenp, loff_t *ppos)
109175+{
109176+ struct do_proc_dointvec_minmax_conv_param param = {
109177+ .min = (int *) table->extra1,
109178+ .max = (int *) table->extra2,
109179+ };
109180+ return do_proc_dointvec(table, write, buffer, lenp, ppos,
109181+ do_proc_dointvec_minmax_conv_secure, &param);
109182+}
109183+
109184 static void validate_coredump_safety(void)
109185 {
109186 #ifdef CONFIG_COREDUMP
109187@@ -2732,6 +2875,12 @@ int proc_dostring(struct ctl_table *table, int write,
109188 return -ENOSYS;
109189 }
109190
109191+int proc_dostring_modpriv(struct ctl_table *table, int write,
109192+ void __user *buffer, size_t *lenp, loff_t *ppos)
109193+{
109194+ return -ENOSYS;
109195+}
109196+
109197 int proc_dointvec(struct ctl_table *table, int write,
109198 void __user *buffer, size_t *lenp, loff_t *ppos)
109199 {
109200@@ -2788,5 +2937,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
109201 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
109202 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
109203 EXPORT_SYMBOL(proc_dostring);
109204+EXPORT_SYMBOL(proc_dostring_modpriv);
109205 EXPORT_SYMBOL(proc_doulongvec_minmax);
109206 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
109207diff --git a/kernel/taskstats.c b/kernel/taskstats.c
109208index 21f82c2..c1984e5 100644
109209--- a/kernel/taskstats.c
109210+++ b/kernel/taskstats.c
109211@@ -28,9 +28,12 @@
109212 #include <linux/fs.h>
109213 #include <linux/file.h>
109214 #include <linux/pid_namespace.h>
109215+#include <linux/grsecurity.h>
109216 #include <net/genetlink.h>
109217 #include <linux/atomic.h>
109218
109219+extern int gr_is_taskstats_denied(int pid);
109220+
109221 /*
109222 * Maximum length of a cpumask that can be specified in
109223 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
109224@@ -567,6 +570,9 @@ err:
109225
109226 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
109227 {
109228+ if (gr_is_taskstats_denied(current->pid))
109229+ return -EACCES;
109230+
109231 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
109232 return cmd_attr_register_cpumask(info);
109233 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
109234diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
109235index 1b001ed..55ef9e4 100644
109236--- a/kernel/time/alarmtimer.c
109237+++ b/kernel/time/alarmtimer.c
109238@@ -823,7 +823,7 @@ static int __init alarmtimer_init(void)
109239 struct platform_device *pdev;
109240 int error = 0;
109241 int i;
109242- struct k_clock alarm_clock = {
109243+ static struct k_clock alarm_clock = {
109244 .clock_getres = alarm_clock_getres,
109245 .clock_get = alarm_clock_get,
109246 .timer_create = alarm_timer_create,
109247diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
109248index 93ef7190..7c85701 100644
109249--- a/kernel/time/hrtimer.c
109250+++ b/kernel/time/hrtimer.c
109251@@ -1393,7 +1393,7 @@ void hrtimer_peek_ahead_timers(void)
109252 local_irq_restore(flags);
109253 }
109254
109255-static void run_hrtimer_softirq(struct softirq_action *h)
109256+static __latent_entropy void run_hrtimer_softirq(void)
109257 {
109258 hrtimer_peek_ahead_timers();
109259 }
109260diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
109261index 0075da7..63cc872 100644
109262--- a/kernel/time/posix-cpu-timers.c
109263+++ b/kernel/time/posix-cpu-timers.c
109264@@ -1449,14 +1449,14 @@ struct k_clock clock_posix_cpu = {
109265
109266 static __init int init_posix_cpu_timers(void)
109267 {
109268- struct k_clock process = {
109269+ static struct k_clock process = {
109270 .clock_getres = process_cpu_clock_getres,
109271 .clock_get = process_cpu_clock_get,
109272 .timer_create = process_cpu_timer_create,
109273 .nsleep = process_cpu_nsleep,
109274 .nsleep_restart = process_cpu_nsleep_restart,
109275 };
109276- struct k_clock thread = {
109277+ static struct k_clock thread = {
109278 .clock_getres = thread_cpu_clock_getres,
109279 .clock_get = thread_cpu_clock_get,
109280 .timer_create = thread_cpu_timer_create,
109281diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
109282index 31ea01f..7fc61ef 100644
109283--- a/kernel/time/posix-timers.c
109284+++ b/kernel/time/posix-timers.c
109285@@ -43,6 +43,7 @@
109286 #include <linux/hash.h>
109287 #include <linux/posix-clock.h>
109288 #include <linux/posix-timers.h>
109289+#include <linux/grsecurity.h>
109290 #include <linux/syscalls.h>
109291 #include <linux/wait.h>
109292 #include <linux/workqueue.h>
109293@@ -124,7 +125,7 @@ static DEFINE_SPINLOCK(hash_lock);
109294 * which we beg off on and pass to do_sys_settimeofday().
109295 */
109296
109297-static struct k_clock posix_clocks[MAX_CLOCKS];
109298+static struct k_clock *posix_clocks[MAX_CLOCKS];
109299
109300 /*
109301 * These ones are defined below.
109302@@ -277,7 +278,7 @@ static int posix_get_tai(clockid_t which_clock, struct timespec *tp)
109303 */
109304 static __init int init_posix_timers(void)
109305 {
109306- struct k_clock clock_realtime = {
109307+ static struct k_clock clock_realtime = {
109308 .clock_getres = hrtimer_get_res,
109309 .clock_get = posix_clock_realtime_get,
109310 .clock_set = posix_clock_realtime_set,
109311@@ -289,7 +290,7 @@ static __init int init_posix_timers(void)
109312 .timer_get = common_timer_get,
109313 .timer_del = common_timer_del,
109314 };
109315- struct k_clock clock_monotonic = {
109316+ static struct k_clock clock_monotonic = {
109317 .clock_getres = hrtimer_get_res,
109318 .clock_get = posix_ktime_get_ts,
109319 .nsleep = common_nsleep,
109320@@ -299,19 +300,19 @@ static __init int init_posix_timers(void)
109321 .timer_get = common_timer_get,
109322 .timer_del = common_timer_del,
109323 };
109324- struct k_clock clock_monotonic_raw = {
109325+ static struct k_clock clock_monotonic_raw = {
109326 .clock_getres = hrtimer_get_res,
109327 .clock_get = posix_get_monotonic_raw,
109328 };
109329- struct k_clock clock_realtime_coarse = {
109330+ static struct k_clock clock_realtime_coarse = {
109331 .clock_getres = posix_get_coarse_res,
109332 .clock_get = posix_get_realtime_coarse,
109333 };
109334- struct k_clock clock_monotonic_coarse = {
109335+ static struct k_clock clock_monotonic_coarse = {
109336 .clock_getres = posix_get_coarse_res,
109337 .clock_get = posix_get_monotonic_coarse,
109338 };
109339- struct k_clock clock_tai = {
109340+ static struct k_clock clock_tai = {
109341 .clock_getres = hrtimer_get_res,
109342 .clock_get = posix_get_tai,
109343 .nsleep = common_nsleep,
109344@@ -321,7 +322,7 @@ static __init int init_posix_timers(void)
109345 .timer_get = common_timer_get,
109346 .timer_del = common_timer_del,
109347 };
109348- struct k_clock clock_boottime = {
109349+ static struct k_clock clock_boottime = {
109350 .clock_getres = hrtimer_get_res,
109351 .clock_get = posix_get_boottime,
109352 .nsleep = common_nsleep,
109353@@ -533,7 +534,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
109354 return;
109355 }
109356
109357- posix_clocks[clock_id] = *new_clock;
109358+ posix_clocks[clock_id] = new_clock;
109359 }
109360 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
109361
109362@@ -579,9 +580,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
109363 return (id & CLOCKFD_MASK) == CLOCKFD ?
109364 &clock_posix_dynamic : &clock_posix_cpu;
109365
109366- if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
109367+ if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
109368 return NULL;
109369- return &posix_clocks[id];
109370+ return posix_clocks[id];
109371 }
109372
109373 static int common_timer_create(struct k_itimer *new_timer)
109374@@ -599,7 +600,7 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
109375 struct k_clock *kc = clockid_to_kclock(which_clock);
109376 struct k_itimer *new_timer;
109377 int error, new_timer_id;
109378- sigevent_t event;
109379+ sigevent_t event = { };
109380 int it_id_set = IT_ID_NOT_SET;
109381
109382 if (!kc)
109383@@ -1014,6 +1015,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
109384 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
109385 return -EFAULT;
109386
109387+ /* only the CLOCK_REALTIME clock can be set, all other clocks
109388+ have their clock_set fptr set to a nosettime dummy function
109389+ CLOCK_REALTIME has a NULL clock_set fptr which causes it to
109390+ call common_clock_set, which calls do_sys_settimeofday, which
109391+ we hook
109392+ */
109393+
109394 return kc->clock_set(which_clock, &new_tp);
109395 }
109396
109397diff --git a/kernel/time/time.c b/kernel/time/time.c
109398index 2c85b77..6530536 100644
109399--- a/kernel/time/time.c
109400+++ b/kernel/time/time.c
109401@@ -173,6 +173,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
109402 return error;
109403
109404 if (tz) {
109405+ /* we log in do_settimeofday called below, so don't log twice
109406+ */
109407+ if (!tv)
109408+ gr_log_timechange();
109409+
109410 sys_tz = *tz;
109411 update_vsyscall_tz();
109412 if (firsttime) {
109413diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
109414index 946acb7..1e13c0f 100644
109415--- a/kernel/time/timekeeping.c
109416+++ b/kernel/time/timekeeping.c
109417@@ -15,6 +15,7 @@
109418 #include <linux/init.h>
109419 #include <linux/mm.h>
109420 #include <linux/sched.h>
109421+#include <linux/grsecurity.h>
109422 #include <linux/syscore_ops.h>
109423 #include <linux/clocksource.h>
109424 #include <linux/jiffies.h>
109425@@ -915,6 +916,8 @@ int do_settimeofday64(const struct timespec64 *ts)
109426 if (!timespec64_valid_strict(ts))
109427 return -EINVAL;
109428
109429+ gr_log_timechange();
109430+
109431 raw_spin_lock_irqsave(&timekeeper_lock, flags);
109432 write_seqcount_begin(&tk_core.seq);
109433
109434diff --git a/kernel/time/timer.c b/kernel/time/timer.c
109435index 2ece3aa..055a295 100644
109436--- a/kernel/time/timer.c
109437+++ b/kernel/time/timer.c
109438@@ -1405,7 +1405,7 @@ void update_process_times(int user_tick)
109439 /*
109440 * This function runs timers and the timer-tq in bottom half context.
109441 */
109442-static void run_timer_softirq(struct softirq_action *h)
109443+static __latent_entropy void run_timer_softirq(void)
109444 {
109445 struct tvec_base *base = __this_cpu_read(tvec_bases);
109446
109447@@ -1468,7 +1468,7 @@ static void process_timeout(unsigned long __data)
109448 *
109449 * In all cases the return value is guaranteed to be non-negative.
109450 */
109451-signed long __sched schedule_timeout(signed long timeout)
109452+signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
109453 {
109454 struct timer_list timer;
109455 unsigned long expire;
109456diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
109457index e878c2e..cf1546bb 100644
109458--- a/kernel/time/timer_list.c
109459+++ b/kernel/time/timer_list.c
109460@@ -45,12 +45,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
109461
109462 static void print_name_offset(struct seq_file *m, void *sym)
109463 {
109464+#ifdef CONFIG_GRKERNSEC_HIDESYM
109465+ SEQ_printf(m, "<%p>", NULL);
109466+#else
109467 char symname[KSYM_NAME_LEN];
109468
109469 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
109470 SEQ_printf(m, "<%pK>", sym);
109471 else
109472 SEQ_printf(m, "%s", symname);
109473+#endif
109474 }
109475
109476 static void
109477@@ -119,7 +123,11 @@ next_one:
109478 static void
109479 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
109480 {
109481+#ifdef CONFIG_GRKERNSEC_HIDESYM
109482+ SEQ_printf(m, " .base: %p\n", NULL);
109483+#else
109484 SEQ_printf(m, " .base: %pK\n", base);
109485+#endif
109486 SEQ_printf(m, " .index: %d\n",
109487 base->index);
109488 SEQ_printf(m, " .resolution: %Lu nsecs\n",
109489@@ -388,7 +396,11 @@ static int __init init_timer_list_procfs(void)
109490 {
109491 struct proc_dir_entry *pe;
109492
109493+#ifdef CONFIG_GRKERNSEC_PROC_ADD
109494+ pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
109495+#else
109496 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
109497+#endif
109498 if (!pe)
109499 return -ENOMEM;
109500 return 0;
109501diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
109502index 1fb08f2..ca4bb1e 100644
109503--- a/kernel/time/timer_stats.c
109504+++ b/kernel/time/timer_stats.c
109505@@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
109506 static unsigned long nr_entries;
109507 static struct entry entries[MAX_ENTRIES];
109508
109509-static atomic_t overflow_count;
109510+static atomic_unchecked_t overflow_count;
109511
109512 /*
109513 * The entries are in a hash-table, for fast lookup:
109514@@ -140,7 +140,7 @@ static void reset_entries(void)
109515 nr_entries = 0;
109516 memset(entries, 0, sizeof(entries));
109517 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
109518- atomic_set(&overflow_count, 0);
109519+ atomic_set_unchecked(&overflow_count, 0);
109520 }
109521
109522 static struct entry *alloc_entry(void)
109523@@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
109524 if (likely(entry))
109525 entry->count++;
109526 else
109527- atomic_inc(&overflow_count);
109528+ atomic_inc_unchecked(&overflow_count);
109529
109530 out_unlock:
109531 raw_spin_unlock_irqrestore(lock, flags);
109532@@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
109533
109534 static void print_name_offset(struct seq_file *m, unsigned long addr)
109535 {
109536+#ifdef CONFIG_GRKERNSEC_HIDESYM
109537+ seq_printf(m, "<%p>", NULL);
109538+#else
109539 char symname[KSYM_NAME_LEN];
109540
109541 if (lookup_symbol_name(addr, symname) < 0)
109542- seq_printf(m, "<%p>", (void *)addr);
109543+ seq_printf(m, "<%pK>", (void *)addr);
109544 else
109545 seq_printf(m, "%s", symname);
109546+#endif
109547 }
109548
109549 static int tstats_show(struct seq_file *m, void *v)
109550@@ -300,8 +304,8 @@ static int tstats_show(struct seq_file *m, void *v)
109551
109552 seq_puts(m, "Timer Stats Version: v0.3\n");
109553 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
109554- if (atomic_read(&overflow_count))
109555- seq_printf(m, "Overflow: %d entries\n", atomic_read(&overflow_count));
109556+ if (atomic_read_unchecked(&overflow_count))
109557+ seq_printf(m, "Overflow: %d entries\n", atomic_read_unchecked(&overflow_count));
109558 seq_printf(m, "Collection: %s\n", timer_stats_active ? "active" : "inactive");
109559
109560 for (i = 0; i < nr_entries; i++) {
109561@@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
109562 {
109563 struct proc_dir_entry *pe;
109564
109565+#ifdef CONFIG_GRKERNSEC_PROC_ADD
109566+ pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
109567+#else
109568 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
109569+#endif
109570 if (!pe)
109571 return -ENOMEM;
109572 return 0;
109573diff --git a/kernel/torture.c b/kernel/torture.c
109574index dd70993..0bf694b 100644
109575--- a/kernel/torture.c
109576+++ b/kernel/torture.c
109577@@ -482,7 +482,7 @@ static int torture_shutdown_notify(struct notifier_block *unused1,
109578 mutex_lock(&fullstop_mutex);
109579 if (ACCESS_ONCE(fullstop) == FULLSTOP_DONTSTOP) {
109580 VERBOSE_TOROUT_STRING("Unscheduled system shutdown detected");
109581- ACCESS_ONCE(fullstop) = FULLSTOP_SHUTDOWN;
109582+ ACCESS_ONCE_RW(fullstop) = FULLSTOP_SHUTDOWN;
109583 } else {
109584 pr_warn("Concurrent rmmod and shutdown illegal!\n");
109585 }
109586@@ -549,14 +549,14 @@ static int torture_stutter(void *arg)
109587 if (!torture_must_stop()) {
109588 if (stutter > 1) {
109589 schedule_timeout_interruptible(stutter - 1);
109590- ACCESS_ONCE(stutter_pause_test) = 2;
109591+ ACCESS_ONCE_RW(stutter_pause_test) = 2;
109592 }
109593 schedule_timeout_interruptible(1);
109594- ACCESS_ONCE(stutter_pause_test) = 1;
109595+ ACCESS_ONCE_RW(stutter_pause_test) = 1;
109596 }
109597 if (!torture_must_stop())
109598 schedule_timeout_interruptible(stutter);
109599- ACCESS_ONCE(stutter_pause_test) = 0;
109600+ ACCESS_ONCE_RW(stutter_pause_test) = 0;
109601 torture_shutdown_absorb("torture_stutter");
109602 } while (!torture_must_stop());
109603 torture_kthread_stopping("torture_stutter");
109604@@ -648,7 +648,7 @@ bool torture_cleanup_begin(void)
109605 schedule_timeout_uninterruptible(10);
109606 return true;
109607 }
109608- ACCESS_ONCE(fullstop) = FULLSTOP_RMMOD;
109609+ ACCESS_ONCE_RW(fullstop) = FULLSTOP_RMMOD;
109610 mutex_unlock(&fullstop_mutex);
109611 torture_shutdown_cleanup();
109612 torture_shuffle_cleanup();
109613diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
109614index 483cecf..ac46091 100644
109615--- a/kernel/trace/blktrace.c
109616+++ b/kernel/trace/blktrace.c
109617@@ -328,7 +328,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
109618 struct blk_trace *bt = filp->private_data;
109619 char buf[16];
109620
109621- snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
109622+ snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
109623
109624 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
109625 }
109626@@ -386,7 +386,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
109627 return 1;
109628
109629 bt = buf->chan->private_data;
109630- atomic_inc(&bt->dropped);
109631+ atomic_inc_unchecked(&bt->dropped);
109632 return 0;
109633 }
109634
109635@@ -487,7 +487,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
109636
109637 bt->dir = dir;
109638 bt->dev = dev;
109639- atomic_set(&bt->dropped, 0);
109640+ atomic_set_unchecked(&bt->dropped, 0);
109641 INIT_LIST_HEAD(&bt->running_list);
109642
109643 ret = -EIO;
109644diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
109645index 02bece4..43adc29 100644
109646--- a/kernel/trace/ftrace.c
109647+++ b/kernel/trace/ftrace.c
109648@@ -98,6 +98,13 @@ struct ftrace_pid {
109649 struct pid *pid;
109650 };
109651
109652+static bool ftrace_pids_enabled(void)
109653+{
109654+ return !list_empty(&ftrace_pids);
109655+}
109656+
109657+static void ftrace_update_trampoline(struct ftrace_ops *ops);
109658+
109659 /*
109660 * ftrace_disabled is set when an anomaly is discovered.
109661 * ftrace_disabled is much stronger than ftrace_enabled.
109662@@ -109,7 +116,6 @@ static DEFINE_MUTEX(ftrace_lock);
109663 static struct ftrace_ops *ftrace_control_list __read_mostly = &ftrace_list_end;
109664 static struct ftrace_ops *ftrace_ops_list __read_mostly = &ftrace_list_end;
109665 ftrace_func_t ftrace_trace_function __read_mostly = ftrace_stub;
109666-ftrace_func_t ftrace_pid_function __read_mostly = ftrace_stub;
109667 static struct ftrace_ops global_ops;
109668 static struct ftrace_ops control_ops;
109669
109670@@ -183,14 +189,7 @@ static void ftrace_pid_func(unsigned long ip, unsigned long parent_ip,
109671 if (!test_tsk_trace_trace(current))
109672 return;
109673
109674- ftrace_pid_function(ip, parent_ip, op, regs);
109675-}
109676-
109677-static void set_ftrace_pid_function(ftrace_func_t func)
109678-{
109679- /* do not set ftrace_pid_function to itself! */
109680- if (func != ftrace_pid_func)
109681- ftrace_pid_function = func;
109682+ op->saved_func(ip, parent_ip, op, regs);
109683 }
109684
109685 /**
109686@@ -202,7 +201,6 @@ static void set_ftrace_pid_function(ftrace_func_t func)
109687 void clear_ftrace_function(void)
109688 {
109689 ftrace_trace_function = ftrace_stub;
109690- ftrace_pid_function = ftrace_stub;
109691 }
109692
109693 static void control_ops_disable_all(struct ftrace_ops *ops)
109694@@ -436,6 +434,12 @@ static int __register_ftrace_function(struct ftrace_ops *ops)
109695 } else
109696 add_ftrace_ops(&ftrace_ops_list, ops);
109697
109698+ /* Always save the function, and reset at unregistering */
109699+ ops->saved_func = ops->func;
109700+
109701+ if (ops->flags & FTRACE_OPS_FL_PID && ftrace_pids_enabled())
109702+ ops->func = ftrace_pid_func;
109703+
109704 ftrace_update_trampoline(ops);
109705
109706 if (ftrace_enabled)
109707@@ -463,15 +467,28 @@ static int __unregister_ftrace_function(struct ftrace_ops *ops)
109708 if (ftrace_enabled)
109709 update_ftrace_function();
109710
109711+ ops->func = ops->saved_func;
109712+
109713 return 0;
109714 }
109715
109716 static void ftrace_update_pid_func(void)
109717 {
109718+ bool enabled = ftrace_pids_enabled();
109719+ struct ftrace_ops *op;
109720+
109721 /* Only do something if we are tracing something */
109722 if (ftrace_trace_function == ftrace_stub)
109723 return;
109724
109725+ do_for_each_ftrace_op(op, ftrace_ops_list) {
109726+ if (op->flags & FTRACE_OPS_FL_PID) {
109727+ op->func = enabled ? ftrace_pid_func :
109728+ op->saved_func;
109729+ ftrace_update_trampoline(op);
109730+ }
109731+ } while_for_each_ftrace_op(op);
109732+
109733 update_ftrace_function();
109734 }
109735
109736@@ -1133,7 +1150,8 @@ static struct ftrace_ops global_ops = {
109737 .local_hash.filter_hash = EMPTY_HASH,
109738 INIT_OPS_HASH(global_ops)
109739 .flags = FTRACE_OPS_FL_RECURSION_SAFE |
109740- FTRACE_OPS_FL_INITIALIZED,
109741+ FTRACE_OPS_FL_INITIALIZED |
109742+ FTRACE_OPS_FL_PID,
109743 };
109744
109745 /*
109746@@ -2395,12 +2413,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
109747 if (unlikely(ftrace_disabled))
109748 return 0;
109749
109750+ ret = ftrace_arch_code_modify_prepare();
109751+ FTRACE_WARN_ON(ret);
109752+ if (ret)
109753+ return 0;
109754+
109755 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
109756+ FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
109757 if (ret) {
109758 ftrace_bug(ret, rec);
109759- return 0;
109760 }
109761- return 1;
109762+ return ret ? 0 : 1;
109763 }
109764
109765 /*
109766@@ -4789,8 +4812,10 @@ static int ftrace_process_locs(struct module *mod,
109767 if (!count)
109768 return 0;
109769
109770+ pax_open_kernel();
109771 sort(start, count, sizeof(*start),
109772 ftrace_cmp_ips, ftrace_swap_ips);
109773+ pax_close_kernel();
109774
109775 start_pg = ftrace_allocate_pages(count);
109776 if (!start_pg)
109777@@ -5023,7 +5048,9 @@ static void ftrace_update_trampoline(struct ftrace_ops *ops)
109778
109779 static struct ftrace_ops global_ops = {
109780 .func = ftrace_stub,
109781- .flags = FTRACE_OPS_FL_RECURSION_SAFE | FTRACE_OPS_FL_INITIALIZED,
109782+ .flags = FTRACE_OPS_FL_RECURSION_SAFE |
109783+ FTRACE_OPS_FL_INITIALIZED |
109784+ FTRACE_OPS_FL_PID,
109785 };
109786
109787 static int __init ftrace_nodyn_init(void)
109788@@ -5080,11 +5107,6 @@ void ftrace_init_array_ops(struct trace_array *tr, ftrace_func_t func)
109789 if (WARN_ON(tr->ops->func != ftrace_stub))
109790 printk("ftrace ops had %pS for function\n",
109791 tr->ops->func);
109792- /* Only the top level instance does pid tracing */
109793- if (!list_empty(&ftrace_pids)) {
109794- set_ftrace_pid_function(func);
109795- func = ftrace_pid_func;
109796- }
109797 }
109798 tr->ops->func = func;
109799 tr->ops->private = tr;
109800@@ -5371,7 +5393,7 @@ static void *fpid_start(struct seq_file *m, loff_t *pos)
109801 {
109802 mutex_lock(&ftrace_lock);
109803
109804- if (list_empty(&ftrace_pids) && (!*pos))
109805+ if (!ftrace_pids_enabled() && (!*pos))
109806 return (void *) 1;
109807
109808 return seq_list_start(&ftrace_pids, *pos);
109809@@ -5610,6 +5632,7 @@ static struct ftrace_ops graph_ops = {
109810 .func = ftrace_stub,
109811 .flags = FTRACE_OPS_FL_RECURSION_SAFE |
109812 FTRACE_OPS_FL_INITIALIZED |
109813+ FTRACE_OPS_FL_PID |
109814 FTRACE_OPS_FL_STUB,
109815 #ifdef FTRACE_GRAPH_TRAMP_ADDR
109816 .trampoline = FTRACE_GRAPH_TRAMP_ADDR,
109817@@ -5659,7 +5682,7 @@ static int alloc_retstack_tasklist(struct ftrace_ret_stack **ret_stack_list)
109818
109819 if (t->ret_stack == NULL) {
109820 atomic_set(&t->tracing_graph_pause, 0);
109821- atomic_set(&t->trace_overrun, 0);
109822+ atomic_set_unchecked(&t->trace_overrun, 0);
109823 t->curr_ret_stack = -1;
109824 /* Make sure the tasks see the -1 first: */
109825 smp_wmb();
109826@@ -5882,7 +5905,7 @@ static void
109827 graph_init_task(struct task_struct *t, struct ftrace_ret_stack *ret_stack)
109828 {
109829 atomic_set(&t->tracing_graph_pause, 0);
109830- atomic_set(&t->trace_overrun, 0);
109831+ atomic_set_unchecked(&t->trace_overrun, 0);
109832 t->ftrace_timestamp = 0;
109833 /* make curr_ret_stack visible before we add the ret_stack */
109834 smp_wmb();
109835diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
109836index 0315d43..2e5e9a2 100644
109837--- a/kernel/trace/ring_buffer.c
109838+++ b/kernel/trace/ring_buffer.c
109839@@ -348,9 +348,9 @@ struct buffer_data_page {
109840 */
109841 struct buffer_page {
109842 struct list_head list; /* list of buffer pages */
109843- local_t write; /* index for next write */
109844+ local_unchecked_t write; /* index for next write */
109845 unsigned read; /* index for next read */
109846- local_t entries; /* entries on this page */
109847+ local_unchecked_t entries; /* entries on this page */
109848 unsigned long real_end; /* real end of data */
109849 struct buffer_data_page *page; /* Actual data page */
109850 };
109851@@ -471,11 +471,11 @@ struct ring_buffer_per_cpu {
109852 unsigned long last_overrun;
109853 local_t entries_bytes;
109854 local_t entries;
109855- local_t overrun;
109856- local_t commit_overrun;
109857- local_t dropped_events;
109858+ local_unchecked_t overrun;
109859+ local_unchecked_t commit_overrun;
109860+ local_unchecked_t dropped_events;
109861 local_t committing;
109862- local_t commits;
109863+ local_unchecked_t commits;
109864 unsigned long read;
109865 unsigned long read_bytes;
109866 u64 write_stamp;
109867@@ -1045,8 +1045,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
109868 *
109869 * We add a counter to the write field to denote this.
109870 */
109871- old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
109872- old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
109873+ old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
109874+ old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
109875
109876 /*
109877 * Just make sure we have seen our old_write and synchronize
109878@@ -1074,8 +1074,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
109879 * cmpxchg to only update if an interrupt did not already
109880 * do it for us. If the cmpxchg fails, we don't care.
109881 */
109882- (void)local_cmpxchg(&next_page->write, old_write, val);
109883- (void)local_cmpxchg(&next_page->entries, old_entries, eval);
109884+ (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
109885+ (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
109886
109887 /*
109888 * No need to worry about races with clearing out the commit.
109889@@ -1443,12 +1443,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
109890
109891 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
109892 {
109893- return local_read(&bpage->entries) & RB_WRITE_MASK;
109894+ return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
109895 }
109896
109897 static inline unsigned long rb_page_write(struct buffer_page *bpage)
109898 {
109899- return local_read(&bpage->write) & RB_WRITE_MASK;
109900+ return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
109901 }
109902
109903 static int
109904@@ -1543,7 +1543,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
109905 * bytes consumed in ring buffer from here.
109906 * Increment overrun to account for the lost events.
109907 */
109908- local_add(page_entries, &cpu_buffer->overrun);
109909+ local_add_unchecked(page_entries, &cpu_buffer->overrun);
109910 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
109911 }
109912
109913@@ -2105,7 +2105,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
109914 * it is our responsibility to update
109915 * the counters.
109916 */
109917- local_add(entries, &cpu_buffer->overrun);
109918+ local_add_unchecked(entries, &cpu_buffer->overrun);
109919 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
109920
109921 /*
109922@@ -2255,7 +2255,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
109923 if (tail == BUF_PAGE_SIZE)
109924 tail_page->real_end = 0;
109925
109926- local_sub(length, &tail_page->write);
109927+ local_sub_unchecked(length, &tail_page->write);
109928 return;
109929 }
109930
109931@@ -2290,7 +2290,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
109932 rb_event_set_padding(event);
109933
109934 /* Set the write back to the previous setting */
109935- local_sub(length, &tail_page->write);
109936+ local_sub_unchecked(length, &tail_page->write);
109937 return;
109938 }
109939
109940@@ -2302,7 +2302,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
109941
109942 /* Set write to end of buffer */
109943 length = (tail + length) - BUF_PAGE_SIZE;
109944- local_sub(length, &tail_page->write);
109945+ local_sub_unchecked(length, &tail_page->write);
109946 }
109947
109948 /*
109949@@ -2328,7 +2328,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
109950 * about it.
109951 */
109952 if (unlikely(next_page == commit_page)) {
109953- local_inc(&cpu_buffer->commit_overrun);
109954+ local_inc_unchecked(&cpu_buffer->commit_overrun);
109955 goto out_reset;
109956 }
109957
109958@@ -2358,7 +2358,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
109959 * this is easy, just stop here.
109960 */
109961 if (!(buffer->flags & RB_FL_OVERWRITE)) {
109962- local_inc(&cpu_buffer->dropped_events);
109963+ local_inc_unchecked(&cpu_buffer->dropped_events);
109964 goto out_reset;
109965 }
109966
109967@@ -2384,7 +2384,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
109968 cpu_buffer->tail_page) &&
109969 (cpu_buffer->commit_page ==
109970 cpu_buffer->reader_page))) {
109971- local_inc(&cpu_buffer->commit_overrun);
109972+ local_inc_unchecked(&cpu_buffer->commit_overrun);
109973 goto out_reset;
109974 }
109975 }
109976@@ -2432,7 +2432,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
109977 length += RB_LEN_TIME_EXTEND;
109978
109979 tail_page = cpu_buffer->tail_page;
109980- write = local_add_return(length, &tail_page->write);
109981+ write = local_add_return_unchecked(length, &tail_page->write);
109982
109983 /* set write to only the index of the write */
109984 write &= RB_WRITE_MASK;
109985@@ -2456,7 +2456,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
109986 kmemcheck_annotate_bitfield(event, bitfield);
109987 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
109988
109989- local_inc(&tail_page->entries);
109990+ local_inc_unchecked(&tail_page->entries);
109991
109992 /*
109993 * If this is the first commit on the page, then update
109994@@ -2489,7 +2489,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
109995
109996 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
109997 unsigned long write_mask =
109998- local_read(&bpage->write) & ~RB_WRITE_MASK;
109999+ local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
110000 unsigned long event_length = rb_event_length(event);
110001 /*
110002 * This is on the tail page. It is possible that
110003@@ -2499,7 +2499,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
110004 */
110005 old_index += write_mask;
110006 new_index += write_mask;
110007- index = local_cmpxchg(&bpage->write, old_index, new_index);
110008+ index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
110009 if (index == old_index) {
110010 /* update counters */
110011 local_sub(event_length, &cpu_buffer->entries_bytes);
110012@@ -2514,7 +2514,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
110013 static void rb_start_commit(struct ring_buffer_per_cpu *cpu_buffer)
110014 {
110015 local_inc(&cpu_buffer->committing);
110016- local_inc(&cpu_buffer->commits);
110017+ local_inc_unchecked(&cpu_buffer->commits);
110018 }
110019
110020 static inline void rb_end_commit(struct ring_buffer_per_cpu *cpu_buffer)
110021@@ -2526,7 +2526,7 @@ static inline void rb_end_commit(struct ring_buffer_per_cpu *cpu_buffer)
110022 return;
110023
110024 again:
110025- commits = local_read(&cpu_buffer->commits);
110026+ commits = local_read_unchecked(&cpu_buffer->commits);
110027 /* synchronize with interrupts */
110028 barrier();
110029 if (local_read(&cpu_buffer->committing) == 1)
110030@@ -2542,7 +2542,7 @@ static inline void rb_end_commit(struct ring_buffer_per_cpu *cpu_buffer)
110031 * updating of the commit page and the clearing of the
110032 * committing counter.
110033 */
110034- if (unlikely(local_read(&cpu_buffer->commits) != commits) &&
110035+ if (unlikely(local_read_unchecked(&cpu_buffer->commits) != commits) &&
110036 !local_read(&cpu_buffer->committing)) {
110037 local_inc(&cpu_buffer->committing);
110038 goto again;
110039@@ -2572,7 +2572,7 @@ rb_reserve_next_event(struct ring_buffer *buffer,
110040 barrier();
110041 if (unlikely(ACCESS_ONCE(cpu_buffer->buffer) != buffer)) {
110042 local_dec(&cpu_buffer->committing);
110043- local_dec(&cpu_buffer->commits);
110044+ local_dec_unchecked(&cpu_buffer->commits);
110045 return NULL;
110046 }
110047 #endif
110048@@ -2898,7 +2898,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
110049
110050 /* Do the likely case first */
110051 if (likely(bpage->page == (void *)addr)) {
110052- local_dec(&bpage->entries);
110053+ local_dec_unchecked(&bpage->entries);
110054 return;
110055 }
110056
110057@@ -2910,7 +2910,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
110058 start = bpage;
110059 do {
110060 if (bpage->page == (void *)addr) {
110061- local_dec(&bpage->entries);
110062+ local_dec_unchecked(&bpage->entries);
110063 return;
110064 }
110065 rb_inc_page(cpu_buffer, &bpage);
110066@@ -3194,7 +3194,7 @@ static inline unsigned long
110067 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
110068 {
110069 return local_read(&cpu_buffer->entries) -
110070- (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
110071+ (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
110072 }
110073
110074 /**
110075@@ -3283,7 +3283,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
110076 return 0;
110077
110078 cpu_buffer = buffer->buffers[cpu];
110079- ret = local_read(&cpu_buffer->overrun);
110080+ ret = local_read_unchecked(&cpu_buffer->overrun);
110081
110082 return ret;
110083 }
110084@@ -3306,7 +3306,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
110085 return 0;
110086
110087 cpu_buffer = buffer->buffers[cpu];
110088- ret = local_read(&cpu_buffer->commit_overrun);
110089+ ret = local_read_unchecked(&cpu_buffer->commit_overrun);
110090
110091 return ret;
110092 }
110093@@ -3328,7 +3328,7 @@ ring_buffer_dropped_events_cpu(struct ring_buffer *buffer, int cpu)
110094 return 0;
110095
110096 cpu_buffer = buffer->buffers[cpu];
110097- ret = local_read(&cpu_buffer->dropped_events);
110098+ ret = local_read_unchecked(&cpu_buffer->dropped_events);
110099
110100 return ret;
110101 }
110102@@ -3391,7 +3391,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
110103 /* if you care about this being correct, lock the buffer */
110104 for_each_buffer_cpu(buffer, cpu) {
110105 cpu_buffer = buffer->buffers[cpu];
110106- overruns += local_read(&cpu_buffer->overrun);
110107+ overruns += local_read_unchecked(&cpu_buffer->overrun);
110108 }
110109
110110 return overruns;
110111@@ -3562,8 +3562,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
110112 /*
110113 * Reset the reader page to size zero.
110114 */
110115- local_set(&cpu_buffer->reader_page->write, 0);
110116- local_set(&cpu_buffer->reader_page->entries, 0);
110117+ local_set_unchecked(&cpu_buffer->reader_page->write, 0);
110118+ local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
110119 local_set(&cpu_buffer->reader_page->page->commit, 0);
110120 cpu_buffer->reader_page->real_end = 0;
110121
110122@@ -3597,7 +3597,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
110123 * want to compare with the last_overrun.
110124 */
110125 smp_mb();
110126- overwrite = local_read(&(cpu_buffer->overrun));
110127+ overwrite = local_read_unchecked(&(cpu_buffer->overrun));
110128
110129 /*
110130 * Here's the tricky part.
110131@@ -4169,8 +4169,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
110132
110133 cpu_buffer->head_page
110134 = list_entry(cpu_buffer->pages, struct buffer_page, list);
110135- local_set(&cpu_buffer->head_page->write, 0);
110136- local_set(&cpu_buffer->head_page->entries, 0);
110137+ local_set_unchecked(&cpu_buffer->head_page->write, 0);
110138+ local_set_unchecked(&cpu_buffer->head_page->entries, 0);
110139 local_set(&cpu_buffer->head_page->page->commit, 0);
110140
110141 cpu_buffer->head_page->read = 0;
110142@@ -4180,18 +4180,18 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
110143
110144 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
110145 INIT_LIST_HEAD(&cpu_buffer->new_pages);
110146- local_set(&cpu_buffer->reader_page->write, 0);
110147- local_set(&cpu_buffer->reader_page->entries, 0);
110148+ local_set_unchecked(&cpu_buffer->reader_page->write, 0);
110149+ local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
110150 local_set(&cpu_buffer->reader_page->page->commit, 0);
110151 cpu_buffer->reader_page->read = 0;
110152
110153 local_set(&cpu_buffer->entries_bytes, 0);
110154- local_set(&cpu_buffer->overrun, 0);
110155- local_set(&cpu_buffer->commit_overrun, 0);
110156- local_set(&cpu_buffer->dropped_events, 0);
110157+ local_set_unchecked(&cpu_buffer->overrun, 0);
110158+ local_set_unchecked(&cpu_buffer->commit_overrun, 0);
110159+ local_set_unchecked(&cpu_buffer->dropped_events, 0);
110160 local_set(&cpu_buffer->entries, 0);
110161 local_set(&cpu_buffer->committing, 0);
110162- local_set(&cpu_buffer->commits, 0);
110163+ local_set_unchecked(&cpu_buffer->commits, 0);
110164 cpu_buffer->read = 0;
110165 cpu_buffer->read_bytes = 0;
110166
110167@@ -4592,8 +4592,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
110168 rb_init_page(bpage);
110169 bpage = reader->page;
110170 reader->page = *data_page;
110171- local_set(&reader->write, 0);
110172- local_set(&reader->entries, 0);
110173+ local_set_unchecked(&reader->write, 0);
110174+ local_set_unchecked(&reader->entries, 0);
110175 reader->read = 0;
110176 *data_page = bpage;
110177
110178diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
110179index 0533049..85e27f0 100644
110180--- a/kernel/trace/trace.c
110181+++ b/kernel/trace/trace.c
110182@@ -3538,7 +3538,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
110183 return 0;
110184 }
110185
110186-int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
110187+int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled)
110188 {
110189 /* do nothing if flag is already set */
110190 if (!!(trace_flags & mask) == !!enabled)
110191diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
110192index d261201..da10429 100644
110193--- a/kernel/trace/trace.h
110194+++ b/kernel/trace/trace.h
110195@@ -1271,7 +1271,7 @@ extern const char *__stop___tracepoint_str[];
110196 void trace_printk_init_buffers(void);
110197 void trace_printk_start_comm(void);
110198 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
110199-int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled);
110200+int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled);
110201
110202 /*
110203 * Normal trace_printk() and friends allocates special buffers
110204diff --git a/kernel/trace/trace_clock.c b/kernel/trace/trace_clock.c
110205index 57b67b1..66082a9 100644
110206--- a/kernel/trace/trace_clock.c
110207+++ b/kernel/trace/trace_clock.c
110208@@ -124,7 +124,7 @@ u64 notrace trace_clock_global(void)
110209 return now;
110210 }
110211
110212-static atomic64_t trace_counter;
110213+static atomic64_unchecked_t trace_counter;
110214
110215 /*
110216 * trace_clock_counter(): simply an atomic counter.
110217@@ -133,5 +133,5 @@ static atomic64_t trace_counter;
110218 */
110219 u64 notrace trace_clock_counter(void)
110220 {
110221- return atomic64_add_return(1, &trace_counter);
110222+ return atomic64_inc_return_unchecked(&trace_counter);
110223 }
110224diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
110225index c4de47f..5f134b8 100644
110226--- a/kernel/trace/trace_events.c
110227+++ b/kernel/trace/trace_events.c
110228@@ -1887,7 +1887,6 @@ __trace_early_add_new_event(struct ftrace_event_call *call,
110229 return 0;
110230 }
110231
110232-struct ftrace_module_file_ops;
110233 static void __add_event_to_tracers(struct ftrace_event_call *call);
110234
110235 /* Add an additional event_call dynamically */
110236diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
110237index 7f2e97c..085a257 100644
110238--- a/kernel/trace/trace_events_filter.c
110239+++ b/kernel/trace/trace_events_filter.c
110240@@ -1056,6 +1056,9 @@ static void parse_init(struct filter_parse_state *ps,
110241
110242 static char infix_next(struct filter_parse_state *ps)
110243 {
110244+ if (!ps->infix.cnt)
110245+ return 0;
110246+
110247 ps->infix.cnt--;
110248
110249 return ps->infix.string[ps->infix.tail++];
110250@@ -1071,6 +1074,9 @@ static char infix_peek(struct filter_parse_state *ps)
110251
110252 static void infix_advance(struct filter_parse_state *ps)
110253 {
110254+ if (!ps->infix.cnt)
110255+ return;
110256+
110257 ps->infix.cnt--;
110258 ps->infix.tail++;
110259 }
110260diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
110261index a51e796..1f32ebd 100644
110262--- a/kernel/trace/trace_functions_graph.c
110263+++ b/kernel/trace/trace_functions_graph.c
110264@@ -132,7 +132,7 @@ ftrace_push_return_trace(unsigned long ret, unsigned long func, int *depth,
110265
110266 /* The return trace stack is full */
110267 if (current->curr_ret_stack == FTRACE_RETFUNC_DEPTH - 1) {
110268- atomic_inc(&current->trace_overrun);
110269+ atomic_inc_unchecked(&current->trace_overrun);
110270 return -EBUSY;
110271 }
110272
110273@@ -229,7 +229,7 @@ ftrace_pop_return_trace(struct ftrace_graph_ret *trace, unsigned long *ret,
110274 *ret = current->ret_stack[index].ret;
110275 trace->func = current->ret_stack[index].func;
110276 trace->calltime = current->ret_stack[index].calltime;
110277- trace->overrun = atomic_read(&current->trace_overrun);
110278+ trace->overrun = atomic_read_unchecked(&current->trace_overrun);
110279 trace->depth = index;
110280 }
110281
110282diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
110283index 7a9ba62..2e0e4a1 100644
110284--- a/kernel/trace/trace_mmiotrace.c
110285+++ b/kernel/trace/trace_mmiotrace.c
110286@@ -24,7 +24,7 @@ struct header_iter {
110287 static struct trace_array *mmio_trace_array;
110288 static bool overrun_detected;
110289 static unsigned long prev_overruns;
110290-static atomic_t dropped_count;
110291+static atomic_unchecked_t dropped_count;
110292
110293 static void mmio_reset_data(struct trace_array *tr)
110294 {
110295@@ -124,7 +124,7 @@ static void mmio_close(struct trace_iterator *iter)
110296
110297 static unsigned long count_overruns(struct trace_iterator *iter)
110298 {
110299- unsigned long cnt = atomic_xchg(&dropped_count, 0);
110300+ unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
110301 unsigned long over = ring_buffer_overruns(iter->trace_buffer->buffer);
110302
110303 if (over > prev_overruns)
110304@@ -307,7 +307,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
110305 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
110306 sizeof(*entry), 0, pc);
110307 if (!event) {
110308- atomic_inc(&dropped_count);
110309+ atomic_inc_unchecked(&dropped_count);
110310 return;
110311 }
110312 entry = ring_buffer_event_data(event);
110313@@ -337,7 +337,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
110314 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
110315 sizeof(*entry), 0, pc);
110316 if (!event) {
110317- atomic_inc(&dropped_count);
110318+ atomic_inc_unchecked(&dropped_count);
110319 return;
110320 }
110321 entry = ring_buffer_event_data(event);
110322diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
110323index 25a086b..a918131 100644
110324--- a/kernel/trace/trace_output.c
110325+++ b/kernel/trace/trace_output.c
110326@@ -752,14 +752,16 @@ int register_ftrace_event(struct trace_event *event)
110327 goto out;
110328 }
110329
110330+ pax_open_kernel();
110331 if (event->funcs->trace == NULL)
110332- event->funcs->trace = trace_nop_print;
110333+ *(void **)&event->funcs->trace = trace_nop_print;
110334 if (event->funcs->raw == NULL)
110335- event->funcs->raw = trace_nop_print;
110336+ *(void **)&event->funcs->raw = trace_nop_print;
110337 if (event->funcs->hex == NULL)
110338- event->funcs->hex = trace_nop_print;
110339+ *(void **)&event->funcs->hex = trace_nop_print;
110340 if (event->funcs->binary == NULL)
110341- event->funcs->binary = trace_nop_print;
110342+ *(void **)&event->funcs->binary = trace_nop_print;
110343+ pax_close_kernel();
110344
110345 key = event->type & (EVENT_HASHSIZE - 1);
110346
110347diff --git a/kernel/trace/trace_seq.c b/kernel/trace/trace_seq.c
110348index e694c9f..6775a38 100644
110349--- a/kernel/trace/trace_seq.c
110350+++ b/kernel/trace/trace_seq.c
110351@@ -337,7 +337,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
110352 return 0;
110353 }
110354
110355- seq_buf_path(&s->seq, path, "\n");
110356+ seq_buf_path(&s->seq, path, "\n\\");
110357
110358 if (unlikely(seq_buf_has_overflowed(&s->seq))) {
110359 s->seq.len = save_len;
110360diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
110361index 3f34496..0492d95 100644
110362--- a/kernel/trace/trace_stack.c
110363+++ b/kernel/trace/trace_stack.c
110364@@ -88,7 +88,7 @@ check_stack(unsigned long ip, unsigned long *stack)
110365 return;
110366
110367 /* we do not handle interrupt stacks yet */
110368- if (!object_is_on_stack(stack))
110369+ if (!object_starts_on_stack(stack))
110370 return;
110371
110372 local_irq_save(flags);
110373diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
110374index f97f6e3..d367b48 100644
110375--- a/kernel/trace/trace_syscalls.c
110376+++ b/kernel/trace/trace_syscalls.c
110377@@ -590,6 +590,8 @@ static int perf_sysenter_enable(struct ftrace_event_call *call)
110378 int num;
110379
110380 num = ((struct syscall_metadata *)call->data)->syscall_nr;
110381+ if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))
110382+ return -EINVAL;
110383
110384 mutex_lock(&syscall_trace_lock);
110385 if (!sys_perf_refcount_enter)
110386@@ -610,6 +612,8 @@ static void perf_sysenter_disable(struct ftrace_event_call *call)
110387 int num;
110388
110389 num = ((struct syscall_metadata *)call->data)->syscall_nr;
110390+ if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))
110391+ return;
110392
110393 mutex_lock(&syscall_trace_lock);
110394 sys_perf_refcount_enter--;
110395@@ -662,6 +666,8 @@ static int perf_sysexit_enable(struct ftrace_event_call *call)
110396 int num;
110397
110398 num = ((struct syscall_metadata *)call->data)->syscall_nr;
110399+ if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))
110400+ return -EINVAL;
110401
110402 mutex_lock(&syscall_trace_lock);
110403 if (!sys_perf_refcount_exit)
110404@@ -682,6 +688,8 @@ static void perf_sysexit_disable(struct ftrace_event_call *call)
110405 int num;
110406
110407 num = ((struct syscall_metadata *)call->data)->syscall_nr;
110408+ if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))
110409+ return;
110410
110411 mutex_lock(&syscall_trace_lock);
110412 sys_perf_refcount_exit--;
110413diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
110414index 4109f83..fe1f830 100644
110415--- a/kernel/user_namespace.c
110416+++ b/kernel/user_namespace.c
110417@@ -83,6 +83,21 @@ int create_user_ns(struct cred *new)
110418 !kgid_has_mapping(parent_ns, group))
110419 return -EPERM;
110420
110421+#ifdef CONFIG_GRKERNSEC
110422+ /*
110423+ * This doesn't really inspire confidence:
110424+ * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
110425+ * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
110426+ * Increases kernel attack surface in areas developers
110427+ * previously cared little about ("low importance due
110428+ * to requiring "root" capability")
110429+ * To be removed when this code receives *proper* review
110430+ */
110431+ if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
110432+ !capable(CAP_SETGID))
110433+ return -EPERM;
110434+#endif
110435+
110436 ns = kmem_cache_zalloc(user_ns_cachep, GFP_KERNEL);
110437 if (!ns)
110438 return -ENOMEM;
110439@@ -980,7 +995,7 @@ static int userns_install(struct nsproxy *nsproxy, struct ns_common *ns)
110440 if (atomic_read(&current->mm->mm_users) > 1)
110441 return -EINVAL;
110442
110443- if (current->fs->users != 1)
110444+ if (atomic_read(&current->fs->users) != 1)
110445 return -EINVAL;
110446
110447 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
110448diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
110449index c8eac43..4b5f08f 100644
110450--- a/kernel/utsname_sysctl.c
110451+++ b/kernel/utsname_sysctl.c
110452@@ -47,7 +47,7 @@ static void put_uts(struct ctl_table *table, int write, void *which)
110453 static int proc_do_uts_string(struct ctl_table *table, int write,
110454 void __user *buffer, size_t *lenp, loff_t *ppos)
110455 {
110456- struct ctl_table uts_table;
110457+ ctl_table_no_const uts_table;
110458 int r;
110459 memcpy(&uts_table, table, sizeof(uts_table));
110460 uts_table.data = get_uts(table, write);
110461diff --git a/kernel/watchdog.c b/kernel/watchdog.c
110462index 581a68a..7ff6a89 100644
110463--- a/kernel/watchdog.c
110464+++ b/kernel/watchdog.c
110465@@ -648,7 +648,7 @@ void watchdog_nmi_enable_all(void) {}
110466 void watchdog_nmi_disable_all(void) {}
110467 #endif /* CONFIG_HARDLOCKUP_DETECTOR */
110468
110469-static struct smp_hotplug_thread watchdog_threads = {
110470+static struct smp_hotplug_thread watchdog_threads __read_only = {
110471 .store = &softlockup_watchdog,
110472 .thread_should_run = watchdog_should_run,
110473 .thread_fn = watchdog,
110474diff --git a/kernel/workqueue.c b/kernel/workqueue.c
110475index 586ad91..5f8844a 100644
110476--- a/kernel/workqueue.c
110477+++ b/kernel/workqueue.c
110478@@ -4428,7 +4428,7 @@ static void rebind_workers(struct worker_pool *pool)
110479 WARN_ON_ONCE(!(worker_flags & WORKER_UNBOUND));
110480 worker_flags |= WORKER_REBOUND;
110481 worker_flags &= ~WORKER_UNBOUND;
110482- ACCESS_ONCE(worker->flags) = worker_flags;
110483+ ACCESS_ONCE_RW(worker->flags) = worker_flags;
110484 }
110485
110486 spin_unlock_irq(&pool->lock);
110487diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
110488index ba2b0c8..a571efc 100644
110489--- a/lib/Kconfig.debug
110490+++ b/lib/Kconfig.debug
110491@@ -936,7 +936,7 @@ config DEBUG_MUTEXES
110492
110493 config DEBUG_WW_MUTEX_SLOWPATH
110494 bool "Wait/wound mutex debugging: Slowpath testing"
110495- depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
110496+ depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
110497 select DEBUG_LOCK_ALLOC
110498 select DEBUG_SPINLOCK
110499 select DEBUG_MUTEXES
110500@@ -953,7 +953,7 @@ config DEBUG_WW_MUTEX_SLOWPATH
110501
110502 config DEBUG_LOCK_ALLOC
110503 bool "Lock debugging: detect incorrect freeing of live locks"
110504- depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
110505+ depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
110506 select DEBUG_SPINLOCK
110507 select DEBUG_MUTEXES
110508 select LOCKDEP
110509@@ -967,7 +967,7 @@ config DEBUG_LOCK_ALLOC
110510
110511 config PROVE_LOCKING
110512 bool "Lock debugging: prove locking correctness"
110513- depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
110514+ depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
110515 select LOCKDEP
110516 select DEBUG_SPINLOCK
110517 select DEBUG_MUTEXES
110518@@ -1018,7 +1018,7 @@ config LOCKDEP
110519
110520 config LOCK_STAT
110521 bool "Lock usage statistics"
110522- depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
110523+ depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
110524 select LOCKDEP
110525 select DEBUG_SPINLOCK
110526 select DEBUG_MUTEXES
110527@@ -1496,6 +1496,7 @@ config LATENCYTOP
110528 depends on DEBUG_KERNEL
110529 depends on STACKTRACE_SUPPORT
110530 depends on PROC_FS
110531+ depends on !GRKERNSEC_HIDESYM
110532 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND && !ARC
110533 select KALLSYMS
110534 select KALLSYMS_ALL
110535@@ -1512,7 +1513,7 @@ config ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
110536 config DEBUG_STRICT_USER_COPY_CHECKS
110537 bool "Strict user copy size checks"
110538 depends on ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
110539- depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
110540+ depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
110541 help
110542 Enabling this option turns a certain set of sanity checks for user
110543 copy operations into compile time failures.
110544@@ -1643,7 +1644,7 @@ endmenu # runtime tests
110545
110546 config PROVIDE_OHCI1394_DMA_INIT
110547 bool "Remote debugging over FireWire early on boot"
110548- depends on PCI && X86
110549+ depends on PCI && X86 && !GRKERNSEC
110550 help
110551 If you want to debug problems which hang or crash the kernel early
110552 on boot and the crashing machine has a FireWire port, you can use
110553diff --git a/lib/Makefile b/lib/Makefile
110554index 6c37933..d48e7ca 100644
110555--- a/lib/Makefile
110556+++ b/lib/Makefile
110557@@ -59,7 +59,7 @@ obj-$(CONFIG_BTREE) += btree.o
110558 obj-$(CONFIG_INTERVAL_TREE) += interval_tree.o
110559 obj-$(CONFIG_ASSOCIATIVE_ARRAY) += assoc_array.o
110560 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
110561-obj-$(CONFIG_DEBUG_LIST) += list_debug.o
110562+obj-y += list_debug.o
110563 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
110564
110565 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
110566diff --git a/lib/average.c b/lib/average.c
110567index 114d1be..ab0350c 100644
110568--- a/lib/average.c
110569+++ b/lib/average.c
110570@@ -55,7 +55,7 @@ struct ewma *ewma_add(struct ewma *avg, unsigned long val)
110571 {
110572 unsigned long internal = ACCESS_ONCE(avg->internal);
110573
110574- ACCESS_ONCE(avg->internal) = internal ?
110575+ ACCESS_ONCE_RW(avg->internal) = internal ?
110576 (((internal << avg->weight) - internal) +
110577 (val << avg->factor)) >> avg->weight :
110578 (val << avg->factor);
110579diff --git a/lib/bitmap.c b/lib/bitmap.c
110580index 64c0926f..9de1a1f 100644
110581--- a/lib/bitmap.c
110582+++ b/lib/bitmap.c
110583@@ -234,7 +234,7 @@ int __bitmap_subset(const unsigned long *bitmap1,
110584 }
110585 EXPORT_SYMBOL(__bitmap_subset);
110586
110587-int __bitmap_weight(const unsigned long *bitmap, unsigned int bits)
110588+int __intentional_overflow(-1) __bitmap_weight(const unsigned long *bitmap, unsigned int bits)
110589 {
110590 unsigned int k, lim = bits/BITS_PER_LONG;
110591 int w = 0;
110592@@ -361,7 +361,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
110593 {
110594 int c, old_c, totaldigits, ndigits, nchunks, nbits;
110595 u32 chunk;
110596- const char __user __force *ubuf = (const char __user __force *)buf;
110597+ const char __user *ubuf = (const char __force_user *)buf;
110598
110599 bitmap_zero(maskp, nmaskbits);
110600
110601@@ -446,7 +446,7 @@ int bitmap_parse_user(const char __user *ubuf,
110602 {
110603 if (!access_ok(VERIFY_READ, ubuf, ulen))
110604 return -EFAULT;
110605- return __bitmap_parse((const char __force *)ubuf,
110606+ return __bitmap_parse((const char __force_kernel *)ubuf,
110607 ulen, 1, maskp, nmaskbits);
110608
110609 }
110610@@ -505,7 +505,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
110611 {
110612 unsigned a, b;
110613 int c, old_c, totaldigits;
110614- const char __user __force *ubuf = (const char __user __force *)buf;
110615+ const char __user *ubuf = (const char __force_user *)buf;
110616 int exp_digit, in_range;
110617
110618 totaldigits = c = 0;
110619@@ -600,7 +600,7 @@ int bitmap_parselist_user(const char __user *ubuf,
110620 {
110621 if (!access_ok(VERIFY_READ, ubuf, ulen))
110622 return -EFAULT;
110623- return __bitmap_parselist((const char __force *)ubuf,
110624+ return __bitmap_parselist((const char __force_kernel *)ubuf,
110625 ulen, 1, maskp, nmaskbits);
110626 }
110627 EXPORT_SYMBOL(bitmap_parselist_user);
110628diff --git a/lib/bug.c b/lib/bug.c
110629index 0c3bd95..5a615a1 100644
110630--- a/lib/bug.c
110631+++ b/lib/bug.c
110632@@ -145,6 +145,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
110633 return BUG_TRAP_TYPE_NONE;
110634
110635 bug = find_bug(bugaddr);
110636+ if (!bug)
110637+ return BUG_TRAP_TYPE_NONE;
110638
110639 file = NULL;
110640 line = 0;
110641diff --git a/lib/debugobjects.c b/lib/debugobjects.c
110642index 547f7f9..a6d4ba0 100644
110643--- a/lib/debugobjects.c
110644+++ b/lib/debugobjects.c
110645@@ -289,7 +289,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
110646 if (limit > 4)
110647 return;
110648
110649- is_on_stack = object_is_on_stack(addr);
110650+ is_on_stack = object_starts_on_stack(addr);
110651 if (is_on_stack == onstack)
110652 return;
110653
110654diff --git a/lib/decompress_bunzip2.c b/lib/decompress_bunzip2.c
110655index 6dd0335..1e9c239 100644
110656--- a/lib/decompress_bunzip2.c
110657+++ b/lib/decompress_bunzip2.c
110658@@ -665,7 +665,8 @@ static int INIT start_bunzip(struct bunzip_data **bdp, void *inbuf, long len,
110659
110660 /* Fourth byte (ascii '1'-'9'), indicates block size in units of 100k of
110661 uncompressed data. Allocate intermediate buffer for block. */
110662- bd->dbufSize = 100000*(i-BZh0);
110663+ i -= BZh0;
110664+ bd->dbufSize = 100000 * i;
110665
110666 bd->dbuf = large_malloc(bd->dbufSize * sizeof(int));
110667 if (!bd->dbuf)
110668diff --git a/lib/decompress_unlzma.c b/lib/decompress_unlzma.c
110669index 0be83af..4605e93 100644
110670--- a/lib/decompress_unlzma.c
110671+++ b/lib/decompress_unlzma.c
110672@@ -39,10 +39,10 @@
110673
110674 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
110675
110676-static long long INIT read_int(unsigned char *ptr, int size)
110677+static unsigned long long INIT read_int(unsigned char *ptr, int size)
110678 {
110679 int i;
110680- long long ret = 0;
110681+ unsigned long long ret = 0;
110682
110683 for (i = 0; i < size; i++)
110684 ret = (ret << 8) | ptr[size-i-1];
110685diff --git a/lib/div64.c b/lib/div64.c
110686index 19ea7ed..20cac21 100644
110687--- a/lib/div64.c
110688+++ b/lib/div64.c
110689@@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
110690 EXPORT_SYMBOL(__div64_32);
110691
110692 #ifndef div_s64_rem
110693-s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
110694+s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
110695 {
110696 u64 quotient;
110697
110698@@ -130,7 +130,7 @@ EXPORT_SYMBOL(div64_u64_rem);
110699 * 'http://www.hackersdelight.org/hdcodetxt/divDouble.c.txt'
110700 */
110701 #ifndef div64_u64
110702-u64 div64_u64(u64 dividend, u64 divisor)
110703+u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
110704 {
110705 u32 high = divisor >> 32;
110706 u64 quot;
110707diff --git a/lib/dma-debug.c b/lib/dma-debug.c
110708index ae4b65e..daf0230 100644
110709--- a/lib/dma-debug.c
110710+++ b/lib/dma-debug.c
110711@@ -979,7 +979,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
110712
110713 void dma_debug_add_bus(struct bus_type *bus)
110714 {
110715- struct notifier_block *nb;
110716+ notifier_block_no_const *nb;
110717
110718 if (dma_debug_disabled())
110719 return;
110720@@ -1161,7 +1161,7 @@ static void check_unmap(struct dma_debug_entry *ref)
110721
110722 static void check_for_stack(struct device *dev, void *addr)
110723 {
110724- if (object_is_on_stack(addr))
110725+ if (object_starts_on_stack(addr))
110726 err_printk(dev, NULL, "DMA-API: device driver maps memory from "
110727 "stack [addr=%p]\n", addr);
110728 }
110729diff --git a/lib/inflate.c b/lib/inflate.c
110730index 013a761..c28f3fc 100644
110731--- a/lib/inflate.c
110732+++ b/lib/inflate.c
110733@@ -269,7 +269,7 @@ static void free(void *where)
110734 malloc_ptr = free_mem_ptr;
110735 }
110736 #else
110737-#define malloc(a) kmalloc(a, GFP_KERNEL)
110738+#define malloc(a) kmalloc((a), GFP_KERNEL)
110739 #define free(a) kfree(a)
110740 #endif
110741
110742diff --git a/lib/ioremap.c b/lib/ioremap.c
110743index 86c8911..f5bfc34 100644
110744--- a/lib/ioremap.c
110745+++ b/lib/ioremap.c
110746@@ -75,7 +75,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
110747 unsigned long next;
110748
110749 phys_addr -= addr;
110750- pmd = pmd_alloc(&init_mm, pud, addr);
110751+ pmd = pmd_alloc_kernel(&init_mm, pud, addr);
110752 if (!pmd)
110753 return -ENOMEM;
110754 do {
110755@@ -101,7 +101,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
110756 unsigned long next;
110757
110758 phys_addr -= addr;
110759- pud = pud_alloc(&init_mm, pgd, addr);
110760+ pud = pud_alloc_kernel(&init_mm, pgd, addr);
110761 if (!pud)
110762 return -ENOMEM;
110763 do {
110764diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
110765index bd2bea9..6b3c95e 100644
110766--- a/lib/is_single_threaded.c
110767+++ b/lib/is_single_threaded.c
110768@@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
110769 struct task_struct *p, *t;
110770 bool ret;
110771
110772+ if (!mm)
110773+ return true;
110774+
110775 if (atomic_read(&task->signal->live) != 1)
110776 return false;
110777
110778diff --git a/lib/kobject.c b/lib/kobject.c
110779index 3b841b9..7c215aa 100644
110780--- a/lib/kobject.c
110781+++ b/lib/kobject.c
110782@@ -340,8 +340,9 @@ error:
110783 }
110784 EXPORT_SYMBOL(kobject_init);
110785
110786-static int kobject_add_varg(struct kobject *kobj, struct kobject *parent,
110787- const char *fmt, va_list vargs)
110788+static __printf(3, 0) int kobject_add_varg(struct kobject *kobj,
110789+ struct kobject *parent,
110790+ const char *fmt, va_list vargs)
110791 {
110792 int retval;
110793
110794@@ -936,9 +937,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
110795
110796
110797 static DEFINE_SPINLOCK(kobj_ns_type_lock);
110798-static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
110799+static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
110800
110801-int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
110802+int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
110803 {
110804 enum kobj_ns_type type = ops->type;
110805 int error;
110806diff --git a/lib/list_debug.c b/lib/list_debug.c
110807index c24c2f7..f0296f4 100644
110808--- a/lib/list_debug.c
110809+++ b/lib/list_debug.c
110810@@ -11,7 +11,9 @@
110811 #include <linux/bug.h>
110812 #include <linux/kernel.h>
110813 #include <linux/rculist.h>
110814+#include <linux/mm.h>
110815
110816+#ifdef CONFIG_DEBUG_LIST
110817 /*
110818 * Insert a new entry between two known consecutive entries.
110819 *
110820@@ -19,21 +21,40 @@
110821 * the prev/next entries already!
110822 */
110823
110824+static bool __list_add_debug(struct list_head *new,
110825+ struct list_head *prev,
110826+ struct list_head *next)
110827+{
110828+ if (unlikely(next->prev != prev)) {
110829+ printk(KERN_ERR "list_add corruption. next->prev should be "
110830+ "prev (%p), but was %p. (next=%p).\n",
110831+ prev, next->prev, next);
110832+ BUG();
110833+ return false;
110834+ }
110835+ if (unlikely(prev->next != next)) {
110836+ printk(KERN_ERR "list_add corruption. prev->next should be "
110837+ "next (%p), but was %p. (prev=%p).\n",
110838+ next, prev->next, prev);
110839+ BUG();
110840+ return false;
110841+ }
110842+ if (unlikely(new == prev || new == next)) {
110843+ printk(KERN_ERR "list_add double add: new=%p, prev=%p, next=%p.\n",
110844+ new, prev, next);
110845+ BUG();
110846+ return false;
110847+ }
110848+ return true;
110849+}
110850+
110851 void __list_add(struct list_head *new,
110852- struct list_head *prev,
110853- struct list_head *next)
110854+ struct list_head *prev,
110855+ struct list_head *next)
110856 {
110857- WARN(next->prev != prev,
110858- "list_add corruption. next->prev should be "
110859- "prev (%p), but was %p. (next=%p).\n",
110860- prev, next->prev, next);
110861- WARN(prev->next != next,
110862- "list_add corruption. prev->next should be "
110863- "next (%p), but was %p. (prev=%p).\n",
110864- next, prev->next, prev);
110865- WARN(new == prev || new == next,
110866- "list_add double add: new=%p, prev=%p, next=%p.\n",
110867- new, prev, next);
110868+ if (!__list_add_debug(new, prev, next))
110869+ return;
110870+
110871 next->prev = new;
110872 new->next = next;
110873 new->prev = prev;
110874@@ -41,28 +62,46 @@ void __list_add(struct list_head *new,
110875 }
110876 EXPORT_SYMBOL(__list_add);
110877
110878-void __list_del_entry(struct list_head *entry)
110879+static bool __list_del_entry_debug(struct list_head *entry)
110880 {
110881 struct list_head *prev, *next;
110882
110883 prev = entry->prev;
110884 next = entry->next;
110885
110886- if (WARN(next == LIST_POISON1,
110887- "list_del corruption, %p->next is LIST_POISON1 (%p)\n",
110888- entry, LIST_POISON1) ||
110889- WARN(prev == LIST_POISON2,
110890- "list_del corruption, %p->prev is LIST_POISON2 (%p)\n",
110891- entry, LIST_POISON2) ||
110892- WARN(prev->next != entry,
110893- "list_del corruption. prev->next should be %p, "
110894- "but was %p\n", entry, prev->next) ||
110895- WARN(next->prev != entry,
110896- "list_del corruption. next->prev should be %p, "
110897- "but was %p\n", entry, next->prev))
110898+ if (unlikely(next == LIST_POISON1)) {
110899+ printk(KERN_ERR "list_del corruption, %p->next is LIST_POISON1 (%p)\n",
110900+ entry, LIST_POISON1);
110901+ BUG();
110902+ return false;
110903+ }
110904+ if (unlikely(prev == LIST_POISON2)) {
110905+ printk(KERN_ERR "list_del corruption, %p->prev is LIST_POISON2 (%p)\n",
110906+ entry, LIST_POISON2);
110907+ BUG();
110908+ return false;
110909+ }
110910+ if (unlikely(entry->prev->next != entry)) {
110911+ printk(KERN_ERR "list_del corruption. prev->next should be %p, "
110912+ "but was %p\n", entry, prev->next);
110913+ BUG();
110914+ return false;
110915+ }
110916+ if (unlikely(entry->next->prev != entry)) {
110917+ printk(KERN_ERR "list_del corruption. next->prev should be %p, "
110918+ "but was %p\n", entry, next->prev);
110919+ BUG();
110920+ return false;
110921+ }
110922+ return true;
110923+}
110924+
110925+void __list_del_entry(struct list_head *entry)
110926+{
110927+ if (!__list_del_entry_debug(entry))
110928 return;
110929
110930- __list_del(prev, next);
110931+ __list_del(entry->prev, entry->next);
110932 }
110933 EXPORT_SYMBOL(__list_del_entry);
110934
110935@@ -86,15 +125,85 @@ EXPORT_SYMBOL(list_del);
110936 void __list_add_rcu(struct list_head *new,
110937 struct list_head *prev, struct list_head *next)
110938 {
110939- WARN(next->prev != prev,
110940- "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
110941- prev, next->prev, next);
110942- WARN(prev->next != next,
110943- "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
110944- next, prev->next, prev);
110945+ if (!__list_add_debug(new, prev, next))
110946+ return;
110947+
110948 new->next = next;
110949 new->prev = prev;
110950 rcu_assign_pointer(list_next_rcu(prev), new);
110951 next->prev = new;
110952 }
110953 EXPORT_SYMBOL(__list_add_rcu);
110954+#endif
110955+
110956+void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
110957+{
110958+#ifdef CONFIG_DEBUG_LIST
110959+ if (!__list_add_debug(new, prev, next))
110960+ return;
110961+#endif
110962+
110963+ pax_open_kernel();
110964+ next->prev = new;
110965+ new->next = next;
110966+ new->prev = prev;
110967+ prev->next = new;
110968+ pax_close_kernel();
110969+}
110970+EXPORT_SYMBOL(__pax_list_add);
110971+
110972+void pax_list_del(struct list_head *entry)
110973+{
110974+#ifdef CONFIG_DEBUG_LIST
110975+ if (!__list_del_entry_debug(entry))
110976+ return;
110977+#endif
110978+
110979+ pax_open_kernel();
110980+ __list_del(entry->prev, entry->next);
110981+ entry->next = LIST_POISON1;
110982+ entry->prev = LIST_POISON2;
110983+ pax_close_kernel();
110984+}
110985+EXPORT_SYMBOL(pax_list_del);
110986+
110987+void pax_list_del_init(struct list_head *entry)
110988+{
110989+ pax_open_kernel();
110990+ __list_del(entry->prev, entry->next);
110991+ INIT_LIST_HEAD(entry);
110992+ pax_close_kernel();
110993+}
110994+EXPORT_SYMBOL(pax_list_del_init);
110995+
110996+void __pax_list_add_rcu(struct list_head *new,
110997+ struct list_head *prev, struct list_head *next)
110998+{
110999+#ifdef CONFIG_DEBUG_LIST
111000+ if (!__list_add_debug(new, prev, next))
111001+ return;
111002+#endif
111003+
111004+ pax_open_kernel();
111005+ new->next = next;
111006+ new->prev = prev;
111007+ rcu_assign_pointer(list_next_rcu(prev), new);
111008+ next->prev = new;
111009+ pax_close_kernel();
111010+}
111011+EXPORT_SYMBOL(__pax_list_add_rcu);
111012+
111013+void pax_list_del_rcu(struct list_head *entry)
111014+{
111015+#ifdef CONFIG_DEBUG_LIST
111016+ if (!__list_del_entry_debug(entry))
111017+ return;
111018+#endif
111019+
111020+ pax_open_kernel();
111021+ __list_del(entry->prev, entry->next);
111022+ entry->next = LIST_POISON1;
111023+ entry->prev = LIST_POISON2;
111024+ pax_close_kernel();
111025+}
111026+EXPORT_SYMBOL(pax_list_del_rcu);
111027diff --git a/lib/lockref.c b/lib/lockref.c
111028index 494994b..65caf94 100644
111029--- a/lib/lockref.c
111030+++ b/lib/lockref.c
111031@@ -48,13 +48,13 @@
111032 void lockref_get(struct lockref *lockref)
111033 {
111034 CMPXCHG_LOOP(
111035- new.count++;
111036+ __lockref_inc(&new);
111037 ,
111038 return;
111039 );
111040
111041 spin_lock(&lockref->lock);
111042- lockref->count++;
111043+ __lockref_inc(lockref);
111044 spin_unlock(&lockref->lock);
111045 }
111046 EXPORT_SYMBOL(lockref_get);
111047@@ -69,8 +69,8 @@ int lockref_get_not_zero(struct lockref *lockref)
111048 int retval;
111049
111050 CMPXCHG_LOOP(
111051- new.count++;
111052- if (old.count <= 0)
111053+ __lockref_inc(&new);
111054+ if (__lockref_read(&old) <= 0)
111055 return 0;
111056 ,
111057 return 1;
111058@@ -78,8 +78,8 @@ int lockref_get_not_zero(struct lockref *lockref)
111059
111060 spin_lock(&lockref->lock);
111061 retval = 0;
111062- if (lockref->count > 0) {
111063- lockref->count++;
111064+ if (__lockref_read(lockref) > 0) {
111065+ __lockref_inc(lockref);
111066 retval = 1;
111067 }
111068 spin_unlock(&lockref->lock);
111069@@ -96,17 +96,17 @@ EXPORT_SYMBOL(lockref_get_not_zero);
111070 int lockref_get_or_lock(struct lockref *lockref)
111071 {
111072 CMPXCHG_LOOP(
111073- new.count++;
111074- if (old.count <= 0)
111075+ __lockref_inc(&new);
111076+ if (__lockref_read(&old) <= 0)
111077 break;
111078 ,
111079 return 1;
111080 );
111081
111082 spin_lock(&lockref->lock);
111083- if (lockref->count <= 0)
111084+ if (__lockref_read(lockref) <= 0)
111085 return 0;
111086- lockref->count++;
111087+ __lockref_inc(lockref);
111088 spin_unlock(&lockref->lock);
111089 return 1;
111090 }
111091@@ -122,11 +122,11 @@ EXPORT_SYMBOL(lockref_get_or_lock);
111092 int lockref_put_return(struct lockref *lockref)
111093 {
111094 CMPXCHG_LOOP(
111095- new.count--;
111096- if (old.count <= 0)
111097+ __lockref_dec(&new);
111098+ if (__lockref_read(&old) <= 0)
111099 return -1;
111100 ,
111101- return new.count;
111102+ return __lockref_read(&new);
111103 );
111104 return -1;
111105 }
111106@@ -140,17 +140,17 @@ EXPORT_SYMBOL(lockref_put_return);
111107 int lockref_put_or_lock(struct lockref *lockref)
111108 {
111109 CMPXCHG_LOOP(
111110- new.count--;
111111- if (old.count <= 1)
111112+ __lockref_dec(&new);
111113+ if (__lockref_read(&old) <= 1)
111114 break;
111115 ,
111116 return 1;
111117 );
111118
111119 spin_lock(&lockref->lock);
111120- if (lockref->count <= 1)
111121+ if (__lockref_read(lockref) <= 1)
111122 return 0;
111123- lockref->count--;
111124+ __lockref_dec(lockref);
111125 spin_unlock(&lockref->lock);
111126 return 1;
111127 }
111128@@ -163,7 +163,7 @@ EXPORT_SYMBOL(lockref_put_or_lock);
111129 void lockref_mark_dead(struct lockref *lockref)
111130 {
111131 assert_spin_locked(&lockref->lock);
111132- lockref->count = -128;
111133+ __lockref_set(lockref, -128);
111134 }
111135 EXPORT_SYMBOL(lockref_mark_dead);
111136
111137@@ -177,8 +177,8 @@ int lockref_get_not_dead(struct lockref *lockref)
111138 int retval;
111139
111140 CMPXCHG_LOOP(
111141- new.count++;
111142- if (old.count < 0)
111143+ __lockref_inc(&new);
111144+ if (__lockref_read(&old) < 0)
111145 return 0;
111146 ,
111147 return 1;
111148@@ -186,8 +186,8 @@ int lockref_get_not_dead(struct lockref *lockref)
111149
111150 spin_lock(&lockref->lock);
111151 retval = 0;
111152- if (lockref->count >= 0) {
111153- lockref->count++;
111154+ if (__lockref_read(lockref) >= 0) {
111155+ __lockref_inc(lockref);
111156 retval = 1;
111157 }
111158 spin_unlock(&lockref->lock);
111159diff --git a/lib/nlattr.c b/lib/nlattr.c
111160index f5907d2..36072be 100644
111161--- a/lib/nlattr.c
111162+++ b/lib/nlattr.c
111163@@ -278,6 +278,8 @@ int nla_memcpy(void *dest, const struct nlattr *src, int count)
111164 {
111165 int minlen = min_t(int, count, nla_len(src));
111166
111167+ BUG_ON(minlen < 0);
111168+
111169 memcpy(dest, nla_data(src), minlen);
111170 if (count > minlen)
111171 memset(dest + minlen, 0, count - minlen);
111172diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c
111173index 6111bcb..02e816b 100644
111174--- a/lib/percpu-refcount.c
111175+++ b/lib/percpu-refcount.c
111176@@ -31,7 +31,7 @@
111177 * atomic_long_t can't hit 0 before we've added up all the percpu refs.
111178 */
111179
111180-#define PERCPU_COUNT_BIAS (1LU << (BITS_PER_LONG - 1))
111181+#define PERCPU_COUNT_BIAS (1LU << (BITS_PER_LONG - 2))
111182
111183 static DECLARE_WAIT_QUEUE_HEAD(percpu_ref_switch_waitq);
111184
111185diff --git a/lib/radix-tree.c b/lib/radix-tree.c
111186index 3d2aa27..a472f20 100644
111187--- a/lib/radix-tree.c
111188+++ b/lib/radix-tree.c
111189@@ -67,7 +67,7 @@ struct radix_tree_preload {
111190 int nr;
111191 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
111192 };
111193-static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
111194+static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
111195
111196 static inline void *ptr_to_indirect(void *ptr)
111197 {
111198diff --git a/lib/random32.c b/lib/random32.c
111199index 0bee183..526f12f 100644
111200--- a/lib/random32.c
111201+++ b/lib/random32.c
111202@@ -47,7 +47,7 @@ static inline void prandom_state_selftest(void)
111203 }
111204 #endif
111205
111206-static DEFINE_PER_CPU(struct rnd_state, net_rand_state);
111207+static DEFINE_PER_CPU(struct rnd_state, net_rand_state) __latent_entropy;
111208
111209 /**
111210 * prandom_u32_state - seeded pseudo-random number generator.
111211diff --git a/lib/rbtree.c b/lib/rbtree.c
111212index c16c81a..4dcbda1 100644
111213--- a/lib/rbtree.c
111214+++ b/lib/rbtree.c
111215@@ -380,7 +380,9 @@ static inline void dummy_copy(struct rb_node *old, struct rb_node *new) {}
111216 static inline void dummy_rotate(struct rb_node *old, struct rb_node *new) {}
111217
111218 static const struct rb_augment_callbacks dummy_callbacks = {
111219- dummy_propagate, dummy_copy, dummy_rotate
111220+ .propagate = dummy_propagate,
111221+ .copy = dummy_copy,
111222+ .rotate = dummy_rotate
111223 };
111224
111225 void rb_insert_color(struct rb_node *node, struct rb_root *root)
111226diff --git a/lib/show_mem.c b/lib/show_mem.c
111227index adc98e18..0ce83c2 100644
111228--- a/lib/show_mem.c
111229+++ b/lib/show_mem.c
111230@@ -49,6 +49,6 @@ void show_mem(unsigned int filter)
111231 quicklist_total_size());
111232 #endif
111233 #ifdef CONFIG_MEMORY_FAILURE
111234- printk("%lu pages hwpoisoned\n", atomic_long_read(&num_poisoned_pages));
111235+ printk("%lu pages hwpoisoned\n", atomic_long_read_unchecked(&num_poisoned_pages));
111236 #endif
111237 }
111238diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
111239index e0af6ff..fcc9f15 100644
111240--- a/lib/strncpy_from_user.c
111241+++ b/lib/strncpy_from_user.c
111242@@ -22,7 +22,7 @@
111243 */
111244 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
111245 {
111246- const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
111247+ static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
111248 long res = 0;
111249
111250 /*
111251diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
111252index fe9a325..85cd8aa 100644
111253--- a/lib/strnlen_user.c
111254+++ b/lib/strnlen_user.c
111255@@ -26,7 +26,7 @@
111256 */
111257 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
111258 {
111259- const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
111260+ static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
111261 long align, res = 0;
111262 unsigned long c;
111263
111264diff --git a/lib/swiotlb.c b/lib/swiotlb.c
111265index 3c365ab..75b43df 100644
111266--- a/lib/swiotlb.c
111267+++ b/lib/swiotlb.c
111268@@ -683,7 +683,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
111269
111270 void
111271 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
111272- dma_addr_t dev_addr)
111273+ dma_addr_t dev_addr, struct dma_attrs *attrs)
111274 {
111275 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
111276
111277diff --git a/lib/test-hexdump.c b/lib/test-hexdump.c
111278index c227cc4..5241df3 100644
111279--- a/lib/test-hexdump.c
111280+++ b/lib/test-hexdump.c
111281@@ -25,19 +25,19 @@ static const char * const test_data_1_le[] __initconst = {
111282 "4c", "d1", "19", "99", "43", "b1", "af", "0c",
111283 };
111284
111285-static const char *test_data_2_le[] __initdata = {
111286+static const char * const test_data_2_le[] __initconst = {
111287 "32be", "7bdb", "180a", "b293",
111288 "ba70", "24c4", "837d", "9b34",
111289 "9ca6", "ad31", "0f9c", "e9ac",
111290 "d14c", "9919", "b143", "0caf",
111291 };
111292
111293-static const char *test_data_4_le[] __initdata = {
111294+static const char * const test_data_4_le[] __initconst = {
111295 "7bdb32be", "b293180a", "24c4ba70", "9b34837d",
111296 "ad319ca6", "e9ac0f9c", "9919d14c", "0cafb143",
111297 };
111298
111299-static const char *test_data_8_le[] __initdata = {
111300+static const char * const test_data_8_le[] __initconst = {
111301 "b293180a7bdb32be", "9b34837d24c4ba70",
111302 "e9ac0f9cad319ca6", "0cafb1439919d14c",
111303 };
111304diff --git a/lib/usercopy.c b/lib/usercopy.c
111305index 4f5b1dd..7cab418 100644
111306--- a/lib/usercopy.c
111307+++ b/lib/usercopy.c
111308@@ -7,3 +7,9 @@ void copy_from_user_overflow(void)
111309 WARN(1, "Buffer overflow detected!\n");
111310 }
111311 EXPORT_SYMBOL(copy_from_user_overflow);
111312+
111313+void copy_to_user_overflow(void)
111314+{
111315+ WARN(1, "Buffer overflow detected!\n");
111316+}
111317+EXPORT_SYMBOL(copy_to_user_overflow);
111318diff --git a/lib/vsprintf.c b/lib/vsprintf.c
111319index da39c60..ac91239 100644
111320--- a/lib/vsprintf.c
111321+++ b/lib/vsprintf.c
111322@@ -16,6 +16,9 @@
111323 * - scnprintf and vscnprintf
111324 */
111325
111326+#ifdef CONFIG_GRKERNSEC_HIDESYM
111327+#define __INCLUDED_BY_HIDESYM 1
111328+#endif
111329 #include <stdarg.h>
111330 #include <linux/clk-provider.h>
111331 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
111332@@ -628,7 +631,7 @@ char *symbol_string(char *buf, char *end, void *ptr,
111333 #ifdef CONFIG_KALLSYMS
111334 if (*fmt == 'B')
111335 sprint_backtrace(sym, value);
111336- else if (*fmt != 'f' && *fmt != 's')
111337+ else if (*fmt != 'f' && *fmt != 's' && *fmt != 'X')
111338 sprint_symbol(sym, value);
111339 else
111340 sprint_symbol_no_offset(sym, value);
111341@@ -1360,7 +1363,11 @@ char *clock(char *buf, char *end, struct clk *clk, struct printf_spec spec,
111342 }
111343 }
111344
111345-int kptr_restrict __read_mostly;
111346+#ifdef CONFIG_GRKERNSEC_HIDESYM
111347+int kptr_restrict __read_only = 2;
111348+#else
111349+int kptr_restrict __read_only;
111350+#endif
111351
111352 /*
111353 * Show a '%p' thing. A kernel extension is that the '%p' is followed
111354@@ -1371,8 +1378,10 @@ int kptr_restrict __read_mostly;
111355 *
111356 * - 'F' For symbolic function descriptor pointers with offset
111357 * - 'f' For simple symbolic function names without offset
111358+ * - 'X' For simple symbolic function names without offset approved for use with GRKERNSEC_HIDESYM
111359 * - 'S' For symbolic direct pointers with offset
111360 * - 's' For symbolic direct pointers without offset
111361+ * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
111362 * - '[FfSs]R' as above with __builtin_extract_return_addr() translation
111363 * - 'B' For backtraced symbolic direct pointers with offset
111364 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
111365@@ -1460,12 +1469,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
111366
111367 if (!ptr && *fmt != 'K') {
111368 /*
111369- * Print (null) with the same width as a pointer so it makes
111370+ * Print (nil) with the same width as a pointer so it makes
111371 * tabular output look nice.
111372 */
111373 if (spec.field_width == -1)
111374 spec.field_width = default_width;
111375- return string(buf, end, "(null)", spec);
111376+ return string(buf, end, "(nil)", spec);
111377 }
111378
111379 switch (*fmt) {
111380@@ -1475,6 +1484,14 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
111381 /* Fallthrough */
111382 case 'S':
111383 case 's':
111384+#ifdef CONFIG_GRKERNSEC_HIDESYM
111385+ break;
111386+#else
111387+ return symbol_string(buf, end, ptr, spec, fmt);
111388+#endif
111389+ case 'X':
111390+ ptr = dereference_function_descriptor(ptr);
111391+ case 'A':
111392 case 'B':
111393 return symbol_string(buf, end, ptr, spec, fmt);
111394 case 'R':
111395@@ -1539,6 +1556,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
111396 va_end(va);
111397 return buf;
111398 }
111399+ case 'P':
111400+ break;
111401 case 'K':
111402 /*
111403 * %pK cannot be used in IRQ context because its test
111404@@ -1598,6 +1617,22 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
111405 ((const struct file *)ptr)->f_path.dentry,
111406 spec, fmt);
111407 }
111408+
111409+#ifdef CONFIG_GRKERNSEC_HIDESYM
111410+ /* 'P' = approved pointers to copy to userland,
111411+ as in the /proc/kallsyms case, as we make it display nothing
111412+ for non-root users, and the real contents for root users
111413+ 'X' = approved simple symbols
111414+ Also ignore 'K' pointers, since we force their NULLing for non-root users
111415+ above
111416+ */
111417+ if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'X' && *fmt != 'K' && is_usercopy_object(buf)) {
111418+ printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
111419+ dump_stack();
111420+ ptr = NULL;
111421+ }
111422+#endif
111423+
111424 spec.flags |= SMALL;
111425 if (spec.field_width == -1) {
111426 spec.field_width = default_width;
111427@@ -2296,11 +2331,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
111428 typeof(type) value; \
111429 if (sizeof(type) == 8) { \
111430 args = PTR_ALIGN(args, sizeof(u32)); \
111431- *(u32 *)&value = *(u32 *)args; \
111432- *((u32 *)&value + 1) = *(u32 *)(args + 4); \
111433+ *(u32 *)&value = *(const u32 *)args; \
111434+ *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
111435 } else { \
111436 args = PTR_ALIGN(args, sizeof(type)); \
111437- value = *(typeof(type) *)args; \
111438+ value = *(const typeof(type) *)args; \
111439 } \
111440 args += sizeof(type); \
111441 value; \
111442@@ -2363,7 +2398,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
111443 case FORMAT_TYPE_STR: {
111444 const char *str_arg = args;
111445 args += strlen(str_arg) + 1;
111446- str = string(str, end, (char *)str_arg, spec);
111447+ str = string(str, end, str_arg, spec);
111448 break;
111449 }
111450
111451diff --git a/localversion-grsec b/localversion-grsec
111452new file mode 100644
111453index 0000000..7cd6065
111454--- /dev/null
111455+++ b/localversion-grsec
111456@@ -0,0 +1 @@
111457+-grsec
111458diff --git a/mm/Kconfig b/mm/Kconfig
111459index 390214d..f96e3b8 100644
111460--- a/mm/Kconfig
111461+++ b/mm/Kconfig
111462@@ -342,10 +342,11 @@ config KSM
111463 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
111464
111465 config DEFAULT_MMAP_MIN_ADDR
111466- int "Low address space to protect from user allocation"
111467+ int "Low address space to protect from user allocation"
111468 depends on MMU
111469- default 4096
111470- help
111471+ default 32768 if ALPHA || ARM || PARISC || SPARC32
111472+ default 65536
111473+ help
111474 This is the portion of low virtual memory which should be protected
111475 from userspace allocation. Keeping a user from writing to low pages
111476 can help reduce the impact of kernel NULL pointer bugs.
111477@@ -376,7 +377,7 @@ config MEMORY_FAILURE
111478
111479 config HWPOISON_INJECT
111480 tristate "HWPoison pages injector"
111481- depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
111482+ depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
111483 select PROC_PAGE_MONITOR
111484
111485 config NOMMU_INITIAL_TRIM_EXCESS
111486diff --git a/mm/Kconfig.debug b/mm/Kconfig.debug
111487index 957d3da..1d34e20 100644
111488--- a/mm/Kconfig.debug
111489+++ b/mm/Kconfig.debug
111490@@ -10,6 +10,7 @@ config PAGE_EXTENSION
111491 config DEBUG_PAGEALLOC
111492 bool "Debug page memory allocations"
111493 depends on DEBUG_KERNEL
111494+ depends on !PAX_MEMORY_SANITIZE
111495 depends on !HIBERNATION || ARCH_SUPPORTS_DEBUG_PAGEALLOC && !PPC && !SPARC
111496 depends on !KMEMCHECK
111497 select PAGE_EXTENSION
111498diff --git a/mm/backing-dev.c b/mm/backing-dev.c
111499index 000e7b3..aad2605 100644
111500--- a/mm/backing-dev.c
111501+++ b/mm/backing-dev.c
111502@@ -12,7 +12,7 @@
111503 #include <linux/device.h>
111504 #include <trace/events/writeback.h>
111505
111506-static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
111507+static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
111508
111509 struct backing_dev_info noop_backing_dev_info = {
111510 .name = "noop",
111511@@ -458,7 +458,7 @@ int bdi_setup_and_register(struct backing_dev_info *bdi, char *name)
111512 return err;
111513
111514 err = bdi_register(bdi, NULL, "%.28s-%ld", name,
111515- atomic_long_inc_return(&bdi_seq));
111516+ atomic_long_inc_return_unchecked(&bdi_seq));
111517 if (err) {
111518 bdi_destroy(bdi);
111519 return err;
111520diff --git a/mm/cma_debug.c b/mm/cma_debug.c
111521index 7621ee3..f8e4b60 100644
111522--- a/mm/cma_debug.c
111523+++ b/mm/cma_debug.c
111524@@ -39,7 +39,7 @@ static int cma_used_get(void *data, u64 *val)
111525
111526 mutex_lock(&cma->lock);
111527 /* pages counter is smaller than sizeof(int) */
111528- used = bitmap_weight(cma->bitmap, (int)cma->count);
111529+ used = bitmap_weight(cma->bitmap, (int)cma_bitmap_maxno(cma));
111530 mutex_unlock(&cma->lock);
111531 *val = (u64)used << cma->order_per_bit;
111532
111533@@ -52,13 +52,14 @@ static int cma_maxchunk_get(void *data, u64 *val)
111534 struct cma *cma = data;
111535 unsigned long maxchunk = 0;
111536 unsigned long start, end = 0;
111537+ unsigned long bitmap_maxno = cma_bitmap_maxno(cma);
111538
111539 mutex_lock(&cma->lock);
111540 for (;;) {
111541- start = find_next_zero_bit(cma->bitmap, cma->count, end);
111542+ start = find_next_zero_bit(cma->bitmap, bitmap_maxno, end);
111543 if (start >= cma->count)
111544 break;
111545- end = find_next_bit(cma->bitmap, cma->count, start);
111546+ end = find_next_bit(cma->bitmap, bitmap_maxno, start);
111547 maxchunk = max(end - start, maxchunk);
111548 }
111549 mutex_unlock(&cma->lock);
111550@@ -170,10 +171,10 @@ static void cma_debugfs_add_one(struct cma *cma, int idx)
111551
111552 tmp = debugfs_create_dir(name, cma_debugfs_root);
111553
111554- debugfs_create_file("alloc", S_IWUSR, cma_debugfs_root, cma,
111555+ debugfs_create_file("alloc", S_IWUSR, tmp, cma,
111556 &cma_alloc_fops);
111557
111558- debugfs_create_file("free", S_IWUSR, cma_debugfs_root, cma,
111559+ debugfs_create_file("free", S_IWUSR, tmp, cma,
111560 &cma_free_fops);
111561
111562 debugfs_create_file("base_pfn", S_IRUGO, tmp,
111563diff --git a/mm/filemap.c b/mm/filemap.c
111564index 6bf5e42..1e631ee 100644
111565--- a/mm/filemap.c
111566+++ b/mm/filemap.c
111567@@ -2095,7 +2095,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
111568 struct address_space *mapping = file->f_mapping;
111569
111570 if (!mapping->a_ops->readpage)
111571- return -ENOEXEC;
111572+ return -ENODEV;
111573 file_accessed(file);
111574 vma->vm_ops = &generic_file_vm_ops;
111575 return 0;
111576@@ -2276,6 +2276,7 @@ inline ssize_t generic_write_checks(struct kiocb *iocb, struct iov_iter *from)
111577 pos = iocb->ki_pos;
111578
111579 if (limit != RLIM_INFINITY) {
111580+ gr_learn_resource(current, RLIMIT_FSIZE, iocb->ki_pos, 0);
111581 if (iocb->ki_pos >= limit) {
111582 send_sig(SIGXFSZ, current, 0);
111583 return -EFBIG;
111584diff --git a/mm/gup.c b/mm/gup.c
111585index 6297f6b..7652403 100644
111586--- a/mm/gup.c
111587+++ b/mm/gup.c
111588@@ -265,11 +265,6 @@ static int faultin_page(struct task_struct *tsk, struct vm_area_struct *vma,
111589 unsigned int fault_flags = 0;
111590 int ret;
111591
111592- /* For mm_populate(), just skip the stack guard page. */
111593- if ((*flags & FOLL_POPULATE) &&
111594- (stack_guard_page_start(vma, address) ||
111595- stack_guard_page_end(vma, address + PAGE_SIZE)))
111596- return -ENOENT;
111597 if (*flags & FOLL_WRITE)
111598 fault_flags |= FAULT_FLAG_WRITE;
111599 if (nonblocking)
111600@@ -435,14 +430,14 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
111601 if (!(gup_flags & FOLL_FORCE))
111602 gup_flags |= FOLL_NUMA;
111603
111604- do {
111605+ while (nr_pages) {
111606 struct page *page;
111607 unsigned int foll_flags = gup_flags;
111608 unsigned int page_increm;
111609
111610 /* first iteration or cross vma bound */
111611 if (!vma || start >= vma->vm_end) {
111612- vma = find_extend_vma(mm, start);
111613+ vma = find_vma(mm, start);
111614 if (!vma && in_gate_area(mm, start)) {
111615 int ret;
111616 ret = get_gate_page(mm, start & PAGE_MASK,
111617@@ -454,7 +449,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
111618 goto next_page;
111619 }
111620
111621- if (!vma || check_vma_flags(vma, gup_flags))
111622+ if (!vma || start < vma->vm_start || check_vma_flags(vma, gup_flags))
111623 return i ? : -EFAULT;
111624 if (is_vm_hugetlb_page(vma)) {
111625 i = follow_hugetlb_page(mm, vma, pages, vmas,
111626@@ -509,7 +504,7 @@ next_page:
111627 i += page_increm;
111628 start += page_increm * PAGE_SIZE;
111629 nr_pages -= page_increm;
111630- } while (nr_pages);
111631+ }
111632 return i;
111633 }
111634 EXPORT_SYMBOL(__get_user_pages);
111635diff --git a/mm/highmem.c b/mm/highmem.c
111636index 123bcd3..0de52ba 100644
111637--- a/mm/highmem.c
111638+++ b/mm/highmem.c
111639@@ -195,8 +195,9 @@ static void flush_all_zero_pkmaps(void)
111640 * So no dangers, even with speculative execution.
111641 */
111642 page = pte_page(pkmap_page_table[i]);
111643+ pax_open_kernel();
111644 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
111645-
111646+ pax_close_kernel();
111647 set_page_address(page, NULL);
111648 need_flush = 1;
111649 }
111650@@ -259,9 +260,11 @@ start:
111651 }
111652 }
111653 vaddr = PKMAP_ADDR(last_pkmap_nr);
111654+
111655+ pax_open_kernel();
111656 set_pte_at(&init_mm, vaddr,
111657 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
111658-
111659+ pax_close_kernel();
111660 pkmap_count[last_pkmap_nr] = 1;
111661 set_page_address(page, (void *)vaddr);
111662
111663diff --git a/mm/hugetlb.c b/mm/hugetlb.c
111664index 271e443..c582971 100644
111665--- a/mm/hugetlb.c
111666+++ b/mm/hugetlb.c
111667@@ -2362,6 +2362,7 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
111668 struct ctl_table *table, int write,
111669 void __user *buffer, size_t *length, loff_t *ppos)
111670 {
111671+ ctl_table_no_const t;
111672 struct hstate *h = &default_hstate;
111673 unsigned long tmp = h->max_huge_pages;
111674 int ret;
111675@@ -2369,9 +2370,10 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
111676 if (!hugepages_supported())
111677 return -ENOTSUPP;
111678
111679- table->data = &tmp;
111680- table->maxlen = sizeof(unsigned long);
111681- ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
111682+ t = *table;
111683+ t.data = &tmp;
111684+ t.maxlen = sizeof(unsigned long);
111685+ ret = proc_doulongvec_minmax(&t, write, buffer, length, ppos);
111686 if (ret)
111687 goto out;
111688
111689@@ -2406,6 +2408,7 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
111690 struct hstate *h = &default_hstate;
111691 unsigned long tmp;
111692 int ret;
111693+ ctl_table_no_const hugetlb_table;
111694
111695 if (!hugepages_supported())
111696 return -ENOTSUPP;
111697@@ -2415,9 +2418,10 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
111698 if (write && hstate_is_gigantic(h))
111699 return -EINVAL;
111700
111701- table->data = &tmp;
111702- table->maxlen = sizeof(unsigned long);
111703- ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
111704+ hugetlb_table = *table;
111705+ hugetlb_table.data = &tmp;
111706+ hugetlb_table.maxlen = sizeof(unsigned long);
111707+ ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
111708 if (ret)
111709 goto out;
111710
111711@@ -2907,6 +2911,27 @@ static void unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
111712 i_mmap_unlock_write(mapping);
111713 }
111714
111715+#ifdef CONFIG_PAX_SEGMEXEC
111716+static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
111717+{
111718+ struct mm_struct *mm = vma->vm_mm;
111719+ struct vm_area_struct *vma_m;
111720+ unsigned long address_m;
111721+ pte_t *ptep_m;
111722+
111723+ vma_m = pax_find_mirror_vma(vma);
111724+ if (!vma_m)
111725+ return;
111726+
111727+ BUG_ON(address >= SEGMEXEC_TASK_SIZE);
111728+ address_m = address + SEGMEXEC_TASK_SIZE;
111729+ ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
111730+ get_page(page_m);
111731+ hugepage_add_anon_rmap(page_m, vma_m, address_m);
111732+ set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
111733+}
111734+#endif
111735+
111736 /*
111737 * Hugetlb_cow() should be called with page lock of the original hugepage held.
111738 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
111739@@ -3020,6 +3045,11 @@ retry_avoidcopy:
111740 make_huge_pte(vma, new_page, 1));
111741 page_remove_rmap(old_page);
111742 hugepage_add_new_anon_rmap(new_page, vma, address);
111743+
111744+#ifdef CONFIG_PAX_SEGMEXEC
111745+ pax_mirror_huge_pte(vma, address, new_page);
111746+#endif
111747+
111748 /* Make the old page be freed below */
111749 new_page = old_page;
111750 }
111751@@ -3181,6 +3211,10 @@ retry:
111752 && (vma->vm_flags & VM_SHARED)));
111753 set_huge_pte_at(mm, address, ptep, new_pte);
111754
111755+#ifdef CONFIG_PAX_SEGMEXEC
111756+ pax_mirror_huge_pte(vma, address, page);
111757+#endif
111758+
111759 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
111760 /* Optimization, do the COW without a second fault */
111761 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page, ptl);
111762@@ -3248,6 +3282,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
111763 struct address_space *mapping;
111764 int need_wait_lock = 0;
111765
111766+#ifdef CONFIG_PAX_SEGMEXEC
111767+ struct vm_area_struct *vma_m;
111768+#endif
111769+
111770 address &= huge_page_mask(h);
111771
111772 ptep = huge_pte_offset(mm, address);
111773@@ -3261,6 +3299,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
111774 VM_FAULT_SET_HINDEX(hstate_index(h));
111775 }
111776
111777+#ifdef CONFIG_PAX_SEGMEXEC
111778+ vma_m = pax_find_mirror_vma(vma);
111779+ if (vma_m) {
111780+ unsigned long address_m;
111781+
111782+ if (vma->vm_start > vma_m->vm_start) {
111783+ address_m = address;
111784+ address -= SEGMEXEC_TASK_SIZE;
111785+ vma = vma_m;
111786+ h = hstate_vma(vma);
111787+ } else
111788+ address_m = address + SEGMEXEC_TASK_SIZE;
111789+
111790+ if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
111791+ return VM_FAULT_OOM;
111792+ address_m &= HPAGE_MASK;
111793+ unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
111794+ }
111795+#endif
111796+
111797 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
111798 if (!ptep)
111799 return VM_FAULT_OOM;
111800diff --git a/mm/internal.h b/mm/internal.h
111801index a25e359..e2c96e9 100644
111802--- a/mm/internal.h
111803+++ b/mm/internal.h
111804@@ -156,6 +156,7 @@ __find_buddy_index(unsigned long page_idx, unsigned int order)
111805
111806 extern int __isolate_free_page(struct page *page, unsigned int order);
111807 extern void __free_pages_bootmem(struct page *page, unsigned int order);
111808+extern void free_compound_page(struct page *page);
111809 extern void prep_compound_page(struct page *page, unsigned long order);
111810 #ifdef CONFIG_MEMORY_FAILURE
111811 extern bool is_free_buddy_page(struct page *page);
111812@@ -413,7 +414,7 @@ extern u32 hwpoison_filter_enable;
111813
111814 extern unsigned long vm_mmap_pgoff(struct file *, unsigned long,
111815 unsigned long, unsigned long,
111816- unsigned long, unsigned long);
111817+ unsigned long, unsigned long) __intentional_overflow(-1);
111818
111819 extern void set_pageblock_order(void);
111820 unsigned long reclaim_clean_pages_from_list(struct zone *zone,
111821diff --git a/mm/kmemleak.c b/mm/kmemleak.c
111822index 3716cdb..25b97dc 100644
111823--- a/mm/kmemleak.c
111824+++ b/mm/kmemleak.c
111825@@ -368,7 +368,7 @@ static void print_unreferenced(struct seq_file *seq,
111826
111827 for (i = 0; i < object->trace_len; i++) {
111828 void *ptr = (void *)object->trace[i];
111829- seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
111830+ seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
111831 }
111832 }
111833
111834@@ -1926,7 +1926,7 @@ static int __init kmemleak_late_init(void)
111835 return -ENOMEM;
111836 }
111837
111838- dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
111839+ dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
111840 &kmemleak_fops);
111841 if (!dentry)
111842 pr_warning("Failed to create the debugfs kmemleak file\n");
111843diff --git a/mm/maccess.c b/mm/maccess.c
111844index d53adf9..03a24bf 100644
111845--- a/mm/maccess.c
111846+++ b/mm/maccess.c
111847@@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
111848 set_fs(KERNEL_DS);
111849 pagefault_disable();
111850 ret = __copy_from_user_inatomic(dst,
111851- (__force const void __user *)src, size);
111852+ (const void __force_user *)src, size);
111853 pagefault_enable();
111854 set_fs(old_fs);
111855
111856@@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
111857
111858 set_fs(KERNEL_DS);
111859 pagefault_disable();
111860- ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
111861+ ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
111862 pagefault_enable();
111863 set_fs(old_fs);
111864
111865diff --git a/mm/madvise.c b/mm/madvise.c
111866index d551475..8fdd7f3 100644
111867--- a/mm/madvise.c
111868+++ b/mm/madvise.c
111869@@ -51,6 +51,10 @@ static long madvise_behavior(struct vm_area_struct *vma,
111870 pgoff_t pgoff;
111871 unsigned long new_flags = vma->vm_flags;
111872
111873+#ifdef CONFIG_PAX_SEGMEXEC
111874+ struct vm_area_struct *vma_m;
111875+#endif
111876+
111877 switch (behavior) {
111878 case MADV_NORMAL:
111879 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
111880@@ -126,6 +130,13 @@ success:
111881 /*
111882 * vm_flags is protected by the mmap_sem held in write mode.
111883 */
111884+
111885+#ifdef CONFIG_PAX_SEGMEXEC
111886+ vma_m = pax_find_mirror_vma(vma);
111887+ if (vma_m)
111888+ vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
111889+#endif
111890+
111891 vma->vm_flags = new_flags;
111892
111893 out:
111894@@ -277,11 +288,27 @@ static long madvise_dontneed(struct vm_area_struct *vma,
111895 struct vm_area_struct **prev,
111896 unsigned long start, unsigned long end)
111897 {
111898+
111899+#ifdef CONFIG_PAX_SEGMEXEC
111900+ struct vm_area_struct *vma_m;
111901+#endif
111902+
111903 *prev = vma;
111904 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
111905 return -EINVAL;
111906
111907 zap_page_range(vma, start, end - start, NULL);
111908+
111909+#ifdef CONFIG_PAX_SEGMEXEC
111910+ vma_m = pax_find_mirror_vma(vma);
111911+ if (vma_m) {
111912+ if (vma_m->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
111913+ return -EINVAL;
111914+
111915+ zap_page_range(vma_m, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
111916+ }
111917+#endif
111918+
111919 return 0;
111920 }
111921
111922@@ -484,6 +511,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
111923 if (end < start)
111924 return error;
111925
111926+#ifdef CONFIG_PAX_SEGMEXEC
111927+ if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
111928+ if (end > SEGMEXEC_TASK_SIZE)
111929+ return error;
111930+ } else
111931+#endif
111932+
111933+ if (end > TASK_SIZE)
111934+ return error;
111935+
111936 error = 0;
111937 if (end == start)
111938 return error;
111939diff --git a/mm/memory-failure.c b/mm/memory-failure.c
111940index 501820c..9612bcf 100644
111941--- a/mm/memory-failure.c
111942+++ b/mm/memory-failure.c
111943@@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
111944
111945 int sysctl_memory_failure_recovery __read_mostly = 1;
111946
111947-atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
111948+atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
111949
111950 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
111951
111952@@ -198,7 +198,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
111953 pfn, t->comm, t->pid);
111954 si.si_signo = SIGBUS;
111955 si.si_errno = 0;
111956- si.si_addr = (void *)addr;
111957+ si.si_addr = (void __user *)addr;
111958 #ifdef __ARCH_SI_TRAPNO
111959 si.si_trapno = trapno;
111960 #endif
111961@@ -825,7 +825,7 @@ static struct page_state {
111962 unsigned long res;
111963 enum action_page_type type;
111964 int (*action)(struct page *p, unsigned long pfn);
111965-} error_states[] = {
111966+} __do_const error_states[] = {
111967 { reserved, reserved, MSG_KERNEL, me_kernel },
111968 /*
111969 * free pages are specially detected outside this table:
111970@@ -1133,7 +1133,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
111971 nr_pages = 1 << compound_order(hpage);
111972 else /* normal page or thp */
111973 nr_pages = 1;
111974- atomic_long_add(nr_pages, &num_poisoned_pages);
111975+ atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
111976
111977 /*
111978 * We need/can do nothing about count=0 pages.
111979@@ -1162,7 +1162,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
111980 if (PageHWPoison(hpage)) {
111981 if ((hwpoison_filter(p) && TestClearPageHWPoison(p))
111982 || (p != hpage && TestSetPageHWPoison(hpage))) {
111983- atomic_long_sub(nr_pages, &num_poisoned_pages);
111984+ atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
111985 unlock_page(hpage);
111986 return 0;
111987 }
111988@@ -1231,14 +1231,14 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
111989 */
111990 if (!PageHWPoison(p)) {
111991 printk(KERN_ERR "MCE %#lx: just unpoisoned\n", pfn);
111992- atomic_long_sub(nr_pages, &num_poisoned_pages);
111993+ atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
111994 put_page(hpage);
111995 res = 0;
111996 goto out;
111997 }
111998 if (hwpoison_filter(p)) {
111999 if (TestClearPageHWPoison(p))
112000- atomic_long_sub(nr_pages, &num_poisoned_pages);
112001+ atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
112002 unlock_page(hpage);
112003 put_page(hpage);
112004 return 0;
112005@@ -1467,7 +1467,7 @@ int unpoison_memory(unsigned long pfn)
112006 return 0;
112007 }
112008 if (TestClearPageHWPoison(p))
112009- atomic_long_dec(&num_poisoned_pages);
112010+ atomic_long_dec_unchecked(&num_poisoned_pages);
112011 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
112012 return 0;
112013 }
112014@@ -1481,7 +1481,7 @@ int unpoison_memory(unsigned long pfn)
112015 */
112016 if (TestClearPageHWPoison(page)) {
112017 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
112018- atomic_long_sub(nr_pages, &num_poisoned_pages);
112019+ atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
112020 freeit = 1;
112021 if (PageHuge(page))
112022 clear_page_hwpoison_huge_page(page);
112023@@ -1616,11 +1616,11 @@ static int soft_offline_huge_page(struct page *page, int flags)
112024 if (PageHuge(page)) {
112025 set_page_hwpoison_huge_page(hpage);
112026 dequeue_hwpoisoned_huge_page(hpage);
112027- atomic_long_add(1 << compound_order(hpage),
112028+ atomic_long_add_unchecked(1 << compound_order(hpage),
112029 &num_poisoned_pages);
112030 } else {
112031 SetPageHWPoison(page);
112032- atomic_long_inc(&num_poisoned_pages);
112033+ atomic_long_inc_unchecked(&num_poisoned_pages);
112034 }
112035 }
112036 return ret;
112037@@ -1659,7 +1659,7 @@ static int __soft_offline_page(struct page *page, int flags)
112038 put_page(page);
112039 pr_info("soft_offline: %#lx: invalidated\n", pfn);
112040 SetPageHWPoison(page);
112041- atomic_long_inc(&num_poisoned_pages);
112042+ atomic_long_inc_unchecked(&num_poisoned_pages);
112043 return 0;
112044 }
112045
112046@@ -1708,7 +1708,7 @@ static int __soft_offline_page(struct page *page, int flags)
112047 if (!is_free_buddy_page(page))
112048 pr_info("soft offline: %#lx: page leaked\n",
112049 pfn);
112050- atomic_long_inc(&num_poisoned_pages);
112051+ atomic_long_inc_unchecked(&num_poisoned_pages);
112052 }
112053 } else {
112054 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
112055@@ -1778,11 +1778,11 @@ int soft_offline_page(struct page *page, int flags)
112056 if (PageHuge(page)) {
112057 set_page_hwpoison_huge_page(hpage);
112058 if (!dequeue_hwpoisoned_huge_page(hpage))
112059- atomic_long_add(1 << compound_order(hpage),
112060+ atomic_long_add_unchecked(1 << compound_order(hpage),
112061 &num_poisoned_pages);
112062 } else {
112063 if (!TestSetPageHWPoison(page))
112064- atomic_long_inc(&num_poisoned_pages);
112065+ atomic_long_inc_unchecked(&num_poisoned_pages);
112066 }
112067 }
112068 unset_migratetype_isolate(page, MIGRATE_MOVABLE);
112069diff --git a/mm/memory.c b/mm/memory.c
112070index 22e037e..347d230 100644
112071--- a/mm/memory.c
112072+++ b/mm/memory.c
112073@@ -414,6 +414,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
112074 free_pte_range(tlb, pmd, addr);
112075 } while (pmd++, addr = next, addr != end);
112076
112077+#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
112078 start &= PUD_MASK;
112079 if (start < floor)
112080 return;
112081@@ -429,6 +430,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
112082 pud_clear(pud);
112083 pmd_free_tlb(tlb, pmd, start);
112084 mm_dec_nr_pmds(tlb->mm);
112085+#endif
112086 }
112087
112088 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
112089@@ -448,6 +450,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
112090 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
112091 } while (pud++, addr = next, addr != end);
112092
112093+#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
112094 start &= PGDIR_MASK;
112095 if (start < floor)
112096 return;
112097@@ -462,6 +465,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
112098 pud = pud_offset(pgd, start);
112099 pgd_clear(pgd);
112100 pud_free_tlb(tlb, pud, start);
112101+#endif
112102+
112103 }
112104
112105 /*
112106@@ -690,7 +695,7 @@ static void print_bad_pte(struct vm_area_struct *vma, unsigned long addr,
112107 /*
112108 * Choose text because data symbols depend on CONFIG_KALLSYMS_ALL=y
112109 */
112110- pr_alert("file:%pD fault:%pf mmap:%pf readpage:%pf\n",
112111+ pr_alert("file:%pD fault:%pX mmap:%pX readpage:%pX\n",
112112 vma->vm_file,
112113 vma->vm_ops ? vma->vm_ops->fault : NULL,
112114 vma->vm_file ? vma->vm_file->f_op->mmap : NULL,
112115@@ -1463,6 +1468,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
112116 page_add_file_rmap(page);
112117 set_pte_at(mm, addr, pte, mk_pte(page, prot));
112118
112119+#ifdef CONFIG_PAX_SEGMEXEC
112120+ pax_mirror_file_pte(vma, addr, page, ptl);
112121+#endif
112122+
112123 retval = 0;
112124 pte_unmap_unlock(pte, ptl);
112125 return retval;
112126@@ -1507,9 +1516,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
112127 if (!page_count(page))
112128 return -EINVAL;
112129 if (!(vma->vm_flags & VM_MIXEDMAP)) {
112130+
112131+#ifdef CONFIG_PAX_SEGMEXEC
112132+ struct vm_area_struct *vma_m;
112133+#endif
112134+
112135 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
112136 BUG_ON(vma->vm_flags & VM_PFNMAP);
112137 vma->vm_flags |= VM_MIXEDMAP;
112138+
112139+#ifdef CONFIG_PAX_SEGMEXEC
112140+ vma_m = pax_find_mirror_vma(vma);
112141+ if (vma_m)
112142+ vma_m->vm_flags |= VM_MIXEDMAP;
112143+#endif
112144+
112145 }
112146 return insert_page(vma, addr, page, vma->vm_page_prot);
112147 }
112148@@ -1592,6 +1613,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
112149 unsigned long pfn)
112150 {
112151 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
112152+ BUG_ON(vma->vm_mirror);
112153
112154 if (addr < vma->vm_start || addr >= vma->vm_end)
112155 return -EFAULT;
112156@@ -1839,7 +1861,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
112157
112158 BUG_ON(pud_huge(*pud));
112159
112160- pmd = pmd_alloc(mm, pud, addr);
112161+ pmd = (mm == &init_mm) ?
112162+ pmd_alloc_kernel(mm, pud, addr) :
112163+ pmd_alloc(mm, pud, addr);
112164 if (!pmd)
112165 return -ENOMEM;
112166 do {
112167@@ -1859,7 +1883,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
112168 unsigned long next;
112169 int err;
112170
112171- pud = pud_alloc(mm, pgd, addr);
112172+ pud = (mm == &init_mm) ?
112173+ pud_alloc_kernel(mm, pgd, addr) :
112174+ pud_alloc(mm, pgd, addr);
112175 if (!pud)
112176 return -ENOMEM;
112177 do {
112178@@ -2040,6 +2066,185 @@ static inline int wp_page_reuse(struct mm_struct *mm,
112179 return VM_FAULT_WRITE;
112180 }
112181
112182+#ifdef CONFIG_PAX_SEGMEXEC
112183+static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
112184+{
112185+ struct mm_struct *mm = vma->vm_mm;
112186+ spinlock_t *ptl;
112187+ pte_t *pte, entry;
112188+
112189+ pte = pte_offset_map_lock(mm, pmd, address, &ptl);
112190+ entry = *pte;
112191+ if (!pte_present(entry)) {
112192+ if (!pte_none(entry)) {
112193+ free_swap_and_cache(pte_to_swp_entry(entry));
112194+ pte_clear_not_present_full(mm, address, pte, 0);
112195+ }
112196+ } else {
112197+ struct page *page;
112198+
112199+ flush_cache_page(vma, address, pte_pfn(entry));
112200+ entry = ptep_clear_flush(vma, address, pte);
112201+ BUG_ON(pte_dirty(entry));
112202+ page = vm_normal_page(vma, address, entry);
112203+ if (page) {
112204+ update_hiwater_rss(mm);
112205+ if (PageAnon(page))
112206+ dec_mm_counter_fast(mm, MM_ANONPAGES);
112207+ else
112208+ dec_mm_counter_fast(mm, MM_FILEPAGES);
112209+ page_remove_rmap(page);
112210+ page_cache_release(page);
112211+ }
112212+ }
112213+ pte_unmap_unlock(pte, ptl);
112214+}
112215+
112216+/* PaX: if vma is mirrored, synchronize the mirror's PTE
112217+ *
112218+ * the ptl of the lower mapped page is held on entry and is not released on exit
112219+ * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
112220+ */
112221+static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
112222+{
112223+ struct mm_struct *mm = vma->vm_mm;
112224+ unsigned long address_m;
112225+ spinlock_t *ptl_m;
112226+ struct vm_area_struct *vma_m;
112227+ pmd_t *pmd_m;
112228+ pte_t *pte_m, entry_m;
112229+
112230+ BUG_ON(!page_m || !PageAnon(page_m));
112231+
112232+ vma_m = pax_find_mirror_vma(vma);
112233+ if (!vma_m)
112234+ return;
112235+
112236+ BUG_ON(!PageLocked(page_m));
112237+ BUG_ON(address >= SEGMEXEC_TASK_SIZE);
112238+ address_m = address + SEGMEXEC_TASK_SIZE;
112239+ pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
112240+ pte_m = pte_offset_map(pmd_m, address_m);
112241+ ptl_m = pte_lockptr(mm, pmd_m);
112242+ if (ptl != ptl_m) {
112243+ spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
112244+ if (!pte_none(*pte_m))
112245+ goto out;
112246+ }
112247+
112248+ entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
112249+ page_cache_get(page_m);
112250+ page_add_anon_rmap(page_m, vma_m, address_m);
112251+ inc_mm_counter_fast(mm, MM_ANONPAGES);
112252+ set_pte_at(mm, address_m, pte_m, entry_m);
112253+ update_mmu_cache(vma_m, address_m, pte_m);
112254+out:
112255+ if (ptl != ptl_m)
112256+ spin_unlock(ptl_m);
112257+ pte_unmap(pte_m);
112258+ unlock_page(page_m);
112259+}
112260+
112261+void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
112262+{
112263+ struct mm_struct *mm = vma->vm_mm;
112264+ unsigned long address_m;
112265+ spinlock_t *ptl_m;
112266+ struct vm_area_struct *vma_m;
112267+ pmd_t *pmd_m;
112268+ pte_t *pte_m, entry_m;
112269+
112270+ BUG_ON(!page_m || PageAnon(page_m));
112271+
112272+ vma_m = pax_find_mirror_vma(vma);
112273+ if (!vma_m)
112274+ return;
112275+
112276+ BUG_ON(address >= SEGMEXEC_TASK_SIZE);
112277+ address_m = address + SEGMEXEC_TASK_SIZE;
112278+ pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
112279+ pte_m = pte_offset_map(pmd_m, address_m);
112280+ ptl_m = pte_lockptr(mm, pmd_m);
112281+ if (ptl != ptl_m) {
112282+ spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
112283+ if (!pte_none(*pte_m))
112284+ goto out;
112285+ }
112286+
112287+ entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
112288+ page_cache_get(page_m);
112289+ page_add_file_rmap(page_m);
112290+ inc_mm_counter_fast(mm, MM_FILEPAGES);
112291+ set_pte_at(mm, address_m, pte_m, entry_m);
112292+ update_mmu_cache(vma_m, address_m, pte_m);
112293+out:
112294+ if (ptl != ptl_m)
112295+ spin_unlock(ptl_m);
112296+ pte_unmap(pte_m);
112297+}
112298+
112299+static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
112300+{
112301+ struct mm_struct *mm = vma->vm_mm;
112302+ unsigned long address_m;
112303+ spinlock_t *ptl_m;
112304+ struct vm_area_struct *vma_m;
112305+ pmd_t *pmd_m;
112306+ pte_t *pte_m, entry_m;
112307+
112308+ vma_m = pax_find_mirror_vma(vma);
112309+ if (!vma_m)
112310+ return;
112311+
112312+ BUG_ON(address >= SEGMEXEC_TASK_SIZE);
112313+ address_m = address + SEGMEXEC_TASK_SIZE;
112314+ pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
112315+ pte_m = pte_offset_map(pmd_m, address_m);
112316+ ptl_m = pte_lockptr(mm, pmd_m);
112317+ if (ptl != ptl_m) {
112318+ spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
112319+ if (!pte_none(*pte_m))
112320+ goto out;
112321+ }
112322+
112323+ entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
112324+ set_pte_at(mm, address_m, pte_m, entry_m);
112325+out:
112326+ if (ptl != ptl_m)
112327+ spin_unlock(ptl_m);
112328+ pte_unmap(pte_m);
112329+}
112330+
112331+static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
112332+{
112333+ struct page *page_m;
112334+ pte_t entry;
112335+
112336+ if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
112337+ goto out;
112338+
112339+ entry = *pte;
112340+ page_m = vm_normal_page(vma, address, entry);
112341+ if (!page_m)
112342+ pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
112343+ else if (PageAnon(page_m)) {
112344+ if (pax_find_mirror_vma(vma)) {
112345+ pte_unmap_unlock(pte, ptl);
112346+ lock_page(page_m);
112347+ pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
112348+ if (pte_same(entry, *pte))
112349+ pax_mirror_anon_pte(vma, address, page_m, ptl);
112350+ else
112351+ unlock_page(page_m);
112352+ }
112353+ } else
112354+ pax_mirror_file_pte(vma, address, page_m, ptl);
112355+
112356+out:
112357+ pte_unmap_unlock(pte, ptl);
112358+}
112359+#endif
112360+
112361 /*
112362 * Handle the case of a page which we actually need to copy to a new page.
112363 *
112364@@ -2093,6 +2298,12 @@ static int wp_page_copy(struct mm_struct *mm, struct vm_area_struct *vma,
112365 */
112366 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
112367 if (likely(pte_same(*page_table, orig_pte))) {
112368+
112369+#ifdef CONFIG_PAX_SEGMEXEC
112370+ if (pax_find_mirror_vma(vma))
112371+ BUG_ON(!trylock_page(new_page));
112372+#endif
112373+
112374 if (old_page) {
112375 if (!PageAnon(old_page)) {
112376 dec_mm_counter_fast(mm, MM_FILEPAGES);
112377@@ -2147,6 +2358,10 @@ static int wp_page_copy(struct mm_struct *mm, struct vm_area_struct *vma,
112378 page_remove_rmap(old_page);
112379 }
112380
112381+#ifdef CONFIG_PAX_SEGMEXEC
112382+ pax_mirror_anon_pte(vma, address, new_page, ptl);
112383+#endif
112384+
112385 /* Free the old page.. */
112386 new_page = old_page;
112387 page_copied = 1;
112388@@ -2578,6 +2793,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
112389 swap_free(entry);
112390 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
112391 try_to_free_swap(page);
112392+
112393+#ifdef CONFIG_PAX_SEGMEXEC
112394+ if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
112395+#endif
112396+
112397 unlock_page(page);
112398 if (page != swapcache) {
112399 /*
112400@@ -2601,6 +2821,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
112401
112402 /* No need to invalidate - it was non-present before */
112403 update_mmu_cache(vma, address, page_table);
112404+
112405+#ifdef CONFIG_PAX_SEGMEXEC
112406+ pax_mirror_anon_pte(vma, address, page, ptl);
112407+#endif
112408+
112409 unlock:
112410 pte_unmap_unlock(page_table, ptl);
112411 out:
112412@@ -2620,40 +2845,6 @@ out_release:
112413 }
112414
112415 /*
112416- * This is like a special single-page "expand_{down|up}wards()",
112417- * except we must first make sure that 'address{-|+}PAGE_SIZE'
112418- * doesn't hit another vma.
112419- */
112420-static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
112421-{
112422- address &= PAGE_MASK;
112423- if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
112424- struct vm_area_struct *prev = vma->vm_prev;
112425-
112426- /*
112427- * Is there a mapping abutting this one below?
112428- *
112429- * That's only ok if it's the same stack mapping
112430- * that has gotten split..
112431- */
112432- if (prev && prev->vm_end == address)
112433- return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
112434-
112435- return expand_downwards(vma, address - PAGE_SIZE);
112436- }
112437- if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
112438- struct vm_area_struct *next = vma->vm_next;
112439-
112440- /* As VM_GROWSDOWN but s/below/above/ */
112441- if (next && next->vm_start == address + PAGE_SIZE)
112442- return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
112443-
112444- return expand_upwards(vma, address + PAGE_SIZE);
112445- }
112446- return 0;
112447-}
112448-
112449-/*
112450 * We enter with non-exclusive mmap_sem (to exclude vma changes,
112451 * but allow concurrent faults), and pte mapped but not yet locked.
112452 * We return with mmap_sem still held, but pte unmapped and unlocked.
112453@@ -2663,27 +2854,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
112454 unsigned int flags)
112455 {
112456 struct mem_cgroup *memcg;
112457- struct page *page;
112458+ struct page *page = NULL;
112459 spinlock_t *ptl;
112460 pte_t entry;
112461
112462- pte_unmap(page_table);
112463-
112464- /* Check if we need to add a guard page to the stack */
112465- if (check_stack_guard_page(vma, address) < 0)
112466- return VM_FAULT_SIGSEGV;
112467-
112468- /* Use the zero-page for reads */
112469 if (!(flags & FAULT_FLAG_WRITE) && !mm_forbids_zeropage(mm)) {
112470 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
112471 vma->vm_page_prot));
112472- page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
112473+ ptl = pte_lockptr(mm, pmd);
112474+ spin_lock(ptl);
112475 if (!pte_none(*page_table))
112476 goto unlock;
112477 goto setpte;
112478 }
112479
112480 /* Allocate our own private page. */
112481+ pte_unmap(page_table);
112482+
112483 if (unlikely(anon_vma_prepare(vma)))
112484 goto oom;
112485 page = alloc_zeroed_user_highpage_movable(vma, address);
112486@@ -2707,6 +2894,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
112487 if (!pte_none(*page_table))
112488 goto release;
112489
112490+#ifdef CONFIG_PAX_SEGMEXEC
112491+ if (pax_find_mirror_vma(vma))
112492+ BUG_ON(!trylock_page(page));
112493+#endif
112494+
112495 inc_mm_counter_fast(mm, MM_ANONPAGES);
112496 page_add_new_anon_rmap(page, vma, address);
112497 mem_cgroup_commit_charge(page, memcg, false);
112498@@ -2716,6 +2908,12 @@ setpte:
112499
112500 /* No need to invalidate - it was non-present before */
112501 update_mmu_cache(vma, address, page_table);
112502+
112503+#ifdef CONFIG_PAX_SEGMEXEC
112504+ if (page)
112505+ pax_mirror_anon_pte(vma, address, page, ptl);
112506+#endif
112507+
112508 unlock:
112509 pte_unmap_unlock(page_table, ptl);
112510 return 0;
112511@@ -2948,6 +3146,11 @@ static int do_read_fault(struct mm_struct *mm, struct vm_area_struct *vma,
112512 return ret;
112513 }
112514 do_set_pte(vma, address, fault_page, pte, false, false);
112515+
112516+#ifdef CONFIG_PAX_SEGMEXEC
112517+ pax_mirror_file_pte(vma, address, fault_page, ptl);
112518+#endif
112519+
112520 unlock_page(fault_page);
112521 unlock_out:
112522 pte_unmap_unlock(pte, ptl);
112523@@ -2999,7 +3202,18 @@ static int do_cow_fault(struct mm_struct *mm, struct vm_area_struct *vma,
112524 }
112525 goto uncharge_out;
112526 }
112527+
112528+#ifdef CONFIG_PAX_SEGMEXEC
112529+ if (pax_find_mirror_vma(vma))
112530+ BUG_ON(!trylock_page(new_page));
112531+#endif
112532+
112533 do_set_pte(vma, address, new_page, pte, true, true);
112534+
112535+#ifdef CONFIG_PAX_SEGMEXEC
112536+ pax_mirror_anon_pte(vma, address, new_page, ptl);
112537+#endif
112538+
112539 mem_cgroup_commit_charge(new_page, memcg, false);
112540 lru_cache_add_active_or_unevictable(new_page, vma);
112541 pte_unmap_unlock(pte, ptl);
112542@@ -3057,6 +3271,11 @@ static int do_shared_fault(struct mm_struct *mm, struct vm_area_struct *vma,
112543 return ret;
112544 }
112545 do_set_pte(vma, address, fault_page, pte, true, false);
112546+
112547+#ifdef CONFIG_PAX_SEGMEXEC
112548+ pax_mirror_file_pte(vma, address, fault_page, ptl);
112549+#endif
112550+
112551 pte_unmap_unlock(pte, ptl);
112552
112553 if (set_page_dirty(fault_page))
112554@@ -3280,6 +3499,12 @@ static int handle_pte_fault(struct mm_struct *mm,
112555 if (flags & FAULT_FLAG_WRITE)
112556 flush_tlb_fix_spurious_fault(vma, address);
112557 }
112558+
112559+#ifdef CONFIG_PAX_SEGMEXEC
112560+ pax_mirror_pte(vma, address, pte, pmd, ptl);
112561+ return 0;
112562+#endif
112563+
112564 unlock:
112565 pte_unmap_unlock(pte, ptl);
112566 return 0;
112567@@ -3299,9 +3524,41 @@ static int __handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
112568 pmd_t *pmd;
112569 pte_t *pte;
112570
112571+#ifdef CONFIG_PAX_SEGMEXEC
112572+ struct vm_area_struct *vma_m;
112573+#endif
112574+
112575 if (unlikely(is_vm_hugetlb_page(vma)))
112576 return hugetlb_fault(mm, vma, address, flags);
112577
112578+#ifdef CONFIG_PAX_SEGMEXEC
112579+ vma_m = pax_find_mirror_vma(vma);
112580+ if (vma_m) {
112581+ unsigned long address_m;
112582+ pgd_t *pgd_m;
112583+ pud_t *pud_m;
112584+ pmd_t *pmd_m;
112585+
112586+ if (vma->vm_start > vma_m->vm_start) {
112587+ address_m = address;
112588+ address -= SEGMEXEC_TASK_SIZE;
112589+ vma = vma_m;
112590+ } else
112591+ address_m = address + SEGMEXEC_TASK_SIZE;
112592+
112593+ pgd_m = pgd_offset(mm, address_m);
112594+ pud_m = pud_alloc(mm, pgd_m, address_m);
112595+ if (!pud_m)
112596+ return VM_FAULT_OOM;
112597+ pmd_m = pmd_alloc(mm, pud_m, address_m);
112598+ if (!pmd_m)
112599+ return VM_FAULT_OOM;
112600+ if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
112601+ return VM_FAULT_OOM;
112602+ pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
112603+ }
112604+#endif
112605+
112606 pgd = pgd_offset(mm, address);
112607 pud = pud_alloc(mm, pgd, address);
112608 if (!pud)
112609@@ -3436,6 +3693,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
112610 spin_unlock(&mm->page_table_lock);
112611 return 0;
112612 }
112613+
112614+int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
112615+{
112616+ pud_t *new = pud_alloc_one(mm, address);
112617+ if (!new)
112618+ return -ENOMEM;
112619+
112620+ smp_wmb(); /* See comment in __pte_alloc */
112621+
112622+ spin_lock(&mm->page_table_lock);
112623+ if (pgd_present(*pgd)) /* Another has populated it */
112624+ pud_free(mm, new);
112625+ else
112626+ pgd_populate_kernel(mm, pgd, new);
112627+ spin_unlock(&mm->page_table_lock);
112628+ return 0;
112629+}
112630 #endif /* __PAGETABLE_PUD_FOLDED */
112631
112632 #ifndef __PAGETABLE_PMD_FOLDED
112633@@ -3468,6 +3742,32 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
112634 spin_unlock(&mm->page_table_lock);
112635 return 0;
112636 }
112637+
112638+int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
112639+{
112640+ pmd_t *new = pmd_alloc_one(mm, address);
112641+ if (!new)
112642+ return -ENOMEM;
112643+
112644+ smp_wmb(); /* See comment in __pte_alloc */
112645+
112646+ spin_lock(&mm->page_table_lock);
112647+#ifndef __ARCH_HAS_4LEVEL_HACK
112648+ if (!pud_present(*pud)) {
112649+ mm_inc_nr_pmds(mm);
112650+ pud_populate_kernel(mm, pud, new);
112651+ } else /* Another has populated it */
112652+ pmd_free(mm, new);
112653+#else
112654+ if (!pgd_present(*pud)) {
112655+ mm_inc_nr_pmds(mm);
112656+ pgd_populate_kernel(mm, pud, new);
112657+ } else /* Another has populated it */
112658+ pmd_free(mm, new);
112659+#endif /* __ARCH_HAS_4LEVEL_HACK */
112660+ spin_unlock(&mm->page_table_lock);
112661+ return 0;
112662+}
112663 #endif /* __PAGETABLE_PMD_FOLDED */
112664
112665 static int __follow_pte(struct mm_struct *mm, unsigned long address,
112666@@ -3577,8 +3877,8 @@ out:
112667 return ret;
112668 }
112669
112670-int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
112671- void *buf, int len, int write)
112672+ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
112673+ void *buf, size_t len, int write)
112674 {
112675 resource_size_t phys_addr;
112676 unsigned long prot = 0;
112677@@ -3604,8 +3904,8 @@ EXPORT_SYMBOL_GPL(generic_access_phys);
112678 * Access another process' address space as given in mm. If non-NULL, use the
112679 * given task for page fault accounting.
112680 */
112681-static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
112682- unsigned long addr, void *buf, int len, int write)
112683+static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
112684+ unsigned long addr, void *buf, size_t len, int write)
112685 {
112686 struct vm_area_struct *vma;
112687 void *old_buf = buf;
112688@@ -3613,7 +3913,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
112689 down_read(&mm->mmap_sem);
112690 /* ignore errors, just check how much was successfully transferred */
112691 while (len) {
112692- int bytes, ret, offset;
112693+ ssize_t bytes, ret, offset;
112694 void *maddr;
112695 struct page *page = NULL;
112696
112697@@ -3674,8 +3974,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
112698 *
112699 * The caller must hold a reference on @mm.
112700 */
112701-int access_remote_vm(struct mm_struct *mm, unsigned long addr,
112702- void *buf, int len, int write)
112703+ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
112704+ void *buf, size_t len, int write)
112705 {
112706 return __access_remote_vm(NULL, mm, addr, buf, len, write);
112707 }
112708@@ -3685,11 +3985,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
112709 * Source/target buffer must be kernel space,
112710 * Do not walk the page table directly, use get_user_pages
112711 */
112712-int access_process_vm(struct task_struct *tsk, unsigned long addr,
112713- void *buf, int len, int write)
112714+ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
112715+ void *buf, size_t len, int write)
112716 {
112717 struct mm_struct *mm;
112718- int ret;
112719+ ssize_t ret;
112720
112721 mm = get_task_mm(tsk);
112722 if (!mm)
112723diff --git a/mm/mempolicy.c b/mm/mempolicy.c
112724index 99d4c1d..a577817 100644
112725--- a/mm/mempolicy.c
112726+++ b/mm/mempolicy.c
112727@@ -703,6 +703,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
112728 unsigned long vmstart;
112729 unsigned long vmend;
112730
112731+#ifdef CONFIG_PAX_SEGMEXEC
112732+ struct vm_area_struct *vma_m;
112733+#endif
112734+
112735 vma = find_vma(mm, start);
112736 if (!vma || vma->vm_start > start)
112737 return -EFAULT;
112738@@ -746,6 +750,16 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
112739 err = vma_replace_policy(vma, new_pol);
112740 if (err)
112741 goto out;
112742+
112743+#ifdef CONFIG_PAX_SEGMEXEC
112744+ vma_m = pax_find_mirror_vma(vma);
112745+ if (vma_m) {
112746+ err = vma_replace_policy(vma_m, new_pol);
112747+ if (err)
112748+ goto out;
112749+ }
112750+#endif
112751+
112752 }
112753
112754 out:
112755@@ -1161,6 +1175,17 @@ static long do_mbind(unsigned long start, unsigned long len,
112756
112757 if (end < start)
112758 return -EINVAL;
112759+
112760+#ifdef CONFIG_PAX_SEGMEXEC
112761+ if (mm->pax_flags & MF_PAX_SEGMEXEC) {
112762+ if (end > SEGMEXEC_TASK_SIZE)
112763+ return -EINVAL;
112764+ } else
112765+#endif
112766+
112767+ if (end > TASK_SIZE)
112768+ return -EINVAL;
112769+
112770 if (end == start)
112771 return 0;
112772
112773@@ -1386,8 +1411,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
112774 */
112775 tcred = __task_cred(task);
112776 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
112777- !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
112778- !capable(CAP_SYS_NICE)) {
112779+ !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
112780 rcu_read_unlock();
112781 err = -EPERM;
112782 goto out_put;
112783@@ -1418,6 +1442,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
112784 goto out;
112785 }
112786
112787+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
112788+ if (mm != current->mm &&
112789+ (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
112790+ mmput(mm);
112791+ err = -EPERM;
112792+ goto out;
112793+ }
112794+#endif
112795+
112796 err = do_migrate_pages(mm, old, new,
112797 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
112798
112799diff --git a/mm/migrate.c b/mm/migrate.c
112800index f53838f..a26fa94 100644
112801--- a/mm/migrate.c
112802+++ b/mm/migrate.c
112803@@ -1484,8 +1484,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
112804 */
112805 tcred = __task_cred(task);
112806 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
112807- !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
112808- !capable(CAP_SYS_NICE)) {
112809+ !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
112810 rcu_read_unlock();
112811 err = -EPERM;
112812 goto out;
112813diff --git a/mm/mlock.c b/mm/mlock.c
112814index 6fd2cf1..cbae765 100644
112815--- a/mm/mlock.c
112816+++ b/mm/mlock.c
112817@@ -14,6 +14,7 @@
112818 #include <linux/pagevec.h>
112819 #include <linux/mempolicy.h>
112820 #include <linux/syscalls.h>
112821+#include <linux/security.h>
112822 #include <linux/sched.h>
112823 #include <linux/export.h>
112824 #include <linux/rmap.h>
112825@@ -557,7 +558,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
112826 {
112827 unsigned long nstart, end, tmp;
112828 struct vm_area_struct * vma, * prev;
112829- int error;
112830+ int error = 0;
112831
112832 VM_BUG_ON(start & ~PAGE_MASK);
112833 VM_BUG_ON(len != PAGE_ALIGN(len));
112834@@ -566,6 +567,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
112835 return -EINVAL;
112836 if (end == start)
112837 return 0;
112838+ if (end > TASK_SIZE)
112839+ return -EINVAL;
112840+
112841 vma = find_vma(current->mm, start);
112842 if (!vma || vma->vm_start > start)
112843 return -ENOMEM;
112844@@ -577,6 +581,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
112845 for (nstart = start ; ; ) {
112846 vm_flags_t newflags;
112847
112848+#ifdef CONFIG_PAX_SEGMEXEC
112849+ if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
112850+ break;
112851+#endif
112852+
112853 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
112854
112855 newflags = vma->vm_flags & ~VM_LOCKED;
112856@@ -627,6 +636,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
112857 locked += current->mm->locked_vm;
112858
112859 /* check against resource limits */
112860+ gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
112861 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
112862 error = do_mlock(start, len, 1);
112863
112864@@ -668,6 +678,11 @@ static int do_mlockall(int flags)
112865 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
112866 vm_flags_t newflags;
112867
112868+#ifdef CONFIG_PAX_SEGMEXEC
112869+ if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
112870+ break;
112871+#endif
112872+
112873 newflags = vma->vm_flags & ~VM_LOCKED;
112874 if (flags & MCL_CURRENT)
112875 newflags |= VM_LOCKED;
112876@@ -699,8 +714,10 @@ SYSCALL_DEFINE1(mlockall, int, flags)
112877 lock_limit >>= PAGE_SHIFT;
112878
112879 ret = -ENOMEM;
112880+
112881+ gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
112882+
112883 down_write(&current->mm->mmap_sem);
112884-
112885 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
112886 capable(CAP_IPC_LOCK))
112887 ret = do_mlockall(flags);
112888diff --git a/mm/mm_init.c b/mm/mm_init.c
112889index 5f420f7..dd42fb1b 100644
112890--- a/mm/mm_init.c
112891+++ b/mm/mm_init.c
112892@@ -177,7 +177,7 @@ static int __meminit mm_compute_batch_notifier(struct notifier_block *self,
112893 return NOTIFY_OK;
112894 }
112895
112896-static struct notifier_block compute_batch_nb __meminitdata = {
112897+static struct notifier_block compute_batch_nb __meminitconst = {
112898 .notifier_call = mm_compute_batch_notifier,
112899 .priority = IPC_CALLBACK_PRI, /* use lowest priority */
112900 };
112901diff --git a/mm/mmap.c b/mm/mmap.c
112902index bb50cac..6d50a9f 100644
112903--- a/mm/mmap.c
112904+++ b/mm/mmap.c
112905@@ -41,6 +41,7 @@
112906 #include <linux/notifier.h>
112907 #include <linux/memory.h>
112908 #include <linux/printk.h>
112909+#include <linux/random.h>
112910
112911 #include <asm/uaccess.h>
112912 #include <asm/cacheflush.h>
112913@@ -57,6 +58,16 @@
112914 #define arch_rebalance_pgtables(addr, len) (addr)
112915 #endif
112916
112917+static inline void verify_mm_writelocked(struct mm_struct *mm)
112918+{
112919+#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
112920+ if (unlikely(down_read_trylock(&mm->mmap_sem))) {
112921+ up_read(&mm->mmap_sem);
112922+ BUG();
112923+ }
112924+#endif
112925+}
112926+
112927 static void unmap_region(struct mm_struct *mm,
112928 struct vm_area_struct *vma, struct vm_area_struct *prev,
112929 unsigned long start, unsigned long end);
112930@@ -76,16 +87,25 @@ static void unmap_region(struct mm_struct *mm,
112931 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
112932 *
112933 */
112934-pgprot_t protection_map[16] = {
112935+pgprot_t protection_map[16] __read_only = {
112936 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
112937 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
112938 };
112939
112940-pgprot_t vm_get_page_prot(unsigned long vm_flags)
112941+pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
112942 {
112943- return __pgprot(pgprot_val(protection_map[vm_flags &
112944+ pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
112945 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
112946 pgprot_val(arch_vm_get_page_prot(vm_flags)));
112947+
112948+#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
112949+ if (!(__supported_pte_mask & _PAGE_NX) &&
112950+ (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
112951+ (vm_flags & (VM_READ | VM_WRITE)))
112952+ prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
112953+#endif
112954+
112955+ return prot;
112956 }
112957 EXPORT_SYMBOL(vm_get_page_prot);
112958
112959@@ -114,6 +134,7 @@ unsigned long sysctl_overcommit_kbytes __read_mostly;
112960 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
112961 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
112962 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
112963+unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
112964 /*
112965 * Make sure vm_committed_as in one cacheline and not cacheline shared with
112966 * other variables. It can be updated by several CPUs frequently.
112967@@ -271,6 +292,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
112968 struct vm_area_struct *next = vma->vm_next;
112969
112970 might_sleep();
112971+ BUG_ON(vma->vm_mirror);
112972 if (vma->vm_ops && vma->vm_ops->close)
112973 vma->vm_ops->close(vma);
112974 if (vma->vm_file)
112975@@ -284,6 +306,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len);
112976
112977 SYSCALL_DEFINE1(brk, unsigned long, brk)
112978 {
112979+ unsigned long rlim;
112980 unsigned long retval;
112981 unsigned long newbrk, oldbrk;
112982 struct mm_struct *mm = current->mm;
112983@@ -314,7 +337,13 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
112984 * segment grow beyond its set limit the in case where the limit is
112985 * not page aligned -Ram Gupta
112986 */
112987- if (check_data_rlimit(rlimit(RLIMIT_DATA), brk, mm->start_brk,
112988+ rlim = rlimit(RLIMIT_DATA);
112989+#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
112990+ /* force a minimum 16MB brk heap on setuid/setgid binaries */
112991+ if (rlim < PAGE_SIZE && (get_dumpable(mm) != SUID_DUMP_USER) && gr_is_global_nonroot(current_uid()))
112992+ rlim = 4096 * PAGE_SIZE;
112993+#endif
112994+ if (check_data_rlimit(rlim, brk, mm->start_brk,
112995 mm->end_data, mm->start_data))
112996 goto out;
112997
112998@@ -967,6 +996,12 @@ static int
112999 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
113000 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
113001 {
113002+
113003+#ifdef CONFIG_PAX_SEGMEXEC
113004+ if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
113005+ return 0;
113006+#endif
113007+
113008 if (is_mergeable_vma(vma, file, vm_flags) &&
113009 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
113010 if (vma->vm_pgoff == vm_pgoff)
113011@@ -986,6 +1021,12 @@ static int
113012 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
113013 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
113014 {
113015+
113016+#ifdef CONFIG_PAX_SEGMEXEC
113017+ if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
113018+ return 0;
113019+#endif
113020+
113021 if (is_mergeable_vma(vma, file, vm_flags) &&
113022 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
113023 pgoff_t vm_pglen;
113024@@ -1035,6 +1076,13 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
113025 struct vm_area_struct *area, *next;
113026 int err;
113027
113028+#ifdef CONFIG_PAX_SEGMEXEC
113029+ unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
113030+ struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
113031+
113032+ BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
113033+#endif
113034+
113035 /*
113036 * We later require that vma->vm_flags == vm_flags,
113037 * so this tests vma->vm_flags & VM_SPECIAL, too.
113038@@ -1050,6 +1098,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
113039 if (next && next->vm_end == end) /* cases 6, 7, 8 */
113040 next = next->vm_next;
113041
113042+#ifdef CONFIG_PAX_SEGMEXEC
113043+ if (prev)
113044+ prev_m = pax_find_mirror_vma(prev);
113045+ if (area)
113046+ area_m = pax_find_mirror_vma(area);
113047+ if (next)
113048+ next_m = pax_find_mirror_vma(next);
113049+#endif
113050+
113051 /*
113052 * Can it merge with the predecessor?
113053 */
113054@@ -1069,9 +1126,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
113055 /* cases 1, 6 */
113056 err = vma_adjust(prev, prev->vm_start,
113057 next->vm_end, prev->vm_pgoff, NULL);
113058- } else /* cases 2, 5, 7 */
113059+
113060+#ifdef CONFIG_PAX_SEGMEXEC
113061+ if (!err && prev_m)
113062+ err = vma_adjust(prev_m, prev_m->vm_start,
113063+ next_m->vm_end, prev_m->vm_pgoff, NULL);
113064+#endif
113065+
113066+ } else { /* cases 2, 5, 7 */
113067 err = vma_adjust(prev, prev->vm_start,
113068 end, prev->vm_pgoff, NULL);
113069+
113070+#ifdef CONFIG_PAX_SEGMEXEC
113071+ if (!err && prev_m)
113072+ err = vma_adjust(prev_m, prev_m->vm_start,
113073+ end_m, prev_m->vm_pgoff, NULL);
113074+#endif
113075+
113076+ }
113077 if (err)
113078 return NULL;
113079 khugepaged_enter_vma_merge(prev, vm_flags);
113080@@ -1085,12 +1157,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
113081 mpol_equal(policy, vma_policy(next)) &&
113082 can_vma_merge_before(next, vm_flags,
113083 anon_vma, file, pgoff+pglen)) {
113084- if (prev && addr < prev->vm_end) /* case 4 */
113085+ if (prev && addr < prev->vm_end) { /* case 4 */
113086 err = vma_adjust(prev, prev->vm_start,
113087 addr, prev->vm_pgoff, NULL);
113088- else /* cases 3, 8 */
113089+
113090+#ifdef CONFIG_PAX_SEGMEXEC
113091+ if (!err && prev_m)
113092+ err = vma_adjust(prev_m, prev_m->vm_start,
113093+ addr_m, prev_m->vm_pgoff, NULL);
113094+#endif
113095+
113096+ } else { /* cases 3, 8 */
113097 err = vma_adjust(area, addr, next->vm_end,
113098 next->vm_pgoff - pglen, NULL);
113099+
113100+#ifdef CONFIG_PAX_SEGMEXEC
113101+ if (!err && area_m)
113102+ err = vma_adjust(area_m, addr_m, next_m->vm_end,
113103+ next_m->vm_pgoff - pglen, NULL);
113104+#endif
113105+
113106+ }
113107 if (err)
113108 return NULL;
113109 khugepaged_enter_vma_merge(area, vm_flags);
113110@@ -1199,8 +1286,10 @@ none:
113111 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
113112 struct file *file, long pages)
113113 {
113114- const unsigned long stack_flags
113115- = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
113116+
113117+#ifdef CONFIG_PAX_RANDMMAP
113118+ if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
113119+#endif
113120
113121 mm->total_vm += pages;
113122
113123@@ -1208,7 +1297,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
113124 mm->shared_vm += pages;
113125 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
113126 mm->exec_vm += pages;
113127- } else if (flags & stack_flags)
113128+ } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
113129 mm->stack_vm += pages;
113130 }
113131 #endif /* CONFIG_PROC_FS */
113132@@ -1238,6 +1327,7 @@ static inline int mlock_future_check(struct mm_struct *mm,
113133 locked += mm->locked_vm;
113134 lock_limit = rlimit(RLIMIT_MEMLOCK);
113135 lock_limit >>= PAGE_SHIFT;
113136+ gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
113137 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
113138 return -EAGAIN;
113139 }
113140@@ -1264,7 +1354,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
113141 * (the exception is when the underlying filesystem is noexec
113142 * mounted, in which case we dont add PROT_EXEC.)
113143 */
113144- if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
113145+ if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
113146 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
113147 prot |= PROT_EXEC;
113148
113149@@ -1290,7 +1380,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
113150 /* Obtain the address to map to. we verify (or select) it and ensure
113151 * that it represents a valid section of the address space.
113152 */
113153- addr = get_unmapped_area(file, addr, len, pgoff, flags);
113154+ addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
113155 if (addr & ~PAGE_MASK)
113156 return addr;
113157
113158@@ -1301,6 +1391,43 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
113159 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
113160 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
113161
113162+#ifdef CONFIG_PAX_MPROTECT
113163+ if (mm->pax_flags & MF_PAX_MPROTECT) {
113164+
113165+#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
113166+ if (file && !pgoff && (vm_flags & VM_EXEC) && mm->binfmt &&
113167+ mm->binfmt->handle_mmap)
113168+ mm->binfmt->handle_mmap(file);
113169+#endif
113170+
113171+#ifndef CONFIG_PAX_MPROTECT_COMPAT
113172+ if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
113173+ gr_log_rwxmmap(file);
113174+
113175+#ifdef CONFIG_PAX_EMUPLT
113176+ vm_flags &= ~VM_EXEC;
113177+#else
113178+ return -EPERM;
113179+#endif
113180+
113181+ }
113182+
113183+ if (!(vm_flags & VM_EXEC))
113184+ vm_flags &= ~VM_MAYEXEC;
113185+#else
113186+ if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
113187+ vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
113188+#endif
113189+ else
113190+ vm_flags &= ~VM_MAYWRITE;
113191+ }
113192+#endif
113193+
113194+#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
113195+ if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
113196+ vm_flags &= ~VM_PAGEEXEC;
113197+#endif
113198+
113199 if (flags & MAP_LOCKED)
113200 if (!can_do_mlock())
113201 return -EPERM;
113202@@ -1388,6 +1515,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
113203 vm_flags |= VM_NORESERVE;
113204 }
113205
113206+ if (!gr_acl_handle_mmap(file, prot))
113207+ return -EACCES;
113208+
113209 addr = mmap_region(file, addr, len, vm_flags, pgoff);
113210 if (!IS_ERR_VALUE(addr) &&
113211 ((vm_flags & VM_LOCKED) ||
113212@@ -1481,7 +1611,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
113213 vm_flags_t vm_flags = vma->vm_flags;
113214
113215 /* If it was private or non-writable, the write bit is already clear */
113216- if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
113217+ if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
113218 return 0;
113219
113220 /* The backer wishes to know when pages are first written to? */
113221@@ -1532,7 +1662,22 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
113222 struct rb_node **rb_link, *rb_parent;
113223 unsigned long charged = 0;
113224
113225+#ifdef CONFIG_PAX_SEGMEXEC
113226+ struct vm_area_struct *vma_m = NULL;
113227+#endif
113228+
113229+ /*
113230+ * mm->mmap_sem is required to protect against another thread
113231+ * changing the mappings in case we sleep.
113232+ */
113233+ verify_mm_writelocked(mm);
113234+
113235 /* Check against address space limit. */
113236+
113237+#ifdef CONFIG_PAX_RANDMMAP
113238+ if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
113239+#endif
113240+
113241 if (!may_expand_vm(mm, len >> PAGE_SHIFT)) {
113242 unsigned long nr_pages;
113243
113244@@ -1555,6 +1700,7 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
113245 &rb_parent)) {
113246 if (do_munmap(mm, addr, len))
113247 return -ENOMEM;
113248+ BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
113249 }
113250
113251 /*
113252@@ -1586,6 +1732,16 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
113253 goto unacct_error;
113254 }
113255
113256+#ifdef CONFIG_PAX_SEGMEXEC
113257+ if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
113258+ vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
113259+ if (!vma_m) {
113260+ error = -ENOMEM;
113261+ goto free_vma;
113262+ }
113263+ }
113264+#endif
113265+
113266 vma->vm_mm = mm;
113267 vma->vm_start = addr;
113268 vma->vm_end = addr + len;
113269@@ -1616,6 +1772,13 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
113270 if (error)
113271 goto unmap_and_free_vma;
113272
113273+#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
113274+ if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
113275+ vma->vm_flags |= VM_PAGEEXEC;
113276+ vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
113277+ }
113278+#endif
113279+
113280 /* Can addr have changed??
113281 *
113282 * Answer: Yes, several device drivers can do it in their
113283@@ -1634,6 +1797,12 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
113284 }
113285
113286 vma_link(mm, vma, prev, rb_link, rb_parent);
113287+
113288+#ifdef CONFIG_PAX_SEGMEXEC
113289+ if (vma_m)
113290+ BUG_ON(pax_mirror_vma(vma_m, vma));
113291+#endif
113292+
113293 /* Once vma denies write, undo our temporary denial count */
113294 if (file) {
113295 if (vm_flags & VM_SHARED)
113296@@ -1646,6 +1815,7 @@ out:
113297 perf_event_mmap(vma);
113298
113299 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
113300+ track_exec_limit(mm, addr, addr + len, vm_flags);
113301 if (vm_flags & VM_LOCKED) {
113302 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
113303 vma == get_gate_vma(current->mm)))
113304@@ -1683,6 +1853,12 @@ allow_write_and_free_vma:
113305 if (vm_flags & VM_DENYWRITE)
113306 allow_write_access(file);
113307 free_vma:
113308+
113309+#ifdef CONFIG_PAX_SEGMEXEC
113310+ if (vma_m)
113311+ kmem_cache_free(vm_area_cachep, vma_m);
113312+#endif
113313+
113314 kmem_cache_free(vm_area_cachep, vma);
113315 unacct_error:
113316 if (charged)
113317@@ -1690,7 +1866,63 @@ unacct_error:
113318 return error;
113319 }
113320
113321-unsigned long unmapped_area(struct vm_unmapped_area_info *info)
113322+#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
113323+unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
113324+{
113325+ if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
113326+ return ((prandom_u32() & 0xFF) + 1) << PAGE_SHIFT;
113327+
113328+ return 0;
113329+}
113330+#endif
113331+
113332+bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
113333+{
113334+ if (!vma) {
113335+#ifdef CONFIG_STACK_GROWSUP
113336+ if (addr > sysctl_heap_stack_gap)
113337+ vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
113338+ else
113339+ vma = find_vma(current->mm, 0);
113340+ if (vma && (vma->vm_flags & VM_GROWSUP))
113341+ return false;
113342+#endif
113343+ return true;
113344+ }
113345+
113346+ if (addr + len > vma->vm_start)
113347+ return false;
113348+
113349+ if (vma->vm_flags & VM_GROWSDOWN)
113350+ return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
113351+#ifdef CONFIG_STACK_GROWSUP
113352+ else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
113353+ return addr - vma->vm_prev->vm_end >= sysctl_heap_stack_gap;
113354+#endif
113355+ else if (offset)
113356+ return offset <= vma->vm_start - addr - len;
113357+
113358+ return true;
113359+}
113360+
113361+unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
113362+{
113363+ if (vma->vm_start < len)
113364+ return -ENOMEM;
113365+
113366+ if (!(vma->vm_flags & VM_GROWSDOWN)) {
113367+ if (offset <= vma->vm_start - len)
113368+ return vma->vm_start - len - offset;
113369+ else
113370+ return -ENOMEM;
113371+ }
113372+
113373+ if (sysctl_heap_stack_gap <= vma->vm_start - len)
113374+ return vma->vm_start - len - sysctl_heap_stack_gap;
113375+ return -ENOMEM;
113376+}
113377+
113378+unsigned long unmapped_area(const struct vm_unmapped_area_info *info)
113379 {
113380 /*
113381 * We implement the search by looking for an rbtree node that
113382@@ -1738,11 +1970,29 @@ unsigned long unmapped_area(struct vm_unmapped_area_info *info)
113383 }
113384 }
113385
113386- gap_start = vma->vm_prev ? vma->vm_prev->vm_end : 0;
113387+ gap_start = vma->vm_prev ? vma->vm_prev->vm_end: 0;
113388 check_current:
113389 /* Check if current node has a suitable gap */
113390 if (gap_start > high_limit)
113391 return -ENOMEM;
113392+
113393+ if (gap_end - gap_start > info->threadstack_offset)
113394+ gap_start += info->threadstack_offset;
113395+ else
113396+ gap_start = gap_end;
113397+
113398+ if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
113399+ if (gap_end - gap_start > sysctl_heap_stack_gap)
113400+ gap_start += sysctl_heap_stack_gap;
113401+ else
113402+ gap_start = gap_end;
113403+ }
113404+ if (vma->vm_flags & VM_GROWSDOWN) {
113405+ if (gap_end - gap_start > sysctl_heap_stack_gap)
113406+ gap_end -= sysctl_heap_stack_gap;
113407+ else
113408+ gap_end = gap_start;
113409+ }
113410 if (gap_end >= low_limit && gap_end - gap_start >= length)
113411 goto found;
113412
113413@@ -1792,7 +2042,7 @@ found:
113414 return gap_start;
113415 }
113416
113417-unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
113418+unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info)
113419 {
113420 struct mm_struct *mm = current->mm;
113421 struct vm_area_struct *vma;
113422@@ -1846,6 +2096,24 @@ check_current:
113423 gap_end = vma->vm_start;
113424 if (gap_end < low_limit)
113425 return -ENOMEM;
113426+
113427+ if (gap_end - gap_start > info->threadstack_offset)
113428+ gap_end -= info->threadstack_offset;
113429+ else
113430+ gap_end = gap_start;
113431+
113432+ if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
113433+ if (gap_end - gap_start > sysctl_heap_stack_gap)
113434+ gap_start += sysctl_heap_stack_gap;
113435+ else
113436+ gap_start = gap_end;
113437+ }
113438+ if (vma->vm_flags & VM_GROWSDOWN) {
113439+ if (gap_end - gap_start > sysctl_heap_stack_gap)
113440+ gap_end -= sysctl_heap_stack_gap;
113441+ else
113442+ gap_end = gap_start;
113443+ }
113444 if (gap_start <= high_limit && gap_end - gap_start >= length)
113445 goto found;
113446
113447@@ -1909,6 +2177,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
113448 struct mm_struct *mm = current->mm;
113449 struct vm_area_struct *vma;
113450 struct vm_unmapped_area_info info;
113451+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
113452
113453 if (len > TASK_SIZE - mmap_min_addr)
113454 return -ENOMEM;
113455@@ -1916,11 +2185,15 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
113456 if (flags & MAP_FIXED)
113457 return addr;
113458
113459+#ifdef CONFIG_PAX_RANDMMAP
113460+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
113461+#endif
113462+
113463 if (addr) {
113464 addr = PAGE_ALIGN(addr);
113465 vma = find_vma(mm, addr);
113466 if (TASK_SIZE - len >= addr && addr >= mmap_min_addr &&
113467- (!vma || addr + len <= vma->vm_start))
113468+ check_heap_stack_gap(vma, addr, len, offset))
113469 return addr;
113470 }
113471
113472@@ -1929,6 +2202,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
113473 info.low_limit = mm->mmap_base;
113474 info.high_limit = TASK_SIZE;
113475 info.align_mask = 0;
113476+ info.threadstack_offset = offset;
113477 return vm_unmapped_area(&info);
113478 }
113479 #endif
113480@@ -1947,6 +2221,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
113481 struct mm_struct *mm = current->mm;
113482 unsigned long addr = addr0;
113483 struct vm_unmapped_area_info info;
113484+ unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
113485
113486 /* requested length too big for entire address space */
113487 if (len > TASK_SIZE - mmap_min_addr)
113488@@ -1955,12 +2230,16 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
113489 if (flags & MAP_FIXED)
113490 return addr;
113491
113492+#ifdef CONFIG_PAX_RANDMMAP
113493+ if (!(mm->pax_flags & MF_PAX_RANDMMAP))
113494+#endif
113495+
113496 /* requesting a specific address */
113497 if (addr) {
113498 addr = PAGE_ALIGN(addr);
113499 vma = find_vma(mm, addr);
113500 if (TASK_SIZE - len >= addr && addr >= mmap_min_addr &&
113501- (!vma || addr + len <= vma->vm_start))
113502+ check_heap_stack_gap(vma, addr, len, offset))
113503 return addr;
113504 }
113505
113506@@ -1969,6 +2248,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
113507 info.low_limit = max(PAGE_SIZE, mmap_min_addr);
113508 info.high_limit = mm->mmap_base;
113509 info.align_mask = 0;
113510+ info.threadstack_offset = offset;
113511 addr = vm_unmapped_area(&info);
113512
113513 /*
113514@@ -1981,6 +2261,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
113515 VM_BUG_ON(addr != -ENOMEM);
113516 info.flags = 0;
113517 info.low_limit = TASK_UNMAPPED_BASE;
113518+
113519+#ifdef CONFIG_PAX_RANDMMAP
113520+ if (mm->pax_flags & MF_PAX_RANDMMAP)
113521+ info.low_limit += mm->delta_mmap;
113522+#endif
113523+
113524 info.high_limit = TASK_SIZE;
113525 addr = vm_unmapped_area(&info);
113526 }
113527@@ -2081,6 +2367,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
113528 return vma;
113529 }
113530
113531+#ifdef CONFIG_PAX_SEGMEXEC
113532+struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
113533+{
113534+ struct vm_area_struct *vma_m;
113535+
113536+ BUG_ON(!vma || vma->vm_start >= vma->vm_end);
113537+ if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
113538+ BUG_ON(vma->vm_mirror);
113539+ return NULL;
113540+ }
113541+ BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
113542+ vma_m = vma->vm_mirror;
113543+ BUG_ON(!vma_m || vma_m->vm_mirror != vma);
113544+ BUG_ON(vma->vm_file != vma_m->vm_file);
113545+ BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
113546+ BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
113547+ BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
113548+ BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
113549+ return vma_m;
113550+}
113551+#endif
113552+
113553 /*
113554 * Verify that the stack growth is acceptable and
113555 * update accounting. This is shared with both the
113556@@ -2098,8 +2406,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
113557
113558 /* Stack limit test */
113559 actual_size = size;
113560- if (size && (vma->vm_flags & (VM_GROWSUP | VM_GROWSDOWN)))
113561- actual_size -= PAGE_SIZE;
113562+ gr_learn_resource(current, RLIMIT_STACK, actual_size, 1);
113563 if (actual_size > READ_ONCE(rlim[RLIMIT_STACK].rlim_cur))
113564 return -ENOMEM;
113565
113566@@ -2110,6 +2417,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
113567 locked = mm->locked_vm + grow;
113568 limit = READ_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
113569 limit >>= PAGE_SHIFT;
113570+ gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
113571 if (locked > limit && !capable(CAP_IPC_LOCK))
113572 return -ENOMEM;
113573 }
113574@@ -2139,37 +2447,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
113575 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
113576 * vma is the last one with address > vma->vm_end. Have to extend vma.
113577 */
113578+#ifndef CONFIG_IA64
113579+static
113580+#endif
113581 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
113582 {
113583 int error;
113584+ bool locknext;
113585
113586 if (!(vma->vm_flags & VM_GROWSUP))
113587 return -EFAULT;
113588
113589+ /* Also guard against wrapping around to address 0. */
113590+ if (address < PAGE_ALIGN(address+1))
113591+ address = PAGE_ALIGN(address+1);
113592+ else
113593+ return -ENOMEM;
113594+
113595 /*
113596 * We must make sure the anon_vma is allocated
113597 * so that the anon_vma locking is not a noop.
113598 */
113599 if (unlikely(anon_vma_prepare(vma)))
113600 return -ENOMEM;
113601+ locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
113602+ if (locknext && anon_vma_prepare(vma->vm_next))
113603+ return -ENOMEM;
113604 vma_lock_anon_vma(vma);
113605+ if (locknext)
113606+ vma_lock_anon_vma(vma->vm_next);
113607
113608 /*
113609 * vma->vm_start/vm_end cannot change under us because the caller
113610 * is required to hold the mmap_sem in read mode. We need the
113611- * anon_vma lock to serialize against concurrent expand_stacks.
113612- * Also guard against wrapping around to address 0.
113613+ * anon_vma locks to serialize against concurrent expand_stacks
113614+ * and expand_upwards.
113615 */
113616- if (address < PAGE_ALIGN(address+4))
113617- address = PAGE_ALIGN(address+4);
113618- else {
113619- vma_unlock_anon_vma(vma);
113620- return -ENOMEM;
113621- }
113622 error = 0;
113623
113624 /* Somebody else might have raced and expanded it already */
113625- if (address > vma->vm_end) {
113626+ 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)
113627+ error = -ENOMEM;
113628+ else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
113629 unsigned long size, grow;
113630
113631 size = address - vma->vm_start;
113632@@ -2204,6 +2523,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
113633 }
113634 }
113635 }
113636+ if (locknext)
113637+ vma_unlock_anon_vma(vma->vm_next);
113638 vma_unlock_anon_vma(vma);
113639 khugepaged_enter_vma_merge(vma, vma->vm_flags);
113640 validate_mm(vma->vm_mm);
113641@@ -2218,6 +2539,8 @@ int expand_downwards(struct vm_area_struct *vma,
113642 unsigned long address)
113643 {
113644 int error;
113645+ bool lockprev = false;
113646+ struct vm_area_struct *prev;
113647
113648 /*
113649 * We must make sure the anon_vma is allocated
113650@@ -2231,6 +2554,15 @@ int expand_downwards(struct vm_area_struct *vma,
113651 if (error)
113652 return error;
113653
113654+ prev = vma->vm_prev;
113655+#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
113656+ lockprev = prev && (prev->vm_flags & VM_GROWSUP);
113657+#endif
113658+ if (lockprev && anon_vma_prepare(prev))
113659+ return -ENOMEM;
113660+ if (lockprev)
113661+ vma_lock_anon_vma(prev);
113662+
113663 vma_lock_anon_vma(vma);
113664
113665 /*
113666@@ -2240,9 +2572,17 @@ int expand_downwards(struct vm_area_struct *vma,
113667 */
113668
113669 /* Somebody else might have raced and expanded it already */
113670- if (address < vma->vm_start) {
113671+ if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
113672+ error = -ENOMEM;
113673+ else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
113674 unsigned long size, grow;
113675
113676+#ifdef CONFIG_PAX_SEGMEXEC
113677+ struct vm_area_struct *vma_m;
113678+
113679+ vma_m = pax_find_mirror_vma(vma);
113680+#endif
113681+
113682 size = vma->vm_end - address;
113683 grow = (vma->vm_start - address) >> PAGE_SHIFT;
113684
113685@@ -2267,13 +2607,27 @@ int expand_downwards(struct vm_area_struct *vma,
113686 vma->vm_pgoff -= grow;
113687 anon_vma_interval_tree_post_update_vma(vma);
113688 vma_gap_update(vma);
113689+
113690+#ifdef CONFIG_PAX_SEGMEXEC
113691+ if (vma_m) {
113692+ anon_vma_interval_tree_pre_update_vma(vma_m);
113693+ vma_m->vm_start -= grow << PAGE_SHIFT;
113694+ vma_m->vm_pgoff -= grow;
113695+ anon_vma_interval_tree_post_update_vma(vma_m);
113696+ vma_gap_update(vma_m);
113697+ }
113698+#endif
113699+
113700 spin_unlock(&vma->vm_mm->page_table_lock);
113701
113702+ track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
113703 perf_event_mmap(vma);
113704 }
113705 }
113706 }
113707 vma_unlock_anon_vma(vma);
113708+ if (lockprev)
113709+ vma_unlock_anon_vma(prev);
113710 khugepaged_enter_vma_merge(vma, vma->vm_flags);
113711 validate_mm(vma->vm_mm);
113712 return error;
113713@@ -2373,6 +2727,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
113714 do {
113715 long nrpages = vma_pages(vma);
113716
113717+#ifdef CONFIG_PAX_SEGMEXEC
113718+ if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
113719+ vma = remove_vma(vma);
113720+ continue;
113721+ }
113722+#endif
113723+
113724 if (vma->vm_flags & VM_ACCOUNT)
113725 nr_accounted += nrpages;
113726 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
113727@@ -2417,6 +2778,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
113728 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
113729 vma->vm_prev = NULL;
113730 do {
113731+
113732+#ifdef CONFIG_PAX_SEGMEXEC
113733+ if (vma->vm_mirror) {
113734+ BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
113735+ vma->vm_mirror->vm_mirror = NULL;
113736+ vma->vm_mirror->vm_flags &= ~VM_EXEC;
113737+ vma->vm_mirror = NULL;
113738+ }
113739+#endif
113740+
113741 vma_rb_erase(vma, &mm->mm_rb);
113742 mm->map_count--;
113743 tail_vma = vma;
113744@@ -2444,14 +2815,33 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
113745 struct vm_area_struct *new;
113746 int err = -ENOMEM;
113747
113748+#ifdef CONFIG_PAX_SEGMEXEC
113749+ struct vm_area_struct *vma_m, *new_m = NULL;
113750+ unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
113751+#endif
113752+
113753 if (is_vm_hugetlb_page(vma) && (addr &
113754 ~(huge_page_mask(hstate_vma(vma)))))
113755 return -EINVAL;
113756
113757+#ifdef CONFIG_PAX_SEGMEXEC
113758+ vma_m = pax_find_mirror_vma(vma);
113759+#endif
113760+
113761 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
113762 if (!new)
113763 goto out_err;
113764
113765+#ifdef CONFIG_PAX_SEGMEXEC
113766+ if (vma_m) {
113767+ new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
113768+ if (!new_m) {
113769+ kmem_cache_free(vm_area_cachep, new);
113770+ goto out_err;
113771+ }
113772+ }
113773+#endif
113774+
113775 /* most fields are the same, copy all, and then fixup */
113776 *new = *vma;
113777
113778@@ -2464,6 +2854,22 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
113779 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
113780 }
113781
113782+#ifdef CONFIG_PAX_SEGMEXEC
113783+ if (vma_m) {
113784+ *new_m = *vma_m;
113785+ INIT_LIST_HEAD(&new_m->anon_vma_chain);
113786+ new_m->vm_mirror = new;
113787+ new->vm_mirror = new_m;
113788+
113789+ if (new_below)
113790+ new_m->vm_end = addr_m;
113791+ else {
113792+ new_m->vm_start = addr_m;
113793+ new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
113794+ }
113795+ }
113796+#endif
113797+
113798 err = vma_dup_policy(vma, new);
113799 if (err)
113800 goto out_free_vma;
113801@@ -2484,6 +2890,38 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
113802 else
113803 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
113804
113805+#ifdef CONFIG_PAX_SEGMEXEC
113806+ if (!err && vma_m) {
113807+ struct mempolicy *pol = vma_policy(new);
113808+
113809+ if (anon_vma_clone(new_m, vma_m))
113810+ goto out_free_mpol;
113811+
113812+ mpol_get(pol);
113813+ set_vma_policy(new_m, pol);
113814+
113815+ if (new_m->vm_file)
113816+ get_file(new_m->vm_file);
113817+
113818+ if (new_m->vm_ops && new_m->vm_ops->open)
113819+ new_m->vm_ops->open(new_m);
113820+
113821+ if (new_below)
113822+ err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
113823+ ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
113824+ else
113825+ err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
113826+
113827+ if (err) {
113828+ if (new_m->vm_ops && new_m->vm_ops->close)
113829+ new_m->vm_ops->close(new_m);
113830+ if (new_m->vm_file)
113831+ fput(new_m->vm_file);
113832+ mpol_put(pol);
113833+ }
113834+ }
113835+#endif
113836+
113837 /* Success. */
113838 if (!err)
113839 return 0;
113840@@ -2493,10 +2931,18 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
113841 new->vm_ops->close(new);
113842 if (new->vm_file)
113843 fput(new->vm_file);
113844- unlink_anon_vmas(new);
113845 out_free_mpol:
113846 mpol_put(vma_policy(new));
113847 out_free_vma:
113848+
113849+#ifdef CONFIG_PAX_SEGMEXEC
113850+ if (new_m) {
113851+ unlink_anon_vmas(new_m);
113852+ kmem_cache_free(vm_area_cachep, new_m);
113853+ }
113854+#endif
113855+
113856+ unlink_anon_vmas(new);
113857 kmem_cache_free(vm_area_cachep, new);
113858 out_err:
113859 return err;
113860@@ -2509,6 +2955,15 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
113861 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
113862 unsigned long addr, int new_below)
113863 {
113864+
113865+#ifdef CONFIG_PAX_SEGMEXEC
113866+ if (mm->pax_flags & MF_PAX_SEGMEXEC) {
113867+ BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
113868+ if (mm->map_count >= sysctl_max_map_count-1)
113869+ return -ENOMEM;
113870+ } else
113871+#endif
113872+
113873 if (mm->map_count >= sysctl_max_map_count)
113874 return -ENOMEM;
113875
113876@@ -2520,11 +2975,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
113877 * work. This now handles partial unmappings.
113878 * Jeremy Fitzhardinge <jeremy@goop.org>
113879 */
113880+#ifdef CONFIG_PAX_SEGMEXEC
113881 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
113882 {
113883+ int ret = __do_munmap(mm, start, len);
113884+ if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
113885+ return ret;
113886+
113887+ return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
113888+}
113889+
113890+int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
113891+#else
113892+int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
113893+#endif
113894+{
113895 unsigned long end;
113896 struct vm_area_struct *vma, *prev, *last;
113897
113898+ /*
113899+ * mm->mmap_sem is required to protect against another thread
113900+ * changing the mappings in case we sleep.
113901+ */
113902+ verify_mm_writelocked(mm);
113903+
113904 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
113905 return -EINVAL;
113906
113907@@ -2602,6 +3076,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
113908 /* Fix up all other VM information */
113909 remove_vma_list(mm, vma);
113910
113911+ track_exec_limit(mm, start, end, 0UL);
113912+
113913 return 0;
113914 }
113915
113916@@ -2610,6 +3086,13 @@ int vm_munmap(unsigned long start, size_t len)
113917 int ret;
113918 struct mm_struct *mm = current->mm;
113919
113920+
113921+#ifdef CONFIG_PAX_SEGMEXEC
113922+ if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
113923+ (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
113924+ return -EINVAL;
113925+#endif
113926+
113927 down_write(&mm->mmap_sem);
113928 ret = do_munmap(mm, start, len);
113929 up_write(&mm->mmap_sem);
113930@@ -2656,6 +3139,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
113931 down_write(&mm->mmap_sem);
113932 vma = find_vma(mm, start);
113933
113934+#ifdef CONFIG_PAX_SEGMEXEC
113935+ if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
113936+ goto out;
113937+#endif
113938+
113939 if (!vma || !(vma->vm_flags & VM_SHARED))
113940 goto out;
113941
113942@@ -2692,16 +3180,6 @@ out:
113943 return ret;
113944 }
113945
113946-static inline void verify_mm_writelocked(struct mm_struct *mm)
113947-{
113948-#ifdef CONFIG_DEBUG_VM
113949- if (unlikely(down_read_trylock(&mm->mmap_sem))) {
113950- WARN_ON(1);
113951- up_read(&mm->mmap_sem);
113952- }
113953-#endif
113954-}
113955-
113956 /*
113957 * this is really a simplified "do_mmap". it only handles
113958 * anonymous maps. eventually we may be able to do some
113959@@ -2715,6 +3193,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
113960 struct rb_node **rb_link, *rb_parent;
113961 pgoff_t pgoff = addr >> PAGE_SHIFT;
113962 int error;
113963+ unsigned long charged;
113964
113965 len = PAGE_ALIGN(len);
113966 if (!len)
113967@@ -2722,10 +3201,24 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
113968
113969 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
113970
113971+#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
113972+ if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
113973+ flags &= ~VM_EXEC;
113974+
113975+#ifdef CONFIG_PAX_MPROTECT
113976+ if (mm->pax_flags & MF_PAX_MPROTECT)
113977+ flags &= ~VM_MAYEXEC;
113978+#endif
113979+
113980+ }
113981+#endif
113982+
113983 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
113984 if (error & ~PAGE_MASK)
113985 return error;
113986
113987+ charged = len >> PAGE_SHIFT;
113988+
113989 error = mlock_future_check(mm, mm->def_flags, len);
113990 if (error)
113991 return error;
113992@@ -2743,16 +3236,17 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
113993 &rb_parent)) {
113994 if (do_munmap(mm, addr, len))
113995 return -ENOMEM;
113996+ BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
113997 }
113998
113999 /* Check against address space limits *after* clearing old maps... */
114000- if (!may_expand_vm(mm, len >> PAGE_SHIFT))
114001+ if (!may_expand_vm(mm, charged))
114002 return -ENOMEM;
114003
114004 if (mm->map_count > sysctl_max_map_count)
114005 return -ENOMEM;
114006
114007- if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
114008+ if (security_vm_enough_memory_mm(mm, charged))
114009 return -ENOMEM;
114010
114011 /* Can we just expand an old private anonymous mapping? */
114012@@ -2766,7 +3260,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
114013 */
114014 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
114015 if (!vma) {
114016- vm_unacct_memory(len >> PAGE_SHIFT);
114017+ vm_unacct_memory(charged);
114018 return -ENOMEM;
114019 }
114020
114021@@ -2780,10 +3274,11 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
114022 vma_link(mm, vma, prev, rb_link, rb_parent);
114023 out:
114024 perf_event_mmap(vma);
114025- mm->total_vm += len >> PAGE_SHIFT;
114026+ mm->total_vm += charged;
114027 if (flags & VM_LOCKED)
114028- mm->locked_vm += (len >> PAGE_SHIFT);
114029+ mm->locked_vm += charged;
114030 vma->vm_flags |= VM_SOFTDIRTY;
114031+ track_exec_limit(mm, addr, addr + len, flags);
114032 return addr;
114033 }
114034
114035@@ -2845,6 +3340,7 @@ void exit_mmap(struct mm_struct *mm)
114036 while (vma) {
114037 if (vma->vm_flags & VM_ACCOUNT)
114038 nr_accounted += vma_pages(vma);
114039+ vma->vm_mirror = NULL;
114040 vma = remove_vma(vma);
114041 }
114042 vm_unacct_memory(nr_accounted);
114043@@ -2859,6 +3355,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
114044 struct vm_area_struct *prev;
114045 struct rb_node **rb_link, *rb_parent;
114046
114047+#ifdef CONFIG_PAX_SEGMEXEC
114048+ struct vm_area_struct *vma_m = NULL;
114049+#endif
114050+
114051+ if (security_mmap_addr(vma->vm_start))
114052+ return -EPERM;
114053+
114054 /*
114055 * The vm_pgoff of a purely anonymous vma should be irrelevant
114056 * until its first write fault, when page's anon_vma and index
114057@@ -2882,7 +3385,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
114058 security_vm_enough_memory_mm(mm, vma_pages(vma)))
114059 return -ENOMEM;
114060
114061+#ifdef CONFIG_PAX_SEGMEXEC
114062+ if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
114063+ vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
114064+ if (!vma_m)
114065+ return -ENOMEM;
114066+ }
114067+#endif
114068+
114069 vma_link(mm, vma, prev, rb_link, rb_parent);
114070+
114071+#ifdef CONFIG_PAX_SEGMEXEC
114072+ if (vma_m)
114073+ BUG_ON(pax_mirror_vma(vma_m, vma));
114074+#endif
114075+
114076 return 0;
114077 }
114078
114079@@ -2901,6 +3418,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
114080 struct rb_node **rb_link, *rb_parent;
114081 bool faulted_in_anon_vma = true;
114082
114083+ BUG_ON(vma->vm_mirror);
114084+
114085 /*
114086 * If anonymous vma has not yet been faulted, update new pgoff
114087 * to match new location, to increase its chance of merging.
114088@@ -2965,6 +3484,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
114089 return NULL;
114090 }
114091
114092+#ifdef CONFIG_PAX_SEGMEXEC
114093+long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
114094+{
114095+ struct vm_area_struct *prev_m;
114096+ struct rb_node **rb_link_m, *rb_parent_m;
114097+ struct mempolicy *pol_m;
114098+
114099+ BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
114100+ BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
114101+ BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
114102+ *vma_m = *vma;
114103+ INIT_LIST_HEAD(&vma_m->anon_vma_chain);
114104+ if (anon_vma_clone(vma_m, vma))
114105+ return -ENOMEM;
114106+ pol_m = vma_policy(vma_m);
114107+ mpol_get(pol_m);
114108+ set_vma_policy(vma_m, pol_m);
114109+ vma_m->vm_start += SEGMEXEC_TASK_SIZE;
114110+ vma_m->vm_end += SEGMEXEC_TASK_SIZE;
114111+ vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
114112+ vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
114113+ if (vma_m->vm_file)
114114+ get_file(vma_m->vm_file);
114115+ if (vma_m->vm_ops && vma_m->vm_ops->open)
114116+ vma_m->vm_ops->open(vma_m);
114117+ BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
114118+ vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
114119+ vma_m->vm_mirror = vma;
114120+ vma->vm_mirror = vma_m;
114121+ return 0;
114122+}
114123+#endif
114124+
114125 /*
114126 * Return true if the calling process may expand its vm space by the passed
114127 * number of pages
114128@@ -2976,6 +3528,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
114129
114130 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
114131
114132+ gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
114133 if (cur + npages > lim)
114134 return 0;
114135 return 1;
114136@@ -3058,6 +3611,22 @@ static struct vm_area_struct *__install_special_mapping(
114137 vma->vm_start = addr;
114138 vma->vm_end = addr + len;
114139
114140+#ifdef CONFIG_PAX_MPROTECT
114141+ if (mm->pax_flags & MF_PAX_MPROTECT) {
114142+#ifndef CONFIG_PAX_MPROTECT_COMPAT
114143+ if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
114144+ return ERR_PTR(-EPERM);
114145+ if (!(vm_flags & VM_EXEC))
114146+ vm_flags &= ~VM_MAYEXEC;
114147+#else
114148+ if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
114149+ vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
114150+#endif
114151+ else
114152+ vm_flags &= ~VM_MAYWRITE;
114153+ }
114154+#endif
114155+
114156 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND | VM_SOFTDIRTY;
114157 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
114158
114159diff --git a/mm/mprotect.c b/mm/mprotect.c
114160index 8858483..72f2464 100644
114161--- a/mm/mprotect.c
114162+++ b/mm/mprotect.c
114163@@ -24,10 +24,18 @@
114164 #include <linux/migrate.h>
114165 #include <linux/perf_event.h>
114166 #include <linux/ksm.h>
114167+#include <linux/sched/sysctl.h>
114168+
114169+#ifdef CONFIG_PAX_MPROTECT
114170+#include <linux/elf.h>
114171+#include <linux/binfmts.h>
114172+#endif
114173+
114174 #include <asm/uaccess.h>
114175 #include <asm/pgtable.h>
114176 #include <asm/cacheflush.h>
114177 #include <asm/tlbflush.h>
114178+#include <asm/mmu_context.h>
114179
114180 /*
114181 * For a prot_numa update we only hold mmap_sem for read so there is a
114182@@ -252,6 +260,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
114183 return pages;
114184 }
114185
114186+#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
114187+/* called while holding the mmap semaphor for writing except stack expansion */
114188+void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
114189+{
114190+ unsigned long oldlimit, newlimit = 0UL;
114191+
114192+ if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
114193+ return;
114194+
114195+ spin_lock(&mm->page_table_lock);
114196+ oldlimit = mm->context.user_cs_limit;
114197+ if ((prot & VM_EXEC) && oldlimit < end)
114198+ /* USER_CS limit moved up */
114199+ newlimit = end;
114200+ else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
114201+ /* USER_CS limit moved down */
114202+ newlimit = start;
114203+
114204+ if (newlimit) {
114205+ mm->context.user_cs_limit = newlimit;
114206+
114207+#ifdef CONFIG_SMP
114208+ wmb();
114209+ cpumask_clear(&mm->context.cpu_user_cs_mask);
114210+ cpumask_set_cpu(smp_processor_id(), &mm->context.cpu_user_cs_mask);
114211+#endif
114212+
114213+ set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
114214+ }
114215+ spin_unlock(&mm->page_table_lock);
114216+ if (newlimit == end) {
114217+ struct vm_area_struct *vma = find_vma(mm, oldlimit);
114218+
114219+ for (; vma && vma->vm_start < end; vma = vma->vm_next)
114220+ if (is_vm_hugetlb_page(vma))
114221+ hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
114222+ else
114223+ change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
114224+ }
114225+}
114226+#endif
114227+
114228 int
114229 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
114230 unsigned long start, unsigned long end, unsigned long newflags)
114231@@ -264,11 +314,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
114232 int error;
114233 int dirty_accountable = 0;
114234
114235+#ifdef CONFIG_PAX_SEGMEXEC
114236+ struct vm_area_struct *vma_m = NULL;
114237+ unsigned long start_m, end_m;
114238+
114239+ start_m = start + SEGMEXEC_TASK_SIZE;
114240+ end_m = end + SEGMEXEC_TASK_SIZE;
114241+#endif
114242+
114243 if (newflags == oldflags) {
114244 *pprev = vma;
114245 return 0;
114246 }
114247
114248+ if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
114249+ struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
114250+
114251+ if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
114252+ return -ENOMEM;
114253+
114254+ if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
114255+ return -ENOMEM;
114256+ }
114257+
114258 /*
114259 * If we make a private mapping writable we increase our commit;
114260 * but (without finer accounting) cannot reduce our commit if we
114261@@ -285,6 +353,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
114262 }
114263 }
114264
114265+#ifdef CONFIG_PAX_SEGMEXEC
114266+ if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
114267+ if (start != vma->vm_start) {
114268+ error = split_vma(mm, vma, start, 1);
114269+ if (error)
114270+ goto fail;
114271+ BUG_ON(!*pprev || (*pprev)->vm_next == vma);
114272+ *pprev = (*pprev)->vm_next;
114273+ }
114274+
114275+ if (end != vma->vm_end) {
114276+ error = split_vma(mm, vma, end, 0);
114277+ if (error)
114278+ goto fail;
114279+ }
114280+
114281+ if (pax_find_mirror_vma(vma)) {
114282+ error = __do_munmap(mm, start_m, end_m - start_m);
114283+ if (error)
114284+ goto fail;
114285+ } else {
114286+ vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
114287+ if (!vma_m) {
114288+ error = -ENOMEM;
114289+ goto fail;
114290+ }
114291+ vma->vm_flags = newflags;
114292+ error = pax_mirror_vma(vma_m, vma);
114293+ if (error) {
114294+ vma->vm_flags = oldflags;
114295+ goto fail;
114296+ }
114297+ }
114298+ }
114299+#endif
114300+
114301 /*
114302 * First try to merge with previous and/or next vma.
114303 */
114304@@ -315,7 +419,19 @@ success:
114305 * vm_flags and vm_page_prot are protected by the mmap_sem
114306 * held in write mode.
114307 */
114308+
114309+#ifdef CONFIG_PAX_SEGMEXEC
114310+ if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
114311+ pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
114312+#endif
114313+
114314 vma->vm_flags = newflags;
114315+
114316+#ifdef CONFIG_PAX_MPROTECT
114317+ if (mm->binfmt && mm->binfmt->handle_mprotect)
114318+ mm->binfmt->handle_mprotect(vma, newflags);
114319+#endif
114320+
114321 dirty_accountable = vma_wants_writenotify(vma);
114322 vma_set_page_prot(vma);
114323
114324@@ -351,6 +467,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
114325 end = start + len;
114326 if (end <= start)
114327 return -ENOMEM;
114328+
114329+#ifdef CONFIG_PAX_SEGMEXEC
114330+ if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
114331+ if (end > SEGMEXEC_TASK_SIZE)
114332+ return -EINVAL;
114333+ } else
114334+#endif
114335+
114336+ if (end > TASK_SIZE)
114337+ return -EINVAL;
114338+
114339 if (!arch_validate_prot(prot))
114340 return -EINVAL;
114341
114342@@ -358,7 +485,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
114343 /*
114344 * Does the application expect PROT_READ to imply PROT_EXEC:
114345 */
114346- if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
114347+ if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
114348 prot |= PROT_EXEC;
114349
114350 vm_flags = calc_vm_prot_bits(prot);
114351@@ -390,6 +517,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
114352 if (start > vma->vm_start)
114353 prev = vma;
114354
114355+#ifdef CONFIG_PAX_MPROTECT
114356+ if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
114357+ current->mm->binfmt->handle_mprotect(vma, vm_flags);
114358+#endif
114359+
114360 for (nstart = start ; ; ) {
114361 unsigned long newflags;
114362
114363@@ -400,6 +532,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
114364
114365 /* newflags >> 4 shift VM_MAY% in place of VM_% */
114366 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
114367+ if (prot & (PROT_WRITE | PROT_EXEC))
114368+ gr_log_rwxmprotect(vma);
114369+
114370+ error = -EACCES;
114371+ goto out;
114372+ }
114373+
114374+ if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
114375 error = -EACCES;
114376 goto out;
114377 }
114378@@ -414,6 +554,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
114379 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
114380 if (error)
114381 goto out;
114382+
114383+ track_exec_limit(current->mm, nstart, tmp, vm_flags);
114384+
114385 nstart = tmp;
114386
114387 if (nstart < prev->vm_end)
114388diff --git a/mm/mremap.c b/mm/mremap.c
114389index 034e2d3..81deca5 100644
114390--- a/mm/mremap.c
114391+++ b/mm/mremap.c
114392@@ -142,6 +142,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
114393 continue;
114394 pte = ptep_get_and_clear(mm, old_addr, old_pte);
114395 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
114396+
114397+#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
114398+ if (!(__supported_pte_mask & _PAGE_NX) && pte_present(pte) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
114399+ pte = pte_exprotect(pte);
114400+#endif
114401+
114402 pte = move_soft_dirty_pte(pte);
114403 set_pte_at(mm, new_addr, new_pte, pte);
114404 }
114405@@ -350,6 +356,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
114406 if (is_vm_hugetlb_page(vma))
114407 return ERR_PTR(-EINVAL);
114408
114409+#ifdef CONFIG_PAX_SEGMEXEC
114410+ if (pax_find_mirror_vma(vma))
114411+ return ERR_PTR(-EINVAL);
114412+#endif
114413+
114414 /* We can't remap across vm area boundaries */
114415 if (old_len > vma->vm_end - addr)
114416 return ERR_PTR(-EFAULT);
114417@@ -396,20 +407,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
114418 unsigned long ret = -EINVAL;
114419 unsigned long charged = 0;
114420 unsigned long map_flags;
114421+ unsigned long pax_task_size = TASK_SIZE;
114422
114423 if (new_addr & ~PAGE_MASK)
114424 goto out;
114425
114426- if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
114427+#ifdef CONFIG_PAX_SEGMEXEC
114428+ if (mm->pax_flags & MF_PAX_SEGMEXEC)
114429+ pax_task_size = SEGMEXEC_TASK_SIZE;
114430+#endif
114431+
114432+ pax_task_size -= PAGE_SIZE;
114433+
114434+ if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
114435 goto out;
114436
114437 /* Check if the location we're moving into overlaps the
114438 * old location at all, and fail if it does.
114439 */
114440- if ((new_addr <= addr) && (new_addr+new_len) > addr)
114441- goto out;
114442-
114443- if ((addr <= new_addr) && (addr+old_len) > new_addr)
114444+ if (addr + old_len > new_addr && new_addr + new_len > addr)
114445 goto out;
114446
114447 ret = do_munmap(mm, new_addr, new_len);
114448@@ -478,6 +494,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
114449 unsigned long ret = -EINVAL;
114450 unsigned long charged = 0;
114451 bool locked = false;
114452+ unsigned long pax_task_size = TASK_SIZE;
114453
114454 if (flags & ~(MREMAP_FIXED | MREMAP_MAYMOVE))
114455 return ret;
114456@@ -499,6 +516,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
114457 if (!new_len)
114458 return ret;
114459
114460+#ifdef CONFIG_PAX_SEGMEXEC
114461+ if (mm->pax_flags & MF_PAX_SEGMEXEC)
114462+ pax_task_size = SEGMEXEC_TASK_SIZE;
114463+#endif
114464+
114465+ pax_task_size -= PAGE_SIZE;
114466+
114467+ if (new_len > pax_task_size || addr > pax_task_size-new_len ||
114468+ old_len > pax_task_size || addr > pax_task_size-old_len)
114469+ return ret;
114470+
114471 down_write(&current->mm->mmap_sem);
114472
114473 if (flags & MREMAP_FIXED) {
114474@@ -549,6 +577,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
114475 new_addr = addr;
114476 }
114477 ret = addr;
114478+ track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
114479 goto out;
114480 }
114481 }
114482@@ -572,7 +601,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
114483 goto out;
114484 }
114485
114486+ map_flags = vma->vm_flags;
114487 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
114488+ if (!(ret & ~PAGE_MASK)) {
114489+ track_exec_limit(current->mm, addr, addr + old_len, 0UL);
114490+ track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
114491+ }
114492 }
114493 out:
114494 if (ret & ~PAGE_MASK)
114495diff --git a/mm/nommu.c b/mm/nommu.c
114496index e544508..b56ce7a 100644
114497--- a/mm/nommu.c
114498+++ b/mm/nommu.c
114499@@ -72,7 +72,6 @@ int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
114500 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
114501 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
114502 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
114503-int heap_stack_gap = 0;
114504
114505 atomic_long_t mmap_pages_allocated;
114506
114507@@ -892,15 +891,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
114508 EXPORT_SYMBOL(find_vma);
114509
114510 /*
114511- * find a VMA
114512- * - we don't extend stack VMAs under NOMMU conditions
114513- */
114514-struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
114515-{
114516- return find_vma(mm, addr);
114517-}
114518-
114519-/*
114520 * expand a stack to a given address
114521 * - not supported under NOMMU conditions
114522 */
114523@@ -1585,6 +1575,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
114524
114525 /* most fields are the same, copy all, and then fixup */
114526 *new = *vma;
114527+ INIT_LIST_HEAD(&new->anon_vma_chain);
114528 *region = *vma->vm_region;
114529 new->vm_region = region;
114530
114531@@ -2007,8 +1998,8 @@ void filemap_map_pages(struct vm_area_struct *vma, struct vm_fault *vmf)
114532 }
114533 EXPORT_SYMBOL(filemap_map_pages);
114534
114535-static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
114536- unsigned long addr, void *buf, int len, int write)
114537+static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
114538+ unsigned long addr, void *buf, size_t len, int write)
114539 {
114540 struct vm_area_struct *vma;
114541
114542@@ -2049,8 +2040,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
114543 *
114544 * The caller must hold a reference on @mm.
114545 */
114546-int access_remote_vm(struct mm_struct *mm, unsigned long addr,
114547- void *buf, int len, int write)
114548+ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
114549+ void *buf, size_t len, int write)
114550 {
114551 return __access_remote_vm(NULL, mm, addr, buf, len, write);
114552 }
114553@@ -2059,7 +2050,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
114554 * Access another process' address space.
114555 * - source/target buffer must be kernel space
114556 */
114557-int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
114558+ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
114559 {
114560 struct mm_struct *mm;
114561
114562diff --git a/mm/page-writeback.c b/mm/page-writeback.c
114563index eb59f7e..b23a2a8 100644
114564--- a/mm/page-writeback.c
114565+++ b/mm/page-writeback.c
114566@@ -664,7 +664,7 @@ static long long pos_ratio_polynom(unsigned long setpoint,
114567 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
114568 * - the bdi dirty thresh drops quickly due to change of JBOD workload
114569 */
114570-static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
114571+static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
114572 unsigned long thresh,
114573 unsigned long bg_thresh,
114574 unsigned long dirty,
114575diff --git a/mm/page_alloc.c b/mm/page_alloc.c
114576index ebffa0e..c61160a 100644
114577--- a/mm/page_alloc.c
114578+++ b/mm/page_alloc.c
114579@@ -61,6 +61,7 @@
114580 #include <linux/hugetlb.h>
114581 #include <linux/sched/rt.h>
114582 #include <linux/page_owner.h>
114583+#include <linux/random.h>
114584
114585 #include <asm/sections.h>
114586 #include <asm/tlbflush.h>
114587@@ -357,7 +358,7 @@ out:
114588 * This usage means that zero-order pages may not be compound.
114589 */
114590
114591-static void free_compound_page(struct page *page)
114592+void free_compound_page(struct page *page)
114593 {
114594 __free_pages_ok(page, compound_order(page));
114595 }
114596@@ -480,7 +481,7 @@ static inline void clear_page_guard(struct zone *zone, struct page *page,
114597 __mod_zone_freepage_state(zone, (1 << order), migratetype);
114598 }
114599 #else
114600-struct page_ext_operations debug_guardpage_ops = { NULL, };
114601+struct page_ext_operations debug_guardpage_ops = { .need = NULL, .init = NULL };
114602 static inline void set_page_guard(struct zone *zone, struct page *page,
114603 unsigned int order, int migratetype) {}
114604 static inline void clear_page_guard(struct zone *zone, struct page *page,
114605@@ -783,6 +784,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
114606 bool compound = PageCompound(page);
114607 int i, bad = 0;
114608
114609+#ifdef CONFIG_PAX_MEMORY_SANITIZE
114610+ unsigned long index = 1UL << order;
114611+#endif
114612+
114613 VM_BUG_ON_PAGE(PageTail(page), page);
114614 VM_BUG_ON_PAGE(compound && compound_order(page) != order, page);
114615
114616@@ -809,6 +814,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
114617 debug_check_no_obj_freed(page_address(page),
114618 PAGE_SIZE << order);
114619 }
114620+
114621+#ifdef CONFIG_PAX_MEMORY_SANITIZE
114622+ for (; index; --index)
114623+ sanitize_highpage(page + index - 1);
114624+#endif
114625+
114626 arch_free_page(page, order);
114627 kernel_map_pages(page, 1 << order, 0);
114628
114629@@ -832,6 +843,20 @@ static void __free_pages_ok(struct page *page, unsigned int order)
114630 local_irq_restore(flags);
114631 }
114632
114633+#ifdef CONFIG_PAX_LATENT_ENTROPY
114634+bool __meminitdata extra_latent_entropy;
114635+
114636+static int __init setup_pax_extra_latent_entropy(char *str)
114637+{
114638+ extra_latent_entropy = true;
114639+ return 0;
114640+}
114641+early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
114642+
114643+volatile u64 latent_entropy __latent_entropy;
114644+EXPORT_SYMBOL(latent_entropy);
114645+#endif
114646+
114647 void __init __free_pages_bootmem(struct page *page, unsigned int order)
114648 {
114649 unsigned int nr_pages = 1 << order;
114650@@ -847,6 +872,19 @@ void __init __free_pages_bootmem(struct page *page, unsigned int order)
114651 __ClearPageReserved(p);
114652 set_page_count(p, 0);
114653
114654+#ifdef CONFIG_PAX_LATENT_ENTROPY
114655+ if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
114656+ u64 hash = 0;
114657+ size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
114658+ const u64 *data = lowmem_page_address(page);
114659+
114660+ for (index = 0; index < end; index++)
114661+ hash ^= hash + data[index];
114662+ latent_entropy ^= hash;
114663+ add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
114664+ }
114665+#endif
114666+
114667 page_zone(page)->managed_pages += nr_pages;
114668 set_page_refcounted(page);
114669 __free_pages(page, order);
114670@@ -974,8 +1012,10 @@ static int prep_new_page(struct page *page, unsigned int order, gfp_t gfp_flags,
114671 kernel_map_pages(page, 1 << order, 1);
114672 kasan_alloc_pages(page, order);
114673
114674+#ifndef CONFIG_PAX_MEMORY_SANITIZE
114675 if (gfp_flags & __GFP_ZERO)
114676 prep_zero_page(page, order, gfp_flags);
114677+#endif
114678
114679 if (order && (gfp_flags & __GFP_COMP))
114680 prep_compound_page(page, order);
114681@@ -1649,6 +1689,8 @@ int __isolate_free_page(struct page *page, unsigned int order)
114682 zone->free_area[order].nr_free--;
114683 rmv_page_order(page);
114684
114685+ set_page_owner(page, order, 0);
114686+
114687 /* Set the pageblock if the isolated page is at least a pageblock */
114688 if (order >= pageblock_order - 1) {
114689 struct page *endpage = page + (1 << order) - 1;
114690@@ -1660,7 +1702,7 @@ int __isolate_free_page(struct page *page, unsigned int order)
114691 }
114692 }
114693
114694- set_page_owner(page, order, 0);
114695+
114696 return 1UL << order;
114697 }
114698
114699@@ -1749,7 +1791,7 @@ struct page *buffered_rmqueue(struct zone *preferred_zone,
114700 }
114701
114702 __mod_zone_page_state(zone, NR_ALLOC_BATCH, -(1 << order));
114703- if (atomic_long_read(&zone->vm_stat[NR_ALLOC_BATCH]) <= 0 &&
114704+ if (atomic_long_read_unchecked(&zone->vm_stat[NR_ALLOC_BATCH]) <= 0 &&
114705 !test_bit(ZONE_FAIR_DEPLETED, &zone->flags))
114706 set_bit(ZONE_FAIR_DEPLETED, &zone->flags);
114707
114708@@ -2068,7 +2110,7 @@ static void reset_alloc_batches(struct zone *preferred_zone)
114709 do {
114710 mod_zone_page_state(zone, NR_ALLOC_BATCH,
114711 high_wmark_pages(zone) - low_wmark_pages(zone) -
114712- atomic_long_read(&zone->vm_stat[NR_ALLOC_BATCH]));
114713+ atomic_long_read_unchecked(&zone->vm_stat[NR_ALLOC_BATCH]));
114714 clear_bit(ZONE_FAIR_DEPLETED, &zone->flags);
114715 } while (zone++ != preferred_zone);
114716 }
114717@@ -5781,7 +5823,7 @@ static void __setup_per_zone_wmarks(void)
114718
114719 __mod_zone_page_state(zone, NR_ALLOC_BATCH,
114720 high_wmark_pages(zone) - low_wmark_pages(zone) -
114721- atomic_long_read(&zone->vm_stat[NR_ALLOC_BATCH]));
114722+ atomic_long_read_unchecked(&zone->vm_stat[NR_ALLOC_BATCH]));
114723
114724 setup_zone_migrate_reserve(zone);
114725 spin_unlock_irqrestore(&zone->lock, flags);
114726diff --git a/mm/percpu.c b/mm/percpu.c
114727index 2dd7448..9bb6305 100644
114728--- a/mm/percpu.c
114729+++ b/mm/percpu.c
114730@@ -131,7 +131,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
114731 static unsigned int pcpu_high_unit_cpu __read_mostly;
114732
114733 /* the address of the first chunk which starts with the kernel static area */
114734-void *pcpu_base_addr __read_mostly;
114735+void *pcpu_base_addr __read_only;
114736 EXPORT_SYMBOL_GPL(pcpu_base_addr);
114737
114738 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
114739diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
114740index e88d071..d80e01a 100644
114741--- a/mm/process_vm_access.c
114742+++ b/mm/process_vm_access.c
114743@@ -13,6 +13,7 @@
114744 #include <linux/uio.h>
114745 #include <linux/sched.h>
114746 #include <linux/highmem.h>
114747+#include <linux/security.h>
114748 #include <linux/ptrace.h>
114749 #include <linux/slab.h>
114750 #include <linux/syscalls.h>
114751@@ -154,19 +155,19 @@ static ssize_t process_vm_rw_core(pid_t pid, struct iov_iter *iter,
114752 ssize_t iov_len;
114753 size_t total_len = iov_iter_count(iter);
114754
114755+ return -ENOSYS; // PaX: until properly audited
114756+
114757 /*
114758 * Work out how many pages of struct pages we're going to need
114759 * when eventually calling get_user_pages
114760 */
114761 for (i = 0; i < riovcnt; i++) {
114762 iov_len = rvec[i].iov_len;
114763- if (iov_len > 0) {
114764- nr_pages_iov = ((unsigned long)rvec[i].iov_base
114765- + iov_len)
114766- / PAGE_SIZE - (unsigned long)rvec[i].iov_base
114767- / PAGE_SIZE + 1;
114768- nr_pages = max(nr_pages, nr_pages_iov);
114769- }
114770+ if (iov_len <= 0)
114771+ continue;
114772+ nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
114773+ (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
114774+ nr_pages = max(nr_pages, nr_pages_iov);
114775 }
114776
114777 if (nr_pages == 0)
114778@@ -194,6 +195,11 @@ static ssize_t process_vm_rw_core(pid_t pid, struct iov_iter *iter,
114779 goto free_proc_pages;
114780 }
114781
114782+ if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
114783+ rc = -EPERM;
114784+ goto put_task_struct;
114785+ }
114786+
114787 mm = mm_access(task, PTRACE_MODE_ATTACH);
114788 if (!mm || IS_ERR(mm)) {
114789 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
114790diff --git a/mm/rmap.c b/mm/rmap.c
114791index 24dd3f9..4eb43f4 100644
114792--- a/mm/rmap.c
114793+++ b/mm/rmap.c
114794@@ -166,6 +166,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
114795 struct anon_vma *anon_vma = vma->anon_vma;
114796 struct anon_vma_chain *avc;
114797
114798+#ifdef CONFIG_PAX_SEGMEXEC
114799+ struct anon_vma_chain *avc_m = NULL;
114800+#endif
114801+
114802 might_sleep();
114803 if (unlikely(!anon_vma)) {
114804 struct mm_struct *mm = vma->vm_mm;
114805@@ -175,6 +179,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
114806 if (!avc)
114807 goto out_enomem;
114808
114809+#ifdef CONFIG_PAX_SEGMEXEC
114810+ avc_m = anon_vma_chain_alloc(GFP_KERNEL);
114811+ if (!avc_m)
114812+ goto out_enomem_free_avc;
114813+#endif
114814+
114815 anon_vma = find_mergeable_anon_vma(vma);
114816 allocated = NULL;
114817 if (!anon_vma) {
114818@@ -188,6 +198,19 @@ int anon_vma_prepare(struct vm_area_struct *vma)
114819 /* page_table_lock to protect against threads */
114820 spin_lock(&mm->page_table_lock);
114821 if (likely(!vma->anon_vma)) {
114822+
114823+#ifdef CONFIG_PAX_SEGMEXEC
114824+ struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
114825+
114826+ if (vma_m) {
114827+ BUG_ON(vma_m->anon_vma);
114828+ vma_m->anon_vma = anon_vma;
114829+ anon_vma_chain_link(vma_m, avc_m, anon_vma);
114830+ anon_vma->degree++;
114831+ avc_m = NULL;
114832+ }
114833+#endif
114834+
114835 vma->anon_vma = anon_vma;
114836 anon_vma_chain_link(vma, avc, anon_vma);
114837 /* vma reference or self-parent link for new root */
114838@@ -200,12 +223,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
114839
114840 if (unlikely(allocated))
114841 put_anon_vma(allocated);
114842+
114843+#ifdef CONFIG_PAX_SEGMEXEC
114844+ if (unlikely(avc_m))
114845+ anon_vma_chain_free(avc_m);
114846+#endif
114847+
114848 if (unlikely(avc))
114849 anon_vma_chain_free(avc);
114850 }
114851 return 0;
114852
114853 out_enomem_free_avc:
114854+
114855+#ifdef CONFIG_PAX_SEGMEXEC
114856+ if (avc_m)
114857+ anon_vma_chain_free(avc_m);
114858+#endif
114859+
114860 anon_vma_chain_free(avc);
114861 out_enomem:
114862 return -ENOMEM;
114863@@ -249,7 +284,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
114864 * good chance of avoiding scanning the whole hierarchy when it searches where
114865 * page is mapped.
114866 */
114867-int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
114868+int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
114869 {
114870 struct anon_vma_chain *avc, *pavc;
114871 struct anon_vma *root = NULL;
114872@@ -303,7 +338,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
114873 * the corresponding VMA in the parent process is attached to.
114874 * Returns 0 on success, non-zero on failure.
114875 */
114876-int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
114877+int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
114878 {
114879 struct anon_vma_chain *avc;
114880 struct anon_vma *anon_vma;
114881@@ -423,8 +458,10 @@ static void anon_vma_ctor(void *data)
114882 void __init anon_vma_init(void)
114883 {
114884 anon_vma_cachep = kmem_cache_create("anon_vma", sizeof(struct anon_vma),
114885- 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC, anon_vma_ctor);
114886- anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain, SLAB_PANIC);
114887+ 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC|SLAB_NO_SANITIZE,
114888+ anon_vma_ctor);
114889+ anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain,
114890+ SLAB_PANIC|SLAB_NO_SANITIZE);
114891 }
114892
114893 /*
114894diff --git a/mm/shmem.c b/mm/shmem.c
114895index 47d536e..8321b4e 100644
114896--- a/mm/shmem.c
114897+++ b/mm/shmem.c
114898@@ -33,7 +33,7 @@
114899 #include <linux/swap.h>
114900 #include <linux/uio.h>
114901
114902-static struct vfsmount *shm_mnt;
114903+struct vfsmount *shm_mnt;
114904
114905 #ifdef CONFIG_SHMEM
114906 /*
114907@@ -80,7 +80,7 @@ static struct vfsmount *shm_mnt;
114908 #define BOGO_DIRENT_SIZE 20
114909
114910 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
114911-#define SHORT_SYMLINK_LEN 128
114912+#define SHORT_SYMLINK_LEN 64
114913
114914 /*
114915 * shmem_fallocate communicates with shmem_fault or shmem_writepage via
114916@@ -2555,6 +2555,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
114917 static int shmem_xattr_validate(const char *name)
114918 {
114919 struct { const char *prefix; size_t len; } arr[] = {
114920+
114921+#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
114922+ { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
114923+#endif
114924+
114925 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
114926 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
114927 };
114928@@ -2610,6 +2615,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
114929 if (err)
114930 return err;
114931
114932+#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
114933+ if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
114934+ if (strcmp(name, XATTR_NAME_PAX_FLAGS))
114935+ return -EOPNOTSUPP;
114936+ if (size > 8)
114937+ return -EINVAL;
114938+ }
114939+#endif
114940+
114941 return simple_xattr_set(&info->xattrs, name, value, size, flags);
114942 }
114943
114944@@ -2993,8 +3007,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
114945 int err = -ENOMEM;
114946
114947 /* Round up to L1_CACHE_BYTES to resist false sharing */
114948- sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
114949- L1_CACHE_BYTES), GFP_KERNEL);
114950+ sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
114951 if (!sbinfo)
114952 return -ENOMEM;
114953
114954diff --git a/mm/slab.c b/mm/slab.c
114955index 7eb38dd..a5172b1 100644
114956--- a/mm/slab.c
114957+++ b/mm/slab.c
114958@@ -314,10 +314,12 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
114959 if ((x)->max_freeable < i) \
114960 (x)->max_freeable = i; \
114961 } while (0)
114962-#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
114963-#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
114964-#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
114965-#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
114966+#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
114967+#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
114968+#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
114969+#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
114970+#define STATS_INC_SANITIZED(x) atomic_inc_unchecked(&(x)->sanitized)
114971+#define STATS_INC_NOT_SANITIZED(x) atomic_inc_unchecked(&(x)->not_sanitized)
114972 #else
114973 #define STATS_INC_ACTIVE(x) do { } while (0)
114974 #define STATS_DEC_ACTIVE(x) do { } while (0)
114975@@ -334,6 +336,8 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
114976 #define STATS_INC_ALLOCMISS(x) do { } while (0)
114977 #define STATS_INC_FREEHIT(x) do { } while (0)
114978 #define STATS_INC_FREEMISS(x) do { } while (0)
114979+#define STATS_INC_SANITIZED(x) do { } while (0)
114980+#define STATS_INC_NOT_SANITIZED(x) do { } while (0)
114981 #endif
114982
114983 #if DEBUG
114984@@ -450,7 +454,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct page *page,
114985 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
114986 */
114987 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
114988- const struct page *page, void *obj)
114989+ const struct page *page, const void *obj)
114990 {
114991 u32 offset = (obj - page->s_mem);
114992 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
114993@@ -1452,7 +1456,7 @@ void __init kmem_cache_init(void)
114994 * structures first. Without this, further allocations will bug.
114995 */
114996 kmalloc_caches[INDEX_NODE] = create_kmalloc_cache("kmalloc-node",
114997- kmalloc_size(INDEX_NODE), ARCH_KMALLOC_FLAGS);
114998+ kmalloc_size(INDEX_NODE), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
114999 slab_state = PARTIAL_NODE;
115000
115001 slab_early_init = 0;
115002@@ -2073,7 +2077,7 @@ __kmem_cache_alias(const char *name, size_t size, size_t align,
115003
115004 cachep = find_mergeable(size, align, flags, name, ctor);
115005 if (cachep) {
115006- cachep->refcount++;
115007+ atomic_inc(&cachep->refcount);
115008
115009 /*
115010 * Adjust the object sizes so that we clear
115011@@ -3371,6 +3375,20 @@ static inline void __cache_free(struct kmem_cache *cachep, void *objp,
115012 struct array_cache *ac = cpu_cache_get(cachep);
115013
115014 check_irq_off();
115015+
115016+#ifdef CONFIG_PAX_MEMORY_SANITIZE
115017+ if (cachep->flags & (SLAB_POISON | SLAB_NO_SANITIZE))
115018+ STATS_INC_NOT_SANITIZED(cachep);
115019+ else {
115020+ memset(objp, PAX_MEMORY_SANITIZE_VALUE, cachep->object_size);
115021+
115022+ if (cachep->ctor)
115023+ cachep->ctor(objp);
115024+
115025+ STATS_INC_SANITIZED(cachep);
115026+ }
115027+#endif
115028+
115029 kmemleak_free_recursive(objp, cachep->flags);
115030 objp = cache_free_debugcheck(cachep, objp, caller);
115031
115032@@ -3483,7 +3501,7 @@ __do_kmalloc_node(size_t size, gfp_t flags, int node, unsigned long caller)
115033 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
115034 }
115035
115036-void *__kmalloc_node(size_t size, gfp_t flags, int node)
115037+void * __size_overflow(1) __kmalloc_node(size_t size, gfp_t flags, int node)
115038 {
115039 return __do_kmalloc_node(size, flags, node, _RET_IP_);
115040 }
115041@@ -3503,7 +3521,7 @@ EXPORT_SYMBOL(__kmalloc_node_track_caller);
115042 * @flags: the type of memory to allocate (see kmalloc).
115043 * @caller: function caller for debug tracking of the caller
115044 */
115045-static __always_inline void *__do_kmalloc(size_t size, gfp_t flags,
115046+static __always_inline void * __size_overflow(1) __do_kmalloc(size_t size, gfp_t flags,
115047 unsigned long caller)
115048 {
115049 struct kmem_cache *cachep;
115050@@ -3576,6 +3594,7 @@ void kfree(const void *objp)
115051
115052 if (unlikely(ZERO_OR_NULL_PTR(objp)))
115053 return;
115054+ VM_BUG_ON(!virt_addr_valid(objp));
115055 local_irq_save(flags);
115056 kfree_debugcheck(objp);
115057 c = virt_to_cache(objp);
115058@@ -3995,14 +4014,22 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
115059 }
115060 /* cpu stats */
115061 {
115062- unsigned long allochit = atomic_read(&cachep->allochit);
115063- unsigned long allocmiss = atomic_read(&cachep->allocmiss);
115064- unsigned long freehit = atomic_read(&cachep->freehit);
115065- unsigned long freemiss = atomic_read(&cachep->freemiss);
115066+ unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
115067+ unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
115068+ unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
115069+ unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
115070
115071 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
115072 allochit, allocmiss, freehit, freemiss);
115073 }
115074+#ifdef CONFIG_PAX_MEMORY_SANITIZE
115075+ {
115076+ unsigned long sanitized = atomic_read_unchecked(&cachep->sanitized);
115077+ unsigned long not_sanitized = atomic_read_unchecked(&cachep->not_sanitized);
115078+
115079+ seq_printf(m, " : pax %6lu %6lu", sanitized, not_sanitized);
115080+ }
115081+#endif
115082 #endif
115083 }
115084
115085@@ -4210,13 +4237,69 @@ static const struct file_operations proc_slabstats_operations = {
115086 static int __init slab_proc_init(void)
115087 {
115088 #ifdef CONFIG_DEBUG_SLAB_LEAK
115089- proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
115090+ proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
115091 #endif
115092 return 0;
115093 }
115094 module_init(slab_proc_init);
115095 #endif
115096
115097+bool is_usercopy_object(const void *ptr)
115098+{
115099+ struct page *page;
115100+ struct kmem_cache *cachep;
115101+
115102+ if (ZERO_OR_NULL_PTR(ptr))
115103+ return false;
115104+
115105+ if (!slab_is_available())
115106+ return false;
115107+
115108+ if (!virt_addr_valid(ptr))
115109+ return false;
115110+
115111+ page = virt_to_head_page(ptr);
115112+
115113+ if (!PageSlab(page))
115114+ return false;
115115+
115116+ cachep = page->slab_cache;
115117+ return cachep->flags & SLAB_USERCOPY;
115118+}
115119+
115120+#ifdef CONFIG_PAX_USERCOPY
115121+const char *check_heap_object(const void *ptr, unsigned long n)
115122+{
115123+ struct page *page;
115124+ struct kmem_cache *cachep;
115125+ unsigned int objnr;
115126+ unsigned long offset;
115127+
115128+ if (ZERO_OR_NULL_PTR(ptr))
115129+ return "<null>";
115130+
115131+ if (!virt_addr_valid(ptr))
115132+ return NULL;
115133+
115134+ page = virt_to_head_page(ptr);
115135+
115136+ if (!PageSlab(page))
115137+ return NULL;
115138+
115139+ cachep = page->slab_cache;
115140+ if (!(cachep->flags & SLAB_USERCOPY))
115141+ return cachep->name;
115142+
115143+ objnr = obj_to_index(cachep, page, ptr);
115144+ BUG_ON(objnr >= cachep->num);
115145+ offset = ptr - index_to_obj(cachep, page, objnr) - obj_offset(cachep);
115146+ if (offset <= cachep->object_size && n <= cachep->object_size - offset)
115147+ return NULL;
115148+
115149+ return cachep->name;
115150+}
115151+#endif
115152+
115153 /**
115154 * ksize - get the actual amount of memory allocated for a given object
115155 * @objp: Pointer to the object
115156diff --git a/mm/slab.h b/mm/slab.h
115157index 4c3ac12..7b2e470 100644
115158--- a/mm/slab.h
115159+++ b/mm/slab.h
115160@@ -22,7 +22,7 @@ struct kmem_cache {
115161 unsigned int align; /* Alignment as calculated */
115162 unsigned long flags; /* Active flags on the slab */
115163 const char *name; /* Slab name for sysfs */
115164- int refcount; /* Use counter */
115165+ atomic_t refcount; /* Use counter */
115166 void (*ctor)(void *); /* Called on object slot creation */
115167 struct list_head list; /* List of all slab caches on the system */
115168 };
115169@@ -66,6 +66,20 @@ extern struct list_head slab_caches;
115170 /* The slab cache that manages slab cache information */
115171 extern struct kmem_cache *kmem_cache;
115172
115173+#ifdef CONFIG_PAX_MEMORY_SANITIZE
115174+#ifdef CONFIG_X86_64
115175+#define PAX_MEMORY_SANITIZE_VALUE '\xfe'
115176+#else
115177+#define PAX_MEMORY_SANITIZE_VALUE '\xff'
115178+#endif
115179+enum pax_sanitize_mode {
115180+ PAX_SANITIZE_SLAB_OFF = 0,
115181+ PAX_SANITIZE_SLAB_FAST,
115182+ PAX_SANITIZE_SLAB_FULL,
115183+};
115184+extern enum pax_sanitize_mode pax_sanitize_slab;
115185+#endif
115186+
115187 unsigned long calculate_alignment(unsigned long flags,
115188 unsigned long align, unsigned long size);
115189
115190@@ -114,7 +128,8 @@ static inline unsigned long kmem_cache_flags(unsigned long object_size,
115191
115192 /* Legal flag mask for kmem_cache_create(), for various configurations */
115193 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
115194- SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
115195+ SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | \
115196+ SLAB_USERCOPY | SLAB_NO_SANITIZE)
115197
115198 #if defined(CONFIG_DEBUG_SLAB)
115199 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
115200@@ -315,6 +330,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
115201 return s;
115202
115203 page = virt_to_head_page(x);
115204+
115205+ BUG_ON(!PageSlab(page));
115206+
115207 cachep = page->slab_cache;
115208 if (slab_equal_or_root(cachep, s))
115209 return cachep;
115210diff --git a/mm/slab_common.c b/mm/slab_common.c
115211index 999bb34..9843aea 100644
115212--- a/mm/slab_common.c
115213+++ b/mm/slab_common.c
115214@@ -25,11 +25,35 @@
115215
115216 #include "slab.h"
115217
115218-enum slab_state slab_state;
115219+enum slab_state slab_state __read_only;
115220 LIST_HEAD(slab_caches);
115221 DEFINE_MUTEX(slab_mutex);
115222 struct kmem_cache *kmem_cache;
115223
115224+#ifdef CONFIG_PAX_MEMORY_SANITIZE
115225+enum pax_sanitize_mode pax_sanitize_slab __read_only = PAX_SANITIZE_SLAB_FAST;
115226+static int __init pax_sanitize_slab_setup(char *str)
115227+{
115228+ if (!str)
115229+ return 0;
115230+
115231+ if (!strcmp(str, "0") || !strcmp(str, "off")) {
115232+ pr_info("PaX slab sanitization: %s\n", "disabled");
115233+ pax_sanitize_slab = PAX_SANITIZE_SLAB_OFF;
115234+ } else if (!strcmp(str, "1") || !strcmp(str, "fast")) {
115235+ pr_info("PaX slab sanitization: %s\n", "fast");
115236+ pax_sanitize_slab = PAX_SANITIZE_SLAB_FAST;
115237+ } else if (!strcmp(str, "full")) {
115238+ pr_info("PaX slab sanitization: %s\n", "full");
115239+ pax_sanitize_slab = PAX_SANITIZE_SLAB_FULL;
115240+ } else
115241+ pr_err("PaX slab sanitization: unsupported option '%s'\n", str);
115242+
115243+ return 0;
115244+}
115245+early_param("pax_sanitize_slab", pax_sanitize_slab_setup);
115246+#endif
115247+
115248 /*
115249 * Set of flags that will prevent slab merging
115250 */
115251@@ -44,7 +68,7 @@ struct kmem_cache *kmem_cache;
115252 * Merge control. If this is set then no merging of slab caches will occur.
115253 * (Could be removed. This was introduced to pacify the merge skeptics.)
115254 */
115255-static int slab_nomerge;
115256+static int slab_nomerge = 1;
115257
115258 static int __init setup_slab_nomerge(char *str)
115259 {
115260@@ -217,7 +241,7 @@ int slab_unmergeable(struct kmem_cache *s)
115261 /*
115262 * We may have set a slab to be unmergeable during bootstrap.
115263 */
115264- if (s->refcount < 0)
115265+ if (atomic_read(&s->refcount) < 0)
115266 return 1;
115267
115268 return 0;
115269@@ -321,7 +345,7 @@ do_kmem_cache_create(const char *name, size_t object_size, size_t size,
115270 if (err)
115271 goto out_free_cache;
115272
115273- s->refcount = 1;
115274+ atomic_set(&s->refcount, 1);
115275 list_add(&s->list, &slab_caches);
115276 out:
115277 if (err)
115278@@ -386,6 +410,13 @@ kmem_cache_create(const char *name, size_t size, size_t align,
115279 */
115280 flags &= CACHE_CREATE_MASK;
115281
115282+#ifdef CONFIG_PAX_MEMORY_SANITIZE
115283+ if (pax_sanitize_slab == PAX_SANITIZE_SLAB_OFF || (flags & SLAB_DESTROY_BY_RCU))
115284+ flags |= SLAB_NO_SANITIZE;
115285+ else if (pax_sanitize_slab == PAX_SANITIZE_SLAB_FULL)
115286+ flags &= ~SLAB_NO_SANITIZE;
115287+#endif
115288+
115289 s = __kmem_cache_alias(name, size, align, flags, ctor);
115290 if (s)
115291 goto out_unlock;
115292@@ -456,7 +487,7 @@ static void do_kmem_cache_release(struct list_head *release,
115293 rcu_barrier();
115294
115295 list_for_each_entry_safe(s, s2, release, list) {
115296-#ifdef SLAB_SUPPORTS_SYSFS
115297+#if defined(SLAB_SUPPORTS_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
115298 sysfs_slab_remove(s);
115299 #else
115300 slab_kmem_cache_release(s);
115301@@ -625,8 +656,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
115302
115303 mutex_lock(&slab_mutex);
115304
115305- s->refcount--;
115306- if (s->refcount)
115307+ if (!atomic_dec_and_test(&s->refcount))
115308 goto out_unlock;
115309
115310 for_each_memcg_cache_safe(c, c2, s) {
115311@@ -691,7 +721,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
115312 panic("Creation of kmalloc slab %s size=%zu failed. Reason %d\n",
115313 name, size, err);
115314
115315- s->refcount = -1; /* Exempt from merging for now */
115316+ atomic_set(&s->refcount, -1); /* Exempt from merging for now */
115317 }
115318
115319 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
115320@@ -704,7 +734,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
115321
115322 create_boot_cache(s, name, size, flags);
115323 list_add(&s->list, &slab_caches);
115324- s->refcount = 1;
115325+ atomic_set(&s->refcount, 1);
115326 return s;
115327 }
115328
115329@@ -716,6 +746,11 @@ struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
115330 EXPORT_SYMBOL(kmalloc_dma_caches);
115331 #endif
115332
115333+#ifdef CONFIG_PAX_USERCOPY_SLABS
115334+struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
115335+EXPORT_SYMBOL(kmalloc_usercopy_caches);
115336+#endif
115337+
115338 /*
115339 * Conversion table for small slabs sizes / 8 to the index in the
115340 * kmalloc array. This is necessary for slabs < 192 since we have non power
115341@@ -780,6 +815,13 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags)
115342 return kmalloc_dma_caches[index];
115343
115344 #endif
115345+
115346+#ifdef CONFIG_PAX_USERCOPY_SLABS
115347+ if (unlikely((flags & GFP_USERCOPY)))
115348+ return kmalloc_usercopy_caches[index];
115349+
115350+#endif
115351+
115352 return kmalloc_caches[index];
115353 }
115354
115355@@ -836,7 +878,7 @@ void __init create_kmalloc_caches(unsigned long flags)
115356 for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
115357 if (!kmalloc_caches[i]) {
115358 kmalloc_caches[i] = create_kmalloc_cache(NULL,
115359- 1 << i, flags);
115360+ 1 << i, SLAB_USERCOPY | flags);
115361 }
115362
115363 /*
115364@@ -845,10 +887,10 @@ void __init create_kmalloc_caches(unsigned long flags)
115365 * earlier power of two caches
115366 */
115367 if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[1] && i == 6)
115368- kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, flags);
115369+ kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, SLAB_USERCOPY | flags);
115370
115371 if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[2] && i == 7)
115372- kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, flags);
115373+ kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, SLAB_USERCOPY | flags);
115374 }
115375
115376 /* Kmalloc array is now usable */
115377@@ -881,6 +923,23 @@ void __init create_kmalloc_caches(unsigned long flags)
115378 }
115379 }
115380 #endif
115381+
115382+#ifdef CONFIG_PAX_USERCOPY_SLABS
115383+ for (i = 0; i <= KMALLOC_SHIFT_HIGH; i++) {
115384+ struct kmem_cache *s = kmalloc_caches[i];
115385+
115386+ if (s) {
115387+ int size = kmalloc_size(i);
115388+ char *n = kasprintf(GFP_NOWAIT,
115389+ "usercopy-kmalloc-%d", size);
115390+
115391+ BUG_ON(!n);
115392+ kmalloc_usercopy_caches[i] = create_kmalloc_cache(n,
115393+ size, SLAB_USERCOPY | flags);
115394+ }
115395+ }
115396+#endif
115397+
115398 }
115399 #endif /* !CONFIG_SLOB */
115400
115401@@ -940,6 +999,9 @@ static void print_slabinfo_header(struct seq_file *m)
115402 seq_puts(m, " : globalstat <listallocs> <maxobjs> <grown> <reaped> "
115403 "<error> <maxfreeable> <nodeallocs> <remotefrees> <alienoverflow>");
115404 seq_puts(m, " : cpustat <allochit> <allocmiss> <freehit> <freemiss>");
115405+#ifdef CONFIG_PAX_MEMORY_SANITIZE
115406+ seq_puts(m, " : pax <sanitized> <not_sanitized>");
115407+#endif
115408 #endif
115409 seq_putc(m, '\n');
115410 }
115411@@ -1069,7 +1131,7 @@ static int __init slab_proc_init(void)
115412 module_init(slab_proc_init);
115413 #endif /* CONFIG_SLABINFO */
115414
115415-static __always_inline void *__do_krealloc(const void *p, size_t new_size,
115416+static __always_inline void * __size_overflow(2) __do_krealloc(const void *p, size_t new_size,
115417 gfp_t flags)
115418 {
115419 void *ret;
115420diff --git a/mm/slob.c b/mm/slob.c
115421index 4765f65..fafa9d5 100644
115422--- a/mm/slob.c
115423+++ b/mm/slob.c
115424@@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
115425 /*
115426 * Return the size of a slob block.
115427 */
115428-static slobidx_t slob_units(slob_t *s)
115429+static slobidx_t slob_units(const slob_t *s)
115430 {
115431 if (s->units > 0)
115432 return s->units;
115433@@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
115434 /*
115435 * Return the next free slob block pointer after this one.
115436 */
115437-static slob_t *slob_next(slob_t *s)
115438+static slob_t *slob_next(const slob_t *s)
115439 {
115440 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
115441 slobidx_t next;
115442@@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
115443 /*
115444 * Returns true if s is the last free block in its page.
115445 */
115446-static int slob_last(slob_t *s)
115447+static int slob_last(const slob_t *s)
115448 {
115449 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
115450 }
115451
115452-static void *slob_new_pages(gfp_t gfp, int order, int node)
115453+static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
115454 {
115455- void *page;
115456+ struct page *page;
115457
115458 #ifdef CONFIG_NUMA
115459 if (node != NUMA_NO_NODE)
115460@@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
115461 if (!page)
115462 return NULL;
115463
115464- return page_address(page);
115465+ __SetPageSlab(page);
115466+ return page;
115467 }
115468
115469-static void slob_free_pages(void *b, int order)
115470+static void slob_free_pages(struct page *sp, int order)
115471 {
115472 if (current->reclaim_state)
115473 current->reclaim_state->reclaimed_slab += 1 << order;
115474- free_pages((unsigned long)b, order);
115475+ __ClearPageSlab(sp);
115476+ page_mapcount_reset(sp);
115477+ sp->private = 0;
115478+ __free_pages(sp, order);
115479 }
115480
115481 /*
115482@@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
115483
115484 /* Not enough space: must allocate a new page */
115485 if (!b) {
115486- b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
115487- if (!b)
115488+ sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
115489+ if (!sp)
115490 return NULL;
115491- sp = virt_to_page(b);
115492- __SetPageSlab(sp);
115493+ b = page_address(sp);
115494
115495 spin_lock_irqsave(&slob_lock, flags);
115496 sp->units = SLOB_UNITS(PAGE_SIZE);
115497 sp->freelist = b;
115498+ sp->private = 0;
115499 INIT_LIST_HEAD(&sp->lru);
115500 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
115501 set_slob_page_free(sp, slob_list);
115502@@ -337,7 +341,7 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
115503 /*
115504 * slob_free: entry point into the slob allocator.
115505 */
115506-static void slob_free(void *block, int size)
115507+static void slob_free(struct kmem_cache *c, void *block, int size)
115508 {
115509 struct page *sp;
115510 slob_t *prev, *next, *b = (slob_t *)block;
115511@@ -359,12 +363,15 @@ static void slob_free(void *block, int size)
115512 if (slob_page_free(sp))
115513 clear_slob_page_free(sp);
115514 spin_unlock_irqrestore(&slob_lock, flags);
115515- __ClearPageSlab(sp);
115516- page_mapcount_reset(sp);
115517- slob_free_pages(b, 0);
115518+ slob_free_pages(sp, 0);
115519 return;
115520 }
115521
115522+#ifdef CONFIG_PAX_MEMORY_SANITIZE
115523+ if (pax_sanitize_slab && !(c && (c->flags & SLAB_NO_SANITIZE)))
115524+ memset(block, PAX_MEMORY_SANITIZE_VALUE, size);
115525+#endif
115526+
115527 if (!slob_page_free(sp)) {
115528 /* This slob page is about to become partially free. Easy! */
115529 sp->units = units;
115530@@ -424,11 +431,10 @@ out:
115531 */
115532
115533 static __always_inline void *
115534-__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
115535+__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
115536 {
115537- unsigned int *m;
115538- int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
115539- void *ret;
115540+ slob_t *m;
115541+ void *ret = NULL;
115542
115543 gfp &= gfp_allowed_mask;
115544
115545@@ -442,27 +448,45 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
115546
115547 if (!m)
115548 return NULL;
115549- *m = size;
115550+ BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
115551+ BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
115552+ m[0].units = size;
115553+ m[1].units = align;
115554 ret = (void *)m + align;
115555
115556 trace_kmalloc_node(caller, ret,
115557 size, size + align, gfp, node);
115558 } else {
115559 unsigned int order = get_order(size);
115560+ struct page *page;
115561
115562 if (likely(order))
115563 gfp |= __GFP_COMP;
115564- ret = slob_new_pages(gfp, order, node);
115565+ page = slob_new_pages(gfp, order, node);
115566+ if (page) {
115567+ ret = page_address(page);
115568+ page->private = size;
115569+ }
115570
115571 trace_kmalloc_node(caller, ret,
115572 size, PAGE_SIZE << order, gfp, node);
115573 }
115574
115575- kmemleak_alloc(ret, size, 1, gfp);
115576 return ret;
115577 }
115578
115579-void *__kmalloc(size_t size, gfp_t gfp)
115580+static __always_inline void *
115581+__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
115582+{
115583+ int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
115584+ void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
115585+
115586+ if (!ZERO_OR_NULL_PTR(ret))
115587+ kmemleak_alloc(ret, size, 1, gfp);
115588+ return ret;
115589+}
115590+
115591+void * __size_overflow(1) __kmalloc(size_t size, gfp_t gfp)
115592 {
115593 return __do_kmalloc_node(size, gfp, NUMA_NO_NODE, _RET_IP_);
115594 }
115595@@ -491,34 +515,112 @@ void kfree(const void *block)
115596 return;
115597 kmemleak_free(block);
115598
115599+ VM_BUG_ON(!virt_addr_valid(block));
115600 sp = virt_to_page(block);
115601- if (PageSlab(sp)) {
115602+ VM_BUG_ON(!PageSlab(sp));
115603+ if (!sp->private) {
115604 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
115605- unsigned int *m = (unsigned int *)(block - align);
115606- slob_free(m, *m + align);
115607- } else
115608+ slob_t *m = (slob_t *)(block - align);
115609+ slob_free(NULL, m, m[0].units + align);
115610+ } else {
115611+ __ClearPageSlab(sp);
115612+ page_mapcount_reset(sp);
115613+ sp->private = 0;
115614 __free_pages(sp, compound_order(sp));
115615+ }
115616 }
115617 EXPORT_SYMBOL(kfree);
115618
115619+bool is_usercopy_object(const void *ptr)
115620+{
115621+ if (!slab_is_available())
115622+ return false;
115623+
115624+ // PAX: TODO
115625+
115626+ return false;
115627+}
115628+
115629+#ifdef CONFIG_PAX_USERCOPY
115630+const char *check_heap_object(const void *ptr, unsigned long n)
115631+{
115632+ struct page *page;
115633+ const slob_t *free;
115634+ const void *base;
115635+ unsigned long flags;
115636+
115637+ if (ZERO_OR_NULL_PTR(ptr))
115638+ return "<null>";
115639+
115640+ if (!virt_addr_valid(ptr))
115641+ return NULL;
115642+
115643+ page = virt_to_head_page(ptr);
115644+ if (!PageSlab(page))
115645+ return NULL;
115646+
115647+ if (page->private) {
115648+ base = page;
115649+ if (base <= ptr && n <= page->private - (ptr - base))
115650+ return NULL;
115651+ return "<slob>";
115652+ }
115653+
115654+ /* some tricky double walking to find the chunk */
115655+ spin_lock_irqsave(&slob_lock, flags);
115656+ base = (void *)((unsigned long)ptr & PAGE_MASK);
115657+ free = page->freelist;
115658+
115659+ while (!slob_last(free) && (void *)free <= ptr) {
115660+ base = free + slob_units(free);
115661+ free = slob_next(free);
115662+ }
115663+
115664+ while (base < (void *)free) {
115665+ slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
115666+ int size = SLOB_UNIT * SLOB_UNITS(m + align);
115667+ int offset;
115668+
115669+ if (ptr < base + align)
115670+ break;
115671+
115672+ offset = ptr - base - align;
115673+ if (offset >= m) {
115674+ base += size;
115675+ continue;
115676+ }
115677+
115678+ if (n > m - offset)
115679+ break;
115680+
115681+ spin_unlock_irqrestore(&slob_lock, flags);
115682+ return NULL;
115683+ }
115684+
115685+ spin_unlock_irqrestore(&slob_lock, flags);
115686+ return "<slob>";
115687+}
115688+#endif
115689+
115690 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
115691 size_t ksize(const void *block)
115692 {
115693 struct page *sp;
115694 int align;
115695- unsigned int *m;
115696+ slob_t *m;
115697
115698 BUG_ON(!block);
115699 if (unlikely(block == ZERO_SIZE_PTR))
115700 return 0;
115701
115702 sp = virt_to_page(block);
115703- if (unlikely(!PageSlab(sp)))
115704- return PAGE_SIZE << compound_order(sp);
115705+ VM_BUG_ON(!PageSlab(sp));
115706+ if (sp->private)
115707+ return sp->private;
115708
115709 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
115710- m = (unsigned int *)(block - align);
115711- return SLOB_UNITS(*m) * SLOB_UNIT;
115712+ m = (slob_t *)(block - align);
115713+ return SLOB_UNITS(m[0].units) * SLOB_UNIT;
115714 }
115715 EXPORT_SYMBOL(ksize);
115716
115717@@ -534,23 +636,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
115718
115719 static void *slob_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
115720 {
115721- void *b;
115722+ void *b = NULL;
115723
115724 flags &= gfp_allowed_mask;
115725
115726 lockdep_trace_alloc(flags);
115727
115728+#ifdef CONFIG_PAX_USERCOPY_SLABS
115729+ b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
115730+#else
115731 if (c->size < PAGE_SIZE) {
115732 b = slob_alloc(c->size, flags, c->align, node);
115733 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
115734 SLOB_UNITS(c->size) * SLOB_UNIT,
115735 flags, node);
115736 } else {
115737- b = slob_new_pages(flags, get_order(c->size), node);
115738+ struct page *sp;
115739+
115740+ sp = slob_new_pages(flags, get_order(c->size), node);
115741+ if (sp) {
115742+ b = page_address(sp);
115743+ sp->private = c->size;
115744+ }
115745 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
115746 PAGE_SIZE << get_order(c->size),
115747 flags, node);
115748 }
115749+#endif
115750
115751 if (b && c->ctor)
115752 c->ctor(b);
115753@@ -566,7 +678,7 @@ void *kmem_cache_alloc(struct kmem_cache *cachep, gfp_t flags)
115754 EXPORT_SYMBOL(kmem_cache_alloc);
115755
115756 #ifdef CONFIG_NUMA
115757-void *__kmalloc_node(size_t size, gfp_t gfp, int node)
115758+void * __size_overflow(1) __kmalloc_node(size_t size, gfp_t gfp, int node)
115759 {
115760 return __do_kmalloc_node(size, gfp, node, _RET_IP_);
115761 }
115762@@ -579,12 +691,16 @@ void *kmem_cache_alloc_node(struct kmem_cache *cachep, gfp_t gfp, int node)
115763 EXPORT_SYMBOL(kmem_cache_alloc_node);
115764 #endif
115765
115766-static void __kmem_cache_free(void *b, int size)
115767+static void __kmem_cache_free(struct kmem_cache *c, void *b, int size)
115768 {
115769- if (size < PAGE_SIZE)
115770- slob_free(b, size);
115771+ struct page *sp;
115772+
115773+ sp = virt_to_page(b);
115774+ BUG_ON(!PageSlab(sp));
115775+ if (!sp->private)
115776+ slob_free(c, b, size);
115777 else
115778- slob_free_pages(b, get_order(size));
115779+ slob_free_pages(sp, get_order(size));
115780 }
115781
115782 static void kmem_rcu_free(struct rcu_head *head)
115783@@ -592,22 +708,36 @@ static void kmem_rcu_free(struct rcu_head *head)
115784 struct slob_rcu *slob_rcu = (struct slob_rcu *)head;
115785 void *b = (void *)slob_rcu - (slob_rcu->size - sizeof(struct slob_rcu));
115786
115787- __kmem_cache_free(b, slob_rcu->size);
115788+ __kmem_cache_free(NULL, b, slob_rcu->size);
115789 }
115790
115791 void kmem_cache_free(struct kmem_cache *c, void *b)
115792 {
115793+ int size = c->size;
115794+
115795+#ifdef CONFIG_PAX_USERCOPY_SLABS
115796+ if (size + c->align < PAGE_SIZE) {
115797+ size += c->align;
115798+ b -= c->align;
115799+ }
115800+#endif
115801+
115802 kmemleak_free_recursive(b, c->flags);
115803 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
115804 struct slob_rcu *slob_rcu;
115805- slob_rcu = b + (c->size - sizeof(struct slob_rcu));
115806- slob_rcu->size = c->size;
115807+ slob_rcu = b + (size - sizeof(struct slob_rcu));
115808+ slob_rcu->size = size;
115809 call_rcu(&slob_rcu->head, kmem_rcu_free);
115810 } else {
115811- __kmem_cache_free(b, c->size);
115812+ __kmem_cache_free(c, b, size);
115813 }
115814
115815+#ifdef CONFIG_PAX_USERCOPY_SLABS
115816+ trace_kfree(_RET_IP_, b);
115817+#else
115818 trace_kmem_cache_free(_RET_IP_, b);
115819+#endif
115820+
115821 }
115822 EXPORT_SYMBOL(kmem_cache_free);
115823
115824diff --git a/mm/slub.c b/mm/slub.c
115825index 54c0876..31383a1 100644
115826--- a/mm/slub.c
115827+++ b/mm/slub.c
115828@@ -198,7 +198,7 @@ struct track {
115829
115830 enum track_item { TRACK_ALLOC, TRACK_FREE };
115831
115832-#ifdef CONFIG_SYSFS
115833+#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
115834 static int sysfs_slab_add(struct kmem_cache *);
115835 static int sysfs_slab_alias(struct kmem_cache *, const char *);
115836 static void memcg_propagate_slab_attrs(struct kmem_cache *s);
115837@@ -556,7 +556,7 @@ static void print_track(const char *s, struct track *t)
115838 if (!t->addr)
115839 return;
115840
115841- pr_err("INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
115842+ pr_err("INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
115843 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
115844 #ifdef CONFIG_STACKTRACE
115845 {
115846@@ -2707,6 +2707,14 @@ static __always_inline void slab_free(struct kmem_cache *s,
115847
115848 slab_free_hook(s, x);
115849
115850+#ifdef CONFIG_PAX_MEMORY_SANITIZE
115851+ if (!(s->flags & SLAB_NO_SANITIZE)) {
115852+ memset(x, PAX_MEMORY_SANITIZE_VALUE, s->object_size);
115853+ if (s->ctor)
115854+ s->ctor(x);
115855+ }
115856+#endif
115857+
115858 redo:
115859 /*
115860 * Determine the currently cpus per cpu slab.
115861@@ -3048,6 +3056,9 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order)
115862 s->inuse = size;
115863
115864 if (((flags & (SLAB_DESTROY_BY_RCU | SLAB_POISON)) ||
115865+#ifdef CONFIG_PAX_MEMORY_SANITIZE
115866+ (!(flags & SLAB_NO_SANITIZE)) ||
115867+#endif
115868 s->ctor)) {
115869 /*
115870 * Relocate free pointer after the object if it is not
115871@@ -3302,7 +3313,7 @@ static int __init setup_slub_min_objects(char *str)
115872
115873 __setup("slub_min_objects=", setup_slub_min_objects);
115874
115875-void *__kmalloc(size_t size, gfp_t flags)
115876+void * __size_overflow(1) __kmalloc(size_t size, gfp_t flags)
115877 {
115878 struct kmem_cache *s;
115879 void *ret;
115880@@ -3340,7 +3351,7 @@ static void *kmalloc_large_node(size_t size, gfp_t flags, int node)
115881 return ptr;
115882 }
115883
115884-void *__kmalloc_node(size_t size, gfp_t flags, int node)
115885+void * __size_overflow(1) __kmalloc_node(size_t size, gfp_t flags, int node)
115886 {
115887 struct kmem_cache *s;
115888 void *ret;
115889@@ -3388,6 +3399,59 @@ static size_t __ksize(const void *object)
115890 return slab_ksize(page->slab_cache);
115891 }
115892
115893+bool is_usercopy_object(const void *ptr)
115894+{
115895+ struct page *page;
115896+ struct kmem_cache *s;
115897+
115898+ if (ZERO_OR_NULL_PTR(ptr))
115899+ return false;
115900+
115901+ if (!slab_is_available())
115902+ return false;
115903+
115904+ if (!virt_addr_valid(ptr))
115905+ return false;
115906+
115907+ page = virt_to_head_page(ptr);
115908+
115909+ if (!PageSlab(page))
115910+ return false;
115911+
115912+ s = page->slab_cache;
115913+ return s->flags & SLAB_USERCOPY;
115914+}
115915+
115916+#ifdef CONFIG_PAX_USERCOPY
115917+const char *check_heap_object(const void *ptr, unsigned long n)
115918+{
115919+ struct page *page;
115920+ struct kmem_cache *s;
115921+ unsigned long offset;
115922+
115923+ if (ZERO_OR_NULL_PTR(ptr))
115924+ return "<null>";
115925+
115926+ if (!virt_addr_valid(ptr))
115927+ return NULL;
115928+
115929+ page = virt_to_head_page(ptr);
115930+
115931+ if (!PageSlab(page))
115932+ return NULL;
115933+
115934+ s = page->slab_cache;
115935+ if (!(s->flags & SLAB_USERCOPY))
115936+ return s->name;
115937+
115938+ offset = (ptr - page_address(page)) % s->size;
115939+ if (offset <= s->object_size && n <= s->object_size - offset)
115940+ return NULL;
115941+
115942+ return s->name;
115943+}
115944+#endif
115945+
115946 size_t ksize(const void *object)
115947 {
115948 size_t size = __ksize(object);
115949@@ -3408,6 +3472,7 @@ void kfree(const void *x)
115950 if (unlikely(ZERO_OR_NULL_PTR(x)))
115951 return;
115952
115953+ VM_BUG_ON(!virt_addr_valid(x));
115954 page = virt_to_head_page(x);
115955 if (unlikely(!PageSlab(page))) {
115956 BUG_ON(!PageCompound(page));
115957@@ -3724,7 +3789,7 @@ __kmem_cache_alias(const char *name, size_t size, size_t align,
115958
115959 s = find_mergeable(size, align, flags, name, ctor);
115960 if (s) {
115961- s->refcount++;
115962+ atomic_inc(&s->refcount);
115963
115964 /*
115965 * Adjust the object sizes so that we clear
115966@@ -3740,7 +3805,7 @@ __kmem_cache_alias(const char *name, size_t size, size_t align,
115967 }
115968
115969 if (sysfs_slab_alias(s, name)) {
115970- s->refcount--;
115971+ atomic_dec(&s->refcount);
115972 s = NULL;
115973 }
115974 }
115975@@ -3857,7 +3922,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
115976 }
115977 #endif
115978
115979-#ifdef CONFIG_SYSFS
115980+#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
115981 static int count_inuse(struct page *page)
115982 {
115983 return page->inuse;
115984@@ -4138,7 +4203,11 @@ static int list_locations(struct kmem_cache *s, char *buf,
115985 len += sprintf(buf + len, "%7ld ", l->count);
115986
115987 if (l->addr)
115988+#ifdef CONFIG_GRKERNSEC_HIDESYM
115989+ len += sprintf(buf + len, "%pS", NULL);
115990+#else
115991 len += sprintf(buf + len, "%pS", (void *)l->addr);
115992+#endif
115993 else
115994 len += sprintf(buf + len, "<not-available>");
115995
115996@@ -4236,12 +4305,12 @@ static void __init resiliency_test(void)
115997 validate_slab_cache(kmalloc_caches[9]);
115998 }
115999 #else
116000-#ifdef CONFIG_SYSFS
116001+#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
116002 static void resiliency_test(void) {};
116003 #endif
116004 #endif
116005
116006-#ifdef CONFIG_SYSFS
116007+#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
116008 enum slab_stat_type {
116009 SL_ALL, /* All slabs */
116010 SL_PARTIAL, /* Only partially allocated slabs */
116011@@ -4478,13 +4547,17 @@ static ssize_t ctor_show(struct kmem_cache *s, char *buf)
116012 {
116013 if (!s->ctor)
116014 return 0;
116015+#ifdef CONFIG_GRKERNSEC_HIDESYM
116016+ return sprintf(buf, "%pS\n", NULL);
116017+#else
116018 return sprintf(buf, "%pS\n", s->ctor);
116019+#endif
116020 }
116021 SLAB_ATTR_RO(ctor);
116022
116023 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
116024 {
116025- return sprintf(buf, "%d\n", s->refcount < 0 ? 0 : s->refcount - 1);
116026+ return sprintf(buf, "%d\n", atomic_read(&s->refcount) < 0 ? 0 : atomic_read(&s->refcount) - 1);
116027 }
116028 SLAB_ATTR_RO(aliases);
116029
116030@@ -4572,6 +4645,22 @@ static ssize_t cache_dma_show(struct kmem_cache *s, char *buf)
116031 SLAB_ATTR_RO(cache_dma);
116032 #endif
116033
116034+#ifdef CONFIG_PAX_USERCOPY_SLABS
116035+static ssize_t usercopy_show(struct kmem_cache *s, char *buf)
116036+{
116037+ return sprintf(buf, "%d\n", !!(s->flags & SLAB_USERCOPY));
116038+}
116039+SLAB_ATTR_RO(usercopy);
116040+#endif
116041+
116042+#ifdef CONFIG_PAX_MEMORY_SANITIZE
116043+static ssize_t sanitize_show(struct kmem_cache *s, char *buf)
116044+{
116045+ return sprintf(buf, "%d\n", !(s->flags & SLAB_NO_SANITIZE));
116046+}
116047+SLAB_ATTR_RO(sanitize);
116048+#endif
116049+
116050 static ssize_t destroy_by_rcu_show(struct kmem_cache *s, char *buf)
116051 {
116052 return sprintf(buf, "%d\n", !!(s->flags & SLAB_DESTROY_BY_RCU));
116053@@ -4627,7 +4716,7 @@ static ssize_t trace_store(struct kmem_cache *s, const char *buf,
116054 * as well as cause other issues like converting a mergeable
116055 * cache into an umergeable one.
116056 */
116057- if (s->refcount > 1)
116058+ if (atomic_read(&s->refcount) > 1)
116059 return -EINVAL;
116060
116061 s->flags &= ~SLAB_TRACE;
116062@@ -4747,7 +4836,7 @@ static ssize_t failslab_show(struct kmem_cache *s, char *buf)
116063 static ssize_t failslab_store(struct kmem_cache *s, const char *buf,
116064 size_t length)
116065 {
116066- if (s->refcount > 1)
116067+ if (atomic_read(&s->refcount) > 1)
116068 return -EINVAL;
116069
116070 s->flags &= ~SLAB_FAILSLAB;
116071@@ -4914,6 +5003,12 @@ static struct attribute *slab_attrs[] = {
116072 #ifdef CONFIG_ZONE_DMA
116073 &cache_dma_attr.attr,
116074 #endif
116075+#ifdef CONFIG_PAX_USERCOPY_SLABS
116076+ &usercopy_attr.attr,
116077+#endif
116078+#ifdef CONFIG_PAX_MEMORY_SANITIZE
116079+ &sanitize_attr.attr,
116080+#endif
116081 #ifdef CONFIG_NUMA
116082 &remote_node_defrag_ratio_attr.attr,
116083 #endif
116084@@ -5155,6 +5250,7 @@ static char *create_unique_id(struct kmem_cache *s)
116085 return name;
116086 }
116087
116088+#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
116089 static int sysfs_slab_add(struct kmem_cache *s)
116090 {
116091 int err;
116092@@ -5228,6 +5324,7 @@ void sysfs_slab_remove(struct kmem_cache *s)
116093 kobject_del(&s->kobj);
116094 kobject_put(&s->kobj);
116095 }
116096+#endif
116097
116098 /*
116099 * Need to buffer aliases during bootup until sysfs becomes
116100@@ -5241,6 +5338,7 @@ struct saved_alias {
116101
116102 static struct saved_alias *alias_list;
116103
116104+#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
116105 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
116106 {
116107 struct saved_alias *al;
116108@@ -5263,6 +5361,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
116109 alias_list = al;
116110 return 0;
116111 }
116112+#endif
116113
116114 static int __init slab_sysfs_init(void)
116115 {
116116diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
116117index 4cba9c2..b4f9fcc 100644
116118--- a/mm/sparse-vmemmap.c
116119+++ b/mm/sparse-vmemmap.c
116120@@ -131,7 +131,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
116121 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
116122 if (!p)
116123 return NULL;
116124- pud_populate(&init_mm, pud, p);
116125+ pud_populate_kernel(&init_mm, pud, p);
116126 }
116127 return pud;
116128 }
116129@@ -143,7 +143,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
116130 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
116131 if (!p)
116132 return NULL;
116133- pgd_populate(&init_mm, pgd, p);
116134+ pgd_populate_kernel(&init_mm, pgd, p);
116135 }
116136 return pgd;
116137 }
116138diff --git a/mm/sparse.c b/mm/sparse.c
116139index d1b48b6..6e8590e 100644
116140--- a/mm/sparse.c
116141+++ b/mm/sparse.c
116142@@ -750,7 +750,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
116143
116144 for (i = 0; i < PAGES_PER_SECTION; i++) {
116145 if (PageHWPoison(&memmap[i])) {
116146- atomic_long_sub(1, &num_poisoned_pages);
116147+ atomic_long_sub_unchecked(1, &num_poisoned_pages);
116148 ClearPageHWPoison(&memmap[i]);
116149 }
116150 }
116151diff --git a/mm/swap.c b/mm/swap.c
116152index a7251a8..ac754a9 100644
116153--- a/mm/swap.c
116154+++ b/mm/swap.c
116155@@ -85,6 +85,8 @@ static void __put_compound_page(struct page *page)
116156 if (!PageHuge(page))
116157 __page_cache_release(page);
116158 dtor = get_compound_page_dtor(page);
116159+ if (!PageHuge(page))
116160+ BUG_ON(dtor != free_compound_page);
116161 (*dtor)(page);
116162 }
116163
116164diff --git a/mm/swapfile.c b/mm/swapfile.c
116165index a7e7210..b286e7d 100644
116166--- a/mm/swapfile.c
116167+++ b/mm/swapfile.c
116168@@ -84,7 +84,7 @@ static DEFINE_MUTEX(swapon_mutex);
116169
116170 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
116171 /* Activity counter to indicate that a swapon or swapoff has occurred */
116172-static atomic_t proc_poll_event = ATOMIC_INIT(0);
116173+static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
116174
116175 static inline unsigned char swap_count(unsigned char ent)
116176 {
116177@@ -1944,7 +1944,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
116178 spin_unlock(&swap_lock);
116179
116180 err = 0;
116181- atomic_inc(&proc_poll_event);
116182+ atomic_inc_unchecked(&proc_poll_event);
116183 wake_up_interruptible(&proc_poll_wait);
116184
116185 out_dput:
116186@@ -1961,8 +1961,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
116187
116188 poll_wait(file, &proc_poll_wait, wait);
116189
116190- if (seq->poll_event != atomic_read(&proc_poll_event)) {
116191- seq->poll_event = atomic_read(&proc_poll_event);
116192+ if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
116193+ seq->poll_event = atomic_read_unchecked(&proc_poll_event);
116194 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
116195 }
116196
116197@@ -2060,7 +2060,7 @@ static int swaps_open(struct inode *inode, struct file *file)
116198 return ret;
116199
116200 seq = file->private_data;
116201- seq->poll_event = atomic_read(&proc_poll_event);
116202+ seq->poll_event = atomic_read_unchecked(&proc_poll_event);
116203 return 0;
116204 }
116205
116206@@ -2520,7 +2520,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
116207 (frontswap_map) ? "FS" : "");
116208
116209 mutex_unlock(&swapon_mutex);
116210- atomic_inc(&proc_poll_event);
116211+ atomic_inc_unchecked(&proc_poll_event);
116212 wake_up_interruptible(&proc_poll_wait);
116213
116214 if (S_ISREG(inode->i_mode))
116215diff --git a/mm/util.c b/mm/util.c
116216index 68ff8a5..40c7a70 100644
116217--- a/mm/util.c
116218+++ b/mm/util.c
116219@@ -233,6 +233,12 @@ struct task_struct *task_of_stack(struct task_struct *task,
116220 void arch_pick_mmap_layout(struct mm_struct *mm)
116221 {
116222 mm->mmap_base = TASK_UNMAPPED_BASE;
116223+
116224+#ifdef CONFIG_PAX_RANDMMAP
116225+ if (mm->pax_flags & MF_PAX_RANDMMAP)
116226+ mm->mmap_base += mm->delta_mmap;
116227+#endif
116228+
116229 mm->get_unmapped_area = arch_get_unmapped_area;
116230 }
116231 #endif
116232@@ -434,6 +440,9 @@ int get_cmdline(struct task_struct *task, char *buffer, int buflen)
116233 if (!mm->arg_end)
116234 goto out_mm; /* Shh! No looking before we're done */
116235
116236+ if (gr_acl_handle_procpidmem(task))
116237+ goto out_mm;
116238+
116239 len = mm->arg_end - mm->arg_start;
116240
116241 if (len > buflen)
116242diff --git a/mm/vmalloc.c b/mm/vmalloc.c
116243index 2faaa29..9744185 100644
116244--- a/mm/vmalloc.c
116245+++ b/mm/vmalloc.c
116246@@ -40,20 +40,65 @@ struct vfree_deferred {
116247 struct work_struct wq;
116248 };
116249 static DEFINE_PER_CPU(struct vfree_deferred, vfree_deferred);
116250+static DEFINE_PER_CPU(struct vfree_deferred, vunmap_deferred);
116251+
116252+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
116253+struct stack_deferred_llist {
116254+ struct llist_head list;
116255+ void *stack;
116256+ void *lowmem_stack;
116257+};
116258+
116259+struct stack_deferred {
116260+ struct stack_deferred_llist list;
116261+ struct work_struct wq;
116262+};
116263+
116264+static DEFINE_PER_CPU(struct stack_deferred, stack_deferred);
116265+#endif
116266
116267 static void __vunmap(const void *, int);
116268
116269-static void free_work(struct work_struct *w)
116270+static void vfree_work(struct work_struct *w)
116271 {
116272 struct vfree_deferred *p = container_of(w, struct vfree_deferred, wq);
116273 struct llist_node *llnode = llist_del_all(&p->list);
116274 while (llnode) {
116275- void *p = llnode;
116276+ void *x = llnode;
116277 llnode = llist_next(llnode);
116278- __vunmap(p, 1);
116279+ __vunmap(x, 1);
116280 }
116281 }
116282
116283+static void vunmap_work(struct work_struct *w)
116284+{
116285+ struct vfree_deferred *p = container_of(w, struct vfree_deferred, wq);
116286+ struct llist_node *llnode = llist_del_all(&p->list);
116287+ while (llnode) {
116288+ void *x = llnode;
116289+ llnode = llist_next(llnode);
116290+ __vunmap(x, 0);
116291+ }
116292+}
116293+
116294+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
116295+static void unmap_work(struct work_struct *w)
116296+{
116297+ struct stack_deferred *p = container_of(w, struct stack_deferred, wq);
116298+ struct llist_node *llnode = llist_del_all(&p->list.list);
116299+ while (llnode) {
116300+ struct stack_deferred_llist *x =
116301+ llist_entry((struct llist_head *)llnode,
116302+ struct stack_deferred_llist, list);
116303+ void *stack = ACCESS_ONCE(x->stack);
116304+ void *lowmem_stack = ACCESS_ONCE(x->lowmem_stack);
116305+ llnode = llist_next(llnode);
116306+ __vunmap(stack, 0);
116307+ free_kmem_pages((unsigned long)lowmem_stack, THREAD_SIZE_ORDER);
116308+ }
116309+}
116310+#endif
116311+
116312 /*** Page table manipulation functions ***/
116313
116314 static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
116315@@ -62,8 +107,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
116316
116317 pte = pte_offset_kernel(pmd, addr);
116318 do {
116319- pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
116320- WARN_ON(!pte_none(ptent) && !pte_present(ptent));
116321+
116322+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
116323+ if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
116324+ BUG_ON(!pte_exec(*pte));
116325+ set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
116326+ continue;
116327+ }
116328+#endif
116329+
116330+ {
116331+ pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
116332+ WARN_ON(!pte_none(ptent) && !pte_present(ptent));
116333+ }
116334 } while (pte++, addr += PAGE_SIZE, addr != end);
116335 }
116336
116337@@ -127,16 +183,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
116338 pte = pte_alloc_kernel(pmd, addr);
116339 if (!pte)
116340 return -ENOMEM;
116341+
116342+ pax_open_kernel();
116343 do {
116344 struct page *page = pages[*nr];
116345
116346- if (WARN_ON(!pte_none(*pte)))
116347+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
116348+ if (pgprot_val(prot) & _PAGE_NX)
116349+#endif
116350+
116351+ if (!pte_none(*pte)) {
116352+ pax_close_kernel();
116353+ WARN_ON(1);
116354 return -EBUSY;
116355- if (WARN_ON(!page))
116356+ }
116357+ if (!page) {
116358+ pax_close_kernel();
116359+ WARN_ON(1);
116360 return -ENOMEM;
116361+ }
116362 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
116363 (*nr)++;
116364 } while (pte++, addr += PAGE_SIZE, addr != end);
116365+ pax_close_kernel();
116366 return 0;
116367 }
116368
116369@@ -146,7 +215,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
116370 pmd_t *pmd;
116371 unsigned long next;
116372
116373- pmd = pmd_alloc(&init_mm, pud, addr);
116374+ pmd = pmd_alloc_kernel(&init_mm, pud, addr);
116375 if (!pmd)
116376 return -ENOMEM;
116377 do {
116378@@ -163,7 +232,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
116379 pud_t *pud;
116380 unsigned long next;
116381
116382- pud = pud_alloc(&init_mm, pgd, addr);
116383+ pud = pud_alloc_kernel(&init_mm, pgd, addr);
116384 if (!pud)
116385 return -ENOMEM;
116386 do {
116387@@ -223,6 +292,12 @@ int is_vmalloc_or_module_addr(const void *x)
116388 if (addr >= MODULES_VADDR && addr < MODULES_END)
116389 return 1;
116390 #endif
116391+
116392+#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
116393+ if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
116394+ return 1;
116395+#endif
116396+
116397 return is_vmalloc_addr(x);
116398 }
116399
116400@@ -243,8 +318,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
116401
116402 if (!pgd_none(*pgd)) {
116403 pud_t *pud = pud_offset(pgd, addr);
116404+#ifdef CONFIG_X86
116405+ if (!pud_large(*pud))
116406+#endif
116407 if (!pud_none(*pud)) {
116408 pmd_t *pmd = pmd_offset(pud, addr);
116409+#ifdef CONFIG_X86
116410+ if (!pmd_large(*pmd))
116411+#endif
116412 if (!pmd_none(*pmd)) {
116413 pte_t *ptep, pte;
116414
116415@@ -346,7 +427,7 @@ static void purge_vmap_area_lazy(void);
116416 * Allocate a region of KVA of the specified size and alignment, within the
116417 * vstart and vend.
116418 */
116419-static struct vmap_area *alloc_vmap_area(unsigned long size,
116420+static struct vmap_area * __size_overflow(1) alloc_vmap_area(unsigned long size,
116421 unsigned long align,
116422 unsigned long vstart, unsigned long vend,
116423 int node, gfp_t gfp_mask)
116424@@ -1202,13 +1283,27 @@ void __init vmalloc_init(void)
116425 for_each_possible_cpu(i) {
116426 struct vmap_block_queue *vbq;
116427 struct vfree_deferred *p;
116428+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
116429+ struct stack_deferred *p2;
116430+#endif
116431
116432 vbq = &per_cpu(vmap_block_queue, i);
116433 spin_lock_init(&vbq->lock);
116434 INIT_LIST_HEAD(&vbq->free);
116435+
116436 p = &per_cpu(vfree_deferred, i);
116437 init_llist_head(&p->list);
116438- INIT_WORK(&p->wq, free_work);
116439+ INIT_WORK(&p->wq, vfree_work);
116440+
116441+ p = &per_cpu(vunmap_deferred, i);
116442+ init_llist_head(&p->list);
116443+ INIT_WORK(&p->wq, vunmap_work);
116444+
116445+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
116446+ p2 = &per_cpu(stack_deferred, i);
116447+ init_llist_head(&p2->list.list);
116448+ INIT_WORK(&p2->wq, unmap_work);
116449+#endif
116450 }
116451
116452 /* Import existing vmlist entries. */
116453@@ -1333,6 +1428,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
116454 struct vm_struct *area;
116455
116456 BUG_ON(in_interrupt());
116457+
116458+#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
116459+ if (flags & VM_KERNEXEC) {
116460+ if (start != VMALLOC_START || end != VMALLOC_END)
116461+ return NULL;
116462+ start = (unsigned long)MODULES_EXEC_VADDR;
116463+ end = (unsigned long)MODULES_EXEC_END;
116464+ }
116465+#endif
116466+
116467 if (flags & VM_IOREMAP)
116468 align = 1ul << clamp_t(int, fls_long(size),
116469 PAGE_SHIFT, IOREMAP_MAX_ORDER);
116470@@ -1531,13 +1636,36 @@ EXPORT_SYMBOL(vfree);
116471 */
116472 void vunmap(const void *addr)
116473 {
116474- BUG_ON(in_interrupt());
116475- might_sleep();
116476- if (addr)
116477+ if (!addr)
116478+ return;
116479+ if (unlikely(in_interrupt())) {
116480+ struct vfree_deferred *p = this_cpu_ptr(&vunmap_deferred);
116481+ if (llist_add((struct llist_node *)addr, &p->list))
116482+ schedule_work(&p->wq);
116483+ } else {
116484+ might_sleep();
116485 __vunmap(addr, 0);
116486+ }
116487 }
116488 EXPORT_SYMBOL(vunmap);
116489
116490+#ifdef CONFIG_GRKERNSEC_KSTACKOVERFLOW
116491+void unmap_process_stacks(struct task_struct *task)
116492+{
116493+ if (unlikely(in_interrupt())) {
116494+ struct stack_deferred *p = this_cpu_ptr(&stack_deferred);
116495+ struct stack_deferred_llist *list = task->stack;
116496+ list->stack = task->stack;
116497+ list->lowmem_stack = task->lowmem_stack;
116498+ if (llist_add((struct llist_node *)&list->list, &p->list.list))
116499+ schedule_work(&p->wq);
116500+ } else {
116501+ __vunmap(task->stack, 0);
116502+ free_kmem_pages((unsigned long)task->lowmem_stack, THREAD_SIZE_ORDER);
116503+ }
116504+}
116505+#endif
116506+
116507 /**
116508 * vmap - map an array of pages into virtually contiguous space
116509 * @pages: array of page pointers
116510@@ -1558,6 +1686,11 @@ void *vmap(struct page **pages, unsigned int count,
116511 if (count > totalram_pages)
116512 return NULL;
116513
116514+#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
116515+ if (!(pgprot_val(prot) & _PAGE_NX))
116516+ flags |= VM_KERNEXEC;
116517+#endif
116518+
116519 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
116520 __builtin_return_address(0));
116521 if (!area)
116522@@ -1662,6 +1795,14 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
116523 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
116524 goto fail;
116525
116526+#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
116527+ if (!(pgprot_val(prot) & _PAGE_NX)) {
116528+ vm_flags |= VM_KERNEXEC;
116529+ start = VMALLOC_START;
116530+ end = VMALLOC_END;
116531+ }
116532+#endif
116533+
116534 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED |
116535 vm_flags, start, end, node, gfp_mask, caller);
116536 if (!area)
116537@@ -1838,10 +1979,9 @@ EXPORT_SYMBOL(vzalloc_node);
116538 * For tight control over page level allocator and protection flags
116539 * use __vmalloc() instead.
116540 */
116541-
116542 void *vmalloc_exec(unsigned long size)
116543 {
116544- return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
116545+ return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
116546 NUMA_NO_NODE, __builtin_return_address(0));
116547 }
116548
116549@@ -2148,6 +2288,8 @@ int remap_vmalloc_range_partial(struct vm_area_struct *vma, unsigned long uaddr,
116550 {
116551 struct vm_struct *area;
116552
116553+ BUG_ON(vma->vm_mirror);
116554+
116555 size = PAGE_ALIGN(size);
116556
116557 if (!PAGE_ALIGNED(uaddr) || !PAGE_ALIGNED(kaddr))
116558@@ -2630,7 +2772,11 @@ static int s_show(struct seq_file *m, void *p)
116559 v->addr, v->addr + v->size, v->size);
116560
116561 if (v->caller)
116562+#ifdef CONFIG_GRKERNSEC_HIDESYM
116563+ seq_printf(m, " %pK", v->caller);
116564+#else
116565 seq_printf(m, " %pS", v->caller);
116566+#endif
116567
116568 if (v->nr_pages)
116569 seq_printf(m, " pages=%d", v->nr_pages);
116570diff --git a/mm/vmstat.c b/mm/vmstat.c
116571index 4f5cd97..9fb715a 100644
116572--- a/mm/vmstat.c
116573+++ b/mm/vmstat.c
116574@@ -27,6 +27,7 @@
116575 #include <linux/mm_inline.h>
116576 #include <linux/page_ext.h>
116577 #include <linux/page_owner.h>
116578+#include <linux/grsecurity.h>
116579
116580 #include "internal.h"
116581
116582@@ -86,7 +87,7 @@ void vm_events_fold_cpu(int cpu)
116583 *
116584 * vm_stat contains the global counters
116585 */
116586-atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
116587+atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
116588 EXPORT_SYMBOL(vm_stat);
116589
116590 #ifdef CONFIG_SMP
116591@@ -438,7 +439,7 @@ static int fold_diff(int *diff)
116592
116593 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
116594 if (diff[i]) {
116595- atomic_long_add(diff[i], &vm_stat[i]);
116596+ atomic_long_add_unchecked(diff[i], &vm_stat[i]);
116597 changes++;
116598 }
116599 return changes;
116600@@ -476,7 +477,7 @@ static int refresh_cpu_vm_stats(void)
116601 v = this_cpu_xchg(p->vm_stat_diff[i], 0);
116602 if (v) {
116603
116604- atomic_long_add(v, &zone->vm_stat[i]);
116605+ atomic_long_add_unchecked(v, &zone->vm_stat[i]);
116606 global_diff[i] += v;
116607 #ifdef CONFIG_NUMA
116608 /* 3 seconds idle till flush */
116609@@ -540,7 +541,7 @@ void cpu_vm_stats_fold(int cpu)
116610
116611 v = p->vm_stat_diff[i];
116612 p->vm_stat_diff[i] = 0;
116613- atomic_long_add(v, &zone->vm_stat[i]);
116614+ atomic_long_add_unchecked(v, &zone->vm_stat[i]);
116615 global_diff[i] += v;
116616 }
116617 }
116618@@ -560,8 +561,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
116619 if (pset->vm_stat_diff[i]) {
116620 int v = pset->vm_stat_diff[i];
116621 pset->vm_stat_diff[i] = 0;
116622- atomic_long_add(v, &zone->vm_stat[i]);
116623- atomic_long_add(v, &vm_stat[i]);
116624+ atomic_long_add_unchecked(v, &zone->vm_stat[i]);
116625+ atomic_long_add_unchecked(v, &vm_stat[i]);
116626 }
116627 }
116628 #endif
116629@@ -1293,10 +1294,22 @@ static void *vmstat_start(struct seq_file *m, loff_t *pos)
116630 stat_items_size += sizeof(struct vm_event_state);
116631 #endif
116632
116633- v = kmalloc(stat_items_size, GFP_KERNEL);
116634+ v = kzalloc(stat_items_size, GFP_KERNEL);
116635 m->private = v;
116636 if (!v)
116637 return ERR_PTR(-ENOMEM);
116638+
116639+#ifdef CONFIG_GRKERNSEC_PROC_ADD
116640+#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
116641+ if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)
116642+#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
116643+ && !in_group_p(grsec_proc_gid)
116644+#endif
116645+ )
116646+ return (unsigned long *)m->private + *pos;
116647+#endif
116648+#endif
116649+
116650 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
116651 v[i] = global_page_state(i);
116652 v += NR_VM_ZONE_STAT_ITEMS;
116653@@ -1528,10 +1541,16 @@ static int __init setup_vmstat(void)
116654 cpu_notifier_register_done();
116655 #endif
116656 #ifdef CONFIG_PROC_FS
116657- proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
116658- proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
116659- proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
116660- proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
116661+ {
116662+ mode_t gr_mode = S_IRUGO;
116663+#ifdef CONFIG_GRKERNSEC_PROC_ADD
116664+ gr_mode = S_IRUSR;
116665+#endif
116666+ proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
116667+ proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
116668+ proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
116669+ proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
116670+ }
116671 #endif
116672 return 0;
116673 }
116674diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
116675index 59555f0..fd7ade9 100644
116676--- a/net/8021q/vlan.c
116677+++ b/net/8021q/vlan.c
116678@@ -491,7 +491,7 @@ out:
116679 return NOTIFY_DONE;
116680 }
116681
116682-static struct notifier_block vlan_notifier_block __read_mostly = {
116683+static struct notifier_block vlan_notifier_block = {
116684 .notifier_call = vlan_device_event,
116685 };
116686
116687@@ -566,8 +566,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
116688 err = -EPERM;
116689 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
116690 break;
116691- if ((args.u.name_type >= 0) &&
116692- (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
116693+ if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
116694 struct vlan_net *vn;
116695
116696 vn = net_generic(net, vlan_net_id);
116697diff --git a/net/8021q/vlan_netlink.c b/net/8021q/vlan_netlink.c
116698index c92b52f..006c052 100644
116699--- a/net/8021q/vlan_netlink.c
116700+++ b/net/8021q/vlan_netlink.c
116701@@ -245,7 +245,7 @@ static struct net *vlan_get_link_net(const struct net_device *dev)
116702 return dev_net(real_dev);
116703 }
116704
116705-struct rtnl_link_ops vlan_link_ops __read_mostly = {
116706+struct rtnl_link_ops vlan_link_ops = {
116707 .kind = "vlan",
116708 .maxtype = IFLA_VLAN_MAX,
116709 .policy = vlan_policy,
116710diff --git a/net/9p/mod.c b/net/9p/mod.c
116711index 6ab36ae..6f1841b 100644
116712--- a/net/9p/mod.c
116713+++ b/net/9p/mod.c
116714@@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
116715 void v9fs_register_trans(struct p9_trans_module *m)
116716 {
116717 spin_lock(&v9fs_trans_lock);
116718- list_add_tail(&m->list, &v9fs_trans_list);
116719+ pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
116720 spin_unlock(&v9fs_trans_lock);
116721 }
116722 EXPORT_SYMBOL(v9fs_register_trans);
116723@@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
116724 void v9fs_unregister_trans(struct p9_trans_module *m)
116725 {
116726 spin_lock(&v9fs_trans_lock);
116727- list_del_init(&m->list);
116728+ pax_list_del_init((struct list_head *)&m->list);
116729 spin_unlock(&v9fs_trans_lock);
116730 }
116731 EXPORT_SYMBOL(v9fs_unregister_trans);
116732diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
116733index bced8c0..ef253b7 100644
116734--- a/net/9p/trans_fd.c
116735+++ b/net/9p/trans_fd.c
116736@@ -428,7 +428,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
116737 oldfs = get_fs();
116738 set_fs(get_ds());
116739 /* The cast to a user pointer is valid due to the set_fs() */
116740- ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
116741+ ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
116742 set_fs(oldfs);
116743
116744 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
116745diff --git a/net/appletalk/atalk_proc.c b/net/appletalk/atalk_proc.c
116746index af46bc4..f9adfcd 100644
116747--- a/net/appletalk/atalk_proc.c
116748+++ b/net/appletalk/atalk_proc.c
116749@@ -256,7 +256,7 @@ int __init atalk_proc_init(void)
116750 struct proc_dir_entry *p;
116751 int rc = -ENOMEM;
116752
116753- atalk_proc_dir = proc_mkdir("atalk", init_net.proc_net);
116754+ atalk_proc_dir = proc_mkdir_restrict("atalk", init_net.proc_net);
116755 if (!atalk_proc_dir)
116756 goto out;
116757
116758diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
116759index 876fbe8..8bbea9f 100644
116760--- a/net/atm/atm_misc.c
116761+++ b/net/atm/atm_misc.c
116762@@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
116763 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
116764 return 1;
116765 atm_return(vcc, truesize);
116766- atomic_inc(&vcc->stats->rx_drop);
116767+ atomic_inc_unchecked(&vcc->stats->rx_drop);
116768 return 0;
116769 }
116770 EXPORT_SYMBOL(atm_charge);
116771@@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
116772 }
116773 }
116774 atm_return(vcc, guess);
116775- atomic_inc(&vcc->stats->rx_drop);
116776+ atomic_inc_unchecked(&vcc->stats->rx_drop);
116777 return NULL;
116778 }
116779 EXPORT_SYMBOL(atm_alloc_charge);
116780@@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
116781
116782 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
116783 {
116784-#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
116785+#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
116786 __SONET_ITEMS
116787 #undef __HANDLE_ITEM
116788 }
116789@@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
116790
116791 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
116792 {
116793-#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
116794+#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
116795 __SONET_ITEMS
116796 #undef __HANDLE_ITEM
116797 }
116798diff --git a/net/atm/lec.c b/net/atm/lec.c
116799index cd3b379..977a3c9 100644
116800--- a/net/atm/lec.c
116801+++ b/net/atm/lec.c
116802@@ -111,9 +111,9 @@ static inline void lec_arp_put(struct lec_arp_table *entry)
116803 }
116804
116805 static struct lane2_ops lane2_ops = {
116806- lane2_resolve, /* resolve, spec 3.1.3 */
116807- lane2_associate_req, /* associate_req, spec 3.1.4 */
116808- NULL /* associate indicator, spec 3.1.5 */
116809+ .resolve = lane2_resolve,
116810+ .associate_req = lane2_associate_req,
116811+ .associate_indicator = NULL
116812 };
116813
116814 static unsigned char bus_mac[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
116815diff --git a/net/atm/lec.h b/net/atm/lec.h
116816index 4149db1..f2ab682 100644
116817--- a/net/atm/lec.h
116818+++ b/net/atm/lec.h
116819@@ -48,7 +48,7 @@ struct lane2_ops {
116820 const u8 *tlvs, u32 sizeoftlvs);
116821 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
116822 const u8 *tlvs, u32 sizeoftlvs);
116823-};
116824+} __no_const;
116825
116826 /*
116827 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
116828diff --git a/net/atm/mpoa_caches.c b/net/atm/mpoa_caches.c
116829index d1b2d9a..d549f7f 100644
116830--- a/net/atm/mpoa_caches.c
116831+++ b/net/atm/mpoa_caches.c
116832@@ -535,30 +535,30 @@ static void eg_destroy_cache(struct mpoa_client *mpc)
116833
116834
116835 static struct in_cache_ops ingress_ops = {
116836- in_cache_add_entry, /* add_entry */
116837- in_cache_get, /* get */
116838- in_cache_get_with_mask, /* get_with_mask */
116839- in_cache_get_by_vcc, /* get_by_vcc */
116840- in_cache_put, /* put */
116841- in_cache_remove_entry, /* remove_entry */
116842- cache_hit, /* cache_hit */
116843- clear_count_and_expired, /* clear_count */
116844- check_resolving_entries, /* check_resolving */
116845- refresh_entries, /* refresh */
116846- in_destroy_cache /* destroy_cache */
116847+ .add_entry = in_cache_add_entry,
116848+ .get = in_cache_get,
116849+ .get_with_mask = in_cache_get_with_mask,
116850+ .get_by_vcc = in_cache_get_by_vcc,
116851+ .put = in_cache_put,
116852+ .remove_entry = in_cache_remove_entry,
116853+ .cache_hit = cache_hit,
116854+ .clear_count = clear_count_and_expired,
116855+ .check_resolving = check_resolving_entries,
116856+ .refresh = refresh_entries,
116857+ .destroy_cache = in_destroy_cache
116858 };
116859
116860 static struct eg_cache_ops egress_ops = {
116861- eg_cache_add_entry, /* add_entry */
116862- eg_cache_get_by_cache_id, /* get_by_cache_id */
116863- eg_cache_get_by_tag, /* get_by_tag */
116864- eg_cache_get_by_vcc, /* get_by_vcc */
116865- eg_cache_get_by_src_ip, /* get_by_src_ip */
116866- eg_cache_put, /* put */
116867- eg_cache_remove_entry, /* remove_entry */
116868- update_eg_cache_entry, /* update */
116869- clear_expired, /* clear_expired */
116870- eg_destroy_cache /* destroy_cache */
116871+ .add_entry = eg_cache_add_entry,
116872+ .get_by_cache_id = eg_cache_get_by_cache_id,
116873+ .get_by_tag = eg_cache_get_by_tag,
116874+ .get_by_vcc = eg_cache_get_by_vcc,
116875+ .get_by_src_ip = eg_cache_get_by_src_ip,
116876+ .put = eg_cache_put,
116877+ .remove_entry = eg_cache_remove_entry,
116878+ .update = update_eg_cache_entry,
116879+ .clear_expired = clear_expired,
116880+ .destroy_cache = eg_destroy_cache
116881 };
116882
116883
116884diff --git a/net/atm/proc.c b/net/atm/proc.c
116885index bbb6461..cf04016 100644
116886--- a/net/atm/proc.c
116887+++ b/net/atm/proc.c
116888@@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
116889 const struct k_atm_aal_stats *stats)
116890 {
116891 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
116892- atomic_read(&stats->tx), atomic_read(&stats->tx_err),
116893- atomic_read(&stats->rx), atomic_read(&stats->rx_err),
116894- atomic_read(&stats->rx_drop));
116895+ atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
116896+ atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
116897+ atomic_read_unchecked(&stats->rx_drop));
116898 }
116899
116900 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
116901diff --git a/net/atm/resources.c b/net/atm/resources.c
116902index 0447d5d..3cf4728 100644
116903--- a/net/atm/resources.c
116904+++ b/net/atm/resources.c
116905@@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
116906 static void copy_aal_stats(struct k_atm_aal_stats *from,
116907 struct atm_aal_stats *to)
116908 {
116909-#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
116910+#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
116911 __AAL_STAT_ITEMS
116912 #undef __HANDLE_ITEM
116913 }
116914@@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
116915 static void subtract_aal_stats(struct k_atm_aal_stats *from,
116916 struct atm_aal_stats *to)
116917 {
116918-#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
116919+#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
116920 __AAL_STAT_ITEMS
116921 #undef __HANDLE_ITEM
116922 }
116923diff --git a/net/ax25/ax25_subr.c b/net/ax25/ax25_subr.c
116924index 1997538..3b78e84 100644
116925--- a/net/ax25/ax25_subr.c
116926+++ b/net/ax25/ax25_subr.c
116927@@ -264,6 +264,7 @@ void ax25_disconnect(ax25_cb *ax25, int reason)
116928 {
116929 ax25_clear_queues(ax25);
116930
116931+ ax25_stop_heartbeat(ax25);
116932 ax25_stop_t1timer(ax25);
116933 ax25_stop_t2timer(ax25);
116934 ax25_stop_t3timer(ax25);
116935diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
116936index 919a5ce..cc6b444 100644
116937--- a/net/ax25/sysctl_net_ax25.c
116938+++ b/net/ax25/sysctl_net_ax25.c
116939@@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
116940 {
116941 char path[sizeof("net/ax25/") + IFNAMSIZ];
116942 int k;
116943- struct ctl_table *table;
116944+ ctl_table_no_const *table;
116945
116946 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
116947 if (!table)
116948diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
116949index 00e00e0..710fcd2 100644
116950--- a/net/batman-adv/bat_iv_ogm.c
116951+++ b/net/batman-adv/bat_iv_ogm.c
116952@@ -312,7 +312,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
116953
116954 /* randomize initial seqno to avoid collision */
116955 get_random_bytes(&random_seqno, sizeof(random_seqno));
116956- atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
116957+ atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
116958
116959 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
116960 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
116961@@ -917,9 +917,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
116962 batadv_ogm_packet->tvlv_len = htons(tvlv_len);
116963
116964 /* change sequence number to network order */
116965- seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
116966+ seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
116967 batadv_ogm_packet->seqno = htonl(seqno);
116968- atomic_inc(&hard_iface->bat_iv.ogm_seqno);
116969+ atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
116970
116971 batadv_iv_ogm_slide_own_bcast_window(hard_iface);
116972
116973@@ -1596,7 +1596,7 @@ static void batadv_iv_ogm_process(const struct sk_buff *skb, int ogm_offset,
116974 return;
116975
116976 /* could be changed by schedule_own_packet() */
116977- if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
116978+ if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
116979
116980 if (ogm_packet->flags & BATADV_DIRECTLINK)
116981 has_directlink_flag = true;
116982diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c
116983index 3d1dcaa..4699f4e 100644
116984--- a/net/batman-adv/fragmentation.c
116985+++ b/net/batman-adv/fragmentation.c
116986@@ -449,7 +449,7 @@ bool batadv_frag_send_packet(struct sk_buff *skb,
116987 frag_header.packet_type = BATADV_UNICAST_FRAG;
116988 frag_header.version = BATADV_COMPAT_VERSION;
116989 frag_header.ttl = BATADV_TTL;
116990- frag_header.seqno = htons(atomic_inc_return(&bat_priv->frag_seqno));
116991+ frag_header.seqno = htons(atomic_inc_return_unchecked(&bat_priv->frag_seqno));
116992 frag_header.reserved = 0;
116993 frag_header.no = 0;
116994 frag_header.total_size = htons(skb->len);
116995diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
116996index 5ec31d7..e371631 100644
116997--- a/net/batman-adv/soft-interface.c
116998+++ b/net/batman-adv/soft-interface.c
116999@@ -295,7 +295,7 @@ send:
117000 primary_if->net_dev->dev_addr);
117001
117002 /* set broadcast sequence number */
117003- seqno = atomic_inc_return(&bat_priv->bcast_seqno);
117004+ seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
117005 bcast_packet->seqno = htonl(seqno);
117006
117007 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
117008@@ -760,7 +760,7 @@ static int batadv_softif_init_late(struct net_device *dev)
117009 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
117010
117011 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
117012- atomic_set(&bat_priv->bcast_seqno, 1);
117013+ atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
117014 atomic_set(&bat_priv->tt.vn, 0);
117015 atomic_set(&bat_priv->tt.local_changes, 0);
117016 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
117017@@ -774,7 +774,7 @@ static int batadv_softif_init_late(struct net_device *dev)
117018
117019 /* randomize initial seqno to avoid collision */
117020 get_random_bytes(&random_seqno, sizeof(random_seqno));
117021- atomic_set(&bat_priv->frag_seqno, random_seqno);
117022+ atomic_set_unchecked(&bat_priv->frag_seqno, random_seqno);
117023
117024 bat_priv->primary_if = NULL;
117025 bat_priv->num_ifaces = 0;
117026@@ -982,7 +982,7 @@ int batadv_softif_is_valid(const struct net_device *net_dev)
117027 return 0;
117028 }
117029
117030-struct rtnl_link_ops batadv_link_ops __read_mostly = {
117031+struct rtnl_link_ops batadv_link_ops = {
117032 .kind = "batadv",
117033 .priv_size = sizeof(struct batadv_priv),
117034 .setup = batadv_softif_init_early,
117035diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
117036index 9398c3f..0e79657 100644
117037--- a/net/batman-adv/types.h
117038+++ b/net/batman-adv/types.h
117039@@ -67,7 +67,7 @@ enum batadv_dhcp_recipient {
117040 struct batadv_hard_iface_bat_iv {
117041 unsigned char *ogm_buff;
117042 int ogm_buff_len;
117043- atomic_t ogm_seqno;
117044+ atomic_unchecked_t ogm_seqno;
117045 };
117046
117047 /**
117048@@ -766,7 +766,7 @@ struct batadv_priv {
117049 atomic_t bonding;
117050 atomic_t fragmentation;
117051 atomic_t packet_size_max;
117052- atomic_t frag_seqno;
117053+ atomic_unchecked_t frag_seqno;
117054 #ifdef CONFIG_BATMAN_ADV_BLA
117055 atomic_t bridge_loop_avoidance;
117056 #endif
117057@@ -785,7 +785,7 @@ struct batadv_priv {
117058 #endif
117059 uint32_t isolation_mark;
117060 uint32_t isolation_mark_mask;
117061- atomic_t bcast_seqno;
117062+ atomic_unchecked_t bcast_seqno;
117063 atomic_t bcast_queue_left;
117064 atomic_t batman_queue_left;
117065 char num_ifaces;
117066diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
117067index 56f9edb..0a13cd1 100644
117068--- a/net/bluetooth/hci_sock.c
117069+++ b/net/bluetooth/hci_sock.c
117070@@ -1241,7 +1241,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
117071 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
117072 }
117073
117074- len = min_t(unsigned int, len, sizeof(uf));
117075+ len = min((size_t)len, sizeof(uf));
117076 if (copy_from_user(&uf, optval, len)) {
117077 err = -EFAULT;
117078 break;
117079diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
117080index dad4197..253bbdf 100644
117081--- a/net/bluetooth/l2cap_core.c
117082+++ b/net/bluetooth/l2cap_core.c
117083@@ -3541,8 +3541,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
117084 break;
117085
117086 case L2CAP_CONF_RFC:
117087- if (olen == sizeof(rfc))
117088- memcpy(&rfc, (void *)val, olen);
117089+ if (olen != sizeof(rfc))
117090+ break;
117091+
117092+ memcpy(&rfc, (void *)val, olen);
117093
117094 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
117095 rfc.mode != chan->mode)
117096diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
117097index a7278f0..3443626 100644
117098--- a/net/bluetooth/l2cap_sock.c
117099+++ b/net/bluetooth/l2cap_sock.c
117100@@ -633,7 +633,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
117101 struct sock *sk = sock->sk;
117102 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
117103 struct l2cap_options opts;
117104- int len, err = 0;
117105+ int err = 0;
117106+ size_t len = optlen;
117107 u32 opt;
117108
117109 BT_DBG("sk %p", sk);
117110@@ -660,7 +661,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
117111 opts.max_tx = chan->max_tx;
117112 opts.txwin_size = chan->tx_win;
117113
117114- len = min_t(unsigned int, sizeof(opts), optlen);
117115+ len = min(sizeof(opts), len);
117116 if (copy_from_user((char *) &opts, optval, len)) {
117117 err = -EFAULT;
117118 break;
117119@@ -747,7 +748,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
117120 struct bt_security sec;
117121 struct bt_power pwr;
117122 struct l2cap_conn *conn;
117123- int len, err = 0;
117124+ int err = 0;
117125+ size_t len = optlen;
117126 u32 opt;
117127
117128 BT_DBG("sk %p", sk);
117129@@ -771,7 +773,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
117130
117131 sec.level = BT_SECURITY_LOW;
117132
117133- len = min_t(unsigned int, sizeof(sec), optlen);
117134+ len = min(sizeof(sec), len);
117135 if (copy_from_user((char *) &sec, optval, len)) {
117136 err = -EFAULT;
117137 break;
117138@@ -867,7 +869,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
117139
117140 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
117141
117142- len = min_t(unsigned int, sizeof(pwr), optlen);
117143+ len = min(sizeof(pwr), len);
117144 if (copy_from_user((char *) &pwr, optval, len)) {
117145 err = -EFAULT;
117146 break;
117147diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
117148index 825e8fb..efc24a4 100644
117149--- a/net/bluetooth/rfcomm/sock.c
117150+++ b/net/bluetooth/rfcomm/sock.c
117151@@ -686,7 +686,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
117152 struct sock *sk = sock->sk;
117153 struct bt_security sec;
117154 int err = 0;
117155- size_t len;
117156+ size_t len = optlen;
117157 u32 opt;
117158
117159 BT_DBG("sk %p", sk);
117160@@ -708,7 +708,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
117161
117162 sec.level = BT_SECURITY_LOW;
117163
117164- len = min_t(unsigned int, sizeof(sec), optlen);
117165+ len = min(sizeof(sec), len);
117166 if (copy_from_user((char *) &sec, optval, len)) {
117167 err = -EFAULT;
117168 break;
117169diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
117170index 8e385a0..a5bdd8e 100644
117171--- a/net/bluetooth/rfcomm/tty.c
117172+++ b/net/bluetooth/rfcomm/tty.c
117173@@ -752,7 +752,7 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
117174 BT_DBG("tty %p id %d", tty, tty->index);
117175
117176 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
117177- dev->channel, dev->port.count);
117178+ dev->channel, atomic_read(&dev->port.count));
117179
117180 err = tty_port_open(&dev->port, tty, filp);
117181 if (err)
117182@@ -775,7 +775,7 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
117183 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
117184
117185 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
117186- dev->port.count);
117187+ atomic_read(&dev->port.count));
117188
117189 tty_port_close(&dev->port, tty, filp);
117190 }
117191diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
117192index 1ab3dc9..7b815bc 100644
117193--- a/net/bluetooth/smp.c
117194+++ b/net/bluetooth/smp.c
117195@@ -2295,6 +2295,10 @@ int smp_conn_security(struct hci_conn *hcon, __u8 sec_level)
117196 return 1;
117197
117198 chan = conn->smp;
117199+ if (!chan) {
117200+ BT_ERR("SMP security requested but not available");
117201+ return 1;
117202+ }
117203
117204 if (!hci_dev_test_flag(hcon->hdev, HCI_LE_ENABLED))
117205 return 1;
117206diff --git a/net/bridge/br_mdb.c b/net/bridge/br_mdb.c
117207index e29ad70b..cc00066 100644
117208--- a/net/bridge/br_mdb.c
117209+++ b/net/bridge/br_mdb.c
117210@@ -371,6 +371,7 @@ static int __br_mdb_add(struct net *net, struct net_bridge *br,
117211 if (!p || p->br != br || p->state == BR_STATE_DISABLED)
117212 return -EINVAL;
117213
117214+ memset(&ip, 0, sizeof(ip));
117215 ip.proto = entry->addr.proto;
117216 if (ip.proto == htons(ETH_P_IP))
117217 ip.u.ip4 = entry->addr.u.ip4;
117218@@ -417,6 +418,7 @@ static int __br_mdb_del(struct net_bridge *br, struct br_mdb_entry *entry)
117219 if (!netif_running(br->dev) || br->multicast_disabled)
117220 return -EINVAL;
117221
117222+ memset(&ip, 0, sizeof(ip));
117223 ip.proto = entry->addr.proto;
117224 if (ip.proto == htons(ETH_P_IP)) {
117225 if (timer_pending(&br->ip4_other_query.timer))
117226diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
117227index 4b5c236..0627070 100644
117228--- a/net/bridge/br_netlink.c
117229+++ b/net/bridge/br_netlink.c
117230@@ -841,7 +841,7 @@ static struct rtnl_af_ops br_af_ops __read_mostly = {
117231 .get_link_af_size = br_get_link_af_size,
117232 };
117233
117234-struct rtnl_link_ops br_link_ops __read_mostly = {
117235+struct rtnl_link_ops br_link_ops = {
117236 .kind = "bridge",
117237 .priv_size = sizeof(struct net_bridge),
117238 .setup = br_dev_setup,
117239diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
117240index 91180a7..1301daa 100644
117241--- a/net/bridge/netfilter/ebtables.c
117242+++ b/net/bridge/netfilter/ebtables.c
117243@@ -1533,7 +1533,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
117244 tmp.valid_hooks = t->table->valid_hooks;
117245 }
117246 mutex_unlock(&ebt_mutex);
117247- if (copy_to_user(user, &tmp, *len) != 0) {
117248+ if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
117249 BUGPRINT("c2u Didn't work\n");
117250 ret = -EFAULT;
117251 break;
117252@@ -2339,7 +2339,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
117253 goto out;
117254 tmp.valid_hooks = t->valid_hooks;
117255
117256- if (copy_to_user(user, &tmp, *len) != 0) {
117257+ if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
117258 ret = -EFAULT;
117259 break;
117260 }
117261@@ -2350,7 +2350,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
117262 tmp.entries_size = t->table->entries_size;
117263 tmp.valid_hooks = t->table->valid_hooks;
117264
117265- if (copy_to_user(user, &tmp, *len) != 0) {
117266+ if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
117267 ret = -EFAULT;
117268 break;
117269 }
117270diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
117271index f5afda1..dcf770a 100644
117272--- a/net/caif/cfctrl.c
117273+++ b/net/caif/cfctrl.c
117274@@ -10,6 +10,7 @@
117275 #include <linux/spinlock.h>
117276 #include <linux/slab.h>
117277 #include <linux/pkt_sched.h>
117278+#include <linux/sched.h>
117279 #include <net/caif/caif_layer.h>
117280 #include <net/caif/cfpkt.h>
117281 #include <net/caif/cfctrl.h>
117282@@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
117283 memset(&dev_info, 0, sizeof(dev_info));
117284 dev_info.id = 0xff;
117285 cfsrvl_init(&this->serv, 0, &dev_info, false);
117286- atomic_set(&this->req_seq_no, 1);
117287- atomic_set(&this->rsp_seq_no, 1);
117288+ atomic_set_unchecked(&this->req_seq_no, 1);
117289+ atomic_set_unchecked(&this->rsp_seq_no, 1);
117290 this->serv.layer.receive = cfctrl_recv;
117291 sprintf(this->serv.layer.name, "ctrl");
117292 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
117293@@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
117294 struct cfctrl_request_info *req)
117295 {
117296 spin_lock_bh(&ctrl->info_list_lock);
117297- atomic_inc(&ctrl->req_seq_no);
117298- req->sequence_no = atomic_read(&ctrl->req_seq_no);
117299+ atomic_inc_unchecked(&ctrl->req_seq_no);
117300+ req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
117301 list_add_tail(&req->list, &ctrl->list);
117302 spin_unlock_bh(&ctrl->info_list_lock);
117303 }
117304@@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
117305 if (p != first)
117306 pr_warn("Requests are not received in order\n");
117307
117308- atomic_set(&ctrl->rsp_seq_no,
117309+ atomic_set_unchecked(&ctrl->rsp_seq_no,
117310 p->sequence_no);
117311 list_del(&p->list);
117312 goto out;
117313diff --git a/net/caif/chnl_net.c b/net/caif/chnl_net.c
117314index 67a4a36..8d28068 100644
117315--- a/net/caif/chnl_net.c
117316+++ b/net/caif/chnl_net.c
117317@@ -515,7 +515,7 @@ static const struct nla_policy ipcaif_policy[IFLA_CAIF_MAX + 1] = {
117318 };
117319
117320
117321-static struct rtnl_link_ops ipcaif_link_ops __read_mostly = {
117322+static struct rtnl_link_ops ipcaif_link_ops = {
117323 .kind = "caif",
117324 .priv_size = sizeof(struct chnl_net),
117325 .setup = ipcaif_net_setup,
117326diff --git a/net/can/af_can.c b/net/can/af_can.c
117327index 689c818..6323851 100644
117328--- a/net/can/af_can.c
117329+++ b/net/can/af_can.c
117330@@ -888,7 +888,7 @@ static const struct net_proto_family can_family_ops = {
117331 };
117332
117333 /* notifier block for netdevice event */
117334-static struct notifier_block can_netdev_notifier __read_mostly = {
117335+static struct notifier_block can_netdev_notifier = {
117336 .notifier_call = can_notifier,
117337 };
117338
117339diff --git a/net/can/bcm.c b/net/can/bcm.c
117340index b523453..f96e639 100644
117341--- a/net/can/bcm.c
117342+++ b/net/can/bcm.c
117343@@ -1618,7 +1618,7 @@ static int __init bcm_module_init(void)
117344 }
117345
117346 /* create /proc/net/can-bcm directory */
117347- proc_dir = proc_mkdir("can-bcm", init_net.proc_net);
117348+ proc_dir = proc_mkdir_restrict("can-bcm", init_net.proc_net);
117349 return 0;
117350 }
117351
117352diff --git a/net/can/gw.c b/net/can/gw.c
117353index a6f448e..5902171 100644
117354--- a/net/can/gw.c
117355+++ b/net/can/gw.c
117356@@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
117357 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
117358
117359 static HLIST_HEAD(cgw_list);
117360-static struct notifier_block notifier;
117361
117362 static struct kmem_cache *cgw_cache __read_mostly;
117363
117364@@ -948,6 +947,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh)
117365 return err;
117366 }
117367
117368+static struct notifier_block notifier = {
117369+ .notifier_call = cgw_notifier
117370+};
117371+
117372 static __init int cgw_module_init(void)
117373 {
117374 /* sanitize given module parameter */
117375@@ -963,7 +966,6 @@ static __init int cgw_module_init(void)
117376 return -ENOMEM;
117377
117378 /* set notifier */
117379- notifier.notifier_call = cgw_notifier;
117380 register_netdevice_notifier(&notifier);
117381
117382 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
117383diff --git a/net/can/proc.c b/net/can/proc.c
117384index 1a19b98..df2b4ec 100644
117385--- a/net/can/proc.c
117386+++ b/net/can/proc.c
117387@@ -514,7 +514,7 @@ static void can_remove_proc_readentry(const char *name)
117388 void can_init_proc(void)
117389 {
117390 /* create /proc/net/can directory */
117391- can_dir = proc_mkdir("can", init_net.proc_net);
117392+ can_dir = proc_mkdir_restrict("can", init_net.proc_net);
117393
117394 if (!can_dir) {
117395 printk(KERN_INFO "can: failed to create /proc/net/can . "
117396diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
117397index 967080a..5e75f04 100644
117398--- a/net/ceph/messenger.c
117399+++ b/net/ceph/messenger.c
117400@@ -188,7 +188,7 @@ static void con_fault(struct ceph_connection *con);
117401 #define MAX_ADDR_STR_LEN 64 /* 54 is enough */
117402
117403 static char addr_str[ADDR_STR_COUNT][MAX_ADDR_STR_LEN];
117404-static atomic_t addr_str_seq = ATOMIC_INIT(0);
117405+static atomic_unchecked_t addr_str_seq = ATOMIC_INIT(0);
117406
117407 static struct page *zero_page; /* used in certain error cases */
117408
117409@@ -199,7 +199,7 @@ const char *ceph_pr_addr(const struct sockaddr_storage *ss)
117410 struct sockaddr_in *in4 = (struct sockaddr_in *) ss;
117411 struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) ss;
117412
117413- i = atomic_inc_return(&addr_str_seq) & ADDR_STR_COUNT_MASK;
117414+ i = atomic_inc_return_unchecked(&addr_str_seq) & ADDR_STR_COUNT_MASK;
117415 s = addr_str[i];
117416
117417 switch (ss->ss_family) {
117418diff --git a/net/compat.c b/net/compat.c
117419index 5cfd26a..7e43828 100644
117420--- a/net/compat.c
117421+++ b/net/compat.c
117422@@ -98,20 +98,20 @@ int get_compat_msghdr(struct msghdr *kmsg,
117423
117424 #define CMSG_COMPAT_FIRSTHDR(msg) \
117425 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
117426- (struct compat_cmsghdr __user *)((msg)->msg_control) : \
117427+ (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
117428 (struct compat_cmsghdr __user *)NULL)
117429
117430 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
117431 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
117432 (ucmlen) <= (unsigned long) \
117433 ((mhdr)->msg_controllen - \
117434- ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
117435+ ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
117436
117437 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
117438 struct compat_cmsghdr __user *cmsg, int cmsg_len)
117439 {
117440 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
117441- if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
117442+ if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
117443 msg->msg_controllen)
117444 return NULL;
117445 return (struct compat_cmsghdr __user *)ptr;
117446@@ -201,7 +201,7 @@ Efault:
117447
117448 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
117449 {
117450- struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
117451+ struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
117452 struct compat_cmsghdr cmhdr;
117453 struct compat_timeval ctv;
117454 struct compat_timespec cts[3];
117455@@ -257,7 +257,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
117456
117457 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
117458 {
117459- struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
117460+ struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
117461 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
117462 int fdnum = scm->fp->count;
117463 struct file **fp = scm->fp->fp;
117464@@ -345,7 +345,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
117465 return -EFAULT;
117466 old_fs = get_fs();
117467 set_fs(KERNEL_DS);
117468- err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
117469+ err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
117470 set_fs(old_fs);
117471
117472 return err;
117473@@ -406,7 +406,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
117474 len = sizeof(ktime);
117475 old_fs = get_fs();
117476 set_fs(KERNEL_DS);
117477- err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
117478+ err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
117479 set_fs(old_fs);
117480
117481 if (!err) {
117482@@ -549,7 +549,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
117483 case MCAST_JOIN_GROUP:
117484 case MCAST_LEAVE_GROUP:
117485 {
117486- struct compat_group_req __user *gr32 = (void *)optval;
117487+ struct compat_group_req __user *gr32 = (void __user *)optval;
117488 struct group_req __user *kgr =
117489 compat_alloc_user_space(sizeof(struct group_req));
117490 u32 interface;
117491@@ -570,7 +570,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
117492 case MCAST_BLOCK_SOURCE:
117493 case MCAST_UNBLOCK_SOURCE:
117494 {
117495- struct compat_group_source_req __user *gsr32 = (void *)optval;
117496+ struct compat_group_source_req __user *gsr32 = (void __user *)optval;
117497 struct group_source_req __user *kgsr = compat_alloc_user_space(
117498 sizeof(struct group_source_req));
117499 u32 interface;
117500@@ -591,7 +591,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
117501 }
117502 case MCAST_MSFILTER:
117503 {
117504- struct compat_group_filter __user *gf32 = (void *)optval;
117505+ struct compat_group_filter __user *gf32 = (void __user *)optval;
117506 struct group_filter __user *kgf;
117507 u32 interface, fmode, numsrc;
117508
117509@@ -629,7 +629,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
117510 char __user *optval, int __user *optlen,
117511 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
117512 {
117513- struct compat_group_filter __user *gf32 = (void *)optval;
117514+ struct compat_group_filter __user *gf32 = (void __user *)optval;
117515 struct group_filter __user *kgf;
117516 int __user *koptlen;
117517 u32 interface, fmode, numsrc;
117518@@ -773,7 +773,7 @@ COMPAT_SYSCALL_DEFINE2(socketcall, int, call, u32 __user *, args)
117519
117520 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
117521 return -EINVAL;
117522- if (copy_from_user(a, args, nas[call]))
117523+ if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
117524 return -EFAULT;
117525 a0 = a[0];
117526 a1 = a[1];
117527diff --git a/net/core/datagram.c b/net/core/datagram.c
117528index b80fb91..d9f4ea5 100644
117529--- a/net/core/datagram.c
117530+++ b/net/core/datagram.c
117531@@ -131,6 +131,35 @@ out_noerr:
117532 goto out;
117533 }
117534
117535+static int skb_set_peeked(struct sk_buff *skb)
117536+{
117537+ struct sk_buff *nskb;
117538+
117539+ if (skb->peeked)
117540+ return 0;
117541+
117542+ /* We have to unshare an skb before modifying it. */
117543+ if (!skb_shared(skb))
117544+ goto done;
117545+
117546+ nskb = skb_clone(skb, GFP_ATOMIC);
117547+ if (!nskb)
117548+ return -ENOMEM;
117549+
117550+ skb->prev->next = nskb;
117551+ skb->next->prev = nskb;
117552+ nskb->prev = skb->prev;
117553+ nskb->next = skb->next;
117554+
117555+ consume_skb(skb);
117556+ skb = nskb;
117557+
117558+done:
117559+ skb->peeked = 1;
117560+
117561+ return 0;
117562+}
117563+
117564 /**
117565 * __skb_recv_datagram - Receive a datagram skbuff
117566 * @sk: socket
117567@@ -165,7 +194,9 @@ out_noerr:
117568 struct sk_buff *__skb_recv_datagram(struct sock *sk, unsigned int flags,
117569 int *peeked, int *off, int *err)
117570 {
117571+ struct sk_buff_head *queue = &sk->sk_receive_queue;
117572 struct sk_buff *skb, *last;
117573+ unsigned long cpu_flags;
117574 long timeo;
117575 /*
117576 * Caller is allowed not to check sk->sk_err before skb_recv_datagram()
117577@@ -184,8 +215,6 @@ struct sk_buff *__skb_recv_datagram(struct sock *sk, unsigned int flags,
117578 * Look at current nfs client by the way...
117579 * However, this function was correct in any case. 8)
117580 */
117581- unsigned long cpu_flags;
117582- struct sk_buff_head *queue = &sk->sk_receive_queue;
117583 int _off = *off;
117584
117585 last = (struct sk_buff *)queue;
117586@@ -199,7 +228,11 @@ struct sk_buff *__skb_recv_datagram(struct sock *sk, unsigned int flags,
117587 _off -= skb->len;
117588 continue;
117589 }
117590- skb->peeked = 1;
117591+
117592+ error = skb_set_peeked(skb);
117593+ if (error)
117594+ goto unlock_err;
117595+
117596 atomic_inc(&skb->users);
117597 } else
117598 __skb_unlink(skb, queue);
117599@@ -223,6 +256,8 @@ struct sk_buff *__skb_recv_datagram(struct sock *sk, unsigned int flags,
117600
117601 return NULL;
117602
117603+unlock_err:
117604+ spin_unlock_irqrestore(&queue->lock, cpu_flags);
117605 no_packet:
117606 *err = error;
117607 return NULL;
117608@@ -302,7 +337,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
117609 }
117610
117611 kfree_skb(skb);
117612- atomic_inc(&sk->sk_drops);
117613+ atomic_inc_unchecked(&sk->sk_drops);
117614 sk_mem_reclaim_partial(sk);
117615
117616 return err;
117617@@ -622,7 +657,8 @@ __sum16 __skb_checksum_complete_head(struct sk_buff *skb, int len)
117618 !skb->csum_complete_sw)
117619 netdev_rx_csum_fault(skb->dev);
117620 }
117621- skb->csum_valid = !sum;
117622+ if (!skb_shared(skb))
117623+ skb->csum_valid = !sum;
117624 return sum;
117625 }
117626 EXPORT_SYMBOL(__skb_checksum_complete_head);
117627@@ -642,11 +678,13 @@ __sum16 __skb_checksum_complete(struct sk_buff *skb)
117628 netdev_rx_csum_fault(skb->dev);
117629 }
117630
117631- /* Save full packet checksum */
117632- skb->csum = csum;
117633- skb->ip_summed = CHECKSUM_COMPLETE;
117634- skb->csum_complete_sw = 1;
117635- skb->csum_valid = !sum;
117636+ if (!skb_shared(skb)) {
117637+ /* Save full packet checksum */
117638+ skb->csum = csum;
117639+ skb->ip_summed = CHECKSUM_COMPLETE;
117640+ skb->csum_complete_sw = 1;
117641+ skb->csum_valid = !sum;
117642+ }
117643
117644 return sum;
117645 }
117646diff --git a/net/core/dev.c b/net/core/dev.c
117647index aa82f9a..f28b00e 100644
117648--- a/net/core/dev.c
117649+++ b/net/core/dev.c
117650@@ -1720,7 +1720,7 @@ int __dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
117651 {
117652 if (skb_orphan_frags(skb, GFP_ATOMIC) ||
117653 unlikely(!is_skb_forwardable(dev, skb))) {
117654- atomic_long_inc(&dev->rx_dropped);
117655+ atomic_long_inc_unchecked(&dev->rx_dropped);
117656 kfree_skb(skb);
117657 return NET_RX_DROP;
117658 }
117659@@ -3018,7 +3018,7 @@ recursion_alert:
117660 drop:
117661 rcu_read_unlock_bh();
117662
117663- atomic_long_inc(&dev->tx_dropped);
117664+ atomic_long_inc_unchecked(&dev->tx_dropped);
117665 kfree_skb_list(skb);
117666 return rc;
117667 out:
117668@@ -3367,7 +3367,7 @@ enqueue:
117669
117670 local_irq_restore(flags);
117671
117672- atomic_long_inc(&skb->dev->rx_dropped);
117673+ atomic_long_inc_unchecked(&skb->dev->rx_dropped);
117674 kfree_skb(skb);
117675 return NET_RX_DROP;
117676 }
117677@@ -3444,7 +3444,7 @@ int netif_rx_ni(struct sk_buff *skb)
117678 }
117679 EXPORT_SYMBOL(netif_rx_ni);
117680
117681-static void net_tx_action(struct softirq_action *h)
117682+static __latent_entropy void net_tx_action(void)
117683 {
117684 struct softnet_data *sd = this_cpu_ptr(&softnet_data);
117685
117686@@ -3783,7 +3783,7 @@ ncls:
117687 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
117688 } else {
117689 drop:
117690- atomic_long_inc(&skb->dev->rx_dropped);
117691+ atomic_long_inc_unchecked(&skb->dev->rx_dropped);
117692 kfree_skb(skb);
117693 /* Jamal, now you will not able to escape explaining
117694 * me how you were going to use this. :-)
117695@@ -4672,7 +4672,7 @@ out_unlock:
117696 return work;
117697 }
117698
117699-static void net_rx_action(struct softirq_action *h)
117700+static __latent_entropy void net_rx_action(void)
117701 {
117702 struct softnet_data *sd = this_cpu_ptr(&softnet_data);
117703 unsigned long time_limit = jiffies + 2;
117704@@ -6721,8 +6721,8 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
117705 } else {
117706 netdev_stats_to_stats64(storage, &dev->stats);
117707 }
117708- storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
117709- storage->tx_dropped += atomic_long_read(&dev->tx_dropped);
117710+ storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
117711+ storage->tx_dropped += atomic_long_read_unchecked(&dev->tx_dropped);
117712 return storage;
117713 }
117714 EXPORT_SYMBOL(dev_get_stats);
117715diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
117716index b94b1d2..da3ed7c 100644
117717--- a/net/core/dev_ioctl.c
117718+++ b/net/core/dev_ioctl.c
117719@@ -368,8 +368,13 @@ void dev_load(struct net *net, const char *name)
117720 no_module = !dev;
117721 if (no_module && capable(CAP_NET_ADMIN))
117722 no_module = request_module("netdev-%s", name);
117723- if (no_module && capable(CAP_SYS_MODULE))
117724+ if (no_module && capable(CAP_SYS_MODULE)) {
117725+#ifdef CONFIG_GRKERNSEC_MODHARDEN
117726+ ___request_module(true, "grsec_modharden_netdev", "%s", name);
117727+#else
117728 request_module("%s", name);
117729+#endif
117730+ }
117731 }
117732 EXPORT_SYMBOL(dev_load);
117733
117734diff --git a/net/core/dst.c b/net/core/dst.c
117735index e956ce6..002144be 100644
117736--- a/net/core/dst.c
117737+++ b/net/core/dst.c
117738@@ -284,7 +284,9 @@ void dst_release(struct dst_entry *dst)
117739 int newrefcnt;
117740
117741 newrefcnt = atomic_dec_return(&dst->__refcnt);
117742- WARN_ON(newrefcnt < 0);
117743+ if (unlikely(newrefcnt < 0))
117744+ net_warn_ratelimited("%s: dst:%p refcnt:%d\n",
117745+ __func__, dst, newrefcnt);
117746 if (unlikely(dst->flags & DST_NOCACHE) && !newrefcnt)
117747 call_rcu(&dst->rcu_head, dst_destroy_rcu);
117748 }
117749diff --git a/net/core/filter.c b/net/core/filter.c
117750index bf831a8..8d2c4c2 100644
117751--- a/net/core/filter.c
117752+++ b/net/core/filter.c
117753@@ -579,7 +579,11 @@ do_pass:
117754
117755 /* Unknown instruction. */
117756 default:
117757- goto err;
117758+ WARN(1, KERN_ALERT "Unknown sock filter code:%u jt:%u tf:%u k:%u\n",
117759+ fp->code, fp->jt, fp->jf, fp->k);
117760+ kfree(addrs);
117761+ BUG();
117762+ return -EINVAL;
117763 }
117764
117765 insn++;
117766@@ -623,7 +627,7 @@ static int check_load_and_stores(const struct sock_filter *filter, int flen)
117767 u16 *masks, memvalid = 0; /* One bit per cell, 16 cells */
117768 int pc, ret = 0;
117769
117770- BUILD_BUG_ON(BPF_MEMWORDS > 16);
117771+ BUILD_BUG_ON(BPF_MEMWORDS != 16);
117772
117773 masks = kmalloc_array(flen, sizeof(*masks), GFP_KERNEL);
117774 if (!masks)
117775@@ -1038,7 +1042,7 @@ int bpf_prog_create(struct bpf_prog **pfp, struct sock_fprog_kern *fprog)
117776 if (!fp)
117777 return -ENOMEM;
117778
117779- memcpy(fp->insns, fprog->filter, fsize);
117780+ memcpy(fp->insns, (void __force_kernel *)fprog->filter, fsize);
117781
117782 fp->len = fprog->len;
117783 /* Since unattached filters are not copied back to user
117784diff --git a/net/core/flow.c b/net/core/flow.c
117785index 1033725..340f65d 100644
117786--- a/net/core/flow.c
117787+++ b/net/core/flow.c
117788@@ -65,7 +65,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
117789 static int flow_entry_valid(struct flow_cache_entry *fle,
117790 struct netns_xfrm *xfrm)
117791 {
117792- if (atomic_read(&xfrm->flow_cache_genid) != fle->genid)
117793+ if (atomic_read_unchecked(&xfrm->flow_cache_genid) != fle->genid)
117794 return 0;
117795 if (fle->object && !fle->object->ops->check(fle->object))
117796 return 0;
117797@@ -242,7 +242,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
117798 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
117799 fcp->hash_count++;
117800 }
117801- } else if (likely(fle->genid == atomic_read(&net->xfrm.flow_cache_genid))) {
117802+ } else if (likely(fle->genid == atomic_read_unchecked(&net->xfrm.flow_cache_genid))) {
117803 flo = fle->object;
117804 if (!flo)
117805 goto ret_object;
117806@@ -263,7 +263,7 @@ nocache:
117807 }
117808 flo = resolver(net, key, family, dir, flo, ctx);
117809 if (fle) {
117810- fle->genid = atomic_read(&net->xfrm.flow_cache_genid);
117811+ fle->genid = atomic_read_unchecked(&net->xfrm.flow_cache_genid);
117812 if (!IS_ERR(flo))
117813 fle->object = flo;
117814 else
117815diff --git a/net/core/neighbour.c b/net/core/neighbour.c
117816index 2237c1b..c0c80ab 100644
117817--- a/net/core/neighbour.c
117818+++ b/net/core/neighbour.c
117819@@ -2818,7 +2818,7 @@ static int proc_unres_qlen(struct ctl_table *ctl, int write,
117820 void __user *buffer, size_t *lenp, loff_t *ppos)
117821 {
117822 int size, ret;
117823- struct ctl_table tmp = *ctl;
117824+ ctl_table_no_const tmp = *ctl;
117825
117826 tmp.extra1 = &zero;
117827 tmp.extra2 = &unres_qlen_max;
117828@@ -2880,7 +2880,7 @@ static int neigh_proc_dointvec_zero_intmax(struct ctl_table *ctl, int write,
117829 void __user *buffer,
117830 size_t *lenp, loff_t *ppos)
117831 {
117832- struct ctl_table tmp = *ctl;
117833+ ctl_table_no_const tmp = *ctl;
117834 int ret;
117835
117836 tmp.extra1 = &zero;
117837diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
117838index 2bf8329..2eb1423 100644
117839--- a/net/core/net-procfs.c
117840+++ b/net/core/net-procfs.c
117841@@ -79,7 +79,13 @@ static void dev_seq_printf_stats(struct seq_file *seq, struct net_device *dev)
117842 struct rtnl_link_stats64 temp;
117843 const struct rtnl_link_stats64 *stats = dev_get_stats(dev, &temp);
117844
117845- seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
117846+ if (gr_proc_is_restricted())
117847+ seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
117848+ "%8llu %7llu %4llu %4llu %4llu %5llu %7llu %10llu\n",
117849+ dev->name, 0ULL, 0ULL, 0ULL, 0ULL, 0ULL, 0ULL, 0ULL, 0ULL, 0ULL, 0ULL,
117850+ 0ULL, 0ULL, 0ULL, 0ULL, 0ULL, 0ULL);
117851+ else
117852+ seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
117853 "%8llu %7llu %4llu %4llu %4llu %5llu %7llu %10llu\n",
117854 dev->name, stats->rx_bytes, stats->rx_packets,
117855 stats->rx_errors,
117856@@ -166,7 +172,7 @@ static int softnet_seq_show(struct seq_file *seq, void *v)
117857 return 0;
117858 }
117859
117860-static const struct seq_operations dev_seq_ops = {
117861+const struct seq_operations dev_seq_ops = {
117862 .start = dev_seq_start,
117863 .next = dev_seq_next,
117864 .stop = dev_seq_stop,
117865@@ -196,7 +202,7 @@ static const struct seq_operations softnet_seq_ops = {
117866
117867 static int softnet_seq_open(struct inode *inode, struct file *file)
117868 {
117869- return seq_open(file, &softnet_seq_ops);
117870+ return seq_open_restrict(file, &softnet_seq_ops);
117871 }
117872
117873 static const struct file_operations softnet_seq_fops = {
117874@@ -283,8 +289,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
117875 else
117876 seq_printf(seq, "%04x", ntohs(pt->type));
117877
117878+#ifdef CONFIG_GRKERNSEC_HIDESYM
117879+ seq_printf(seq, " %-8s %pf\n",
117880+ pt->dev ? pt->dev->name : "", NULL);
117881+#else
117882 seq_printf(seq, " %-8s %pf\n",
117883 pt->dev ? pt->dev->name : "", pt->func);
117884+#endif
117885 }
117886
117887 return 0;
117888diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
117889index 4238d6d..e6b605c 100644
117890--- a/net/core/net-sysfs.c
117891+++ b/net/core/net-sysfs.c
117892@@ -288,7 +288,7 @@ static ssize_t carrier_changes_show(struct device *dev,
117893 {
117894 struct net_device *netdev = to_net_dev(dev);
117895 return sprintf(buf, fmt_dec,
117896- atomic_read(&netdev->carrier_changes));
117897+ atomic_read_unchecked(&netdev->carrier_changes));
117898 }
117899 static DEVICE_ATTR_RO(carrier_changes);
117900
117901diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
117902index 572af00..5acf072 100644
117903--- a/net/core/net_namespace.c
117904+++ b/net/core/net_namespace.c
117905@@ -734,7 +734,7 @@ static int __register_pernet_operations(struct list_head *list,
117906 int error;
117907 LIST_HEAD(net_exit_list);
117908
117909- list_add_tail(&ops->list, list);
117910+ pax_list_add_tail((struct list_head *)&ops->list, list);
117911 if (ops->init || (ops->id && ops->size)) {
117912 for_each_net(net) {
117913 error = ops_init(ops, net);
117914@@ -747,7 +747,7 @@ static int __register_pernet_operations(struct list_head *list,
117915
117916 out_undo:
117917 /* If I have an error cleanup all namespaces I initialized */
117918- list_del(&ops->list);
117919+ pax_list_del((struct list_head *)&ops->list);
117920 ops_exit_list(ops, &net_exit_list);
117921 ops_free_list(ops, &net_exit_list);
117922 return error;
117923@@ -758,7 +758,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
117924 struct net *net;
117925 LIST_HEAD(net_exit_list);
117926
117927- list_del(&ops->list);
117928+ pax_list_del((struct list_head *)&ops->list);
117929 for_each_net(net)
117930 list_add_tail(&net->exit_list, &net_exit_list);
117931 ops_exit_list(ops, &net_exit_list);
117932@@ -892,7 +892,7 @@ int register_pernet_device(struct pernet_operations *ops)
117933 mutex_lock(&net_mutex);
117934 error = register_pernet_operations(&pernet_list, ops);
117935 if (!error && (first_device == &pernet_list))
117936- first_device = &ops->list;
117937+ first_device = (struct list_head *)&ops->list;
117938 mutex_unlock(&net_mutex);
117939 return error;
117940 }
117941diff --git a/net/core/netpoll.c b/net/core/netpoll.c
117942index c126a87..10ad89d 100644
117943--- a/net/core/netpoll.c
117944+++ b/net/core/netpoll.c
117945@@ -377,7 +377,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
117946 struct udphdr *udph;
117947 struct iphdr *iph;
117948 struct ethhdr *eth;
117949- static atomic_t ip_ident;
117950+ static atomic_unchecked_t ip_ident;
117951 struct ipv6hdr *ip6h;
117952
117953 udp_len = len + sizeof(*udph);
117954@@ -448,7 +448,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
117955 put_unaligned(0x45, (unsigned char *)iph);
117956 iph->tos = 0;
117957 put_unaligned(htons(ip_len), &(iph->tot_len));
117958- iph->id = htons(atomic_inc_return(&ip_ident));
117959+ iph->id = htons(atomic_inc_return_unchecked(&ip_ident));
117960 iph->frag_off = 0;
117961 iph->ttl = 64;
117962 iph->protocol = IPPROTO_UDP;
117963diff --git a/net/core/pktgen.c b/net/core/pktgen.c
117964index 508155b..fad080f 100644
117965--- a/net/core/pktgen.c
117966+++ b/net/core/pktgen.c
117967@@ -3755,7 +3755,7 @@ static int __net_init pg_net_init(struct net *net)
117968 pn->net = net;
117969 INIT_LIST_HEAD(&pn->pktgen_threads);
117970 pn->pktgen_exiting = false;
117971- pn->proc_dir = proc_mkdir(PG_PROC_DIR, pn->net->proc_net);
117972+ pn->proc_dir = proc_mkdir_restrict(PG_PROC_DIR, pn->net->proc_net);
117973 if (!pn->proc_dir) {
117974 pr_warn("cannot create /proc/net/%s\n", PG_PROC_DIR);
117975 return -ENODEV;
117976diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
117977index 8de3682..fcb8a5e 100644
117978--- a/net/core/rtnetlink.c
117979+++ b/net/core/rtnetlink.c
117980@@ -61,7 +61,7 @@ struct rtnl_link {
117981 rtnl_doit_func doit;
117982 rtnl_dumpit_func dumpit;
117983 rtnl_calcit_func calcit;
117984-};
117985+} __no_const;
117986
117987 static DEFINE_MUTEX(rtnl_mutex);
117988
117989@@ -307,10 +307,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
117990 * to use the ops for creating device. So do not
117991 * fill up dellink as well. That disables rtnl_dellink.
117992 */
117993- if (ops->setup && !ops->dellink)
117994- ops->dellink = unregister_netdevice_queue;
117995+ if (ops->setup && !ops->dellink) {
117996+ pax_open_kernel();
117997+ *(void **)&ops->dellink = unregister_netdevice_queue;
117998+ pax_close_kernel();
117999+ }
118000
118001- list_add_tail(&ops->list, &link_ops);
118002+ pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
118003 return 0;
118004 }
118005 EXPORT_SYMBOL_GPL(__rtnl_link_register);
118006@@ -357,7 +360,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
118007 for_each_net(net) {
118008 __rtnl_kill_links(net, ops);
118009 }
118010- list_del(&ops->list);
118011+ pax_list_del((struct list_head *)&ops->list);
118012 }
118013 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
118014
118015@@ -1066,7 +1069,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
118016 (dev->ifalias &&
118017 nla_put_string(skb, IFLA_IFALIAS, dev->ifalias)) ||
118018 nla_put_u32(skb, IFLA_CARRIER_CHANGES,
118019- atomic_read(&dev->carrier_changes)))
118020+ atomic_read_unchecked(&dev->carrier_changes)))
118021 goto nla_put_failure;
118022
118023 if (1) {
118024@@ -1748,10 +1751,13 @@ static int do_setlink(const struct sk_buff *skb,
118025 goto errout;
118026
118027 nla_for_each_nested(attr, tb[IFLA_VF_PORTS], rem) {
118028- if (nla_type(attr) != IFLA_VF_PORT)
118029- continue;
118030- err = nla_parse_nested(port, IFLA_PORT_MAX,
118031- attr, ifla_port_policy);
118032+ if (nla_type(attr) != IFLA_VF_PORT ||
118033+ nla_len(attr) < NLA_HDRLEN) {
118034+ err = -EINVAL;
118035+ goto errout;
118036+ }
118037+ err = nla_parse_nested(port, IFLA_PORT_MAX, attr,
118038+ ifla_port_policy);
118039 if (err < 0)
118040 goto errout;
118041 if (!port[IFLA_PORT_VF]) {
118042diff --git a/net/core/scm.c b/net/core/scm.c
118043index 3b6899b..cf36238 100644
118044--- a/net/core/scm.c
118045+++ b/net/core/scm.c
118046@@ -209,7 +209,7 @@ EXPORT_SYMBOL(__scm_send);
118047 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
118048 {
118049 struct cmsghdr __user *cm
118050- = (__force struct cmsghdr __user *)msg->msg_control;
118051+ = (struct cmsghdr __force_user *)msg->msg_control;
118052 struct cmsghdr cmhdr;
118053 int cmlen = CMSG_LEN(len);
118054 int err;
118055@@ -232,7 +232,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
118056 err = -EFAULT;
118057 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
118058 goto out;
118059- if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
118060+ if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
118061 goto out;
118062 cmlen = CMSG_SPACE(len);
118063 if (msg->msg_controllen < cmlen)
118064@@ -248,7 +248,7 @@ EXPORT_SYMBOL(put_cmsg);
118065 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
118066 {
118067 struct cmsghdr __user *cm
118068- = (__force struct cmsghdr __user*)msg->msg_control;
118069+ = (struct cmsghdr __force_user *)msg->msg_control;
118070
118071 int fdmax = 0;
118072 int fdnum = scm->fp->count;
118073@@ -268,7 +268,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
118074 if (fdnum < fdmax)
118075 fdmax = fdnum;
118076
118077- for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
118078+ for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
118079 i++, cmfptr++)
118080 {
118081 struct socket *sock;
118082diff --git a/net/core/skbuff.c b/net/core/skbuff.c
118083index 41ec022..3cc0a1c 100644
118084--- a/net/core/skbuff.c
118085+++ b/net/core/skbuff.c
118086@@ -2139,7 +2139,7 @@ EXPORT_SYMBOL(__skb_checksum);
118087 __wsum skb_checksum(const struct sk_buff *skb, int offset,
118088 int len, __wsum csum)
118089 {
118090- const struct skb_checksum_ops ops = {
118091+ static const struct skb_checksum_ops ops = {
118092 .update = csum_partial_ext,
118093 .combine = csum_block_add_ext,
118094 };
118095@@ -3335,12 +3335,14 @@ void __init skb_init(void)
118096 skbuff_head_cache = kmem_cache_create("skbuff_head_cache",
118097 sizeof(struct sk_buff),
118098 0,
118099- SLAB_HWCACHE_ALIGN|SLAB_PANIC,
118100+ SLAB_HWCACHE_ALIGN|SLAB_PANIC|
118101+ SLAB_NO_SANITIZE,
118102 NULL);
118103 skbuff_fclone_cache = kmem_cache_create("skbuff_fclone_cache",
118104 sizeof(struct sk_buff_fclones),
118105 0,
118106- SLAB_HWCACHE_ALIGN|SLAB_PANIC,
118107+ SLAB_HWCACHE_ALIGN|SLAB_PANIC|
118108+ SLAB_NO_SANITIZE,
118109 NULL);
118110 }
118111
118112diff --git a/net/core/sock.c b/net/core/sock.c
118113index dc30dc5..8bb3ef3 100644
118114--- a/net/core/sock.c
118115+++ b/net/core/sock.c
118116@@ -440,7 +440,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
118117 struct sk_buff_head *list = &sk->sk_receive_queue;
118118
118119 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
118120- atomic_inc(&sk->sk_drops);
118121+ atomic_inc_unchecked(&sk->sk_drops);
118122 trace_sock_rcvqueue_full(sk, skb);
118123 return -ENOMEM;
118124 }
118125@@ -450,7 +450,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
118126 return err;
118127
118128 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
118129- atomic_inc(&sk->sk_drops);
118130+ atomic_inc_unchecked(&sk->sk_drops);
118131 return -ENOBUFS;
118132 }
118133
118134@@ -483,7 +483,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
118135 skb->dev = NULL;
118136
118137 if (sk_rcvqueues_full(sk, sk->sk_rcvbuf)) {
118138- atomic_inc(&sk->sk_drops);
118139+ atomic_inc_unchecked(&sk->sk_drops);
118140 goto discard_and_relse;
118141 }
118142 if (nested)
118143@@ -501,7 +501,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
118144 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
118145 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
118146 bh_unlock_sock(sk);
118147- atomic_inc(&sk->sk_drops);
118148+ atomic_inc_unchecked(&sk->sk_drops);
118149 goto discard_and_relse;
118150 }
118151
118152@@ -907,6 +907,7 @@ set_rcvbuf:
118153 }
118154 break;
118155
118156+#ifndef GRKERNSEC_BPF_HARDEN
118157 case SO_ATTACH_BPF:
118158 ret = -EINVAL;
118159 if (optlen == sizeof(u32)) {
118160@@ -919,7 +920,7 @@ set_rcvbuf:
118161 ret = sk_attach_bpf(ufd, sk);
118162 }
118163 break;
118164-
118165+#endif
118166 case SO_DETACH_FILTER:
118167 ret = sk_detach_filter(sk);
118168 break;
118169@@ -1021,12 +1022,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
118170 struct timeval tm;
118171 } v;
118172
118173- int lv = sizeof(int);
118174- int len;
118175+ unsigned int lv = sizeof(int);
118176+ unsigned int len;
118177
118178 if (get_user(len, optlen))
118179 return -EFAULT;
118180- if (len < 0)
118181+ if (len > INT_MAX)
118182 return -EINVAL;
118183
118184 memset(&v, 0, sizeof(v));
118185@@ -1164,11 +1165,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
118186
118187 case SO_PEERNAME:
118188 {
118189- char address[128];
118190+ char address[_K_SS_MAXSIZE];
118191
118192 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
118193 return -ENOTCONN;
118194- if (lv < len)
118195+ if (lv < len || sizeof address < len)
118196 return -EINVAL;
118197 if (copy_to_user(optval, address, len))
118198 return -EFAULT;
118199@@ -1256,7 +1257,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
118200
118201 if (len > lv)
118202 len = lv;
118203- if (copy_to_user(optval, &v, len))
118204+ if (len > sizeof(v) || copy_to_user(optval, &v, len))
118205 return -EFAULT;
118206 lenout:
118207 if (put_user(len, optlen))
118208@@ -2359,7 +2360,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
118209 */
118210 smp_wmb();
118211 atomic_set(&sk->sk_refcnt, 1);
118212- atomic_set(&sk->sk_drops, 0);
118213+ atomic_set_unchecked(&sk->sk_drops, 0);
118214 }
118215 EXPORT_SYMBOL(sock_init_data);
118216
118217@@ -2487,6 +2488,7 @@ void sock_enable_timestamp(struct sock *sk, int flag)
118218 int sock_recv_errqueue(struct sock *sk, struct msghdr *msg, int len,
118219 int level, int type)
118220 {
118221+ struct sock_extended_err ee;
118222 struct sock_exterr_skb *serr;
118223 struct sk_buff *skb;
118224 int copied, err;
118225@@ -2508,7 +2510,8 @@ int sock_recv_errqueue(struct sock *sk, struct msghdr *msg, int len,
118226 sock_recv_timestamp(msg, sk, skb);
118227
118228 serr = SKB_EXT_ERR(skb);
118229- put_cmsg(msg, level, type, sizeof(serr->ee), &serr->ee);
118230+ ee = serr->ee;
118231+ put_cmsg(msg, level, type, sizeof ee, &ee);
118232
118233 msg->msg_flags |= MSG_ERRQUEUE;
118234 err = copied;
118235diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
118236index 74dddf8..7f4e77e 100644
118237--- a/net/core/sock_diag.c
118238+++ b/net/core/sock_diag.c
118239@@ -9,7 +9,7 @@
118240 #include <linux/inet_diag.h>
118241 #include <linux/sock_diag.h>
118242
118243-static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
118244+static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
118245 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
118246 static DEFINE_MUTEX(sock_diag_table_mutex);
118247
118248@@ -127,8 +127,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
118249 mutex_lock(&sock_diag_table_mutex);
118250 if (sock_diag_handlers[hndl->family])
118251 err = -EBUSY;
118252- else
118253+ else {
118254+ pax_open_kernel();
118255 sock_diag_handlers[hndl->family] = hndl;
118256+ pax_close_kernel();
118257+ }
118258 mutex_unlock(&sock_diag_table_mutex);
118259
118260 return err;
118261@@ -144,7 +147,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
118262
118263 mutex_lock(&sock_diag_table_mutex);
118264 BUG_ON(sock_diag_handlers[family] != hnld);
118265+ pax_open_kernel();
118266 sock_diag_handlers[family] = NULL;
118267+ pax_close_kernel();
118268 mutex_unlock(&sock_diag_table_mutex);
118269 }
118270 EXPORT_SYMBOL_GPL(sock_diag_unregister);
118271diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
118272index 95b6139..3048623 100644
118273--- a/net/core/sysctl_net_core.c
118274+++ b/net/core/sysctl_net_core.c
118275@@ -35,7 +35,7 @@ static int rps_sock_flow_sysctl(struct ctl_table *table, int write,
118276 {
118277 unsigned int orig_size, size;
118278 int ret, i;
118279- struct ctl_table tmp = {
118280+ ctl_table_no_const tmp = {
118281 .data = &size,
118282 .maxlen = sizeof(size),
118283 .mode = table->mode
118284@@ -203,7 +203,7 @@ static int set_default_qdisc(struct ctl_table *table, int write,
118285 void __user *buffer, size_t *lenp, loff_t *ppos)
118286 {
118287 char id[IFNAMSIZ];
118288- struct ctl_table tbl = {
118289+ ctl_table_no_const tbl = {
118290 .data = id,
118291 .maxlen = IFNAMSIZ,
118292 };
118293@@ -221,7 +221,7 @@ static int set_default_qdisc(struct ctl_table *table, int write,
118294 static int proc_do_rss_key(struct ctl_table *table, int write,
118295 void __user *buffer, size_t *lenp, loff_t *ppos)
118296 {
118297- struct ctl_table fake_table;
118298+ ctl_table_no_const fake_table;
118299 char buf[NETDEV_RSS_KEY_LEN * 3];
118300
118301 snprintf(buf, sizeof(buf), "%*phC", NETDEV_RSS_KEY_LEN, netdev_rss_key);
118302@@ -285,7 +285,7 @@ static struct ctl_table net_core_table[] = {
118303 .mode = 0444,
118304 .proc_handler = proc_do_rss_key,
118305 },
118306-#ifdef CONFIG_BPF_JIT
118307+#if defined(CONFIG_BPF_JIT) && !defined(CONFIG_GRKERNSEC_BPF_HARDEN)
118308 {
118309 .procname = "bpf_jit_enable",
118310 .data = &bpf_jit_enable,
118311@@ -409,13 +409,12 @@ static struct ctl_table netns_core_table[] = {
118312
118313 static __net_init int sysctl_core_net_init(struct net *net)
118314 {
118315- struct ctl_table *tbl;
118316+ ctl_table_no_const *tbl = NULL;
118317
118318 net->core.sysctl_somaxconn = SOMAXCONN;
118319
118320- tbl = netns_core_table;
118321 if (!net_eq(net, &init_net)) {
118322- tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
118323+ tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
118324 if (tbl == NULL)
118325 goto err_dup;
118326
118327@@ -425,17 +424,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
118328 if (net->user_ns != &init_user_ns) {
118329 tbl[0].procname = NULL;
118330 }
118331- }
118332-
118333- net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
118334+ net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
118335+ } else
118336+ net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
118337 if (net->core.sysctl_hdr == NULL)
118338 goto err_reg;
118339
118340 return 0;
118341
118342 err_reg:
118343- if (tbl != netns_core_table)
118344- kfree(tbl);
118345+ kfree(tbl);
118346 err_dup:
118347 return -ENOMEM;
118348 }
118349@@ -450,7 +448,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
118350 kfree(tbl);
118351 }
118352
118353-static __net_initdata struct pernet_operations sysctl_core_ops = {
118354+static __net_initconst struct pernet_operations sysctl_core_ops = {
118355 .init = sysctl_core_net_init,
118356 .exit = sysctl_core_net_exit,
118357 };
118358diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
118359index 754484b..4f4b894 100644
118360--- a/net/decnet/af_decnet.c
118361+++ b/net/decnet/af_decnet.c
118362@@ -466,6 +466,7 @@ static struct proto dn_proto = {
118363 .sysctl_rmem = sysctl_decnet_rmem,
118364 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
118365 .obj_size = sizeof(struct dn_sock),
118366+ .slab_flags = SLAB_USERCOPY,
118367 };
118368
118369 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
118370diff --git a/net/decnet/dn_dev.c b/net/decnet/dn_dev.c
118371index b2c26b0..41f803e 100644
118372--- a/net/decnet/dn_dev.c
118373+++ b/net/decnet/dn_dev.c
118374@@ -201,7 +201,7 @@ static struct dn_dev_sysctl_table {
118375 .extra1 = &min_t3,
118376 .extra2 = &max_t3
118377 },
118378- {0}
118379+ { }
118380 },
118381 };
118382
118383diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
118384index 5325b54..a0d4d69 100644
118385--- a/net/decnet/sysctl_net_decnet.c
118386+++ b/net/decnet/sysctl_net_decnet.c
118387@@ -174,7 +174,7 @@ static int dn_node_address_handler(struct ctl_table *table, int write,
118388
118389 if (len > *lenp) len = *lenp;
118390
118391- if (copy_to_user(buffer, addr, len))
118392+ if (len > sizeof addr || copy_to_user(buffer, addr, len))
118393 return -EFAULT;
118394
118395 *lenp = len;
118396@@ -237,7 +237,7 @@ static int dn_def_dev_handler(struct ctl_table *table, int write,
118397
118398 if (len > *lenp) len = *lenp;
118399
118400- if (copy_to_user(buffer, devname, len))
118401+ if (len > sizeof devname || copy_to_user(buffer, devname, len))
118402 return -EFAULT;
118403
118404 *lenp = len;
118405diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
118406index 392e29a..da953a2 100644
118407--- a/net/dsa/dsa.c
118408+++ b/net/dsa/dsa.c
118409@@ -851,7 +851,7 @@ static struct packet_type dsa_pack_type __read_mostly = {
118410 .func = dsa_switch_rcv,
118411 };
118412
118413-static struct notifier_block dsa_netdevice_nb __read_mostly = {
118414+static struct notifier_block dsa_netdevice_nb = {
118415 .notifier_call = dsa_slave_netdevice_event,
118416 };
118417
118418diff --git a/net/hsr/hsr_netlink.c b/net/hsr/hsr_netlink.c
118419index a2c7e4c..3dc9f67 100644
118420--- a/net/hsr/hsr_netlink.c
118421+++ b/net/hsr/hsr_netlink.c
118422@@ -102,7 +102,7 @@ nla_put_failure:
118423 return -EMSGSIZE;
118424 }
118425
118426-static struct rtnl_link_ops hsr_link_ops __read_mostly = {
118427+static struct rtnl_link_ops hsr_link_ops = {
118428 .kind = "hsr",
118429 .maxtype = IFLA_HSR_MAX,
118430 .policy = hsr_policy,
118431diff --git a/net/ieee802154/6lowpan/core.c b/net/ieee802154/6lowpan/core.c
118432index 0ae5822..3fe3627 100644
118433--- a/net/ieee802154/6lowpan/core.c
118434+++ b/net/ieee802154/6lowpan/core.c
118435@@ -219,7 +219,7 @@ static void lowpan_dellink(struct net_device *dev, struct list_head *head)
118436 dev_put(real_dev);
118437 }
118438
118439-static struct rtnl_link_ops lowpan_link_ops __read_mostly = {
118440+static struct rtnl_link_ops lowpan_link_ops = {
118441 .kind = "lowpan",
118442 .priv_size = sizeof(struct lowpan_dev_info),
118443 .setup = lowpan_setup,
118444diff --git a/net/ieee802154/6lowpan/reassembly.c b/net/ieee802154/6lowpan/reassembly.c
118445index f46e4d1..dcb7f86 100644
118446--- a/net/ieee802154/6lowpan/reassembly.c
118447+++ b/net/ieee802154/6lowpan/reassembly.c
118448@@ -207,7 +207,7 @@ found:
118449 } else {
118450 fq->q.meat += skb->len;
118451 }
118452- add_frag_mem_limit(&fq->q, skb->truesize);
118453+ add_frag_mem_limit(fq->q.net, skb->truesize);
118454
118455 if (fq->q.flags == (INET_FRAG_FIRST_IN | INET_FRAG_LAST_IN) &&
118456 fq->q.meat == fq->q.len) {
118457@@ -287,7 +287,7 @@ static int lowpan_frag_reasm(struct lowpan_frag_queue *fq, struct sk_buff *prev,
118458 clone->data_len = clone->len;
118459 head->data_len -= clone->len;
118460 head->len -= clone->len;
118461- add_frag_mem_limit(&fq->q, clone->truesize);
118462+ add_frag_mem_limit(fq->q.net, clone->truesize);
118463 }
118464
118465 WARN_ON(head == NULL);
118466@@ -310,7 +310,7 @@ static int lowpan_frag_reasm(struct lowpan_frag_queue *fq, struct sk_buff *prev,
118467 }
118468 fp = next;
118469 }
118470- sub_frag_mem_limit(&fq->q, sum_truesize);
118471+ sub_frag_mem_limit(fq->q.net, sum_truesize);
118472
118473 head->next = NULL;
118474 head->dev = dev;
118475@@ -435,14 +435,13 @@ static struct ctl_table lowpan_frags_ctl_table[] = {
118476
118477 static int __net_init lowpan_frags_ns_sysctl_register(struct net *net)
118478 {
118479- struct ctl_table *table;
118480+ ctl_table_no_const *table = NULL;
118481 struct ctl_table_header *hdr;
118482 struct netns_ieee802154_lowpan *ieee802154_lowpan =
118483 net_ieee802154_lowpan(net);
118484
118485- table = lowpan_frags_ns_ctl_table;
118486 if (!net_eq(net, &init_net)) {
118487- table = kmemdup(table, sizeof(lowpan_frags_ns_ctl_table),
118488+ table = kmemdup(lowpan_frags_ns_ctl_table, sizeof(lowpan_frags_ns_ctl_table),
118489 GFP_KERNEL);
118490 if (table == NULL)
118491 goto err_alloc;
118492@@ -457,9 +456,9 @@ static int __net_init lowpan_frags_ns_sysctl_register(struct net *net)
118493 /* Don't export sysctls to unprivileged users */
118494 if (net->user_ns != &init_user_ns)
118495 table[0].procname = NULL;
118496- }
118497-
118498- hdr = register_net_sysctl(net, "net/ieee802154/6lowpan", table);
118499+ hdr = register_net_sysctl(net, "net/ieee802154/6lowpan", table);
118500+ } else
118501+ hdr = register_net_sysctl(net, "net/ieee802154/6lowpan", lowpan_frags_ns_ctl_table);
118502 if (hdr == NULL)
118503 goto err_reg;
118504
118505@@ -467,8 +466,7 @@ static int __net_init lowpan_frags_ns_sysctl_register(struct net *net)
118506 return 0;
118507
118508 err_reg:
118509- if (!net_eq(net, &init_net))
118510- kfree(table);
118511+ kfree(table);
118512 err_alloc:
118513 return -ENOMEM;
118514 }
118515diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
118516index a5aa54e..3bd5f9f 100644
118517--- a/net/ipv4/af_inet.c
118518+++ b/net/ipv4/af_inet.c
118519@@ -1391,7 +1391,7 @@ int inet_recv_error(struct sock *sk, struct msghdr *msg, int len, int *addr_len)
118520 return ip_recv_error(sk, msg, len, addr_len);
118521 #if IS_ENABLED(CONFIG_IPV6)
118522 if (sk->sk_family == AF_INET6)
118523- return pingv6_ops.ipv6_recv_error(sk, msg, len, addr_len);
118524+ return pingv6_ops->ipv6_recv_error(sk, msg, len, addr_len);
118525 #endif
118526 return -EINVAL;
118527 }
118528diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
118529index 419d23c..2084616 100644
118530--- a/net/ipv4/devinet.c
118531+++ b/net/ipv4/devinet.c
118532@@ -69,7 +69,8 @@
118533
118534 static struct ipv4_devconf ipv4_devconf = {
118535 .data = {
118536- [IPV4_DEVCONF_ACCEPT_REDIRECTS - 1] = 1,
118537+ [IPV4_DEVCONF_ACCEPT_REDIRECTS - 1] = 0,
118538+ [IPV4_DEVCONF_RP_FILTER - 1] = 1,
118539 [IPV4_DEVCONF_SEND_REDIRECTS - 1] = 1,
118540 [IPV4_DEVCONF_SECURE_REDIRECTS - 1] = 1,
118541 [IPV4_DEVCONF_SHARED_MEDIA - 1] = 1,
118542@@ -80,7 +81,8 @@ static struct ipv4_devconf ipv4_devconf = {
118543
118544 static struct ipv4_devconf ipv4_devconf_dflt = {
118545 .data = {
118546- [IPV4_DEVCONF_ACCEPT_REDIRECTS - 1] = 1,
118547+ [IPV4_DEVCONF_ACCEPT_REDIRECTS - 1] = 0,
118548+ [IPV4_DEVCONF_RP_FILTER - 1] = 1,
118549 [IPV4_DEVCONF_SEND_REDIRECTS - 1] = 1,
118550 [IPV4_DEVCONF_SECURE_REDIRECTS - 1] = 1,
118551 [IPV4_DEVCONF_SHARED_MEDIA - 1] = 1,
118552@@ -1580,7 +1582,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
118553 idx = 0;
118554 head = &net->dev_index_head[h];
118555 rcu_read_lock();
118556- cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
118557+ cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
118558 net->dev_base_seq;
118559 hlist_for_each_entry_rcu(dev, head, index_hlist) {
118560 if (idx < s_idx)
118561@@ -1899,7 +1901,7 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb,
118562 idx = 0;
118563 head = &net->dev_index_head[h];
118564 rcu_read_lock();
118565- cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
118566+ cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
118567 net->dev_base_seq;
118568 hlist_for_each_entry_rcu(dev, head, index_hlist) {
118569 if (idx < s_idx)
118570@@ -2134,7 +2136,7 @@ static int ipv4_doint_and_flush(struct ctl_table *ctl, int write,
118571 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
118572 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
118573
118574-static struct devinet_sysctl_table {
118575+static const struct devinet_sysctl_table {
118576 struct ctl_table_header *sysctl_header;
118577 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
118578 } devinet_sysctl = {
118579@@ -2266,7 +2268,7 @@ static __net_init int devinet_init_net(struct net *net)
118580 int err;
118581 struct ipv4_devconf *all, *dflt;
118582 #ifdef CONFIG_SYSCTL
118583- struct ctl_table *tbl = ctl_forward_entry;
118584+ ctl_table_no_const *tbl = NULL;
118585 struct ctl_table_header *forw_hdr;
118586 #endif
118587
118588@@ -2284,7 +2286,7 @@ static __net_init int devinet_init_net(struct net *net)
118589 goto err_alloc_dflt;
118590
118591 #ifdef CONFIG_SYSCTL
118592- tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
118593+ tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
118594 if (!tbl)
118595 goto err_alloc_ctl;
118596
118597@@ -2304,7 +2306,10 @@ static __net_init int devinet_init_net(struct net *net)
118598 goto err_reg_dflt;
118599
118600 err = -ENOMEM;
118601- forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
118602+ if (!net_eq(net, &init_net))
118603+ forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
118604+ else
118605+ forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
118606 if (!forw_hdr)
118607 goto err_reg_ctl;
118608 net->ipv4.forw_hdr = forw_hdr;
118609@@ -2320,8 +2325,7 @@ err_reg_ctl:
118610 err_reg_dflt:
118611 __devinet_sysctl_unregister(all);
118612 err_reg_all:
118613- if (tbl != ctl_forward_entry)
118614- kfree(tbl);
118615+ kfree(tbl);
118616 err_alloc_ctl:
118617 #endif
118618 if (dflt != &ipv4_devconf_dflt)
118619diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
118620index 872494e..8e0b4d1 100644
118621--- a/net/ipv4/fib_frontend.c
118622+++ b/net/ipv4/fib_frontend.c
118623@@ -1083,12 +1083,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
118624 #ifdef CONFIG_IP_ROUTE_MULTIPATH
118625 fib_sync_up(dev);
118626 #endif
118627- atomic_inc(&net->ipv4.dev_addr_genid);
118628+ atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
118629 rt_cache_flush(dev_net(dev));
118630 break;
118631 case NETDEV_DOWN:
118632 fib_del_ifaddr(ifa, NULL);
118633- atomic_inc(&net->ipv4.dev_addr_genid);
118634+ atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
118635 if (!ifa->ifa_dev->ifa_list) {
118636 /* Last address was deleted from this interface.
118637 * Disable IP.
118638@@ -1126,7 +1126,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
118639 #ifdef CONFIG_IP_ROUTE_MULTIPATH
118640 fib_sync_up(dev);
118641 #endif
118642- atomic_inc(&net->ipv4.dev_addr_genid);
118643+ atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
118644 rt_cache_flush(net);
118645 break;
118646 case NETDEV_DOWN:
118647diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
118648index 8d695b6..752d427a 100644
118649--- a/net/ipv4/fib_semantics.c
118650+++ b/net/ipv4/fib_semantics.c
118651@@ -752,7 +752,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
118652 nh->nh_saddr = inet_select_addr(nh->nh_dev,
118653 nh->nh_gw,
118654 nh->nh_parent->fib_scope);
118655- nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
118656+ nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
118657
118658 return nh->nh_saddr;
118659 }
118660diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c
118661index 5e346a0..d0a7c03 100644
118662--- a/net/ipv4/inet_fragment.c
118663+++ b/net/ipv4/inet_fragment.c
118664@@ -131,34 +131,22 @@ inet_evict_bucket(struct inet_frags *f, struct inet_frag_bucket *hb)
118665 unsigned int evicted = 0;
118666 HLIST_HEAD(expired);
118667
118668-evict_again:
118669 spin_lock(&hb->chain_lock);
118670
118671 hlist_for_each_entry_safe(fq, n, &hb->chain, list) {
118672 if (!inet_fragq_should_evict(fq))
118673 continue;
118674
118675- if (!del_timer(&fq->timer)) {
118676- /* q expiring right now thus increment its refcount so
118677- * it won't be freed under us and wait until the timer
118678- * has finished executing then destroy it
118679- */
118680- atomic_inc(&fq->refcnt);
118681- spin_unlock(&hb->chain_lock);
118682- del_timer_sync(&fq->timer);
118683- inet_frag_put(fq, f);
118684- goto evict_again;
118685- }
118686+ if (!del_timer(&fq->timer))
118687+ continue;
118688
118689- fq->flags |= INET_FRAG_EVICTED;
118690- hlist_del(&fq->list);
118691- hlist_add_head(&fq->list, &expired);
118692+ hlist_add_head(&fq->list_evictor, &expired);
118693 ++evicted;
118694 }
118695
118696 spin_unlock(&hb->chain_lock);
118697
118698- hlist_for_each_entry_safe(fq, n, &expired, list)
118699+ hlist_for_each_entry_safe(fq, n, &expired, list_evictor)
118700 f->frag_expire((unsigned long) fq);
118701
118702 return evicted;
118703@@ -240,19 +228,21 @@ void inet_frags_exit_net(struct netns_frags *nf, struct inet_frags *f)
118704 int i;
118705
118706 nf->low_thresh = 0;
118707- local_bh_disable();
118708
118709 evict_again:
118710+ local_bh_disable();
118711 seq = read_seqbegin(&f->rnd_seqlock);
118712
118713 for (i = 0; i < INETFRAGS_HASHSZ ; i++)
118714 inet_evict_bucket(f, &f->hash[i]);
118715
118716- if (read_seqretry(&f->rnd_seqlock, seq))
118717+ local_bh_enable();
118718+ cond_resched();
118719+
118720+ if (read_seqretry(&f->rnd_seqlock, seq) ||
118721+ percpu_counter_sum(&nf->mem))
118722 goto evict_again;
118723
118724- local_bh_enable();
118725-
118726 percpu_counter_destroy(&nf->mem);
118727 }
118728 EXPORT_SYMBOL(inet_frags_exit_net);
118729@@ -284,8 +274,8 @@ static inline void fq_unlink(struct inet_frag_queue *fq, struct inet_frags *f)
118730 struct inet_frag_bucket *hb;
118731
118732 hb = get_frag_bucket_locked(fq, f);
118733- if (!(fq->flags & INET_FRAG_EVICTED))
118734- hlist_del(&fq->list);
118735+ hlist_del(&fq->list);
118736+ fq->flags |= INET_FRAG_COMPLETE;
118737 spin_unlock(&hb->chain_lock);
118738 }
118739
118740@@ -297,7 +287,6 @@ void inet_frag_kill(struct inet_frag_queue *fq, struct inet_frags *f)
118741 if (!(fq->flags & INET_FRAG_COMPLETE)) {
118742 fq_unlink(fq, f);
118743 atomic_dec(&fq->refcnt);
118744- fq->flags |= INET_FRAG_COMPLETE;
118745 }
118746 }
118747 EXPORT_SYMBOL(inet_frag_kill);
118748@@ -330,11 +319,12 @@ void inet_frag_destroy(struct inet_frag_queue *q, struct inet_frags *f)
118749 fp = xp;
118750 }
118751 sum = sum_truesize + f->qsize;
118752- sub_frag_mem_limit(q, sum);
118753
118754 if (f->destructor)
118755 f->destructor(q);
118756 kmem_cache_free(f->frags_cachep, q);
118757+
118758+ sub_frag_mem_limit(nf, sum);
118759 }
118760 EXPORT_SYMBOL(inet_frag_destroy);
118761
118762@@ -390,7 +380,7 @@ static struct inet_frag_queue *inet_frag_alloc(struct netns_frags *nf,
118763
118764 q->net = nf;
118765 f->constructor(q, arg);
118766- add_frag_mem_limit(q, f->qsize);
118767+ add_frag_mem_limit(nf, f->qsize);
118768
118769 setup_timer(&q->timer, f->frag_expire, (unsigned long)q);
118770 spin_lock_init(&q->lock);
118771diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
118772index c6fb80b..8705495 100644
118773--- a/net/ipv4/inet_hashtables.c
118774+++ b/net/ipv4/inet_hashtables.c
118775@@ -18,6 +18,7 @@
118776 #include <linux/sched.h>
118777 #include <linux/slab.h>
118778 #include <linux/wait.h>
118779+#include <linux/security.h>
118780
118781 #include <net/inet_connection_sock.h>
118782 #include <net/inet_hashtables.h>
118783@@ -53,6 +54,8 @@ u32 sk_ehashfn(const struct sock *sk)
118784 sk->sk_daddr, sk->sk_dport);
118785 }
118786
118787+extern void gr_update_task_in_ip_table(const struct inet_sock *inet);
118788+
118789 /*
118790 * Allocate and initialize a new local port bind bucket.
118791 * The bindhash mutex for snum's hash chain must be held here.
118792@@ -564,6 +567,8 @@ ok:
118793 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
118794 spin_unlock(&head->lock);
118795
118796+ gr_update_task_in_ip_table(inet_sk(sk));
118797+
118798 if (tw) {
118799 inet_twsk_deschedule(tw);
118800 while (twrefcnt) {
118801diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
118802index 241afd7..31b95d5 100644
118803--- a/net/ipv4/inetpeer.c
118804+++ b/net/ipv4/inetpeer.c
118805@@ -461,7 +461,7 @@ relookup:
118806 if (p) {
118807 p->daddr = *daddr;
118808 atomic_set(&p->refcnt, 1);
118809- atomic_set(&p->rid, 0);
118810+ atomic_set_unchecked(&p->rid, 0);
118811 p->metrics[RTAX_LOCK-1] = INETPEER_METRICS_NEW;
118812 p->rate_tokens = 0;
118813 /* 60*HZ is arbitrary, but chosen enough high so that the first
118814diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
118815index cc1da6d..593fc73 100644
118816--- a/net/ipv4/ip_fragment.c
118817+++ b/net/ipv4/ip_fragment.c
118818@@ -192,7 +192,7 @@ static void ip_expire(unsigned long arg)
118819 ipq_kill(qp);
118820 IP_INC_STATS_BH(net, IPSTATS_MIB_REASMFAILS);
118821
118822- if (!(qp->q.flags & INET_FRAG_EVICTED)) {
118823+ if (!inet_frag_evicting(&qp->q)) {
118824 struct sk_buff *head = qp->q.fragments;
118825 const struct iphdr *iph;
118826 int err;
118827@@ -268,7 +268,7 @@ static int ip_frag_too_far(struct ipq *qp)
118828 return 0;
118829
118830 start = qp->rid;
118831- end = atomic_inc_return(&peer->rid);
118832+ end = atomic_inc_return_unchecked(&peer->rid);
118833 qp->rid = end;
118834
118835 rc = qp->q.fragments && (end - start) > max;
118836@@ -301,7 +301,7 @@ static int ip_frag_reinit(struct ipq *qp)
118837 kfree_skb(fp);
118838 fp = xp;
118839 } while (fp);
118840- sub_frag_mem_limit(&qp->q, sum_truesize);
118841+ sub_frag_mem_limit(qp->q.net, sum_truesize);
118842
118843 qp->q.flags = 0;
118844 qp->q.len = 0;
118845@@ -446,7 +446,7 @@ found:
118846 qp->q.fragments = next;
118847
118848 qp->q.meat -= free_it->len;
118849- sub_frag_mem_limit(&qp->q, free_it->truesize);
118850+ sub_frag_mem_limit(qp->q.net, free_it->truesize);
118851 kfree_skb(free_it);
118852 }
118853 }
118854@@ -470,7 +470,7 @@ found:
118855 qp->q.stamp = skb->tstamp;
118856 qp->q.meat += skb->len;
118857 qp->ecn |= ecn;
118858- add_frag_mem_limit(&qp->q, skb->truesize);
118859+ add_frag_mem_limit(qp->q.net, skb->truesize);
118860 if (offset == 0)
118861 qp->q.flags |= INET_FRAG_FIRST_IN;
118862
118863@@ -573,7 +573,7 @@ static int ip_frag_reasm(struct ipq *qp, struct sk_buff *prev,
118864 head->len -= clone->len;
118865 clone->csum = 0;
118866 clone->ip_summed = head->ip_summed;
118867- add_frag_mem_limit(&qp->q, clone->truesize);
118868+ add_frag_mem_limit(qp->q.net, clone->truesize);
118869 }
118870
118871 skb_push(head, head->data - skb_network_header(head));
118872@@ -601,7 +601,7 @@ static int ip_frag_reasm(struct ipq *qp, struct sk_buff *prev,
118873 }
118874 fp = next;
118875 }
118876- sub_frag_mem_limit(&qp->q, sum_truesize);
118877+ sub_frag_mem_limit(qp->q.net, sum_truesize);
118878
118879 head->next = NULL;
118880 head->dev = dev;
118881@@ -750,12 +750,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
118882
118883 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
118884 {
118885- struct ctl_table *table;
118886+ ctl_table_no_const *table = NULL;
118887 struct ctl_table_header *hdr;
118888
118889- table = ip4_frags_ns_ctl_table;
118890 if (!net_eq(net, &init_net)) {
118891- table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
118892+ table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
118893 if (!table)
118894 goto err_alloc;
118895
118896@@ -769,9 +768,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
118897 /* Don't export sysctls to unprivileged users */
118898 if (net->user_ns != &init_user_ns)
118899 table[0].procname = NULL;
118900- }
118901+ hdr = register_net_sysctl(net, "net/ipv4", table);
118902+ } else
118903+ hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
118904
118905- hdr = register_net_sysctl(net, "net/ipv4", table);
118906 if (!hdr)
118907 goto err_reg;
118908
118909@@ -779,8 +779,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
118910 return 0;
118911
118912 err_reg:
118913- if (!net_eq(net, &init_net))
118914- kfree(table);
118915+ kfree(table);
118916 err_alloc:
118917 return -ENOMEM;
118918 }
118919diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
118920index 5fd7064..d13d75f 100644
118921--- a/net/ipv4/ip_gre.c
118922+++ b/net/ipv4/ip_gre.c
118923@@ -115,7 +115,7 @@ static bool log_ecn_error = true;
118924 module_param(log_ecn_error, bool, 0644);
118925 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
118926
118927-static struct rtnl_link_ops ipgre_link_ops __read_mostly;
118928+static struct rtnl_link_ops ipgre_link_ops;
118929 static int ipgre_tunnel_init(struct net_device *dev);
118930
118931 static int ipgre_net_id __read_mostly;
118932@@ -819,7 +819,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
118933 [IFLA_GRE_ENCAP_DPORT] = { .type = NLA_U16 },
118934 };
118935
118936-static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
118937+static struct rtnl_link_ops ipgre_link_ops = {
118938 .kind = "gre",
118939 .maxtype = IFLA_GRE_MAX,
118940 .policy = ipgre_policy,
118941@@ -834,7 +834,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
118942 .get_link_net = ip_tunnel_get_link_net,
118943 };
118944
118945-static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
118946+static struct rtnl_link_ops ipgre_tap_ops = {
118947 .kind = "gretap",
118948 .maxtype = IFLA_GRE_MAX,
118949 .policy = ipgre_policy,
118950diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c
118951index 2db4c87..4db9282 100644
118952--- a/net/ipv4/ip_input.c
118953+++ b/net/ipv4/ip_input.c
118954@@ -147,6 +147,10 @@
118955 #include <linux/mroute.h>
118956 #include <linux/netlink.h>
118957
118958+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
118959+extern int grsec_enable_blackhole;
118960+#endif
118961+
118962 /*
118963 * Process Router Attention IP option (RFC 2113)
118964 */
118965@@ -223,6 +227,9 @@ static int ip_local_deliver_finish(struct sock *sk, struct sk_buff *skb)
118966 if (!raw) {
118967 if (xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) {
118968 IP_INC_STATS_BH(net, IPSTATS_MIB_INUNKNOWNPROTOS);
118969+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
118970+ if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
118971+#endif
118972 icmp_send(skb, ICMP_DEST_UNREACH,
118973 ICMP_PROT_UNREACH, 0);
118974 }
118975diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
118976index 6ddde89..653e224 100644
118977--- a/net/ipv4/ip_sockglue.c
118978+++ b/net/ipv4/ip_sockglue.c
118979@@ -1291,7 +1291,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
118980 len = min_t(unsigned int, len, opt->optlen);
118981 if (put_user(len, optlen))
118982 return -EFAULT;
118983- if (copy_to_user(optval, opt->__data, len))
118984+ if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
118985+ copy_to_user(optval, opt->__data, len))
118986 return -EFAULT;
118987 return 0;
118988 }
118989@@ -1425,7 +1426,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
118990 if (sk->sk_type != SOCK_STREAM)
118991 return -ENOPROTOOPT;
118992
118993- msg.msg_control = (__force void *) optval;
118994+ msg.msg_control = (__force_kernel void *) optval;
118995 msg.msg_controllen = len;
118996 msg.msg_flags = flags;
118997
118998diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
118999index 0c15208..a3a76c5 100644
119000--- a/net/ipv4/ip_vti.c
119001+++ b/net/ipv4/ip_vti.c
119002@@ -45,7 +45,7 @@
119003 #include <net/net_namespace.h>
119004 #include <net/netns/generic.h>
119005
119006-static struct rtnl_link_ops vti_link_ops __read_mostly;
119007+static struct rtnl_link_ops vti_link_ops;
119008
119009 static int vti_net_id __read_mostly;
119010 static int vti_tunnel_init(struct net_device *dev);
119011@@ -525,7 +525,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
119012 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
119013 };
119014
119015-static struct rtnl_link_ops vti_link_ops __read_mostly = {
119016+static struct rtnl_link_ops vti_link_ops = {
119017 .kind = "vti",
119018 .maxtype = IFLA_VTI_MAX,
119019 .policy = vti_policy,
119020diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
119021index 8e7328c..9bd7ed3 100644
119022--- a/net/ipv4/ipconfig.c
119023+++ b/net/ipv4/ipconfig.c
119024@@ -333,7 +333,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
119025
119026 mm_segment_t oldfs = get_fs();
119027 set_fs(get_ds());
119028- res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
119029+ res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
119030 set_fs(oldfs);
119031 return res;
119032 }
119033@@ -344,7 +344,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
119034
119035 mm_segment_t oldfs = get_fs();
119036 set_fs(get_ds());
119037- res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
119038+ res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
119039 set_fs(oldfs);
119040 return res;
119041 }
119042@@ -355,7 +355,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
119043
119044 mm_segment_t oldfs = get_fs();
119045 set_fs(get_ds());
119046- res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
119047+ res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
119048 set_fs(oldfs);
119049 return res;
119050 }
119051diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
119052index ff96396..2e928ba 100644
119053--- a/net/ipv4/ipip.c
119054+++ b/net/ipv4/ipip.c
119055@@ -124,7 +124,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
119056 static int ipip_net_id __read_mostly;
119057
119058 static int ipip_tunnel_init(struct net_device *dev);
119059-static struct rtnl_link_ops ipip_link_ops __read_mostly;
119060+static struct rtnl_link_ops ipip_link_ops;
119061
119062 static int ipip_err(struct sk_buff *skb, u32 info)
119063 {
119064@@ -487,7 +487,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
119065 [IFLA_IPTUN_ENCAP_DPORT] = { .type = NLA_U16 },
119066 };
119067
119068-static struct rtnl_link_ops ipip_link_ops __read_mostly = {
119069+static struct rtnl_link_ops ipip_link_ops = {
119070 .kind = "ipip",
119071 .maxtype = IFLA_IPTUN_MAX,
119072 .policy = ipip_policy,
119073diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
119074index a612007..99ac4bc5 100644
119075--- a/net/ipv4/netfilter/arp_tables.c
119076+++ b/net/ipv4/netfilter/arp_tables.c
119077@@ -884,14 +884,14 @@ static int compat_table_info(const struct xt_table_info *info,
119078 #endif
119079
119080 static int get_info(struct net *net, void __user *user,
119081- const int *len, int compat)
119082+ int len, int compat)
119083 {
119084 char name[XT_TABLE_MAXNAMELEN];
119085 struct xt_table *t;
119086 int ret;
119087
119088- if (*len != sizeof(struct arpt_getinfo)) {
119089- duprintf("length %u != %Zu\n", *len,
119090+ if (len != sizeof(struct arpt_getinfo)) {
119091+ duprintf("length %u != %Zu\n", len,
119092 sizeof(struct arpt_getinfo));
119093 return -EINVAL;
119094 }
119095@@ -928,7 +928,7 @@ static int get_info(struct net *net, void __user *user,
119096 info.size = private->size;
119097 strcpy(info.name, name);
119098
119099- if (copy_to_user(user, &info, *len) != 0)
119100+ if (copy_to_user(user, &info, len) != 0)
119101 ret = -EFAULT;
119102 else
119103 ret = 0;
119104@@ -1695,7 +1695,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
119105
119106 switch (cmd) {
119107 case ARPT_SO_GET_INFO:
119108- ret = get_info(sock_net(sk), user, len, 1);
119109+ ret = get_info(sock_net(sk), user, *len, 1);
119110 break;
119111 case ARPT_SO_GET_ENTRIES:
119112 ret = compat_get_entries(sock_net(sk), user, len);
119113@@ -1740,7 +1740,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
119114
119115 switch (cmd) {
119116 case ARPT_SO_GET_INFO:
119117- ret = get_info(sock_net(sk), user, len, 0);
119118+ ret = get_info(sock_net(sk), user, *len, 0);
119119 break;
119120
119121 case ARPT_SO_GET_ENTRIES:
119122diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
119123index 2d0e265..67e5b8d 100644
119124--- a/net/ipv4/netfilter/ip_tables.c
119125+++ b/net/ipv4/netfilter/ip_tables.c
119126@@ -1072,14 +1072,14 @@ static int compat_table_info(const struct xt_table_info *info,
119127 #endif
119128
119129 static int get_info(struct net *net, void __user *user,
119130- const int *len, int compat)
119131+ int len, int compat)
119132 {
119133 char name[XT_TABLE_MAXNAMELEN];
119134 struct xt_table *t;
119135 int ret;
119136
119137- if (*len != sizeof(struct ipt_getinfo)) {
119138- duprintf("length %u != %zu\n", *len,
119139+ if (len != sizeof(struct ipt_getinfo)) {
119140+ duprintf("length %u != %zu\n", len,
119141 sizeof(struct ipt_getinfo));
119142 return -EINVAL;
119143 }
119144@@ -1116,7 +1116,7 @@ static int get_info(struct net *net, void __user *user,
119145 info.size = private->size;
119146 strcpy(info.name, name);
119147
119148- if (copy_to_user(user, &info, *len) != 0)
119149+ if (copy_to_user(user, &info, len) != 0)
119150 ret = -EFAULT;
119151 else
119152 ret = 0;
119153@@ -1978,7 +1978,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
119154
119155 switch (cmd) {
119156 case IPT_SO_GET_INFO:
119157- ret = get_info(sock_net(sk), user, len, 1);
119158+ ret = get_info(sock_net(sk), user, *len, 1);
119159 break;
119160 case IPT_SO_GET_ENTRIES:
119161 ret = compat_get_entries(sock_net(sk), user, len);
119162@@ -2025,7 +2025,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
119163
119164 switch (cmd) {
119165 case IPT_SO_GET_INFO:
119166- ret = get_info(sock_net(sk), user, len, 0);
119167+ ret = get_info(sock_net(sk), user, *len, 0);
119168 break;
119169
119170 case IPT_SO_GET_ENTRIES:
119171diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c b/net/ipv4/netfilter/ipt_CLUSTERIP.c
119172index 771ab3d..5b99b18 100644
119173--- a/net/ipv4/netfilter/ipt_CLUSTERIP.c
119174+++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c
119175@@ -725,7 +725,7 @@ static int clusterip_net_init(struct net *net)
119176 spin_lock_init(&cn->lock);
119177
119178 #ifdef CONFIG_PROC_FS
119179- cn->procdir = proc_mkdir("ipt_CLUSTERIP", net->proc_net);
119180+ cn->procdir = proc_mkdir_restrict("ipt_CLUSTERIP", net->proc_net);
119181 if (!cn->procdir) {
119182 pr_err("Unable to proc dir entry\n");
119183 return -ENOMEM;
119184diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
119185index 05ff44b..da00000 100644
119186--- a/net/ipv4/ping.c
119187+++ b/net/ipv4/ping.c
119188@@ -59,7 +59,7 @@ struct ping_table {
119189 };
119190
119191 static struct ping_table ping_table;
119192-struct pingv6_ops pingv6_ops;
119193+struct pingv6_ops *pingv6_ops;
119194 EXPORT_SYMBOL_GPL(pingv6_ops);
119195
119196 static u16 ping_port_rover;
119197@@ -359,7 +359,7 @@ static int ping_check_bind_addr(struct sock *sk, struct inet_sock *isk,
119198 return -ENODEV;
119199 }
119200 }
119201- has_addr = pingv6_ops.ipv6_chk_addr(net, &addr->sin6_addr, dev,
119202+ has_addr = pingv6_ops->ipv6_chk_addr(net, &addr->sin6_addr, dev,
119203 scoped);
119204 rcu_read_unlock();
119205
119206@@ -567,7 +567,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
119207 }
119208 #if IS_ENABLED(CONFIG_IPV6)
119209 } else if (skb->protocol == htons(ETH_P_IPV6)) {
119210- harderr = pingv6_ops.icmpv6_err_convert(type, code, &err);
119211+ harderr = pingv6_ops->icmpv6_err_convert(type, code, &err);
119212 #endif
119213 }
119214
119215@@ -585,7 +585,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
119216 info, (u8 *)icmph);
119217 #if IS_ENABLED(CONFIG_IPV6)
119218 } else if (family == AF_INET6) {
119219- pingv6_ops.ipv6_icmp_error(sk, skb, err, 0,
119220+ pingv6_ops->ipv6_icmp_error(sk, skb, err, 0,
119221 info, (u8 *)icmph);
119222 #endif
119223 }
119224@@ -918,10 +918,10 @@ int ping_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int noblock,
119225 }
119226
119227 if (inet6_sk(sk)->rxopt.all)
119228- pingv6_ops.ip6_datagram_recv_common_ctl(sk, msg, skb);
119229+ pingv6_ops->ip6_datagram_recv_common_ctl(sk, msg, skb);
119230 if (skb->protocol == htons(ETH_P_IPV6) &&
119231 inet6_sk(sk)->rxopt.all)
119232- pingv6_ops.ip6_datagram_recv_specific_ctl(sk, msg, skb);
119233+ pingv6_ops->ip6_datagram_recv_specific_ctl(sk, msg, skb);
119234 else if (skb->protocol == htons(ETH_P_IP) && isk->cmsg_flags)
119235 ip_cmsg_recv(msg, skb);
119236 #endif
119237@@ -1116,7 +1116,7 @@ static void ping_v4_format_sock(struct sock *sp, struct seq_file *f,
119238 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
119239 0, sock_i_ino(sp),
119240 atomic_read(&sp->sk_refcnt), sp,
119241- atomic_read(&sp->sk_drops));
119242+ atomic_read_unchecked(&sp->sk_drops));
119243 }
119244
119245 static int ping_v4_seq_show(struct seq_file *seq, void *v)
119246diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
119247index 561cd4b..a32a155 100644
119248--- a/net/ipv4/raw.c
119249+++ b/net/ipv4/raw.c
119250@@ -323,7 +323,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
119251 int raw_rcv(struct sock *sk, struct sk_buff *skb)
119252 {
119253 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
119254- atomic_inc(&sk->sk_drops);
119255+ atomic_inc_unchecked(&sk->sk_drops);
119256 kfree_skb(skb);
119257 return NET_RX_DROP;
119258 }
119259@@ -771,16 +771,20 @@ static int raw_init(struct sock *sk)
119260
119261 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
119262 {
119263+ struct icmp_filter filter;
119264+
119265 if (optlen > sizeof(struct icmp_filter))
119266 optlen = sizeof(struct icmp_filter);
119267- if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
119268+ if (copy_from_user(&filter, optval, optlen))
119269 return -EFAULT;
119270+ raw_sk(sk)->filter = filter;
119271 return 0;
119272 }
119273
119274 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
119275 {
119276 int len, ret = -EFAULT;
119277+ struct icmp_filter filter;
119278
119279 if (get_user(len, optlen))
119280 goto out;
119281@@ -790,8 +794,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
119282 if (len > sizeof(struct icmp_filter))
119283 len = sizeof(struct icmp_filter);
119284 ret = -EFAULT;
119285- if (put_user(len, optlen) ||
119286- copy_to_user(optval, &raw_sk(sk)->filter, len))
119287+ filter = raw_sk(sk)->filter;
119288+ if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
119289 goto out;
119290 ret = 0;
119291 out: return ret;
119292@@ -1020,7 +1024,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
119293 0, 0L, 0,
119294 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
119295 0, sock_i_ino(sp),
119296- atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
119297+ atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
119298 }
119299
119300 static int raw_seq_show(struct seq_file *seq, void *v)
119301diff --git a/net/ipv4/route.c b/net/ipv4/route.c
119302index f45f2a1..e7d47a3 100644
119303--- a/net/ipv4/route.c
119304+++ b/net/ipv4/route.c
119305@@ -227,7 +227,7 @@ static const struct seq_operations rt_cache_seq_ops = {
119306
119307 static int rt_cache_seq_open(struct inode *inode, struct file *file)
119308 {
119309- return seq_open(file, &rt_cache_seq_ops);
119310+ return seq_open_restrict(file, &rt_cache_seq_ops);
119311 }
119312
119313 static const struct file_operations rt_cache_seq_fops = {
119314@@ -318,7 +318,7 @@ static const struct seq_operations rt_cpu_seq_ops = {
119315
119316 static int rt_cpu_seq_open(struct inode *inode, struct file *file)
119317 {
119318- return seq_open(file, &rt_cpu_seq_ops);
119319+ return seq_open_restrict(file, &rt_cpu_seq_ops);
119320 }
119321
119322 static const struct file_operations rt_cpu_seq_fops = {
119323@@ -356,7 +356,7 @@ static int rt_acct_proc_show(struct seq_file *m, void *v)
119324
119325 static int rt_acct_proc_open(struct inode *inode, struct file *file)
119326 {
119327- return single_open(file, rt_acct_proc_show, NULL);
119328+ return single_open_restrict(file, rt_acct_proc_show, NULL);
119329 }
119330
119331 static const struct file_operations rt_acct_proc_fops = {
119332@@ -458,11 +458,11 @@ static struct neighbour *ipv4_neigh_lookup(const struct dst_entry *dst,
119333
119334 #define IP_IDENTS_SZ 2048u
119335 struct ip_ident_bucket {
119336- atomic_t id;
119337+ atomic_unchecked_t id;
119338 u32 stamp32;
119339 };
119340
119341-static struct ip_ident_bucket *ip_idents __read_mostly;
119342+static struct ip_ident_bucket ip_idents[IP_IDENTS_SZ] __read_mostly;
119343
119344 /* In order to protect privacy, we add a perturbation to identifiers
119345 * if one generator is seldom used. This makes hard for an attacker
119346@@ -478,7 +478,7 @@ u32 ip_idents_reserve(u32 hash, int segs)
119347 if (old != now && cmpxchg(&bucket->stamp32, old, now) == old)
119348 delta = prandom_u32_max(now - old);
119349
119350- return atomic_add_return(segs + delta, &bucket->id) - segs;
119351+ return atomic_add_return_unchecked(segs + delta, &bucket->id) - segs;
119352 }
119353 EXPORT_SYMBOL(ip_idents_reserve);
119354
119355@@ -2641,34 +2641,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
119356 .maxlen = sizeof(int),
119357 .mode = 0200,
119358 .proc_handler = ipv4_sysctl_rtcache_flush,
119359+ .extra1 = &init_net,
119360 },
119361 { },
119362 };
119363
119364 static __net_init int sysctl_route_net_init(struct net *net)
119365 {
119366- struct ctl_table *tbl;
119367+ ctl_table_no_const *tbl = NULL;
119368
119369- tbl = ipv4_route_flush_table;
119370 if (!net_eq(net, &init_net)) {
119371- tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
119372+ tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
119373 if (!tbl)
119374 goto err_dup;
119375
119376 /* Don't export sysctls to unprivileged users */
119377 if (net->user_ns != &init_user_ns)
119378 tbl[0].procname = NULL;
119379- }
119380- tbl[0].extra1 = net;
119381+ tbl[0].extra1 = net;
119382+ net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
119383+ } else
119384+ net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
119385
119386- net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
119387 if (!net->ipv4.route_hdr)
119388 goto err_reg;
119389 return 0;
119390
119391 err_reg:
119392- if (tbl != ipv4_route_flush_table)
119393- kfree(tbl);
119394+ kfree(tbl);
119395 err_dup:
119396 return -ENOMEM;
119397 }
119398@@ -2691,8 +2691,8 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
119399
119400 static __net_init int rt_genid_init(struct net *net)
119401 {
119402- atomic_set(&net->ipv4.rt_genid, 0);
119403- atomic_set(&net->fnhe_genid, 0);
119404+ atomic_set_unchecked(&net->ipv4.rt_genid, 0);
119405+ atomic_set_unchecked(&net->fnhe_genid, 0);
119406 get_random_bytes(&net->ipv4.dev_addr_genid,
119407 sizeof(net->ipv4.dev_addr_genid));
119408 return 0;
119409@@ -2736,11 +2736,7 @@ int __init ip_rt_init(void)
119410 int rc = 0;
119411 int cpu;
119412
119413- ip_idents = kmalloc(IP_IDENTS_SZ * sizeof(*ip_idents), GFP_KERNEL);
119414- if (!ip_idents)
119415- panic("IP: failed to allocate ip_idents\n");
119416-
119417- prandom_bytes(ip_idents, IP_IDENTS_SZ * sizeof(*ip_idents));
119418+ prandom_bytes(ip_idents, sizeof(ip_idents));
119419
119420 for_each_possible_cpu(cpu) {
119421 struct uncached_list *ul = &per_cpu(rt_uncached_list, cpu);
119422diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
119423index c3852a7..7bdbde7 100644
119424--- a/net/ipv4/sysctl_net_ipv4.c
119425+++ b/net/ipv4/sysctl_net_ipv4.c
119426@@ -60,7 +60,7 @@ static int ipv4_local_port_range(struct ctl_table *table, int write,
119427 container_of(table->data, struct net, ipv4.ip_local_ports.range);
119428 int ret;
119429 int range[2];
119430- struct ctl_table tmp = {
119431+ ctl_table_no_const tmp = {
119432 .data = &range,
119433 .maxlen = sizeof(range),
119434 .mode = table->mode,
119435@@ -118,7 +118,7 @@ static int ipv4_ping_group_range(struct ctl_table *table, int write,
119436 int ret;
119437 gid_t urange[2];
119438 kgid_t low, high;
119439- struct ctl_table tmp = {
119440+ ctl_table_no_const tmp = {
119441 .data = &urange,
119442 .maxlen = sizeof(urange),
119443 .mode = table->mode,
119444@@ -149,7 +149,7 @@ static int proc_tcp_congestion_control(struct ctl_table *ctl, int write,
119445 void __user *buffer, size_t *lenp, loff_t *ppos)
119446 {
119447 char val[TCP_CA_NAME_MAX];
119448- struct ctl_table tbl = {
119449+ ctl_table_no_const tbl = {
119450 .data = val,
119451 .maxlen = TCP_CA_NAME_MAX,
119452 };
119453@@ -168,7 +168,7 @@ static int proc_tcp_available_congestion_control(struct ctl_table *ctl,
119454 void __user *buffer, size_t *lenp,
119455 loff_t *ppos)
119456 {
119457- struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
119458+ ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
119459 int ret;
119460
119461 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
119462@@ -185,7 +185,7 @@ static int proc_allowed_congestion_control(struct ctl_table *ctl,
119463 void __user *buffer, size_t *lenp,
119464 loff_t *ppos)
119465 {
119466- struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
119467+ ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
119468 int ret;
119469
119470 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
119471@@ -204,7 +204,7 @@ static int proc_tcp_fastopen_key(struct ctl_table *ctl, int write,
119472 void __user *buffer, size_t *lenp,
119473 loff_t *ppos)
119474 {
119475- struct ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
119476+ ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
119477 struct tcp_fastopen_context *ctxt;
119478 int ret;
119479 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
119480@@ -902,13 +902,12 @@ static struct ctl_table ipv4_net_table[] = {
119481
119482 static __net_init int ipv4_sysctl_init_net(struct net *net)
119483 {
119484- struct ctl_table *table;
119485+ ctl_table_no_const *table = NULL;
119486
119487- table = ipv4_net_table;
119488 if (!net_eq(net, &init_net)) {
119489 int i;
119490
119491- table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
119492+ table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
119493 if (!table)
119494 goto err_alloc;
119495
119496@@ -917,7 +916,10 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
119497 table[i].data += (void *)net - (void *)&init_net;
119498 }
119499
119500- net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
119501+ if (!net_eq(net, &init_net))
119502+ net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
119503+ else
119504+ net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
119505 if (!net->ipv4.ipv4_hdr)
119506 goto err_reg;
119507
119508diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
119509index c9ab964..607d9f7 100644
119510--- a/net/ipv4/tcp_input.c
119511+++ b/net/ipv4/tcp_input.c
119512@@ -767,7 +767,7 @@ static void tcp_update_pacing_rate(struct sock *sk)
119513 * without any lock. We want to make sure compiler wont store
119514 * intermediate values in this location.
119515 */
119516- ACCESS_ONCE(sk->sk_pacing_rate) = min_t(u64, rate,
119517+ ACCESS_ONCE_RW(sk->sk_pacing_rate) = min_t(u64, rate,
119518 sk->sk_max_pacing_rate);
119519 }
119520
119521@@ -4610,7 +4610,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
119522 * simplifies code)
119523 */
119524 static void
119525-tcp_collapse(struct sock *sk, struct sk_buff_head *list,
119526+__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
119527 struct sk_buff *head, struct sk_buff *tail,
119528 u32 start, u32 end)
119529 {
119530@@ -5605,6 +5605,7 @@ discard:
119531 tcp_paws_reject(&tp->rx_opt, 0))
119532 goto discard_and_undo;
119533
119534+#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
119535 if (th->syn) {
119536 /* We see SYN without ACK. It is attempt of
119537 * simultaneous connect with crossed SYNs.
119538@@ -5655,6 +5656,7 @@ discard:
119539 goto discard;
119540 #endif
119541 }
119542+#endif
119543 /* "fifth, if neither of the SYN or RST bits is set then
119544 * drop the segment and return."
119545 */
119546@@ -5701,7 +5703,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
119547 goto discard;
119548
119549 if (th->syn) {
119550- if (th->fin)
119551+ if (th->fin || th->urg || th->psh)
119552 goto discard;
119553 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
119554 return 1;
119555diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
119556index fc1c658..42a8d34 100644
119557--- a/net/ipv4/tcp_ipv4.c
119558+++ b/net/ipv4/tcp_ipv4.c
119559@@ -89,6 +89,10 @@ int sysctl_tcp_tw_reuse __read_mostly;
119560 int sysctl_tcp_low_latency __read_mostly;
119561 EXPORT_SYMBOL(sysctl_tcp_low_latency);
119562
119563+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
119564+extern int grsec_enable_blackhole;
119565+#endif
119566+
119567 #ifdef CONFIG_TCP_MD5SIG
119568 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
119569 __be32 daddr, __be32 saddr, const struct tcphdr *th);
119570@@ -1427,6 +1431,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
119571 return 0;
119572
119573 reset:
119574+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
119575+ if (!grsec_enable_blackhole)
119576+#endif
119577 tcp_v4_send_reset(rsk, skb);
119578 discard:
119579 kfree_skb(skb);
119580@@ -1591,12 +1598,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
119581 TCP_SKB_CB(skb)->sacked = 0;
119582
119583 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
119584- if (!sk)
119585+ if (!sk) {
119586+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
119587+ ret = 1;
119588+#endif
119589 goto no_tcp_socket;
119590-
119591+ }
119592 process:
119593- if (sk->sk_state == TCP_TIME_WAIT)
119594+ if (sk->sk_state == TCP_TIME_WAIT) {
119595+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
119596+ ret = 2;
119597+#endif
119598 goto do_time_wait;
119599+ }
119600
119601 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
119602 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
119603@@ -1652,6 +1666,10 @@ csum_error:
119604 bad_packet:
119605 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
119606 } else {
119607+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
119608+ if (!grsec_enable_blackhole || (ret == 1 &&
119609+ (skb->dev->flags & IFF_LOOPBACK)))
119610+#endif
119611 tcp_v4_send_reset(NULL, skb);
119612 }
119613
119614diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
119615index 17e7339..c72ff6c 100644
119616--- a/net/ipv4/tcp_minisocks.c
119617+++ b/net/ipv4/tcp_minisocks.c
119618@@ -27,6 +27,10 @@
119619 #include <net/inet_common.h>
119620 #include <net/xfrm.h>
119621
119622+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
119623+extern int grsec_enable_blackhole;
119624+#endif
119625+
119626 int sysctl_tcp_syncookies __read_mostly = 1;
119627 EXPORT_SYMBOL(sysctl_tcp_syncookies);
119628
119629@@ -778,7 +782,10 @@ embryonic_reset:
119630 * avoid becoming vulnerable to outside attack aiming at
119631 * resetting legit local connections.
119632 */
119633- req->rsk_ops->send_reset(sk, skb);
119634+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
119635+ if (!grsec_enable_blackhole)
119636+#endif
119637+ req->rsk_ops->send_reset(sk, skb);
119638 } else if (fastopen) { /* received a valid RST pkt */
119639 reqsk_fastopen_remove(sk, req, true);
119640 tcp_reset(sk);
119641diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
119642index ebf5ff5..4d1ff32 100644
119643--- a/net/ipv4/tcp_probe.c
119644+++ b/net/ipv4/tcp_probe.c
119645@@ -236,7 +236,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
119646 if (cnt + width >= len)
119647 break;
119648
119649- if (copy_to_user(buf + cnt, tbuf, width))
119650+ if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
119651 return -EFAULT;
119652 cnt += width;
119653 }
119654diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
119655index 8c65dc1..55fd1ba 100644
119656--- a/net/ipv4/tcp_timer.c
119657+++ b/net/ipv4/tcp_timer.c
119658@@ -22,6 +22,10 @@
119659 #include <linux/gfp.h>
119660 #include <net/tcp.h>
119661
119662+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
119663+extern int grsec_lastack_retries;
119664+#endif
119665+
119666 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
119667 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
119668 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
119669@@ -195,6 +199,13 @@ static int tcp_write_timeout(struct sock *sk)
119670 }
119671 }
119672
119673+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
119674+ if ((sk->sk_state == TCP_LAST_ACK) &&
119675+ (grsec_lastack_retries > 0) &&
119676+ (grsec_lastack_retries < retry_until))
119677+ retry_until = grsec_lastack_retries;
119678+#endif
119679+
119680 if (retransmits_timed_out(sk, retry_until,
119681 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
119682 /* Has it gone just too far? */
119683diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
119684index 83aa604..dbfddf5 100644
119685--- a/net/ipv4/udp.c
119686+++ b/net/ipv4/udp.c
119687@@ -87,6 +87,7 @@
119688 #include <linux/types.h>
119689 #include <linux/fcntl.h>
119690 #include <linux/module.h>
119691+#include <linux/security.h>
119692 #include <linux/socket.h>
119693 #include <linux/sockios.h>
119694 #include <linux/igmp.h>
119695@@ -115,6 +116,10 @@
119696 #include <net/busy_poll.h>
119697 #include "udp_impl.h"
119698
119699+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
119700+extern int grsec_enable_blackhole;
119701+#endif
119702+
119703 struct udp_table udp_table __read_mostly;
119704 EXPORT_SYMBOL(udp_table);
119705
119706@@ -608,6 +613,9 @@ static inline bool __udp_is_mcast_sock(struct net *net, struct sock *sk,
119707 return true;
119708 }
119709
119710+extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
119711+extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
119712+
119713 /*
119714 * This routine is called by the ICMP module when it gets some
119715 * sort of error condition. If err < 0 then the socket should
119716@@ -944,9 +952,18 @@ int udp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
119717 dport = usin->sin_port;
119718 if (dport == 0)
119719 return -EINVAL;
119720+
119721+ err = gr_search_udp_sendmsg(sk, usin);
119722+ if (err)
119723+ return err;
119724 } else {
119725 if (sk->sk_state != TCP_ESTABLISHED)
119726 return -EDESTADDRREQ;
119727+
119728+ err = gr_search_udp_sendmsg(sk, NULL);
119729+ if (err)
119730+ return err;
119731+
119732 daddr = inet->inet_daddr;
119733 dport = inet->inet_dport;
119734 /* Open fast path for connected socket.
119735@@ -1193,7 +1210,7 @@ static unsigned int first_packet_length(struct sock *sk)
119736 IS_UDPLITE(sk));
119737 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
119738 IS_UDPLITE(sk));
119739- atomic_inc(&sk->sk_drops);
119740+ atomic_inc_unchecked(&sk->sk_drops);
119741 __skb_unlink(skb, rcvq);
119742 __skb_queue_tail(&list_kill, skb);
119743 }
119744@@ -1273,6 +1290,10 @@ try_again:
119745 if (!skb)
119746 goto out;
119747
119748+ err = gr_search_udp_recvmsg(sk, skb);
119749+ if (err)
119750+ goto out_free;
119751+
119752 ulen = skb->len - sizeof(struct udphdr);
119753 copied = len;
119754 if (copied > ulen)
119755@@ -1305,7 +1326,7 @@ try_again:
119756 if (unlikely(err)) {
119757 trace_kfree_skb(skb, udp_recvmsg);
119758 if (!peeked) {
119759- atomic_inc(&sk->sk_drops);
119760+ atomic_inc_unchecked(&sk->sk_drops);
119761 UDP_INC_STATS_USER(sock_net(sk),
119762 UDP_MIB_INERRORS, is_udplite);
119763 }
119764@@ -1599,7 +1620,7 @@ csum_error:
119765 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
119766 drop:
119767 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
119768- atomic_inc(&sk->sk_drops);
119769+ atomic_inc_unchecked(&sk->sk_drops);
119770 kfree_skb(skb);
119771 return -1;
119772 }
119773@@ -1617,7 +1638,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
119774 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
119775
119776 if (!skb1) {
119777- atomic_inc(&sk->sk_drops);
119778+ atomic_inc_unchecked(&sk->sk_drops);
119779 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
119780 IS_UDPLITE(sk));
119781 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
119782@@ -1823,6 +1844,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
119783 goto csum_error;
119784
119785 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
119786+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
119787+ if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
119788+#endif
119789 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
119790
119791 /*
119792@@ -2420,7 +2444,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
119793 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
119794 0, sock_i_ino(sp),
119795 atomic_read(&sp->sk_refcnt), sp,
119796- atomic_read(&sp->sk_drops));
119797+ atomic_read_unchecked(&sp->sk_drops));
119798 }
119799
119800 int udp4_seq_show(struct seq_file *seq, void *v)
119801diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
119802index bff6974..c63736c 100644
119803--- a/net/ipv4/xfrm4_policy.c
119804+++ b/net/ipv4/xfrm4_policy.c
119805@@ -186,11 +186,11 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
119806 fl4->flowi4_tos = iph->tos;
119807 }
119808
119809-static inline int xfrm4_garbage_collect(struct dst_ops *ops)
119810+static int xfrm4_garbage_collect(struct dst_ops *ops)
119811 {
119812 struct net *net = container_of(ops, struct net, xfrm.xfrm4_dst_ops);
119813
119814- xfrm4_policy_afinfo.garbage_collect(net);
119815+ xfrm_garbage_collect_deferred(net);
119816 return (dst_entries_get_slow(ops) > ops->gc_thresh * 2);
119817 }
119818
119819@@ -268,19 +268,18 @@ static struct ctl_table xfrm4_policy_table[] = {
119820
119821 static int __net_init xfrm4_net_init(struct net *net)
119822 {
119823- struct ctl_table *table;
119824+ ctl_table_no_const *table = NULL;
119825 struct ctl_table_header *hdr;
119826
119827- table = xfrm4_policy_table;
119828 if (!net_eq(net, &init_net)) {
119829- table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
119830+ table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
119831 if (!table)
119832 goto err_alloc;
119833
119834 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
119835- }
119836-
119837- hdr = register_net_sysctl(net, "net/ipv4", table);
119838+ hdr = register_net_sysctl(net, "net/ipv4", table);
119839+ } else
119840+ hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
119841 if (!hdr)
119842 goto err_reg;
119843
119844@@ -288,8 +287,7 @@ static int __net_init xfrm4_net_init(struct net *net)
119845 return 0;
119846
119847 err_reg:
119848- if (!net_eq(net, &init_net))
119849- kfree(table);
119850+ kfree(table);
119851 err_alloc:
119852 return -ENOMEM;
119853 }
119854diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
119855index 37b70e8..1475ab7 100644
119856--- a/net/ipv6/addrconf.c
119857+++ b/net/ipv6/addrconf.c
119858@@ -178,7 +178,7 @@ static struct ipv6_devconf ipv6_devconf __read_mostly = {
119859 .hop_limit = IPV6_DEFAULT_HOPLIMIT,
119860 .mtu6 = IPV6_MIN_MTU,
119861 .accept_ra = 1,
119862- .accept_redirects = 1,
119863+ .accept_redirects = 0,
119864 .autoconf = 1,
119865 .force_mld_version = 0,
119866 .mldv1_unsolicited_report_interval = 10 * HZ,
119867@@ -219,7 +219,7 @@ static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = {
119868 .hop_limit = IPV6_DEFAULT_HOPLIMIT,
119869 .mtu6 = IPV6_MIN_MTU,
119870 .accept_ra = 1,
119871- .accept_redirects = 1,
119872+ .accept_redirects = 0,
119873 .autoconf = 1,
119874 .force_mld_version = 0,
119875 .mldv1_unsolicited_report_interval = 10 * HZ,
119876@@ -620,7 +620,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb,
119877 idx = 0;
119878 head = &net->dev_index_head[h];
119879 rcu_read_lock();
119880- cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^
119881+ cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^
119882 net->dev_base_seq;
119883 hlist_for_each_entry_rcu(dev, head, index_hlist) {
119884 if (idx < s_idx)
119885@@ -2506,7 +2506,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
119886 p.iph.ihl = 5;
119887 p.iph.protocol = IPPROTO_IPV6;
119888 p.iph.ttl = 64;
119889- ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
119890+ ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
119891
119892 if (ops->ndo_do_ioctl) {
119893 mm_segment_t oldfs = get_fs();
119894@@ -3772,16 +3772,23 @@ static const struct file_operations if6_fops = {
119895 .release = seq_release_net,
119896 };
119897
119898+extern void register_ipv6_seq_ops_addr(struct seq_operations *addr);
119899+extern void unregister_ipv6_seq_ops_addr(void);
119900+
119901 static int __net_init if6_proc_net_init(struct net *net)
119902 {
119903- if (!proc_create("if_inet6", S_IRUGO, net->proc_net, &if6_fops))
119904+ register_ipv6_seq_ops_addr(&if6_seq_ops);
119905+ if (!proc_create("if_inet6", S_IRUGO, net->proc_net, &if6_fops)) {
119906+ unregister_ipv6_seq_ops_addr();
119907 return -ENOMEM;
119908+ }
119909 return 0;
119910 }
119911
119912 static void __net_exit if6_proc_net_exit(struct net *net)
119913 {
119914 remove_proc_entry("if_inet6", net->proc_net);
119915+ unregister_ipv6_seq_ops_addr();
119916 }
119917
119918 static struct pernet_operations if6_proc_net_ops = {
119919@@ -4400,7 +4407,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
119920 s_ip_idx = ip_idx = cb->args[2];
119921
119922 rcu_read_lock();
119923- cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
119924+ cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
119925 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
119926 idx = 0;
119927 head = &net->dev_index_head[h];
119928@@ -5057,7 +5064,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
119929 rt_genid_bump_ipv6(net);
119930 break;
119931 }
119932- atomic_inc(&net->ipv6.dev_addr_genid);
119933+ atomic_inc_unchecked(&net->ipv6.dev_addr_genid);
119934 }
119935
119936 static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
119937@@ -5077,7 +5084,7 @@ int addrconf_sysctl_forward(struct ctl_table *ctl, int write,
119938 int *valp = ctl->data;
119939 int val = *valp;
119940 loff_t pos = *ppos;
119941- struct ctl_table lctl;
119942+ ctl_table_no_const lctl;
119943 int ret;
119944
119945 /*
119946@@ -5102,7 +5109,7 @@ int addrconf_sysctl_mtu(struct ctl_table *ctl, int write,
119947 {
119948 struct inet6_dev *idev = ctl->extra1;
119949 int min_mtu = IPV6_MIN_MTU;
119950- struct ctl_table lctl;
119951+ ctl_table_no_const lctl;
119952
119953 lctl = *ctl;
119954 lctl.extra1 = &min_mtu;
119955@@ -5177,7 +5184,7 @@ int addrconf_sysctl_disable(struct ctl_table *ctl, int write,
119956 int *valp = ctl->data;
119957 int val = *valp;
119958 loff_t pos = *ppos;
119959- struct ctl_table lctl;
119960+ ctl_table_no_const lctl;
119961 int ret;
119962
119963 /*
119964@@ -5242,7 +5249,7 @@ static int addrconf_sysctl_stable_secret(struct ctl_table *ctl, int write,
119965 int err;
119966 struct in6_addr addr;
119967 char str[IPV6_MAX_STRLEN];
119968- struct ctl_table lctl = *ctl;
119969+ ctl_table_no_const lctl = *ctl;
119970 struct net *net = ctl->extra2;
119971 struct ipv6_stable_secret *secret = ctl->data;
119972
119973diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
119974index eef63b3..d68f5da 100644
119975--- a/net/ipv6/af_inet6.c
119976+++ b/net/ipv6/af_inet6.c
119977@@ -768,7 +768,7 @@ static int __net_init inet6_net_init(struct net *net)
119978 net->ipv6.sysctl.auto_flowlabels = 0;
119979 net->ipv6.sysctl.idgen_retries = 3;
119980 net->ipv6.sysctl.idgen_delay = 1 * HZ;
119981- atomic_set(&net->ipv6.fib6_sernum, 1);
119982+ atomic_set_unchecked(&net->ipv6.fib6_sernum, 1);
119983
119984 err = ipv6_init_mibs(net);
119985 if (err)
119986diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
119987index 62d908e..bac79a9 100644
119988--- a/net/ipv6/datagram.c
119989+++ b/net/ipv6/datagram.c
119990@@ -967,5 +967,5 @@ void ip6_dgram_sock_seq_show(struct seq_file *seq, struct sock *sp,
119991 0,
119992 sock_i_ino(sp),
119993 atomic_read(&sp->sk_refcnt), sp,
119994- atomic_read(&sp->sk_drops));
119995+ atomic_read_unchecked(&sp->sk_drops));
119996 }
119997diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
119998index 2c2b5d5..cc01abd 100644
119999--- a/net/ipv6/icmp.c
120000+++ b/net/ipv6/icmp.c
120001@@ -1004,7 +1004,7 @@ static struct ctl_table ipv6_icmp_table_template[] = {
120002
120003 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
120004 {
120005- struct ctl_table *table;
120006+ ctl_table_no_const *table;
120007
120008 table = kmemdup(ipv6_icmp_table_template,
120009 sizeof(ipv6_icmp_table_template),
120010diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
120011index bde57b1..5b45dbb 100644
120012--- a/net/ipv6/ip6_fib.c
120013+++ b/net/ipv6/ip6_fib.c
120014@@ -99,9 +99,9 @@ static int fib6_new_sernum(struct net *net)
120015 int new, old;
120016
120017 do {
120018- old = atomic_read(&net->ipv6.fib6_sernum);
120019+ old = atomic_read_unchecked(&net->ipv6.fib6_sernum);
120020 new = old < INT_MAX ? old + 1 : 1;
120021- } while (atomic_cmpxchg(&net->ipv6.fib6_sernum,
120022+ } while (atomic_cmpxchg_unchecked(&net->ipv6.fib6_sernum,
120023 old, new) != old);
120024 return new;
120025 }
120026diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
120027index a38d3ac..d02e37d 100644
120028--- a/net/ipv6/ip6_gre.c
120029+++ b/net/ipv6/ip6_gre.c
120030@@ -71,8 +71,8 @@ struct ip6gre_net {
120031 struct net_device *fb_tunnel_dev;
120032 };
120033
120034-static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
120035-static struct rtnl_link_ops ip6gre_tap_ops __read_mostly;
120036+static struct rtnl_link_ops ip6gre_link_ops;
120037+static struct rtnl_link_ops ip6gre_tap_ops;
120038 static int ip6gre_tunnel_init(struct net_device *dev);
120039 static void ip6gre_tunnel_setup(struct net_device *dev);
120040 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
120041@@ -1280,7 +1280,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
120042 }
120043
120044
120045-static struct inet6_protocol ip6gre_protocol __read_mostly = {
120046+static struct inet6_protocol ip6gre_protocol = {
120047 .handler = ip6gre_rcv,
120048 .err_handler = ip6gre_err,
120049 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
120050@@ -1639,7 +1639,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
120051 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
120052 };
120053
120054-static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
120055+static struct rtnl_link_ops ip6gre_link_ops = {
120056 .kind = "ip6gre",
120057 .maxtype = IFLA_GRE_MAX,
120058 .policy = ip6gre_policy,
120059@@ -1654,7 +1654,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
120060 .get_link_net = ip6_tnl_get_link_net,
120061 };
120062
120063-static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
120064+static struct rtnl_link_ops ip6gre_tap_ops = {
120065 .kind = "ip6gretap",
120066 .maxtype = IFLA_GRE_MAX,
120067 .policy = ip6gre_policy,
120068diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
120069index 5cafd92..d5aead4 100644
120070--- a/net/ipv6/ip6_tunnel.c
120071+++ b/net/ipv6/ip6_tunnel.c
120072@@ -80,7 +80,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
120073
120074 static int ip6_tnl_dev_init(struct net_device *dev);
120075 static void ip6_tnl_dev_setup(struct net_device *dev);
120076-static struct rtnl_link_ops ip6_link_ops __read_mostly;
120077+static struct rtnl_link_ops ip6_link_ops;
120078
120079 static int ip6_tnl_net_id __read_mostly;
120080 struct ip6_tnl_net {
120081@@ -1776,7 +1776,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
120082 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
120083 };
120084
120085-static struct rtnl_link_ops ip6_link_ops __read_mostly = {
120086+static struct rtnl_link_ops ip6_link_ops = {
120087 .kind = "ip6tnl",
120088 .maxtype = IFLA_IPTUN_MAX,
120089 .policy = ip6_tnl_policy,
120090diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c
120091index 0224c03..c5ec3d9 100644
120092--- a/net/ipv6/ip6_vti.c
120093+++ b/net/ipv6/ip6_vti.c
120094@@ -62,7 +62,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
120095
120096 static int vti6_dev_init(struct net_device *dev);
120097 static void vti6_dev_setup(struct net_device *dev);
120098-static struct rtnl_link_ops vti6_link_ops __read_mostly;
120099+static struct rtnl_link_ops vti6_link_ops;
120100
120101 static int vti6_net_id __read_mostly;
120102 struct vti6_net {
120103@@ -1019,7 +1019,7 @@ static const struct nla_policy vti6_policy[IFLA_VTI_MAX + 1] = {
120104 [IFLA_VTI_OKEY] = { .type = NLA_U32 },
120105 };
120106
120107-static struct rtnl_link_ops vti6_link_ops __read_mostly = {
120108+static struct rtnl_link_ops vti6_link_ops = {
120109 .kind = "vti6",
120110 .maxtype = IFLA_VTI_MAX,
120111 .policy = vti6_policy,
120112diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
120113index 63e6956..ebbbcf6 100644
120114--- a/net/ipv6/ipv6_sockglue.c
120115+++ b/net/ipv6/ipv6_sockglue.c
120116@@ -1015,7 +1015,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
120117 if (sk->sk_type != SOCK_STREAM)
120118 return -ENOPROTOOPT;
120119
120120- msg.msg_control = optval;
120121+ msg.msg_control = (void __force_kernel *)optval;
120122 msg.msg_controllen = len;
120123 msg.msg_flags = flags;
120124
120125diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
120126index 96f153c..82fcad9 100644
120127--- a/net/ipv6/ndisc.c
120128+++ b/net/ipv6/ndisc.c
120129@@ -1650,6 +1650,7 @@ int ndisc_rcv(struct sk_buff *skb)
120130 static int ndisc_netdev_event(struct notifier_block *this, unsigned long event, void *ptr)
120131 {
120132 struct net_device *dev = netdev_notifier_info_to_dev(ptr);
120133+ struct netdev_notifier_change_info *change_info;
120134 struct net *net = dev_net(dev);
120135 struct inet6_dev *idev;
120136
120137@@ -1664,6 +1665,11 @@ static int ndisc_netdev_event(struct notifier_block *this, unsigned long event,
120138 ndisc_send_unsol_na(dev);
120139 in6_dev_put(idev);
120140 break;
120141+ case NETDEV_CHANGE:
120142+ change_info = ptr;
120143+ if (change_info->flags_changed & IFF_NOARP)
120144+ neigh_changeaddr(&nd_tbl, dev);
120145+ break;
120146 case NETDEV_DOWN:
120147 neigh_ifdown(&nd_tbl, dev);
120148 fib6_run_gc(0, net, false);
120149diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
120150index 62f5b0d..331fdb1 100644
120151--- a/net/ipv6/netfilter/ip6_tables.c
120152+++ b/net/ipv6/netfilter/ip6_tables.c
120153@@ -1085,14 +1085,14 @@ static int compat_table_info(const struct xt_table_info *info,
120154 #endif
120155
120156 static int get_info(struct net *net, void __user *user,
120157- const int *len, int compat)
120158+ int len, int compat)
120159 {
120160 char name[XT_TABLE_MAXNAMELEN];
120161 struct xt_table *t;
120162 int ret;
120163
120164- if (*len != sizeof(struct ip6t_getinfo)) {
120165- duprintf("length %u != %zu\n", *len,
120166+ if (len != sizeof(struct ip6t_getinfo)) {
120167+ duprintf("length %u != %zu\n", len,
120168 sizeof(struct ip6t_getinfo));
120169 return -EINVAL;
120170 }
120171@@ -1129,7 +1129,7 @@ static int get_info(struct net *net, void __user *user,
120172 info.size = private->size;
120173 strcpy(info.name, name);
120174
120175- if (copy_to_user(user, &info, *len) != 0)
120176+ if (copy_to_user(user, &info, len) != 0)
120177 ret = -EFAULT;
120178 else
120179 ret = 0;
120180@@ -1991,7 +1991,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
120181
120182 switch (cmd) {
120183 case IP6T_SO_GET_INFO:
120184- ret = get_info(sock_net(sk), user, len, 1);
120185+ ret = get_info(sock_net(sk), user, *len, 1);
120186 break;
120187 case IP6T_SO_GET_ENTRIES:
120188 ret = compat_get_entries(sock_net(sk), user, len);
120189@@ -2038,7 +2038,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
120190
120191 switch (cmd) {
120192 case IP6T_SO_GET_INFO:
120193- ret = get_info(sock_net(sk), user, len, 0);
120194+ ret = get_info(sock_net(sk), user, *len, 0);
120195 break;
120196
120197 case IP6T_SO_GET_ENTRIES:
120198diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
120199index 6f187c8..55e564f 100644
120200--- a/net/ipv6/netfilter/nf_conntrack_reasm.c
120201+++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
120202@@ -96,12 +96,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
120203
120204 static int nf_ct_frag6_sysctl_register(struct net *net)
120205 {
120206- struct ctl_table *table;
120207+ ctl_table_no_const *table = NULL;
120208 struct ctl_table_header *hdr;
120209
120210- table = nf_ct_frag6_sysctl_table;
120211 if (!net_eq(net, &init_net)) {
120212- table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
120213+ table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
120214 GFP_KERNEL);
120215 if (table == NULL)
120216 goto err_alloc;
120217@@ -112,9 +111,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
120218 table[2].data = &net->nf_frag.frags.high_thresh;
120219 table[2].extra1 = &net->nf_frag.frags.low_thresh;
120220 table[2].extra2 = &init_net.nf_frag.frags.high_thresh;
120221- }
120222-
120223- hdr = register_net_sysctl(net, "net/netfilter", table);
120224+ hdr = register_net_sysctl(net, "net/netfilter", table);
120225+ } else
120226+ hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
120227 if (hdr == NULL)
120228 goto err_reg;
120229
120230@@ -122,8 +121,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
120231 return 0;
120232
120233 err_reg:
120234- if (!net_eq(net, &init_net))
120235- kfree(table);
120236+ kfree(table);
120237 err_alloc:
120238 return -ENOMEM;
120239 }
120240@@ -348,7 +346,7 @@ found:
120241 fq->ecn |= ecn;
120242 if (payload_len > fq->q.max_size)
120243 fq->q.max_size = payload_len;
120244- add_frag_mem_limit(&fq->q, skb->truesize);
120245+ add_frag_mem_limit(fq->q.net, skb->truesize);
120246
120247 /* The first fragment.
120248 * nhoffset is obtained from the first fragment, of course.
120249@@ -430,7 +428,7 @@ nf_ct_frag6_reasm(struct frag_queue *fq, struct net_device *dev)
120250 clone->ip_summed = head->ip_summed;
120251
120252 NFCT_FRAG6_CB(clone)->orig = NULL;
120253- add_frag_mem_limit(&fq->q, clone->truesize);
120254+ add_frag_mem_limit(fq->q.net, clone->truesize);
120255 }
120256
120257 /* We have to remove fragment header from datagram and to relocate
120258@@ -454,7 +452,7 @@ nf_ct_frag6_reasm(struct frag_queue *fq, struct net_device *dev)
120259 head->csum = csum_add(head->csum, fp->csum);
120260 head->truesize += fp->truesize;
120261 }
120262- sub_frag_mem_limit(&fq->q, head->truesize);
120263+ sub_frag_mem_limit(fq->q.net, head->truesize);
120264
120265 head->ignore_df = 1;
120266 head->next = NULL;
120267diff --git a/net/ipv6/ping.c b/net/ipv6/ping.c
120268index 263a516..692f738 100644
120269--- a/net/ipv6/ping.c
120270+++ b/net/ipv6/ping.c
120271@@ -240,6 +240,24 @@ static struct pernet_operations ping_v6_net_ops = {
120272 };
120273 #endif
120274
120275+static struct pingv6_ops real_pingv6_ops = {
120276+ .ipv6_recv_error = ipv6_recv_error,
120277+ .ip6_datagram_recv_common_ctl = ip6_datagram_recv_common_ctl,
120278+ .ip6_datagram_recv_specific_ctl = ip6_datagram_recv_specific_ctl,
120279+ .icmpv6_err_convert = icmpv6_err_convert,
120280+ .ipv6_icmp_error = ipv6_icmp_error,
120281+ .ipv6_chk_addr = ipv6_chk_addr,
120282+};
120283+
120284+static struct pingv6_ops dummy_pingv6_ops = {
120285+ .ipv6_recv_error = dummy_ipv6_recv_error,
120286+ .ip6_datagram_recv_common_ctl = dummy_ip6_datagram_recv_ctl,
120287+ .ip6_datagram_recv_specific_ctl = dummy_ip6_datagram_recv_ctl,
120288+ .icmpv6_err_convert = dummy_icmpv6_err_convert,
120289+ .ipv6_icmp_error = dummy_ipv6_icmp_error,
120290+ .ipv6_chk_addr = dummy_ipv6_chk_addr,
120291+};
120292+
120293 int __init pingv6_init(void)
120294 {
120295 #ifdef CONFIG_PROC_FS
120296@@ -247,13 +265,7 @@ int __init pingv6_init(void)
120297 if (ret)
120298 return ret;
120299 #endif
120300- pingv6_ops.ipv6_recv_error = ipv6_recv_error;
120301- pingv6_ops.ip6_datagram_recv_common_ctl = ip6_datagram_recv_common_ctl;
120302- pingv6_ops.ip6_datagram_recv_specific_ctl =
120303- ip6_datagram_recv_specific_ctl;
120304- pingv6_ops.icmpv6_err_convert = icmpv6_err_convert;
120305- pingv6_ops.ipv6_icmp_error = ipv6_icmp_error;
120306- pingv6_ops.ipv6_chk_addr = ipv6_chk_addr;
120307+ pingv6_ops = &real_pingv6_ops;
120308 return inet6_register_protosw(&pingv6_protosw);
120309 }
120310
120311@@ -262,14 +274,9 @@ int __init pingv6_init(void)
120312 */
120313 void pingv6_exit(void)
120314 {
120315- pingv6_ops.ipv6_recv_error = dummy_ipv6_recv_error;
120316- pingv6_ops.ip6_datagram_recv_common_ctl = dummy_ip6_datagram_recv_ctl;
120317- pingv6_ops.ip6_datagram_recv_specific_ctl = dummy_ip6_datagram_recv_ctl;
120318- pingv6_ops.icmpv6_err_convert = dummy_icmpv6_err_convert;
120319- pingv6_ops.ipv6_icmp_error = dummy_ipv6_icmp_error;
120320- pingv6_ops.ipv6_chk_addr = dummy_ipv6_chk_addr;
120321 #ifdef CONFIG_PROC_FS
120322 unregister_pernet_subsys(&ping_v6_net_ops);
120323 #endif
120324+ pingv6_ops = &dummy_pingv6_ops;
120325 inet6_unregister_protosw(&pingv6_protosw);
120326 }
120327diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c
120328index 679253d0..70b653c 100644
120329--- a/net/ipv6/proc.c
120330+++ b/net/ipv6/proc.c
120331@@ -310,7 +310,7 @@ static int __net_init ipv6_proc_init_net(struct net *net)
120332 if (!proc_create("snmp6", S_IRUGO, net->proc_net, &snmp6_seq_fops))
120333 goto proc_snmp6_fail;
120334
120335- net->mib.proc_net_devsnmp6 = proc_mkdir("dev_snmp6", net->proc_net);
120336+ net->mib.proc_net_devsnmp6 = proc_mkdir_restrict("dev_snmp6", net->proc_net);
120337 if (!net->mib.proc_net_devsnmp6)
120338 goto proc_dev_snmp6_fail;
120339 return 0;
120340diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
120341index 8072bd4..1629245 100644
120342--- a/net/ipv6/raw.c
120343+++ b/net/ipv6/raw.c
120344@@ -388,7 +388,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
120345 {
120346 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
120347 skb_checksum_complete(skb)) {
120348- atomic_inc(&sk->sk_drops);
120349+ atomic_inc_unchecked(&sk->sk_drops);
120350 kfree_skb(skb);
120351 return NET_RX_DROP;
120352 }
120353@@ -416,7 +416,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
120354 struct raw6_sock *rp = raw6_sk(sk);
120355
120356 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
120357- atomic_inc(&sk->sk_drops);
120358+ atomic_inc_unchecked(&sk->sk_drops);
120359 kfree_skb(skb);
120360 return NET_RX_DROP;
120361 }
120362@@ -440,7 +440,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
120363
120364 if (inet->hdrincl) {
120365 if (skb_checksum_complete(skb)) {
120366- atomic_inc(&sk->sk_drops);
120367+ atomic_inc_unchecked(&sk->sk_drops);
120368 kfree_skb(skb);
120369 return NET_RX_DROP;
120370 }
120371@@ -608,7 +608,7 @@ out:
120372 return err;
120373 }
120374
120375-static int rawv6_send_hdrinc(struct sock *sk, struct msghdr *msg, int length,
120376+static int rawv6_send_hdrinc(struct sock *sk, struct msghdr *msg, unsigned int length,
120377 struct flowi6 *fl6, struct dst_entry **dstp,
120378 unsigned int flags)
120379 {
120380@@ -913,12 +913,15 @@ do_confirm:
120381 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
120382 char __user *optval, int optlen)
120383 {
120384+ struct icmp6_filter filter;
120385+
120386 switch (optname) {
120387 case ICMPV6_FILTER:
120388 if (optlen > sizeof(struct icmp6_filter))
120389 optlen = sizeof(struct icmp6_filter);
120390- if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
120391+ if (copy_from_user(&filter, optval, optlen))
120392 return -EFAULT;
120393+ raw6_sk(sk)->filter = filter;
120394 return 0;
120395 default:
120396 return -ENOPROTOOPT;
120397@@ -931,6 +934,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
120398 char __user *optval, int __user *optlen)
120399 {
120400 int len;
120401+ struct icmp6_filter filter;
120402
120403 switch (optname) {
120404 case ICMPV6_FILTER:
120405@@ -942,7 +946,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
120406 len = sizeof(struct icmp6_filter);
120407 if (put_user(len, optlen))
120408 return -EFAULT;
120409- if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
120410+ filter = raw6_sk(sk)->filter;
120411+ if (len > sizeof filter || copy_to_user(optval, &filter, len))
120412 return -EFAULT;
120413 return 0;
120414 default:
120415diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
120416index 8ffa2c8..0db5dad 100644
120417--- a/net/ipv6/reassembly.c
120418+++ b/net/ipv6/reassembly.c
120419@@ -144,7 +144,7 @@ void ip6_expire_frag_queue(struct net *net, struct frag_queue *fq,
120420
120421 IP6_INC_STATS_BH(net, __in6_dev_get(dev), IPSTATS_MIB_REASMFAILS);
120422
120423- if (fq->q.flags & INET_FRAG_EVICTED)
120424+ if (inet_frag_evicting(&fq->q))
120425 goto out_rcu_unlock;
120426
120427 IP6_INC_STATS_BH(net, __in6_dev_get(dev), IPSTATS_MIB_REASMTIMEOUT);
120428@@ -330,7 +330,7 @@ found:
120429 fq->q.stamp = skb->tstamp;
120430 fq->q.meat += skb->len;
120431 fq->ecn |= ecn;
120432- add_frag_mem_limit(&fq->q, skb->truesize);
120433+ add_frag_mem_limit(fq->q.net, skb->truesize);
120434
120435 /* The first fragment.
120436 * nhoffset is obtained from the first fragment, of course.
120437@@ -443,7 +443,7 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *prev,
120438 head->len -= clone->len;
120439 clone->csum = 0;
120440 clone->ip_summed = head->ip_summed;
120441- add_frag_mem_limit(&fq->q, clone->truesize);
120442+ add_frag_mem_limit(fq->q.net, clone->truesize);
120443 }
120444
120445 /* We have to remove fragment header from datagram and to relocate
120446@@ -481,7 +481,7 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *prev,
120447 }
120448 fp = next;
120449 }
120450- sub_frag_mem_limit(&fq->q, sum_truesize);
120451+ sub_frag_mem_limit(fq->q.net, sum_truesize);
120452
120453 head->next = NULL;
120454 head->dev = dev;
120455@@ -626,12 +626,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
120456
120457 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
120458 {
120459- struct ctl_table *table;
120460+ ctl_table_no_const *table = NULL;
120461 struct ctl_table_header *hdr;
120462
120463- table = ip6_frags_ns_ctl_table;
120464 if (!net_eq(net, &init_net)) {
120465- table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
120466+ table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
120467 if (!table)
120468 goto err_alloc;
120469
120470@@ -645,9 +644,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
120471 /* Don't export sysctls to unprivileged users */
120472 if (net->user_ns != &init_user_ns)
120473 table[0].procname = NULL;
120474- }
120475+ hdr = register_net_sysctl(net, "net/ipv6", table);
120476+ } else
120477+ hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
120478
120479- hdr = register_net_sysctl(net, "net/ipv6", table);
120480 if (!hdr)
120481 goto err_reg;
120482
120483@@ -655,8 +655,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
120484 return 0;
120485
120486 err_reg:
120487- if (!net_eq(net, &init_net))
120488- kfree(table);
120489+ kfree(table);
120490 err_alloc:
120491 return -ENOMEM;
120492 }
120493diff --git a/net/ipv6/route.c b/net/ipv6/route.c
120494index c73ae50..aa55e00 100644
120495--- a/net/ipv6/route.c
120496+++ b/net/ipv6/route.c
120497@@ -3046,7 +3046,7 @@ struct ctl_table ipv6_route_table_template[] = {
120498
120499 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
120500 {
120501- struct ctl_table *table;
120502+ ctl_table_no_const *table;
120503
120504 table = kmemdup(ipv6_route_table_template,
120505 sizeof(ipv6_route_table_template),
120506diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
120507index ac35a28..070cc8c 100644
120508--- a/net/ipv6/sit.c
120509+++ b/net/ipv6/sit.c
120510@@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
120511 static void ipip6_dev_free(struct net_device *dev);
120512 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
120513 __be32 *v4dst);
120514-static struct rtnl_link_ops sit_link_ops __read_mostly;
120515+static struct rtnl_link_ops sit_link_ops;
120516
120517 static int sit_net_id __read_mostly;
120518 struct sit_net {
120519@@ -1749,7 +1749,7 @@ static void ipip6_dellink(struct net_device *dev, struct list_head *head)
120520 unregister_netdevice_queue(dev, head);
120521 }
120522
120523-static struct rtnl_link_ops sit_link_ops __read_mostly = {
120524+static struct rtnl_link_ops sit_link_ops = {
120525 .kind = "sit",
120526 .maxtype = IFLA_IPTUN_MAX,
120527 .policy = ipip6_policy,
120528diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
120529index abcc79f..3b2d2d5 100644
120530--- a/net/ipv6/sysctl_net_ipv6.c
120531+++ b/net/ipv6/sysctl_net_ipv6.c
120532@@ -92,7 +92,7 @@ static struct ctl_table ipv6_rotable[] = {
120533
120534 static int __net_init ipv6_sysctl_net_init(struct net *net)
120535 {
120536- struct ctl_table *ipv6_table;
120537+ ctl_table_no_const *ipv6_table;
120538 struct ctl_table *ipv6_route_table;
120539 struct ctl_table *ipv6_icmp_table;
120540 int err;
120541diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
120542index 3adffb3..a67e4d1 100644
120543--- a/net/ipv6/tcp_ipv6.c
120544+++ b/net/ipv6/tcp_ipv6.c
120545@@ -104,6 +104,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
120546 }
120547 }
120548
120549+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120550+extern int grsec_enable_blackhole;
120551+#endif
120552+
120553 static __u32 tcp_v6_init_sequence(const struct sk_buff *skb)
120554 {
120555 return secure_tcpv6_sequence_number(ipv6_hdr(skb)->daddr.s6_addr32,
120556@@ -1283,6 +1287,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
120557 return 0;
120558
120559 reset:
120560+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120561+ if (!grsec_enable_blackhole)
120562+#endif
120563 tcp_v6_send_reset(sk, skb);
120564 discard:
120565 if (opt_skb)
120566@@ -1392,12 +1399,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
120567
120568 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest,
120569 inet6_iif(skb));
120570- if (!sk)
120571+ if (!sk) {
120572+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120573+ ret = 1;
120574+#endif
120575 goto no_tcp_socket;
120576+ }
120577
120578 process:
120579- if (sk->sk_state == TCP_TIME_WAIT)
120580+ if (sk->sk_state == TCP_TIME_WAIT) {
120581+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120582+ ret = 2;
120583+#endif
120584 goto do_time_wait;
120585+ }
120586
120587 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
120588 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
120589@@ -1448,6 +1463,10 @@ csum_error:
120590 bad_packet:
120591 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
120592 } else {
120593+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120594+ if (!grsec_enable_blackhole || (ret == 1 &&
120595+ (skb->dev->flags & IFF_LOOPBACK)))
120596+#endif
120597 tcp_v6_send_reset(NULL, skb);
120598 }
120599
120600diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
120601index e51fc3e..8f04229 100644
120602--- a/net/ipv6/udp.c
120603+++ b/net/ipv6/udp.c
120604@@ -76,6 +76,10 @@ static u32 udp6_ehashfn(const struct net *net,
120605 udp_ipv6_hash_secret + net_hash_mix(net));
120606 }
120607
120608+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120609+extern int grsec_enable_blackhole;
120610+#endif
120611+
120612 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
120613 {
120614 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
120615@@ -445,7 +449,7 @@ try_again:
120616 if (unlikely(err)) {
120617 trace_kfree_skb(skb, udpv6_recvmsg);
120618 if (!peeked) {
120619- atomic_inc(&sk->sk_drops);
120620+ atomic_inc_unchecked(&sk->sk_drops);
120621 if (is_udp4)
120622 UDP_INC_STATS_USER(sock_net(sk),
120623 UDP_MIB_INERRORS,
120624@@ -709,7 +713,7 @@ csum_error:
120625 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
120626 drop:
120627 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
120628- atomic_inc(&sk->sk_drops);
120629+ atomic_inc_unchecked(&sk->sk_drops);
120630 kfree_skb(skb);
120631 return -1;
120632 }
120633@@ -750,7 +754,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
120634 if (likely(!skb1))
120635 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
120636 if (!skb1) {
120637- atomic_inc(&sk->sk_drops);
120638+ atomic_inc_unchecked(&sk->sk_drops);
120639 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
120640 IS_UDPLITE(sk));
120641 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
120642@@ -934,6 +938,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
120643 goto csum_error;
120644
120645 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
120646+#ifdef CONFIG_GRKERNSEC_BLACKHOLE
120647+ if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
120648+#endif
120649 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
120650
120651 kfree_skb(skb);
120652diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
120653index f337a90..2a9a9db 100644
120654--- a/net/ipv6/xfrm6_policy.c
120655+++ b/net/ipv6/xfrm6_policy.c
120656@@ -222,11 +222,11 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
120657 }
120658 }
120659
120660-static inline int xfrm6_garbage_collect(struct dst_ops *ops)
120661+static int xfrm6_garbage_collect(struct dst_ops *ops)
120662 {
120663 struct net *net = container_of(ops, struct net, xfrm.xfrm6_dst_ops);
120664
120665- xfrm6_policy_afinfo.garbage_collect(net);
120666+ xfrm_garbage_collect_deferred(net);
120667 return dst_entries_get_fast(ops) > ops->gc_thresh * 2;
120668 }
120669
120670@@ -338,19 +338,19 @@ static struct ctl_table xfrm6_policy_table[] = {
120671
120672 static int __net_init xfrm6_net_init(struct net *net)
120673 {
120674- struct ctl_table *table;
120675+ ctl_table_no_const *table = NULL;
120676 struct ctl_table_header *hdr;
120677
120678- table = xfrm6_policy_table;
120679 if (!net_eq(net, &init_net)) {
120680- table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
120681+ table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
120682 if (!table)
120683 goto err_alloc;
120684
120685 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
120686- }
120687+ hdr = register_net_sysctl(net, "net/ipv6", table);
120688+ } else
120689+ hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
120690
120691- hdr = register_net_sysctl(net, "net/ipv6", table);
120692 if (!hdr)
120693 goto err_reg;
120694
120695@@ -358,8 +358,7 @@ static int __net_init xfrm6_net_init(struct net *net)
120696 return 0;
120697
120698 err_reg:
120699- if (!net_eq(net, &init_net))
120700- kfree(table);
120701+ kfree(table);
120702 err_alloc:
120703 return -ENOMEM;
120704 }
120705diff --git a/net/ipx/ipx_proc.c b/net/ipx/ipx_proc.c
120706index c1d247e..9e5949d 100644
120707--- a/net/ipx/ipx_proc.c
120708+++ b/net/ipx/ipx_proc.c
120709@@ -289,7 +289,7 @@ int __init ipx_proc_init(void)
120710 struct proc_dir_entry *p;
120711 int rc = -ENOMEM;
120712
120713- ipx_proc_dir = proc_mkdir("ipx", init_net.proc_net);
120714+ ipx_proc_dir = proc_mkdir_restrict("ipx", init_net.proc_net);
120715
120716 if (!ipx_proc_dir)
120717 goto out;
120718diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
120719index 683346d..cb0e12d 100644
120720--- a/net/irda/ircomm/ircomm_tty.c
120721+++ b/net/irda/ircomm/ircomm_tty.c
120722@@ -310,10 +310,10 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
120723 add_wait_queue(&port->open_wait, &wait);
120724
120725 pr_debug("%s(%d):block_til_ready before block on %s open_count=%d\n",
120726- __FILE__, __LINE__, tty->driver->name, port->count);
120727+ __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
120728
120729 spin_lock_irqsave(&port->lock, flags);
120730- port->count--;
120731+ atomic_dec(&port->count);
120732 port->blocked_open++;
120733 spin_unlock_irqrestore(&port->lock, flags);
120734
120735@@ -348,7 +348,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
120736 }
120737
120738 pr_debug("%s(%d):block_til_ready blocking on %s open_count=%d\n",
120739- __FILE__, __LINE__, tty->driver->name, port->count);
120740+ __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
120741
120742 schedule();
120743 }
120744@@ -358,12 +358,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
120745
120746 spin_lock_irqsave(&port->lock, flags);
120747 if (!tty_hung_up_p(filp))
120748- port->count++;
120749+ atomic_inc(&port->count);
120750 port->blocked_open--;
120751 spin_unlock_irqrestore(&port->lock, flags);
120752
120753 pr_debug("%s(%d):block_til_ready after blocking on %s open_count=%d\n",
120754- __FILE__, __LINE__, tty->driver->name, port->count);
120755+ __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
120756
120757 if (!retval)
120758 port->flags |= ASYNC_NORMAL_ACTIVE;
120759@@ -433,12 +433,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
120760
120761 /* ++ is not atomic, so this should be protected - Jean II */
120762 spin_lock_irqsave(&self->port.lock, flags);
120763- self->port.count++;
120764+ atomic_inc(&self->port.count);
120765 spin_unlock_irqrestore(&self->port.lock, flags);
120766 tty_port_tty_set(&self->port, tty);
120767
120768 pr_debug("%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
120769- self->line, self->port.count);
120770+ self->line, atomic_read(&self->port.count));
120771
120772 /* Not really used by us, but lets do it anyway */
120773 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
120774@@ -961,7 +961,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
120775 tty_kref_put(port->tty);
120776 }
120777 port->tty = NULL;
120778- port->count = 0;
120779+ atomic_set(&port->count, 0);
120780 spin_unlock_irqrestore(&port->lock, flags);
120781
120782 wake_up_interruptible(&port->open_wait);
120783@@ -1308,7 +1308,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
120784 seq_putc(m, '\n');
120785
120786 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
120787- seq_printf(m, "Open count: %d\n", self->port.count);
120788+ seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
120789 seq_printf(m, "Max data size: %d\n", self->max_data_size);
120790 seq_printf(m, "Max header size: %d\n", self->max_header_size);
120791
120792diff --git a/net/irda/irproc.c b/net/irda/irproc.c
120793index b9ac598..f88cc56 100644
120794--- a/net/irda/irproc.c
120795+++ b/net/irda/irproc.c
120796@@ -66,7 +66,7 @@ void __init irda_proc_register(void)
120797 {
120798 int i;
120799
120800- proc_irda = proc_mkdir("irda", init_net.proc_net);
120801+ proc_irda = proc_mkdir_restrict("irda", init_net.proc_net);
120802 if (proc_irda == NULL)
120803 return;
120804
120805diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
120806index 6daa52a..786aa2b 100644
120807--- a/net/iucv/af_iucv.c
120808+++ b/net/iucv/af_iucv.c
120809@@ -686,10 +686,10 @@ static void __iucv_auto_name(struct iucv_sock *iucv)
120810 {
120811 char name[12];
120812
120813- sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
120814+ sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
120815 while (__iucv_get_sock_by_name(name)) {
120816 sprintf(name, "%08x",
120817- atomic_inc_return(&iucv_sk_list.autobind_name));
120818+ atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
120819 }
120820 memcpy(iucv->src_name, name, 8);
120821 }
120822diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
120823index 2a6a1fd..6c112b0 100644
120824--- a/net/iucv/iucv.c
120825+++ b/net/iucv/iucv.c
120826@@ -702,7 +702,7 @@ static int iucv_cpu_notify(struct notifier_block *self,
120827 return NOTIFY_OK;
120828 }
120829
120830-static struct notifier_block __refdata iucv_cpu_notifier = {
120831+static struct notifier_block iucv_cpu_notifier = {
120832 .notifier_call = iucv_cpu_notify,
120833 };
120834
120835diff --git a/net/key/af_key.c b/net/key/af_key.c
120836index f0d52d7..9c9af38 100644
120837--- a/net/key/af_key.c
120838+++ b/net/key/af_key.c
120839@@ -3049,10 +3049,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
120840 static u32 get_acqseq(void)
120841 {
120842 u32 res;
120843- static atomic_t acqseq;
120844+ static atomic_unchecked_t acqseq;
120845
120846 do {
120847- res = atomic_inc_return(&acqseq);
120848+ res = atomic_inc_return_unchecked(&acqseq);
120849 } while (!res);
120850 return res;
120851 }
120852diff --git a/net/l2tp/l2tp_eth.c b/net/l2tp/l2tp_eth.c
120853index 4b55287..bd247f7 100644
120854--- a/net/l2tp/l2tp_eth.c
120855+++ b/net/l2tp/l2tp_eth.c
120856@@ -42,12 +42,12 @@ struct l2tp_eth {
120857 struct sock *tunnel_sock;
120858 struct l2tp_session *session;
120859 struct list_head list;
120860- atomic_long_t tx_bytes;
120861- atomic_long_t tx_packets;
120862- atomic_long_t tx_dropped;
120863- atomic_long_t rx_bytes;
120864- atomic_long_t rx_packets;
120865- atomic_long_t rx_errors;
120866+ atomic_long_unchecked_t tx_bytes;
120867+ atomic_long_unchecked_t tx_packets;
120868+ atomic_long_unchecked_t tx_dropped;
120869+ atomic_long_unchecked_t rx_bytes;
120870+ atomic_long_unchecked_t rx_packets;
120871+ atomic_long_unchecked_t rx_errors;
120872 };
120873
120874 /* via l2tp_session_priv() */
120875@@ -98,10 +98,10 @@ static int l2tp_eth_dev_xmit(struct sk_buff *skb, struct net_device *dev)
120876 int ret = l2tp_xmit_skb(session, skb, session->hdr_len);
120877
120878 if (likely(ret == NET_XMIT_SUCCESS)) {
120879- atomic_long_add(len, &priv->tx_bytes);
120880- atomic_long_inc(&priv->tx_packets);
120881+ atomic_long_add_unchecked(len, &priv->tx_bytes);
120882+ atomic_long_inc_unchecked(&priv->tx_packets);
120883 } else {
120884- atomic_long_inc(&priv->tx_dropped);
120885+ atomic_long_inc_unchecked(&priv->tx_dropped);
120886 }
120887 return NETDEV_TX_OK;
120888 }
120889@@ -111,12 +111,12 @@ static struct rtnl_link_stats64 *l2tp_eth_get_stats64(struct net_device *dev,
120890 {
120891 struct l2tp_eth *priv = netdev_priv(dev);
120892
120893- stats->tx_bytes = atomic_long_read(&priv->tx_bytes);
120894- stats->tx_packets = atomic_long_read(&priv->tx_packets);
120895- stats->tx_dropped = atomic_long_read(&priv->tx_dropped);
120896- stats->rx_bytes = atomic_long_read(&priv->rx_bytes);
120897- stats->rx_packets = atomic_long_read(&priv->rx_packets);
120898- stats->rx_errors = atomic_long_read(&priv->rx_errors);
120899+ stats->tx_bytes = atomic_long_read_unchecked(&priv->tx_bytes);
120900+ stats->tx_packets = atomic_long_read_unchecked(&priv->tx_packets);
120901+ stats->tx_dropped = atomic_long_read_unchecked(&priv->tx_dropped);
120902+ stats->rx_bytes = atomic_long_read_unchecked(&priv->rx_bytes);
120903+ stats->rx_packets = atomic_long_read_unchecked(&priv->rx_packets);
120904+ stats->rx_errors = atomic_long_read_unchecked(&priv->rx_errors);
120905 return stats;
120906 }
120907
120908@@ -167,15 +167,15 @@ static void l2tp_eth_dev_recv(struct l2tp_session *session, struct sk_buff *skb,
120909 nf_reset(skb);
120910
120911 if (dev_forward_skb(dev, skb) == NET_RX_SUCCESS) {
120912- atomic_long_inc(&priv->rx_packets);
120913- atomic_long_add(data_len, &priv->rx_bytes);
120914+ atomic_long_inc_unchecked(&priv->rx_packets);
120915+ atomic_long_add_unchecked(data_len, &priv->rx_bytes);
120916 } else {
120917- atomic_long_inc(&priv->rx_errors);
120918+ atomic_long_inc_unchecked(&priv->rx_errors);
120919 }
120920 return;
120921
120922 error:
120923- atomic_long_inc(&priv->rx_errors);
120924+ atomic_long_inc_unchecked(&priv->rx_errors);
120925 kfree_skb(skb);
120926 }
120927
120928diff --git a/net/l2tp/l2tp_ip.c b/net/l2tp/l2tp_ip.c
120929index 7964993..2c48a3a 100644
120930--- a/net/l2tp/l2tp_ip.c
120931+++ b/net/l2tp/l2tp_ip.c
120932@@ -608,7 +608,7 @@ static struct inet_protosw l2tp_ip_protosw = {
120933 .ops = &l2tp_ip_ops,
120934 };
120935
120936-static struct net_protocol l2tp_ip_protocol __read_mostly = {
120937+static const struct net_protocol l2tp_ip_protocol = {
120938 .handler = l2tp_ip_recv,
120939 .netns_ok = 1,
120940 };
120941diff --git a/net/l2tp/l2tp_ip6.c b/net/l2tp/l2tp_ip6.c
120942index d1ded37..c0d1e49 100644
120943--- a/net/l2tp/l2tp_ip6.c
120944+++ b/net/l2tp/l2tp_ip6.c
120945@@ -755,7 +755,7 @@ static struct inet_protosw l2tp_ip6_protosw = {
120946 .ops = &l2tp_ip6_ops,
120947 };
120948
120949-static struct inet6_protocol l2tp_ip6_protocol __read_mostly = {
120950+static const struct inet6_protocol l2tp_ip6_protocol = {
120951 .handler = l2tp_ip6_recv,
120952 };
120953
120954diff --git a/net/llc/llc_proc.c b/net/llc/llc_proc.c
120955index 1a3c7e0..80f8b0c 100644
120956--- a/net/llc/llc_proc.c
120957+++ b/net/llc/llc_proc.c
120958@@ -247,7 +247,7 @@ int __init llc_proc_init(void)
120959 int rc = -ENOMEM;
120960 struct proc_dir_entry *p;
120961
120962- llc_proc_dir = proc_mkdir("llc", init_net.proc_net);
120963+ llc_proc_dir = proc_mkdir_restrict("llc", init_net.proc_net);
120964 if (!llc_proc_dir)
120965 goto out;
120966
120967diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
120968index ff347a0..6ea4923 100644
120969--- a/net/mac80211/cfg.c
120970+++ b/net/mac80211/cfg.c
120971@@ -582,7 +582,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
120972 ret = ieee80211_vif_use_channel(sdata, chandef,
120973 IEEE80211_CHANCTX_EXCLUSIVE);
120974 }
120975- } else if (local->open_count == local->monitors) {
120976+ } else if (local_read(&local->open_count) == local->monitors) {
120977 local->_oper_chandef = *chandef;
120978 ieee80211_hw_config(local, 0);
120979 }
120980@@ -3428,7 +3428,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
120981 else
120982 local->probe_req_reg--;
120983
120984- if (!local->open_count)
120985+ if (!local_read(&local->open_count))
120986 break;
120987
120988 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
120989@@ -3563,8 +3563,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
120990 if (chanctx_conf) {
120991 *chandef = sdata->vif.bss_conf.chandef;
120992 ret = 0;
120993- } else if (local->open_count > 0 &&
120994- local->open_count == local->monitors &&
120995+ } else if (local_read(&local->open_count) > 0 &&
120996+ local_read(&local->open_count) == local->monitors &&
120997 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
120998 if (local->use_chanctx)
120999 *chandef = local->monitor_chandef;
121000diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
121001index c0a9187..2a13300 100644
121002--- a/net/mac80211/ieee80211_i.h
121003+++ b/net/mac80211/ieee80211_i.h
121004@@ -30,6 +30,7 @@
121005 #include <net/ieee80211_radiotap.h>
121006 #include <net/cfg80211.h>
121007 #include <net/mac80211.h>
121008+#include <asm/local.h>
121009 #include "key.h"
121010 #include "sta_info.h"
121011 #include "debug.h"
121012@@ -1118,7 +1119,7 @@ struct ieee80211_local {
121013 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
121014 spinlock_t queue_stop_reason_lock;
121015
121016- int open_count;
121017+ local_t open_count;
121018 int monitors, cooked_mntrs;
121019 /* number of interfaces with corresponding FIF_ flags */
121020 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
121021diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
121022index 84cef60..53ec813 100644
121023--- a/net/mac80211/iface.c
121024+++ b/net/mac80211/iface.c
121025@@ -550,7 +550,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
121026 break;
121027 }
121028
121029- if (local->open_count == 0) {
121030+ if (local_read(&local->open_count) == 0) {
121031 res = drv_start(local);
121032 if (res)
121033 goto err_del_bss;
121034@@ -597,7 +597,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
121035 res = drv_add_interface(local, sdata);
121036 if (res)
121037 goto err_stop;
121038- } else if (local->monitors == 0 && local->open_count == 0) {
121039+ } else if (local->monitors == 0 && local_read(&local->open_count) == 0) {
121040 res = ieee80211_add_virtual_monitor(local);
121041 if (res)
121042 goto err_stop;
121043@@ -707,7 +707,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
121044 atomic_inc(&local->iff_promiscs);
121045
121046 if (coming_up)
121047- local->open_count++;
121048+ local_inc(&local->open_count);
121049
121050 if (hw_reconf_flags)
121051 ieee80211_hw_config(local, hw_reconf_flags);
121052@@ -745,7 +745,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
121053 err_del_interface:
121054 drv_remove_interface(local, sdata);
121055 err_stop:
121056- if (!local->open_count)
121057+ if (!local_read(&local->open_count))
121058 drv_stop(local);
121059 err_del_bss:
121060 sdata->bss = NULL;
121061@@ -915,7 +915,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
121062 }
121063
121064 if (going_down)
121065- local->open_count--;
121066+ local_dec(&local->open_count);
121067
121068 switch (sdata->vif.type) {
121069 case NL80211_IFTYPE_AP_VLAN:
121070@@ -984,7 +984,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
121071 atomic_set(&sdata->txqs_len[txqi->txq.ac], 0);
121072 }
121073
121074- if (local->open_count == 0)
121075+ if (local_read(&local->open_count) == 0)
121076 ieee80211_clear_tx_pending(local);
121077
121078 /*
121079@@ -1027,7 +1027,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
121080 if (cancel_scan)
121081 flush_delayed_work(&local->scan_work);
121082
121083- if (local->open_count == 0) {
121084+ if (local_read(&local->open_count) == 0) {
121085 ieee80211_stop_device(local);
121086
121087 /* no reconfiguring after stop! */
121088@@ -1038,7 +1038,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
121089 ieee80211_configure_filter(local);
121090 ieee80211_hw_config(local, hw_reconf_flags);
121091
121092- if (local->monitors == local->open_count)
121093+ if (local->monitors == local_read(&local->open_count))
121094 ieee80211_add_virtual_monitor(local);
121095 }
121096
121097diff --git a/net/mac80211/main.c b/net/mac80211/main.c
121098index df3051d..359d2f4 100644
121099--- a/net/mac80211/main.c
121100+++ b/net/mac80211/main.c
121101@@ -175,7 +175,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
121102 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
121103 IEEE80211_CONF_CHANGE_POWER);
121104
121105- if (changed && local->open_count) {
121106+ if (changed && local_read(&local->open_count)) {
121107 ret = drv_config(local, changed);
121108 /*
121109 * Goal:
121110diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
121111index ac6ad62..77dbac5 100644
121112--- a/net/mac80211/pm.c
121113+++ b/net/mac80211/pm.c
121114@@ -12,7 +12,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
121115 struct ieee80211_sub_if_data *sdata;
121116 struct sta_info *sta;
121117
121118- if (!local->open_count)
121119+ if (!local_read(&local->open_count))
121120 goto suspend;
121121
121122 ieee80211_scan_cancel(local);
121123@@ -150,7 +150,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
121124 WARN_ON(!list_empty(&local->chanctx_list));
121125
121126 /* stop hardware - this must stop RX */
121127- if (local->open_count)
121128+ if (local_read(&local->open_count))
121129 ieee80211_stop_device(local);
121130
121131 suspend:
121132diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
121133index d53355b..21f583a 100644
121134--- a/net/mac80211/rate.c
121135+++ b/net/mac80211/rate.c
121136@@ -724,7 +724,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
121137
121138 ASSERT_RTNL();
121139
121140- if (local->open_count)
121141+ if (local_read(&local->open_count))
121142 return -EBUSY;
121143
121144 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
121145diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
121146index 2880f2a..3085cec 100644
121147--- a/net/mac80211/sta_info.c
121148+++ b/net/mac80211/sta_info.c
121149@@ -339,7 +339,7 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
121150 int size = sizeof(struct txq_info) +
121151 ALIGN(hw->txq_data_size, sizeof(void *));
121152
121153- txq_data = kcalloc(ARRAY_SIZE(sta->sta.txq), size, gfp);
121154+ txq_data = kcalloc(size, ARRAY_SIZE(sta->sta.txq), gfp);
121155 if (!txq_data)
121156 goto free;
121157
121158diff --git a/net/mac80211/util.c b/net/mac80211/util.c
121159index b864ebc..17326ff 100644
121160--- a/net/mac80211/util.c
121161+++ b/net/mac80211/util.c
121162@@ -1761,7 +1761,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
121163 bool sched_scan_stopped = false;
121164
121165 /* nothing to do if HW shouldn't run */
121166- if (!local->open_count)
121167+ if (!local_read(&local->open_count))
121168 goto wake_up;
121169
121170 #ifdef CONFIG_PM
121171@@ -2033,7 +2033,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
121172 local->in_reconfig = false;
121173 barrier();
121174
121175- if (local->monitors == local->open_count && local->monitors > 0)
121176+ if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
121177 ieee80211_add_virtual_monitor(local);
121178
121179 /*
121180@@ -2088,7 +2088,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
121181 * If this is for hw restart things are still running.
121182 * We may want to change that later, however.
121183 */
121184- if (local->open_count && (!local->suspended || reconfig_due_to_wowlan))
121185+ if (local_read(&local->open_count) && (!local->suspended || reconfig_due_to_wowlan))
121186 drv_reconfig_complete(local, IEEE80211_RECONFIG_TYPE_RESTART);
121187
121188 if (!local->suspended)
121189@@ -2112,7 +2112,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
121190 flush_delayed_work(&local->scan_work);
121191 }
121192
121193- if (local->open_count && !reconfig_due_to_wowlan)
121194+ if (local_read(&local->open_count) && !reconfig_due_to_wowlan)
121195 drv_reconfig_complete(local, IEEE80211_RECONFIG_TYPE_SUSPEND);
121196
121197 list_for_each_entry(sdata, &local->interfaces, list) {
121198diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
121199index 1f93a59..96faa29 100644
121200--- a/net/mpls/af_mpls.c
121201+++ b/net/mpls/af_mpls.c
121202@@ -456,7 +456,7 @@ static int mpls_dev_sysctl_register(struct net_device *dev,
121203 struct mpls_dev *mdev)
121204 {
121205 char path[sizeof("net/mpls/conf/") + IFNAMSIZ];
121206- struct ctl_table *table;
121207+ ctl_table_no_const *table;
121208 int i;
121209
121210 table = kmemdup(&mpls_dev_table, sizeof(mpls_dev_table), GFP_KERNEL);
121211@@ -1025,7 +1025,7 @@ static int mpls_platform_labels(struct ctl_table *table, int write,
121212 struct net *net = table->data;
121213 int platform_labels = net->mpls.platform_labels;
121214 int ret;
121215- struct ctl_table tmp = {
121216+ ctl_table_no_const tmp = {
121217 .procname = table->procname,
121218 .data = &platform_labels,
121219 .maxlen = sizeof(int),
121220@@ -1055,7 +1055,7 @@ static const struct ctl_table mpls_table[] = {
121221
121222 static int mpls_net_init(struct net *net)
121223 {
121224- struct ctl_table *table;
121225+ ctl_table_no_const *table;
121226
121227 net->mpls.platform_labels = 0;
121228 net->mpls.platform_label = NULL;
121229diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
121230index a0f3e6a3..b026fe2 100644
121231--- a/net/netfilter/Kconfig
121232+++ b/net/netfilter/Kconfig
121233@@ -1112,6 +1112,16 @@ config NETFILTER_XT_MATCH_ESP
121234
121235 To compile it as a module, choose M here. If unsure, say N.
121236
121237+config NETFILTER_XT_MATCH_GRADM
121238+ tristate '"gradm" match support'
121239+ depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
121240+ depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
121241+ ---help---
121242+ The gradm match allows to match on grsecurity RBAC being enabled.
121243+ It is useful when iptables rules are applied early on bootup to
121244+ prevent connections to the machine (except from a trusted host)
121245+ while the RBAC system is disabled.
121246+
121247 config NETFILTER_XT_MATCH_HASHLIMIT
121248 tristate '"hashlimit" match support'
121249 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
121250diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
121251index a87d8b8..d43183c 100644
121252--- a/net/netfilter/Makefile
121253+++ b/net/netfilter/Makefile
121254@@ -139,6 +139,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
121255 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
121256 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
121257 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
121258+obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
121259 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
121260 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
121261 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
121262diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
121263index d259da3..6a32b2c 100644
121264--- a/net/netfilter/ipset/ip_set_core.c
121265+++ b/net/netfilter/ipset/ip_set_core.c
121266@@ -1952,7 +1952,7 @@ done:
121267 return ret;
121268 }
121269
121270-static struct nf_sockopt_ops so_set __read_mostly = {
121271+static struct nf_sockopt_ops so_set = {
121272 .pf = PF_INET,
121273 .get_optmin = SO_IP_SET,
121274 .get_optmax = SO_IP_SET + 1,
121275diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
121276index b0f7b62..0541842 100644
121277--- a/net/netfilter/ipvs/ip_vs_conn.c
121278+++ b/net/netfilter/ipvs/ip_vs_conn.c
121279@@ -572,7 +572,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
121280 /* Increase the refcnt counter of the dest */
121281 ip_vs_dest_hold(dest);
121282
121283- conn_flags = atomic_read(&dest->conn_flags);
121284+ conn_flags = atomic_read_unchecked(&dest->conn_flags);
121285 if (cp->protocol != IPPROTO_UDP)
121286 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
121287 flags = cp->flags;
121288@@ -922,7 +922,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p, int dest_af,
121289
121290 cp->control = NULL;
121291 atomic_set(&cp->n_control, 0);
121292- atomic_set(&cp->in_pkts, 0);
121293+ atomic_set_unchecked(&cp->in_pkts, 0);
121294
121295 cp->packet_xmit = NULL;
121296 cp->app = NULL;
121297@@ -1229,7 +1229,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
121298
121299 /* Don't drop the entry if its number of incoming packets is not
121300 located in [0, 8] */
121301- i = atomic_read(&cp->in_pkts);
121302+ i = atomic_read_unchecked(&cp->in_pkts);
121303 if (i > 8 || i < 0) return 0;
121304
121305 if (!todrop_rate[i]) return 0;
121306diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
121307index 5d2b806..9005b29 100644
121308--- a/net/netfilter/ipvs/ip_vs_core.c
121309+++ b/net/netfilter/ipvs/ip_vs_core.c
121310@@ -574,7 +574,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
121311 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
121312 /* do not touch skb anymore */
121313
121314- atomic_inc(&cp->in_pkts);
121315+ atomic_inc_unchecked(&cp->in_pkts);
121316 ip_vs_conn_put(cp);
121317 return ret;
121318 }
121319@@ -1750,7 +1750,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
121320 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
121321 pkts = sysctl_sync_threshold(ipvs);
121322 else
121323- pkts = atomic_add_return(1, &cp->in_pkts);
121324+ pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
121325
121326 if (ipvs->sync_state & IP_VS_STATE_MASTER)
121327 ip_vs_sync_conn(net, cp, pkts);
121328diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
121329index 285eae3..226f4a7 100644
121330--- a/net/netfilter/ipvs/ip_vs_ctl.c
121331+++ b/net/netfilter/ipvs/ip_vs_ctl.c
121332@@ -814,7 +814,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
121333 */
121334 ip_vs_rs_hash(ipvs, dest);
121335 }
121336- atomic_set(&dest->conn_flags, conn_flags);
121337+ atomic_set_unchecked(&dest->conn_flags, conn_flags);
121338
121339 /* bind the service */
121340 old_svc = rcu_dereference_protected(dest->svc, 1);
121341@@ -1679,7 +1679,7 @@ proc_do_sync_ports(struct ctl_table *table, int write,
121342 * align with netns init in ip_vs_control_net_init()
121343 */
121344
121345-static struct ctl_table vs_vars[] = {
121346+static ctl_table_no_const vs_vars[] __read_only = {
121347 {
121348 .procname = "amemthresh",
121349 .maxlen = sizeof(int),
121350@@ -2020,7 +2020,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
121351 " %-7s %-6d %-10d %-10d\n",
121352 &dest->addr.in6,
121353 ntohs(dest->port),
121354- ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
121355+ ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
121356 atomic_read(&dest->weight),
121357 atomic_read(&dest->activeconns),
121358 atomic_read(&dest->inactconns));
121359@@ -2031,7 +2031,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
121360 "%-7s %-6d %-10d %-10d\n",
121361 ntohl(dest->addr.ip),
121362 ntohs(dest->port),
121363- ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
121364+ ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
121365 atomic_read(&dest->weight),
121366 atomic_read(&dest->activeconns),
121367 atomic_read(&dest->inactconns));
121368@@ -2528,7 +2528,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
121369
121370 entry.addr = dest->addr.ip;
121371 entry.port = dest->port;
121372- entry.conn_flags = atomic_read(&dest->conn_flags);
121373+ entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
121374 entry.weight = atomic_read(&dest->weight);
121375 entry.u_threshold = dest->u_threshold;
121376 entry.l_threshold = dest->l_threshold;
121377@@ -3101,7 +3101,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
121378 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
121379 nla_put_be16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
121380 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
121381- (atomic_read(&dest->conn_flags) &
121382+ (atomic_read_unchecked(&dest->conn_flags) &
121383 IP_VS_CONN_F_FWD_MASK)) ||
121384 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
121385 atomic_read(&dest->weight)) ||
121386@@ -3739,7 +3739,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
121387 {
121388 int idx;
121389 struct netns_ipvs *ipvs = net_ipvs(net);
121390- struct ctl_table *tbl;
121391+ ctl_table_no_const *tbl;
121392
121393 atomic_set(&ipvs->dropentry, 0);
121394 spin_lock_init(&ipvs->dropentry_lock);
121395diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
121396index 127f140..553d652 100644
121397--- a/net/netfilter/ipvs/ip_vs_lblc.c
121398+++ b/net/netfilter/ipvs/ip_vs_lblc.c
121399@@ -118,7 +118,7 @@ struct ip_vs_lblc_table {
121400 * IPVS LBLC sysctl table
121401 */
121402 #ifdef CONFIG_SYSCTL
121403-static struct ctl_table vs_vars_table[] = {
121404+static ctl_table_no_const vs_vars_table[] __read_only = {
121405 {
121406 .procname = "lblc_expiration",
121407 .data = NULL,
121408diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
121409index 2229d2d..b32b785 100644
121410--- a/net/netfilter/ipvs/ip_vs_lblcr.c
121411+++ b/net/netfilter/ipvs/ip_vs_lblcr.c
121412@@ -289,7 +289,7 @@ struct ip_vs_lblcr_table {
121413 * IPVS LBLCR sysctl table
121414 */
121415
121416-static struct ctl_table vs_vars_table[] = {
121417+static ctl_table_no_const vs_vars_table[] __read_only = {
121418 {
121419 .procname = "lblcr_expiration",
121420 .data = NULL,
121421diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
121422index 19b9cce..e4f3112 100644
121423--- a/net/netfilter/ipvs/ip_vs_sync.c
121424+++ b/net/netfilter/ipvs/ip_vs_sync.c
121425@@ -609,7 +609,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
121426 cp = cp->control;
121427 if (cp) {
121428 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
121429- pkts = atomic_add_return(1, &cp->in_pkts);
121430+ pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
121431 else
121432 pkts = sysctl_sync_threshold(ipvs);
121433 ip_vs_sync_conn(net, cp->control, pkts);
121434@@ -771,7 +771,7 @@ control:
121435 if (!cp)
121436 return;
121437 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
121438- pkts = atomic_add_return(1, &cp->in_pkts);
121439+ pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
121440 else
121441 pkts = sysctl_sync_threshold(ipvs);
121442 goto sloop;
121443@@ -919,7 +919,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
121444
121445 if (opt)
121446 memcpy(&cp->in_seq, opt, sizeof(*opt));
121447- atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
121448+ atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
121449 cp->state = state;
121450 cp->old_state = cp->state;
121451 /*
121452diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
121453index 19986ec..416dbc5 100644
121454--- a/net/netfilter/ipvs/ip_vs_xmit.c
121455+++ b/net/netfilter/ipvs/ip_vs_xmit.c
121456@@ -1215,7 +1215,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
121457 else
121458 rc = NF_ACCEPT;
121459 /* do not touch skb anymore */
121460- atomic_inc(&cp->in_pkts);
121461+ atomic_inc_unchecked(&cp->in_pkts);
121462 goto out;
121463 }
121464
121465@@ -1308,7 +1308,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
121466 else
121467 rc = NF_ACCEPT;
121468 /* do not touch skb anymore */
121469- atomic_inc(&cp->in_pkts);
121470+ atomic_inc_unchecked(&cp->in_pkts);
121471 goto out;
121472 }
121473
121474diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
121475index 45da11a..ef3e5dc 100644
121476--- a/net/netfilter/nf_conntrack_acct.c
121477+++ b/net/netfilter/nf_conntrack_acct.c
121478@@ -64,7 +64,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
121479 #ifdef CONFIG_SYSCTL
121480 static int nf_conntrack_acct_init_sysctl(struct net *net)
121481 {
121482- struct ctl_table *table;
121483+ ctl_table_no_const *table;
121484
121485 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
121486 GFP_KERNEL);
121487diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
121488index 13fad86..18c984c 100644
121489--- a/net/netfilter/nf_conntrack_core.c
121490+++ b/net/netfilter/nf_conntrack_core.c
121491@@ -1733,6 +1733,10 @@ void nf_conntrack_init_end(void)
121492 #define DYING_NULLS_VAL ((1<<30)+1)
121493 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
121494
121495+#ifdef CONFIG_GRKERNSEC_HIDESYM
121496+static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
121497+#endif
121498+
121499 int nf_conntrack_init_net(struct net *net)
121500 {
121501 int ret = -ENOMEM;
121502@@ -1758,7 +1762,11 @@ int nf_conntrack_init_net(struct net *net)
121503 if (!net->ct.stat)
121504 goto err_pcpu_lists;
121505
121506+#ifdef CONFIG_GRKERNSEC_HIDESYM
121507+ net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08x", atomic_inc_return_unchecked(&conntrack_cache_id));
121508+#else
121509 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
121510+#endif
121511 if (!net->ct.slabname)
121512 goto err_slabname;
121513
121514diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
121515index 4e78c57..ec8fb74 100644
121516--- a/net/netfilter/nf_conntrack_ecache.c
121517+++ b/net/netfilter/nf_conntrack_ecache.c
121518@@ -264,7 +264,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
121519 #ifdef CONFIG_SYSCTL
121520 static int nf_conntrack_event_init_sysctl(struct net *net)
121521 {
121522- struct ctl_table *table;
121523+ ctl_table_no_const *table;
121524
121525 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
121526 GFP_KERNEL);
121527diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
121528index bd9d315..989947e 100644
121529--- a/net/netfilter/nf_conntrack_helper.c
121530+++ b/net/netfilter/nf_conntrack_helper.c
121531@@ -57,7 +57,7 @@ static struct ctl_table helper_sysctl_table[] = {
121532
121533 static int nf_conntrack_helper_init_sysctl(struct net *net)
121534 {
121535- struct ctl_table *table;
121536+ ctl_table_no_const *table;
121537
121538 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
121539 GFP_KERNEL);
121540diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
121541index b65d586..beec902 100644
121542--- a/net/netfilter/nf_conntrack_proto.c
121543+++ b/net/netfilter/nf_conntrack_proto.c
121544@@ -52,7 +52,7 @@ nf_ct_register_sysctl(struct net *net,
121545
121546 static void
121547 nf_ct_unregister_sysctl(struct ctl_table_header **header,
121548- struct ctl_table **table,
121549+ ctl_table_no_const **table,
121550 unsigned int users)
121551 {
121552 if (users > 0)
121553diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
121554index fc823fa..8311af3 100644
121555--- a/net/netfilter/nf_conntrack_standalone.c
121556+++ b/net/netfilter/nf_conntrack_standalone.c
121557@@ -468,7 +468,7 @@ static struct ctl_table nf_ct_netfilter_table[] = {
121558
121559 static int nf_conntrack_standalone_init_sysctl(struct net *net)
121560 {
121561- struct ctl_table *table;
121562+ ctl_table_no_const *table;
121563
121564 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
121565 GFP_KERNEL);
121566diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
121567index 7a394df..bd91a8a 100644
121568--- a/net/netfilter/nf_conntrack_timestamp.c
121569+++ b/net/netfilter/nf_conntrack_timestamp.c
121570@@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
121571 #ifdef CONFIG_SYSCTL
121572 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
121573 {
121574- struct ctl_table *table;
121575+ ctl_table_no_const *table;
121576
121577 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
121578 GFP_KERNEL);
121579diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
121580index 675d12c..b36e825 100644
121581--- a/net/netfilter/nf_log.c
121582+++ b/net/netfilter/nf_log.c
121583@@ -386,7 +386,7 @@ static const struct file_operations nflog_file_ops = {
121584
121585 #ifdef CONFIG_SYSCTL
121586 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
121587-static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
121588+static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
121589
121590 static int nf_log_proc_dostring(struct ctl_table *table, int write,
121591 void __user *buffer, size_t *lenp, loff_t *ppos)
121592@@ -417,13 +417,15 @@ static int nf_log_proc_dostring(struct ctl_table *table, int write,
121593 rcu_assign_pointer(net->nf.nf_loggers[tindex], logger);
121594 mutex_unlock(&nf_log_mutex);
121595 } else {
121596+ ctl_table_no_const nf_log_table = *table;
121597+
121598 mutex_lock(&nf_log_mutex);
121599 logger = nft_log_dereference(net->nf.nf_loggers[tindex]);
121600 if (!logger)
121601- table->data = "NONE";
121602+ nf_log_table.data = "NONE";
121603 else
121604- table->data = logger->name;
121605- r = proc_dostring(table, write, buffer, lenp, ppos);
121606+ nf_log_table.data = logger->name;
121607+ r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
121608 mutex_unlock(&nf_log_mutex);
121609 }
121610
121611diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
121612index c68c1e5..8b5d670 100644
121613--- a/net/netfilter/nf_sockopt.c
121614+++ b/net/netfilter/nf_sockopt.c
121615@@ -43,7 +43,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
121616 }
121617 }
121618
121619- list_add(&reg->list, &nf_sockopts);
121620+ pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
121621 out:
121622 mutex_unlock(&nf_sockopt_mutex);
121623 return ret;
121624@@ -53,7 +53,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
121625 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
121626 {
121627 mutex_lock(&nf_sockopt_mutex);
121628- list_del(&reg->list);
121629+ pax_list_del((struct list_head *)&reg->list);
121630 mutex_unlock(&nf_sockopt_mutex);
121631 }
121632 EXPORT_SYMBOL(nf_unregister_sockopt);
121633diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
121634index 4ef1fae..f72f08b 100644
121635--- a/net/netfilter/nfnetlink_log.c
121636+++ b/net/netfilter/nfnetlink_log.c
121637@@ -84,7 +84,7 @@ static int nfnl_log_net_id __read_mostly;
121638 struct nfnl_log_net {
121639 spinlock_t instances_lock;
121640 struct hlist_head instance_table[INSTANCE_BUCKETS];
121641- atomic_t global_seq;
121642+ atomic_unchecked_t global_seq;
121643 };
121644
121645 static struct nfnl_log_net *nfnl_log_pernet(struct net *net)
121646@@ -572,7 +572,7 @@ __build_packet_message(struct nfnl_log_net *log,
121647 /* global sequence number */
121648 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
121649 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
121650- htonl(atomic_inc_return(&log->global_seq))))
121651+ htonl(atomic_inc_return_unchecked(&log->global_seq))))
121652 goto nla_put_failure;
121653
121654 if (data_len) {
121655diff --git a/net/netfilter/nft_compat.c b/net/netfilter/nft_compat.c
121656index 7f29cfc..917ef5f 100644
121657--- a/net/netfilter/nft_compat.c
121658+++ b/net/netfilter/nft_compat.c
121659@@ -321,14 +321,7 @@ static void nft_match_eval(const struct nft_expr *expr,
121660 return;
121661 }
121662
121663- switch (ret ? 1 : 0) {
121664- case 1:
121665- regs->verdict.code = NFT_CONTINUE;
121666- break;
121667- case 0:
121668- regs->verdict.code = NFT_BREAK;
121669- break;
121670- }
121671+ regs->verdict.code = ret ? NFT_CONTINUE : NFT_BREAK;
121672 }
121673
121674 static const struct nla_policy nft_match_policy[NFTA_MATCH_MAX + 1] = {
121675diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
121676new file mode 100644
121677index 0000000..c566332
121678--- /dev/null
121679+++ b/net/netfilter/xt_gradm.c
121680@@ -0,0 +1,51 @@
121681+/*
121682+ * gradm match for netfilter
121683